From a2f5a7917d89be37bad1bf7c8dbe29e0734da556 Mon Sep 17 00:00:00 2001 From: vanhec_a Date: Fri, 16 Oct 2015 17:03:34 +0200 Subject: [PATCH 1/2] Whoops ? :') --- src/main/java/fr/xephi/authme/settings/Settings.java | 4 ++-- src/main/resources/config.yml | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/fr/xephi/authme/settings/Settings.java b/src/main/java/fr/xephi/authme/settings/Settings.java index d185a4c1c..6e84a51f9 100644 --- a/src/main/java/fr/xephi/authme/settings/Settings.java +++ b/src/main/java/fr/xephi/authme/settings/Settings.java @@ -274,7 +274,7 @@ public final class Settings extends YamlConfiguration { forceRegisterCommands = configFile.getStringList("settings.forceRegisterCommands"); forceRegisterCommandsAsConsole = configFile.getStringList("settings.forceRegisterCommandsAsConsole"); customAttributes = configFile.getBoolean("Hooks.customAttributes"); - generateImage = configFile.getBoolean("Email.generateImage", true); + generateImage = configFile.getBoolean("Email.generateImage", false); isMySQLWebsite = configFile.getBoolean("DataSource.mySQLWebsite", false); // Load the welcome message @@ -470,7 +470,7 @@ public final class Settings extends YamlConfiguration { changes = true; } if (!contains("Email.generateImage")) { - set("Email.generateImage", true); + set("Email.generateImage", false); changes = true; } if (!contains("DataSource.mySQLRealName")) { diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index ef9fd2144..6e3ad5615 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -352,6 +352,8 @@ Email: - 10minutemail.com # WhiteList only these domains for emails emailWhitelisted: [] + # Do we need to send new password draw in an image ? + generateImage: false Hooks: # Do we need to hook with multiverse for spawn checking? multiverse: true From e1c1d18d050b51bfadf70b5f181cdf0c8b285866 Mon Sep 17 00:00:00 2001 From: Xephi59 Date: Mon, 19 Oct 2015 23:37:42 +0200 Subject: [PATCH 2/2] Fix Player Online check --- .../java/fr/xephi/authme/DataManager.java | 31 +++++--- .../java/fr/xephi/authme/SendMailSSL.java | 4 +- .../authme/listener/AuthMePlayerListener.java | 73 ++++++++++++------- 3 files changed, 68 insertions(+), 40 deletions(-) diff --git a/src/main/java/fr/xephi/authme/DataManager.java b/src/main/java/fr/xephi/authme/DataManager.java index 9263443fb..1fb82eb0a 100644 --- a/src/main/java/fr/xephi/authme/DataManager.java +++ b/src/main/java/fr/xephi/authme/DataManager.java @@ -1,11 +1,5 @@ package fr.xephi.authme; -import fr.xephi.authme.settings.Settings; -import net.milkbowl.vault.permission.Permission; -import org.bukkit.Bukkit; -import org.bukkit.OfflinePlayer; -import org.bukkit.entity.Player; - import java.io.File; import java.util.List; import java.util.concurrent.Callable; @@ -13,6 +7,13 @@ import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.Future; +import org.bukkit.Bukkit; +import org.bukkit.OfflinePlayer; +import org.bukkit.entity.Player; + +import fr.xephi.authme.settings.Settings; +import net.milkbowl.vault.permission.Permission; + public class DataManager { public AuthMe plugin; @@ -110,7 +111,7 @@ public class DataManager { try { playerFile = new File(plugin.getServer().getWorldContainer() + File.separator + Settings.defaultWorld + File.separator + "players" + File.separator + player.getUniqueId() + ".dat"); - } catch(Exception ignore) { + } catch (Exception ignore) { } if (playerFile.exists()) { playerFile.delete(); @@ -135,8 +136,8 @@ public class DataManager { try { File playerFile = null; try { - playerFile = new File(plugin.ess.getDataFolder() + File.separator + "userdata" + File.separator + plugin.getServer().getOfflinePlayer(name).getUniqueId() + ".yml"); - } catch(Exception ignore) { + playerFile = new File(plugin.ess.getDataFolder() + File.separator + "userdata" + File.separator + plugin.getServer().getOfflinePlayer(name).getUniqueId() + ".yml"); + } catch (Exception ignore) { } if (playerFile.exists()) { playerFile.delete(); @@ -155,7 +156,7 @@ public class DataManager { } public synchronized void purgePermissions(List cleared, - Permission permission) { + Permission permission) { int i = 0; for (String name : cleared) { try { @@ -175,6 +176,7 @@ public class DataManager { return true; ExecutorService executor = Executors.newSingleThreadExecutor(); Future result = executor.submit(new Callable() { + @Override public synchronized Boolean call() throws Exception { for (OfflinePlayer op : Utils.getOnlinePlayers()) @@ -192,4 +194,13 @@ public class DataManager { executor.shutdown(); } } + + public Player getOnlinePlayerLower(String name) { + name = name.toLowerCase(); + for (Player player : Bukkit.getOnlinePlayers()) { + if (player.getName().equalsIgnoreCase(name)) + return player; + } + return null; + } } diff --git a/src/main/java/fr/xephi/authme/SendMailSSL.java b/src/main/java/fr/xephi/authme/SendMailSSL.java index d7681ade8..baac19557 100644 --- a/src/main/java/fr/xephi/authme/SendMailSSL.java +++ b/src/main/java/fr/xephi/authme/SendMailSSL.java @@ -95,14 +95,14 @@ public class SendMailSSL { ConsoleLogger.showError("Unable to send new password as image! Using normal text! Dest: " + mail); } } - + Transport transport = session.getTransport("smtp"); message.setContent(multipart); try { transport.connect(smtp, acc, password); } catch (Exception e) { - ConsoleLogger.showError("Can't connect to your SMTP server! Aborting! Can't send recorvery email to " + mail); + ConsoleLogger.showError("Can't connect to your SMTP server! Aborting! Can't send recovery email to " + mail); if (file != null) file.delete(); return; diff --git a/src/main/java/fr/xephi/authme/listener/AuthMePlayerListener.java b/src/main/java/fr/xephi/authme/listener/AuthMePlayerListener.java index 5706ef669..dfdce68bb 100644 --- a/src/main/java/fr/xephi/authme/listener/AuthMePlayerListener.java +++ b/src/main/java/fr/xephi/authme/listener/AuthMePlayerListener.java @@ -1,16 +1,11 @@ package fr.xephi.authme.listener; -import com.google.common.io.ByteArrayDataOutput; -import com.google.common.io.ByteStreams; -import fr.xephi.authme.AuthMe; -import fr.xephi.authme.ConsoleLogger; -import fr.xephi.authme.Utils; -import fr.xephi.authme.cache.auth.PlayerAuth; -import fr.xephi.authme.cache.auth.PlayerCache; -import fr.xephi.authme.cache.limbo.LimboCache; -import fr.xephi.authme.cache.limbo.LimboPlayer; -import fr.xephi.authme.settings.Messages; -import fr.xephi.authme.settings.Settings; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.concurrent.ConcurrentHashMap; +import java.util.regex.PatternSyntaxException; + import org.bukkit.Bukkit; import org.bukkit.GameMode; import org.bukkit.Location; @@ -23,13 +18,37 @@ import org.bukkit.event.block.SignChangeEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.inventory.InventoryOpenEvent; -import org.bukkit.event.player.*; +import org.bukkit.event.player.AsyncPlayerChatEvent; +import org.bukkit.event.player.AsyncPlayerPreLoginEvent; +import org.bukkit.event.player.PlayerBedEnterEvent; +import org.bukkit.event.player.PlayerCommandPreprocessEvent; +import org.bukkit.event.player.PlayerDropItemEvent; +import org.bukkit.event.player.PlayerFishEvent; +import org.bukkit.event.player.PlayerGameModeChangeEvent; +import org.bukkit.event.player.PlayerInteractEntityEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerItemConsumeEvent; +import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.event.player.PlayerKickEvent; +import org.bukkit.event.player.PlayerLoginEvent; +import org.bukkit.event.player.PlayerMoveEvent; +import org.bukkit.event.player.PlayerPickupItemEvent; +import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.event.player.PlayerRespawnEvent; +import org.bukkit.event.player.PlayerShearEntityEvent; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.concurrent.ConcurrentHashMap; -import java.util.regex.PatternSyntaxException; +import com.google.common.io.ByteArrayDataOutput; +import com.google.common.io.ByteStreams; + +import fr.xephi.authme.AuthMe; +import fr.xephi.authme.ConsoleLogger; +import fr.xephi.authme.Utils; +import fr.xephi.authme.cache.auth.PlayerAuth; +import fr.xephi.authme.cache.auth.PlayerCache; +import fr.xephi.authme.cache.limbo.LimboCache; +import fr.xephi.authme.cache.limbo.LimboPlayer; +import fr.xephi.authme.settings.Messages; +import fr.xephi.authme.settings.Settings; public class AuthMePlayerListener implements Listener { @@ -185,6 +204,7 @@ public class AuthMePlayerListener implements Listener { // Shedule login task so works after the prelogin // (Fix found by Koolaid5000) Bukkit.getScheduler().runTask(plugin, new Runnable() { + @Override public void run() { Player player = event.getPlayer(); @@ -201,28 +221,27 @@ public class AuthMePlayerListener implements Listener { }); } - @SuppressWarnings("deprecation") @EventHandler(priority = EventPriority.HIGHEST) public void onPreLogin(AsyncPlayerPreLoginEvent event) { final String name = event.getName().toLowerCase(); - final Player player = Bukkit.getServer().getPlayer(name); + final Player player = plugin.dataManager.getOnlinePlayerLower(name); if (player == null) return; // Check if forceSingleSession is set to true, so kick player that has // joined with same nick of online player - if (Settings.isForceSingleSessionEnabled && plugin.dataManager.isOnline(player, name)) { - event.setKickMessage(m.send("same_nick")[0]); + if (Settings.isForceSingleSessionEnabled) { + event.setKickMessage(m.getString("same_nick")); event.setLoginResult(AsyncPlayerPreLoginEvent.Result.KICK_OTHER); if (LimboCache.getInstance().hasLimboPlayer(name)) Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() { @Override public void run() { - LimboPlayer limbo = LimboCache.getInstance().getLimboPlayer(player.getName().toLowerCase()); - if (limbo != null && PlayerCache.getInstance().isAuthenticated(player.getName().toLowerCase())) { + LimboPlayer limbo = LimboCache.getInstance().getLimboPlayer(name); + if (limbo != null && PlayerCache.getInstance().isAuthenticated(name)) { Utils.addNormal(player, limbo.getGroup()); - LimboCache.getInstance().deleteLimboPlayer(player.getName().toLowerCase()); + LimboCache.getInstance().deleteLimboPlayer(name); } } }); @@ -244,8 +263,7 @@ public class AuthMePlayerListener implements Listener { if (event.getResult() != PlayerLoginEvent.Result.ALLOWED) return; - if (!Settings.countriesBlacklist.isEmpty() && !isAuthAvailable - && !plugin.authmePermissible(player, "authme.bypassantibot")) { + if (!Settings.countriesBlacklist.isEmpty() && !isAuthAvailable && !plugin.authmePermissible(player, "authme.bypassantibot")) { String code = Utils.getCountryCode(event.getAddress().getHostAddress()); if (((code == null) || Settings.countriesBlacklist.contains(code))) { event.setKickMessage(m.send("country_banned")[0]); @@ -253,8 +271,7 @@ public class AuthMePlayerListener implements Listener { return; } } - if (Settings.enableProtection && !Settings.countries.isEmpty() && !isAuthAvailable - && !plugin.authmePermissible(player, "authme.bypassantibot")) { + if (Settings.enableProtection && !Settings.countries.isEmpty() && !isAuthAvailable && !plugin.authmePermissible(player, "authme.bypassantibot")) { String code = Utils.getCountryCode(event.getAddress().getHostAddress()); if (((code == null) || !Settings.countries.contains(code))) { event.setKickMessage(m.send("country_banned")[0]);