diff --git a/src/main/java/fr/xephi/authme/process/join/AsyncronousJoin.java b/src/main/java/fr/xephi/authme/process/join/AsyncronousJoin.java index 442fab0a..613e43c3 100644 --- a/src/main/java/fr/xephi/authme/process/join/AsyncronousJoin.java +++ b/src/main/java/fr/xephi/authme/process/join/AsyncronousJoin.java @@ -1,17 +1,5 @@ package fr.xephi.authme.process.join; -import org.bukkit.Bukkit; -import org.bukkit.GameMode; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.block.Block; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; -import org.bukkit.potion.PotionEffect; -import org.bukkit.potion.PotionEffectType; -import org.bukkit.scheduler.BukkitScheduler; -import org.bukkit.scheduler.BukkitTask; - import fr.xephi.authme.AuthMe; import fr.xephi.authme.ConsoleLogger; import fr.xephi.authme.Utils; @@ -32,6 +20,17 @@ import fr.xephi.authme.settings.Settings; import fr.xephi.authme.settings.Spawn; import fr.xephi.authme.task.MessageTask; import fr.xephi.authme.task.TimeoutTask; +import org.bukkit.Bukkit; +import org.bukkit.GameMode; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; +import org.bukkit.scheduler.BukkitScheduler; +import org.bukkit.scheduler.BukkitTask; public class AsyncronousJoin { @@ -62,10 +61,7 @@ public class AsyncronousJoin { } if (plugin.ess != null && Settings.disableSocialSpy) { - try { - plugin.ess.getUser(player.getName().toLowerCase()).setSocialSpyEnabled(false); - } catch (NoSuchMethodError e) { - } + plugin.ess.getUser(player).setSocialSpyEnabled(false); } final String ip = plugin.getIP(player); @@ -289,7 +285,7 @@ public class AsyncronousJoin { } private void placePlayerSafely(final Player player, - final Location spawnLoc) { + final Location spawnLoc) { Location loc = null; if (spawnLoc == null) return; diff --git a/src/main/java/fr/xephi/authme/security/PasswordSecurity.java b/src/main/java/fr/xephi/authme/security/PasswordSecurity.java index 3cc83cfc..a95a848d 100644 --- a/src/main/java/fr/xephi/authme/security/PasswordSecurity.java +++ b/src/main/java/fr/xephi/authme/security/PasswordSecurity.java @@ -1,19 +1,18 @@ package fr.xephi.authme.security; -import java.math.BigInteger; -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; -import java.security.SecureRandom; -import java.util.HashMap; - -import org.bukkit.Bukkit; - import fr.xephi.authme.AuthMe; import fr.xephi.authme.cache.auth.PlayerAuth; import fr.xephi.authme.events.PasswordEncryptionEvent; import fr.xephi.authme.security.crypts.BCRYPT; import fr.xephi.authme.security.crypts.EncryptionMethod; import fr.xephi.authme.settings.Settings; +import org.bukkit.Bukkit; + +import java.math.BigInteger; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; +import java.security.SecureRandom; +import java.util.HashMap; public class PasswordSecurity { @@ -31,7 +30,7 @@ public class PasswordSecurity { } public static String getHash(HashAlgorithm alg, String password, - String playerName) throws NoSuchAlgorithmException { + String playerName) throws NoSuchAlgorithmException { EncryptionMethod method; try { if (alg != HashAlgorithm.CUSTOM) @@ -126,41 +125,39 @@ public class PasswordSecurity { } public static boolean comparePasswordWithHash(String password, String hash, - String playerName) throws NoSuchAlgorithmException { + String playerName) throws NoSuchAlgorithmException { HashAlgorithm algo = Settings.getPasswordHash; EncryptionMethod method; try { if (algo != HashAlgorithm.CUSTOM) method = (EncryptionMethod) algo.getclasse().newInstance(); - else method = null; - } catch (InstantiationException | IllegalAccessException e) { - throw new NoSuchAlgorithmException("Problem with this hash algorithm"); - } - PasswordEncryptionEvent event = new PasswordEncryptionEvent(method, playerName); - Bukkit.getPluginManager().callEvent(event); - method = event.getMethod(); - if (method == null) - throw new NoSuchAlgorithmException("Unknown hash algorithm"); + else + method = null; + + PasswordEncryptionEvent event = new PasswordEncryptionEvent(method, playerName); + Bukkit.getPluginManager().callEvent(event); + method = event.getMethod(); + + if (method == null) + throw new NoSuchAlgorithmException("Unknown hash algorithm"); - try { if (method.comparePassword(hash, password, playerName)) return true; - } catch (Exception e) { - } - if (Settings.supportOldPassword) { - try { + + if (Settings.supportOldPassword) { if (compareWithAllEncryptionMethod(password, hash, playerName)) return true; - } catch (Exception e) { } + } catch (InstantiationException | IllegalAccessException e) { + throw new NoSuchAlgorithmException("Problem with this hash algorithm"); } return false; } private static boolean compareWithAllEncryptionMethod(String password, - String hash, String playerName) throws NoSuchAlgorithmException { + String hash, String playerName) throws NoSuchAlgorithmException { for (HashAlgorithm algo : HashAlgorithm.values()) { - if (algo != HashAlgorithm.CUSTOM) + if (algo != HashAlgorithm.CUSTOM) { try { EncryptionMethod method = (EncryptionMethod) algo.getclasse().newInstance(); if (method.comparePassword(hash, password, playerName)) { @@ -173,8 +170,9 @@ public class PasswordSecurity { } return true; } - } catch (Exception e) { + } catch (Exception ignored) { } + } } return false; }