commit 0e622b04fa4a22902722e58eea97840998a0e56c Author: Trever Fischer Date: Sat Feb 25 13:05:39 2012 -0500 Initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..eb5a316 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +target diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..7f9c9d8 --- /dev/null +++ b/pom.xml @@ -0,0 +1,46 @@ + + + 4.0.0 + us.camin + Plugin + jar + 0.1 + bukkitplugin + http://maven.apache.org + + UTF-8 + + + + org.bukkit + bukkit + 1.0.0-SNAPSHOT + jar + compile + + + junit + junit + 3.8.1 + test + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + 1.6 + 1.6 + + + + + + + bukkit-repo + http://repo.bukkit.org/service/local/repositories/snapshots/content/ + + + diff --git a/src/main/java/us/camin/JoinListener.java b/src/main/java/us/camin/JoinListener.java new file mode 100644 index 0000000..dd41f84 --- /dev/null +++ b/src/main/java/us/camin/JoinListener.java @@ -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 . + */ + +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; + } +} diff --git a/src/main/java/us/camin/Plugin.java b/src/main/java/us/camin/Plugin.java new file mode 100644 index 0000000..65e47e0 --- /dev/null +++ b/src/main/java/us/camin/Plugin.java @@ -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 . + */ + +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); + } +} diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml new file mode 100644 index 0000000..cccc83a --- /dev/null +++ b/src/main/resources/plugin.yml @@ -0,0 +1,3 @@ +name: CaminusPlugin +main: us.camin.Plugin +version: 0.1