diff --git a/lib/Essentials.jar b/lib/Essentials.jar new file mode 100644 index 00000000..75a82605 Binary files /dev/null and b/lib/Essentials.jar differ diff --git a/pom.xml b/pom.xml index 0bba9591..96f67379 100644 --- a/pom.xml +++ b/pom.xml @@ -28,7 +28,7 @@ - 2.7.16 + 2.7.16b1 org.bukkit @@ -118,6 +118,13 @@ 2.5-b654 system ${project.basedir}/lib/Multiverse-Core-2.5.jar + + + com.earth2me.essentials + Essentials + Pre2.9.4.1 + system + ${project.basedir}/lib/Essentials.jar com.sun.mail diff --git a/src/main/java/uk/org/whoami/authme/AuthMe.java b/src/main/java/uk/org/whoami/authme/AuthMe.java index 634ebdb6..51d16fe5 100644 --- a/src/main/java/uk/org/whoami/authme/AuthMe.java +++ b/src/main/java/uk/org/whoami/authme/AuthMe.java @@ -23,6 +23,8 @@ import java.util.Date; import java.util.HashMap; import java.util.Random; +import com.earth2me.essentials.Essentials; + import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import org.bukkit.plugin.Plugin; @@ -94,6 +96,7 @@ public class AuthMe extends JavaPlugin { public int CombatTag = 0; public double ChestShop = 0; public boolean BungeeCord = false; + public Essentials ess; public Notifications notifications; public API api; public HashMap captcha = new HashMap(); @@ -143,6 +146,9 @@ public class AuthMe extends JavaPlugin { //Check ChestShop checkChestShop(); + + //Check Essentials + checkEssentials(); /* * Back style on start if avaible @@ -346,6 +352,21 @@ public class AuthMe extends JavaPlugin { } } } + + private void checkEssentials() { + if (this.getServer().getPluginManager().getPlugin("Essentials") != null && this.getServer().getPluginManager().getPlugin("Essentials").isEnabled()) { + try { + ess = (Essentials) this.getServer().getPluginManager().getPlugin("Essentials"); + ConsoleLogger.info("Hook with Essentials plugin"); + } catch (NullPointerException npe) { + ess = null; + } catch (ClassCastException cce) { + ess = null; + } catch (NoClassDefFoundError ncdfe) { + ess = null; + } + } + } private void checkNotifications() { if (!Settings.notifications) { diff --git a/src/main/java/uk/org/whoami/authme/ConsoleLogger.java b/src/main/java/uk/org/whoami/authme/ConsoleLogger.java index 93799898..e3b9f1b2 100644 --- a/src/main/java/uk/org/whoami/authme/ConsoleLogger.java +++ b/src/main/java/uk/org/whoami/authme/ConsoleLogger.java @@ -73,7 +73,7 @@ public class ConsoleLogger { w.newLine(); w.close(); } catch (IOException e) { - ConsoleLogger.showError(e.getMessage()); + e.printStackTrace(); } } diff --git a/src/main/java/uk/org/whoami/authme/listener/AuthMePlayerListener.java b/src/main/java/uk/org/whoami/authme/listener/AuthMePlayerListener.java index 0a6e47f7..e76aa66a 100644 --- a/src/main/java/uk/org/whoami/authme/listener/AuthMePlayerListener.java +++ b/src/main/java/uk/org/whoami/authme/listener/AuthMePlayerListener.java @@ -159,7 +159,6 @@ public class AuthMePlayerListener implements Listener { String cmd = event.getMessage().split(" ")[0]; if (!Settings.isChatAllowed && !(Settings.allowCommands.contains(cmd))) { - //System.out.println("debug chat: chat isnt allowed"); event.setCancelled(true); return; } @@ -221,7 +220,6 @@ public class AuthMePlayerListener implements Listener { String cmd = event.getMessage().split(" ")[0]; if (!Settings.isChatAllowed && !(Settings.allowCommands.contains(cmd))) { - //System.out.println("debug chat: chat isnt allowed"); event.setCancelled(true); return; } @@ -283,7 +281,6 @@ public class AuthMePlayerListener implements Listener { String cmd = event.getMessage().split(" ")[0]; if (!Settings.isChatAllowed && !(Settings.allowCommands.contains(cmd))) { - //System.out.println("debug chat: chat isnt allowed"); event.setCancelled(true); return; } @@ -345,7 +342,6 @@ public class AuthMePlayerListener implements Listener { String cmd = event.getMessage().split(" ")[0]; if (!Settings.isChatAllowed && !(Settings.allowCommands.contains(cmd))) { - //System.out.println("debug chat: chat isnt allowed"); event.setCancelled(true); return; } @@ -407,7 +403,6 @@ public class AuthMePlayerListener implements Listener { String cmd = event.getMessage().split(" ")[0]; if (!Settings.isChatAllowed && !(Settings.allowCommands.contains(cmd))) { - //System.out.println("debug chat: chat isnt allowed"); event.setCancelled(true); return; } @@ -469,7 +464,6 @@ public class AuthMePlayerListener implements Listener { String cmd = event.getMessage().split(" ")[0]; if (!Settings.isChatAllowed && !(Settings.allowCommands.contains(cmd))) { - //System.out.println("debug chat: chat isnt allowed"); event.setCancelled(true); return; } @@ -562,23 +556,17 @@ public class AuthMePlayerListener implements Listener { return; } - //Run that asynchronous - Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() { - @Override - public void run() { - if(data.isAuthAvailable(name) && !LimboCache.getInstance().hasLimboPlayer(name)) { - if(!Settings.isSessionsEnabled) { - LimboCache.getInstance().addLimboPlayer(player , utils.removeAll(player)); - } else if(PlayerCache.getInstance().isAuthenticated(name)) { - if(!Settings.sessionExpireOnIpChange) - if(LimboCache.getInstance().hasLimboPlayer(player.getName().toLowerCase())) { - LimboCache.getInstance().deleteLimboPlayer(name); - } - LimboCache.getInstance().addLimboPlayer(player , utils.removeAll(player)); - } - } - } - }); + if(data.isAuthAvailable(name) && !LimboCache.getInstance().hasLimboPlayer(name)) { + if(!Settings.isSessionsEnabled) { + LimboCache.getInstance().addLimboPlayer(player , utils.removeAll(player)); + } else if(PlayerCache.getInstance().isAuthenticated(name)) { + if(!Settings.sessionExpireOnIpChange) + if(LimboCache.getInstance().hasLimboPlayer(player.getName().toLowerCase())) { + LimboCache.getInstance().deleteLimboPlayer(name); + } + LimboCache.getInstance().addLimboPlayer(player , utils.removeAll(player)); + } + } //Check if forceSingleSession is set to true, so kick player that has joined with same nick of online player if(player.isOnline() && Settings.isForceSingleSessionEnabled ) { LimboPlayer limbo = LimboCache.getInstance().getLimboPlayer(player.getName().toLowerCase()); @@ -614,16 +602,6 @@ public class AuthMePlayerListener implements Listener { return; } } - if (Settings.bungee) { - ByteArrayOutputStream b = new ByteArrayOutputStream(); - DataOutputStream out = new DataOutputStream(b); - - try { - out.writeUTF("IP"); - } catch (IOException e) { - } - player.sendPluginMessage(this.plugin, "BungeeCord", b.toByteArray()); - } if (event.getResult() != PlayerLoginEvent.Result.KICK_FULL) return; if (player.isBanned()) return; if (!plugin.authmePermissible(player, "authme.vip")) { @@ -647,6 +625,27 @@ public class AuthMePlayerListener implements Listener { } } + @EventHandler(priority = EventPriority.LOWEST) + public void onPlayerLowestJoin(PlayerJoinEvent event) { + if (event.getPlayer() == null) return; + Player player = event.getPlayer(); + + if (plugin.getCitizensCommunicator().isNPC(player, plugin) || Utils.getInstance().isUnrestricted(player) || CombatTagComunicator.isNPC(player)) { + return; + } + + if (Settings.bungee) { + ByteArrayOutputStream b = new ByteArrayOutputStream(); + DataOutputStream out = new DataOutputStream(b); + + try { + out.writeUTF("IP"); + } catch (IOException e) { + } + player.sendPluginMessage(this.plugin, "BungeeCord", b.toByteArray()); + } + } + @EventHandler(priority = EventPriority.HIGHEST) public void onPlayerJoin(PlayerJoinEvent event) { if (event.getPlayer() == null) { @@ -668,6 +667,9 @@ public class AuthMePlayerListener implements Listener { return; } + if (plugin.ess != null && Settings.disableSocialSpy) + plugin.ess.getUser(player.getName()).setSocialSpyEnabled(false); + String ip = player.getAddress().getAddress().getHostAddress(); if (Settings.bungee) { if (plugin.realIp.containsKey(name)) @@ -776,7 +778,7 @@ public class AuthMePlayerListener implements Listener { }); } - @EventHandler(priority = EventPriority.LOWEST) + @EventHandler(priority = EventPriority.MONITOR) public void onPlayerQuit(PlayerQuitEvent event) { if (event.getPlayer() == null) { return; @@ -784,6 +786,9 @@ public class AuthMePlayerListener implements Listener { Player player = event.getPlayer(); String name = player.getName().toLowerCase(); + Location loc = player.getLocation(); + if (loc.getY() % 1 != 0) + loc.add(0, 0.5, 0); if (plugin.getCitizensCommunicator().isNPC(player, plugin) || Utils.getInstance().isUnrestricted(player) || CombatTagComunicator.isNPC(player)) { return; @@ -791,7 +796,7 @@ public class AuthMePlayerListener implements Listener { if (PlayerCache.getInstance().isAuthenticated(name) && !player.isDead()) { if(Settings.isSaveQuitLocationEnabled && data.isAuthAvailable(name)) { - final PlayerAuth auth = new PlayerAuth(event.getPlayer().getName().toLowerCase(),player.getLocation().getBlock().getX(),player.getLocation().getBlock().getY(),player.getLocation().getBlock().getZ()); + final PlayerAuth auth = new PlayerAuth(event.getPlayer().getName().toLowerCase(),loc.getBlockX(),loc.getBlockY(),loc.getBlockZ()); try { Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() { @Override @@ -831,7 +836,7 @@ public class AuthMePlayerListener implements Listener { player.saveData(); } - @EventHandler(priority=EventPriority.MONITOR) + @EventHandler(priority=EventPriority.MONITOR) public void onPlayerKick(PlayerKickEvent event) { if (event.getPlayer() == null) { return; @@ -841,6 +846,9 @@ public class AuthMePlayerListener implements Listener { } Player player = event.getPlayer(); + Location loc = player.getLocation(); + if (loc.getY() % 1 != 0) + loc.add(0, 0.5, 0); if ((plugin.getCitizensCommunicator().isNPC(player, plugin)) || (Utils.getInstance().isUnrestricted(player)) || (CombatTagComunicator.isNPC(player))) { return; @@ -855,7 +863,7 @@ public class AuthMePlayerListener implements Listener { String name = player.getName().toLowerCase(); if ((PlayerCache.getInstance().isAuthenticated(name)) && (!player.isDead()) && (Settings.isSaveQuitLocationEnabled.booleanValue()) && data.isAuthAvailable(name)) { - final PlayerAuth auth = new PlayerAuth(event.getPlayer().getName().toLowerCase(), (int)player.getLocation().getX(), (int)player.getLocation().getY(), (int)player.getLocation().getZ()); + final PlayerAuth auth = new PlayerAuth(event.getPlayer().getName().toLowerCase(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()); Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() { @Override public void run() { diff --git a/src/main/java/uk/org/whoami/authme/settings/Settings.java b/src/main/java/uk/org/whoami/authme/settings/Settings.java index 80b53a9e..dfd64d38 100644 --- a/src/main/java/uk/org/whoami/authme/settings/Settings.java +++ b/src/main/java/uk/org/whoami/authme/settings/Settings.java @@ -59,7 +59,8 @@ public final class Settings extends YamlConfiguration { isForceSurvivalModeEnabled, isResetInventoryIfCreative, isCachingEnabled, isKickOnWrongPasswordEnabled, getEnablePasswordVerifier, protectInventoryBeforeLogInEnabled, isBackupActivated, isBackupOnStart, isBackupOnStop, enablePasspartu, isStopEnabled, reloadSupport, rakamakUseIp, noConsoleSpam, removePassword, displayOtherAccounts, - useCaptcha, emailRegistration, multiverse, notifications, chestshop, bungee, banUnsafeIp, doubleEmailCheck, sessionExpireOnIpChange; + useCaptcha, emailRegistration, multiverse, notifications, chestshop, bungee, banUnsafeIp, doubleEmailCheck, sessionExpireOnIpChange, + disableSocialSpy; public static String getNickRegex, getUnloggedinGroup, getMySQLHost, getMySQLPort, getMySQLUsername, getMySQLPassword, getMySQLDatabase, getMySQLTablename, @@ -204,6 +205,7 @@ public void loadConfigOptions() { doubleEmailCheck = configFile.getBoolean("settings.registration.doubleEmailCheck", false); sessionExpireOnIpChange = configFile.getBoolean("settings.sessions.sessionExpireOnIpChange", false); useLogging = configFile.getBoolean("Security.console.logConsole", false); + disableSocialSpy = configFile.getBoolean("Hooks.disableSocialSpy", true); saveDefaults(); } @@ -323,6 +325,7 @@ public static void reloadConfigOptions(YamlConfiguration newConfig) { doubleEmailCheck = configFile.getBoolean("settings.registration.doubleEmailCheck", false); sessionExpireOnIpChange = configFile.getBoolean("settings.sessions.sessionExpireOnIpChange", false); useLogging = configFile.getBoolean("Security.console.logConsole", false); + disableSocialSpy = configFile.getBoolean("Hooks.disableSocialSpy", true); } @@ -391,6 +394,8 @@ public void mergeConfig() { set("settings.sessions.sessionExpireOnIpChange", false); if(!contains("Security.console.logConsole")) set("Security.console.logConsole", false); + if(!contains("Hooks.disableSocialSpy")) + set("Hooks.disableSocialSpy", true); plugin.getLogger().info("Merge new Config Options if needed.."); plugin.saveConfig(); diff --git a/src/main/java/uk/org/whoami/authme/settings/Spawn.java b/src/main/java/uk/org/whoami/authme/settings/Spawn.java index 16a85d10..44939e14 100644 --- a/src/main/java/uk/org/whoami/authme/settings/Spawn.java +++ b/src/main/java/uk/org/whoami/authme/settings/Spawn.java @@ -66,6 +66,8 @@ public class Spawn extends CustomConfiguration { return location; } catch (NullPointerException npe) { return null; + } catch (NumberFormatException nfe) { + return null; } } diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 8a4112f1..3455c8ce 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -1,10 +1,10 @@ name: AuthMe -author: darkwarriros,Xephi +author: darkwarriors,Xephi website: http://www.multiplayer-italia.com/ description: AuthMe prevents people, which aren't logged in, from doing stuff like placing blocks, moving, typing commands or seeing the inventory of the current player. main: uk.org.whoami.authme.AuthMe -version: 2.7.16 -softdepend: [Vault, ChestShop, Spout, Multiverse-Core, Notifications, Citizens, CombatTag] +version: 2.7.16b1 +softdepend: [Vault, ChestShop, Spout, Multiverse-Core, Notifications, Citizens, CombatTag, Essentials] commands: register: description: Register an account