From 0dd048774ef0707664316207df71ab05f1fdb1bf Mon Sep 17 00:00:00 2001 From: Xephi Date: Tue, 12 Mar 2013 17:20:33 +0100 Subject: [PATCH] Update 2.7.11b1 --- pom.xml | 2 +- .../authme/commands/RegisterCommand.java | 27 ++++++- .../authme/events/RegisterTeleportEvent.java | 29 +++++++ .../authme/listener/AuthMePlayerListener.java | 24 +++--- .../uk/org/whoami/authme/security/PhpBB.java | 9 +-- .../org/whoami/authme/settings/Settings.java | 76 +++++++------------ src/main/resources/config.yml | 1 + src/main/resources/plugin.yml | 2 +- 8 files changed, 103 insertions(+), 67 deletions(-) create mode 100644 src/main/java/uk/org/whoami/authme/events/RegisterTeleportEvent.java diff --git a/pom.xml b/pom.xml index c99c4032f..864a2710b 100644 --- a/pom.xml +++ b/pom.xml @@ -28,7 +28,7 @@ - 2.7.10-SNAPSHOT + 2.7.11b1 org.bukkit diff --git a/src/main/java/uk/org/whoami/authme/commands/RegisterCommand.java b/src/main/java/uk/org/whoami/authme/commands/RegisterCommand.java index ad505a868..d7e08a854 100644 --- a/src/main/java/uk/org/whoami/authme/commands/RegisterCommand.java +++ b/src/main/java/uk/org/whoami/authme/commands/RegisterCommand.java @@ -41,7 +41,7 @@ import uk.org.whoami.authme.cache.auth.PlayerCache; import uk.org.whoami.authme.cache.limbo.LimboCache; import uk.org.whoami.authme.cache.limbo.LimboPlayer; import uk.org.whoami.authme.datasource.DataSource; -import uk.org.whoami.authme.events.AuthMeTeleportEvent; +import uk.org.whoami.authme.events.RegisterTeleportEvent; import uk.org.whoami.authme.security.PasswordSecurity; import uk.org.whoami.authme.security.RandomString; import uk.org.whoami.authme.settings.Messages; @@ -195,6 +195,29 @@ public class RegisterCommand implements CommandExecutor { LimboCache.getInstance().getLimboPlayer(name).setMessageTaskId(nwMsg.getTaskId()); LimboCache.getInstance().deleteLimboPlayer(name); + if (Settings.isTeleportToSpawnEnabled) { + World world = player.getWorld(); + Location loca = world.getSpawnLocation(); + if (plugin.mv != null) { + try { + loca = plugin.mv.getMVWorldManager().getMVWorld(world).getSpawnLocation(); + } catch (NullPointerException npe) { + + } catch (ClassCastException cce) { + + } catch (NoClassDefFoundError ncdfe) { + + } + } + RegisterTeleportEvent tpEvent = new RegisterTeleportEvent(player, loca); + plugin.getServer().getPluginManager().callEvent(tpEvent); + if(!tpEvent.isCancelled()) { + if (!tpEvent.getTo().getWorld().getChunkAt(tpEvent.getTo()).isLoaded()) { + tpEvent.getTo().getWorld().getChunkAt(tpEvent.getTo()).load(); + } + player.teleport(tpEvent.getTo()); + } + } this.isFirstTimeJoin = true; player.saveData(); if (!Settings.noConsoleSpam) @@ -260,7 +283,7 @@ public class RegisterCommand implements CommandExecutor { } } - AuthMeTeleportEvent tpEvent = new AuthMeTeleportEvent(player, loca); + RegisterTeleportEvent tpEvent = new RegisterTeleportEvent(player, loca); plugin.getServer().getPluginManager().callEvent(tpEvent); if(!tpEvent.isCancelled()) { if (!tpEvent.getTo().getWorld().getChunkAt(tpEvent.getTo()).isLoaded()) { diff --git a/src/main/java/uk/org/whoami/authme/events/RegisterTeleportEvent.java b/src/main/java/uk/org/whoami/authme/events/RegisterTeleportEvent.java new file mode 100644 index 000000000..e2e8b9a59 --- /dev/null +++ b/src/main/java/uk/org/whoami/authme/events/RegisterTeleportEvent.java @@ -0,0 +1,29 @@ +package uk.org.whoami.authme.events; + +import org.bukkit.Location; +import org.bukkit.entity.Player; + +public class RegisterTeleportEvent extends CustomEvent { + + private Player player; + private Location to; + private Location from; + + public RegisterTeleportEvent(Player player, Location to) { + this.player = player; + this.from = player.getLocation(); + this.to = to; + } + public Player getPlayer() { + return player; + } + public void setTo(Location to) { + this.to = to; + } + public Location getTo() { + return to; + } + public Location getFrom() { + return from; + } +} 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 01214baea..7417b42f9 100644 --- a/src/main/java/uk/org/whoami/authme/listener/AuthMePlayerListener.java +++ b/src/main/java/uk/org/whoami/authme/listener/AuthMePlayerListener.java @@ -98,7 +98,7 @@ public class AuthMePlayerListener implements Listener { String name = player.getName().toLowerCase(); - if (plugin.getCitizensCommunicator().isNPC(player, plugin) || Utils.getInstance().isUnrestricted(player) || CombatTagComunicator.isNPC(player) ) { + if (Utils.getInstance().isUnrestricted(player)) { return; } @@ -700,7 +700,7 @@ public class AuthMePlayerListener implements Listener { if((cur - lastLogin < timeout || timeout == 0) && !auth.getIp().equals("198.18.0.1") ) { if (auth.getNickname().equalsIgnoreCase(name) && auth.getIp().equals(ip) ) { - Bukkit.getServer().getPluginManager().callEvent(new SessionEvent(auth, true)); + plugin.getServer().getPluginManager().callEvent(new SessionEvent(auth, true)); if(PlayerCache.getInstance().getAuth(name) != null) { PlayerCache.getInstance().updatePlayer(auth); } else { @@ -709,10 +709,15 @@ public class AuthMePlayerListener implements Listener { player.sendMessage(m._("valid_session")); return; } else { - int gM = gameMode.get(name); - player.setGameMode(GameMode.getByValue(gM)); - player.kickPlayer(m._("unvalid_session")); - return; + if(Settings.sessionExpireOnIpChange && !player.isOnline()) { + PlayerCache.getInstance().removePlayer(name); + LimboCache.getInstance().addLimboPlayer(player , utils.removeAll(player)); + } else { + int gM = gameMode.get(name); + player.setGameMode(GameMode.getByValue(gM)); + player.kickPlayer(m._("unvalid_session")); + return; + } } } else { @@ -741,7 +746,7 @@ public class AuthMePlayerListener implements Listener { try { LimboPlayer limbo = LimboCache.getInstance().getLimboPlayer(player.getName().toLowerCase()); ProtectInventoryEvent ev = new ProtectInventoryEvent(player, limbo.getInventory(), limbo.getArmour(), 36, 4); - Bukkit.getServer().getPluginManager().callEvent(ev); + plugin.getServer().getPluginManager().callEvent(ev); if (ev.isCancelled()) { if (!Settings.noConsoleSpam) ConsoleLogger.info("ProtectInventoryEvent has been cancelled for " + player.getName() + " ..."); @@ -820,7 +825,7 @@ public class AuthMePlayerListener implements Listener { LimboPlayer limbo = LimboCache.getInstance().getLimboPlayer(name); if(Settings.protectInventoryBeforeLogInEnabled && player.hasPlayedBefore()) { RestoreInventoryEvent ev = new RestoreInventoryEvent(player, limbo.getInventory(), limbo.getArmour()); - Bukkit.getServer().getPluginManager().callEvent(ev); + plugin.getServer().getPluginManager().callEvent(ev); if (!ev.isCancelled()) { API.setPlayerInventory(player, limbo.getInventory(), limbo.getArmour()); } @@ -847,6 +852,7 @@ public class AuthMePlayerListener implements Listener { } if (gameMode.containsKey(name)) gameMode.remove(name); player.saveData(); + } @EventHandler(priority=EventPriority.MONITOR) @@ -883,7 +889,7 @@ public class AuthMePlayerListener implements Listener { if (Settings.protectInventoryBeforeLogInEnabled.booleanValue()) { try { RestoreInventoryEvent ev = new RestoreInventoryEvent(player, limbo.getInventory(), limbo.getArmour()); - Bukkit.getServer().getPluginManager().callEvent(ev); + plugin.getServer().getPluginManager().callEvent(ev); if (!ev.isCancelled()) { API.setPlayerInventory(player, ev.getInventory(), ev.getArmor()); } diff --git a/src/main/java/uk/org/whoami/authme/security/PhpBB.java b/src/main/java/uk/org/whoami/authme/security/PhpBB.java index 82f975e6e..27ac1ef3c 100644 --- a/src/main/java/uk/org/whoami/authme/security/PhpBB.java +++ b/src/main/java/uk/org/whoami/authme/security/PhpBB.java @@ -41,16 +41,11 @@ public class PhpBB { return md5(password); } - private String unique_id() { - return unique_id("c"); - } - // global $config; // private boolean dss_seeded = false; - private String unique_id(String extra) { - // TODO Generate something random here. - return "1234567890abcdef"; + private String unique_id() { + return new RandomString(16).nextString(); } 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 e2b361511..7772f6f81 100644 --- a/src/main/java/uk/org/whoami/authme/settings/Settings.java +++ b/src/main/java/uk/org/whoami/authme/settings/Settings.java @@ -60,7 +60,7 @@ 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; + useCaptcha, emailRegistration, multiverse, notifications, chestshop, bungee, banUnsafeIp, doubleEmailCheck, sessionExpireOnIpChange; public static String getNickRegex, getUnloggedinGroup, getMySQLHost, getMySQLPort, @@ -219,6 +219,7 @@ public void loadConfigOptions() { getForcedWorlds = (List) configFile.getList("settings.restrictions.ForceSpawnOnTheseWorlds"); banUnsafeIp = configFile.getBoolean("settings.restrictions.banUnsafedIP", false); doubleEmailCheck = configFile.getBoolean("settings.registration.doubleEmailCheck", false); + sessionExpireOnIpChange = configFile.getBoolean("settings.sessions.sessionExpireOnIpChange", false); saveDefaults(); } @@ -338,19 +339,18 @@ public static void reloadConfigOptions(YamlConfiguration newConfig) { getForcedWorlds = (List) configFile.getList("settings.restrictions.ForceSpawnOnTheseWorlds"); banUnsafeIp = configFile.getBoolean("settings.restrictions.banUnsafedIP", false); doubleEmailCheck = configFile.getBoolean("settings.registration.doubleEmailCheck", false); + sessionExpireOnIpChange = configFile.getBoolean("settings.sessions.sessionExpireOnIpChange", false); } public void mergeConfig() { - if (contains("settings.restrictions.allowedPluginTeleportHandler")) { + if (contains("settings.restrictions.allowedPluginTeleportHandler")) set("settings.restrictions.allowedPluginTeleportHandler", null); - } - if(!contains("DataSource.mySQLColumnEmail")) { + if(!contains("DataSource.mySQLColumnEmail")) set("DataSource.mySQLColumnEmail","email"); - } if(contains("Email.GmailAccount")) { set("Email.mailAccount", getString("Email.GmailAccount")); @@ -362,77 +362,59 @@ public void mergeConfig() { set("Email.GmailPassword", null); } - if(!contains("Email.RecoveryPasswordLength")) { + if(!contains("Email.RecoveryPasswordLength")) set("Email.RecoveryPasswordLength", 8); - } - if(!contains("Email.mailPort")) { + if(!contains("Email.mailPort")) set("Email.mailPort", 465); - } - if(!contains("Email.mailSMTP")) { + if(!contains("Email.mailSMTP")) set("Email.mailSMTP", "smtp.gmail.com"); - } - if(!contains("Email.mailAccount")) { + if(!contains("Email.mailAccount")) set("Email.mailAccount", ""); - } - if(!contains("Email.mailPassword")) { + if(!contains("Email.mailPassword")) set("Email.mailPassword", ""); - } - if(!contains("ExternalBoardOptions.mySQLOtherUsernameColumns")) { + if(!contains("ExternalBoardOptions.mySQLOtherUsernameColumns")) set("ExternalBoardOptions.mySQLOtherUsernameColumns", new ArrayList()); - } - if(!contains("settings.restrictions.displayOtherAccounts")) { + if(!contains("settings.restrictions.displayOtherAccounts")) set("settings.restrictions.displayOtherAccounts", true); - } - if(!contains("DataSource.mySQLColumnId")) { + if(!contains("DataSource.mySQLColumnId")) set("DataSource.mySQLColumnId", "id"); - } - if(!contains("Email.mailSenderName")) { + if(!contains("Email.mailSenderName")) set("Email.mailSenderName", ""); - } - if(!contains("Xenoforo.predefinedSalt")) { + if(!contains("Xenoforo.predefinedSalt")) set("Xenoforo.predefinedSalt", ""); - } - if(!contains("Security.captcha.useCaptcha")) { + if(!contains("Security.captcha.useCaptcha")) set("Security.captcha.useCaptcha", false); - } - if(!contains("Security.captcha.maxLoginTry")) { + if(!contains("Security.captcha.maxLoginTry")) set("Security.captcha.maxLoginTry", 5); - } - if(!contains("Security.captcha.captchaLength")) { + if(!contains("Security.captcha.captchaLength")) set("Security.captcha.captchaLength", 5); - } - if(!contains("Email.mailSubject")) { + if(!contains("Email.mailSubject")) set("Email.mailSubject", ""); - } - if(!contains("Email.mailText")) { + if(!contains("Email.mailText")) set("Email.mailText", "Dear , \n\n This is your new AuthMe password for the server : \n\n \n\n \n\n Do not forget to change password after login! \n /changepassword newPassword"); - } - if(!contains("settings.registration.enableEmailRegistrationSystem")) { + if(!contains("settings.registration.enableEmailRegistrationSystem")) set("settings.registration.enableEmailRegistrationSystem", false); - } - if(!contains("settings.security.doubleMD5SaltLength")) { + if(!contains("settings.security.doubleMD5SaltLength")) set("settings.security.doubleMD5SaltLength", 8); - } - if(!contains("Email.maxRegPerEmail")) { + if(!contains("Email.maxRegPerEmail")) set("Email.maxRegPerEmail", 1); - } if(!contains("Hooks.multiverse")) { set("Hooks.multiverse", true); @@ -441,17 +423,17 @@ public void mergeConfig() { set("Hooks.bungeecord", false); } - if(!contains("settings.restrictions.ForceSpawnOnTheseWorlds")) { + if(!contains("settings.restrictions.ForceSpawnOnTheseWorlds")) set("settings.restrictions.ForceSpawnOnTheseWorlds", new ArrayList()); - } - if(!contains("settings.restrictions.banUnsafedIP")) { + if(!contains("settings.restrictions.banUnsafedIP")) set("settings.restrictions.banUnsafedIP", false); - } - if(!contains("settings.registration.doubleEmailCheck")) { + if(!contains("settings.registration.doubleEmailCheck")) set("settings.registration.doubleEmailCheck", false); - } + + if(!contains("settings.sessions.sessionExpireOnIpChange")) + set("settings.sessions.sessionExpireOnIpChange", false); plugin.getLogger().info("Merge new Config Options if needed.."); plugin.saveConfig(); diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 459d7e1d1..7350973eb 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -25,6 +25,7 @@ settings: sessions: enabled: false timeout: 10 + sessionExpireOnIpChange: false restrictions: allowChat: false allowCommands: diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index cfcf86710..258c018e8 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -3,7 +3,7 @@ author: darkwarriros,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.10b2 +version: 2.7.11b1 softdepend: [Vault, ChestShop, Spout, Multiverse-Core, Notifications, Citizens, CombatTag] commands: register: