Initial commit

This commit is contained in:
Trever Fischer 2012-02-25 13:05:39 -05:00
commit 0e622b04fa
5 changed files with 158 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
target

46
pom.xml Normal file
View File

@ -0,0 +1,46 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>us.camin</groupId>
<artifactId>Plugin</artifactId>
<packaging>jar</packaging>
<version>0.1</version>
<name>bukkitplugin</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId>
<version>1.0.0-SNAPSHOT</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>bukkit-repo</id>
<url>http://repo.bukkit.org/service/local/repositories/snapshots/content/</url>
</repository>
</repositories>
</project>

View File

@ -0,0 +1,66 @@
package us.camin;
/*
This file is part of Caminus
Caminus is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Caminus is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Caminus. If not, see <http://www.gnu.org/licenses/>.
*/
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerListener;
import org.bukkit.event.player.PlayerLoginEvent;
public class JoinListener extends PlayerListener {
public JoinListener() {
}
public static void main(String[] args) throws IOException, MalformedURLException {
JoinListener listener = new JoinListener();
if (listener.isUserAuthed(args[0]))
System.out.println("Yes!");
else
System.out.println("No!");
}
public void onPlayerLogin(PlayerLoginEvent event) {
Player p = event.getPlayer();
try {
if (!isUserAuthed(p.getName()))
event.disallow(PlayerLoginEvent.Result.KICK_WHITELIST, "An active camin.us account is required.");
} catch (MalformedURLException e) {
event.disallow(PlayerLoginEvent.Result.KICK_WHITELIST, "Auth URL is invalid!");
} catch (IOException e) {
event.disallow(PlayerLoginEvent.Result.KICK_WHITELIST, "Camin.us auth server seems down.");
}
}
public boolean isUserAuthed(String user) throws IOException, MalformedURLException {
URL authServer = new URL("http://dev.camin.us/api/validate/"+user);
URLConnection conn = authServer.openConnection();
BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
boolean ret;
if (in.readLine().equals("false"))
ret = false;
ret = true;
in.close();
return ret;
}
}

View File

@ -0,0 +1,42 @@
package us.camin;
/*
This file is part of Caminus
Caminus is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Caminus is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Caminus. If not, see <http://www.gnu.org/licenses/>.
*/
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;
import java.util.HashMap;
import java.util.logging.Logger;
public class Plugin extends JavaPlugin {
Logger log = Logger.getLogger("Caminus");//Define your logger
public void onDisable() {
log.info("[Caminus] Plugin disabled");
}
public void onEnable() {
log.info("[Caminus] Plugin enabled");
PluginManager pm = this.getServer().getPluginManager();
pm.registerEvent(Event.Type.PLAYER_LOGIN, new JoinListener(), Event.Priority.Normal, this);
}
}

View File

@ -0,0 +1,3 @@
name: CaminusPlugin
main: us.camin.Plugin
version: 0.1