diff --git a/src/main/java/fr/xephi/authme/command/executable/authme/SwitchAntiBotCommand.java b/src/main/java/fr/xephi/authme/command/executable/authme/SwitchAntiBotCommand.java index fb844c60..9e074257 100644 --- a/src/main/java/fr/xephi/authme/command/executable/authme/SwitchAntiBotCommand.java +++ b/src/main/java/fr/xephi/authme/command/executable/authme/SwitchAntiBotCommand.java @@ -31,18 +31,19 @@ public class SwitchAntiBotCommand extends ExecutableCommand { return true; } - // Enable the mod - if (newState.equalsIgnoreCase("ON")) { - AntiBot.overrideAntiBotStatus(true); - sender.sendMessage("[AuthMe] AntiBot Manual Ovverride: enabled!"); - return true; - } - - // Disable the mod - if (newState.equalsIgnoreCase("OFF")) { - AntiBot.overrideAntiBotStatus(false); - sender.sendMessage("[AuthMe] AntiBotMod Manual Ovverride: disabled!"); - return true; + if(newState != null) { + // Enable the mod + if (newState.equalsIgnoreCase("ON")) { + AntiBot.overrideAntiBotStatus(true); + sender.sendMessage("[AuthMe] AntiBot Manual Override: enabled!"); + return true; + } + // Disable the mod + if (newState.equalsIgnoreCase("OFF")) { + AntiBot.overrideAntiBotStatus(false); + sender.sendMessage("[AuthMe] AntiBotMod Manual Override: disabled!"); + return true; + } } // Show the invalid arguments warning diff --git a/src/main/java/fr/xephi/authme/converter/vAuthFileReader.java b/src/main/java/fr/xephi/authme/converter/vAuthFileReader.java index 1ab969ea..31ffbb34 100644 --- a/src/main/java/fr/xephi/authme/converter/vAuthFileReader.java +++ b/src/main/java/fr/xephi/authme/converter/vAuthFileReader.java @@ -9,7 +9,6 @@ import org.bukkit.OfflinePlayer; import org.bukkit.command.CommandSender; import java.io.File; -import java.io.IOException; import java.util.Scanner; import java.util.UUID; @@ -35,8 +34,6 @@ public class vAuthFileReader { /** * Method convert. - * - * @throws IOException */ public void convert() { final File file = new File(plugin.getDataFolder().getParent() + "" + File.separator + "vAuth" + File.separator + "passwords.yml"); diff --git a/src/main/java/fr/xephi/authme/datasource/FlatFile.java b/src/main/java/fr/xephi/authme/datasource/FlatFile.java index 19c93ea3..c0fc3cb4 100644 --- a/src/main/java/fr/xephi/authme/datasource/FlatFile.java +++ b/src/main/java/fr/xephi/authme/datasource/FlatFile.java @@ -564,7 +564,7 @@ public class FlatFile implements DataSource { BufferedReader br = null; try { br = new BufferedReader(new FileReader(source)); - String line = ""; + String line; while ((line = br.readLine()) != null) { String[] args = line.split(":"); if (args[0].equals(auth.getNickname())) { diff --git a/src/main/java/fr/xephi/authme/datasource/MySQL.java b/src/main/java/fr/xephi/authme/datasource/MySQL.java index 455361a4..605e80a4 100644 --- a/src/main/java/fr/xephi/authme/datasource/MySQL.java +++ b/src/main/java/fr/xephi/authme/datasource/MySQL.java @@ -46,7 +46,7 @@ public class MySQL implements DataSource { * * @throws ClassNotFoundException * @throws SQLException * @throws PoolInitializationException */ - public MySQL() throws ClassNotFoundException, SQLException, PoolInitializationException { + public MySQL() throws SQLException, PoolInitializationException { this.host = Settings.getMySQLHost; this.port = Settings.getMySQLPort; this.username = Settings.getMySQLUsername; @@ -102,7 +102,7 @@ public class MySQL implements DataSource { /** * Method setConnectionArguments. * - * @throws ClassNotFoundException * @throws IllegalArgumentException + * @throws IllegalArgumentException */ private synchronized void setConnectionArguments() throws IllegalArgumentException { @@ -126,10 +126,10 @@ public class MySQL implements DataSource { /** * Method reloadArguments. * - * @throws ClassNotFoundException * @throws IllegalArgumentException + * @throws IllegalArgumentException */ private synchronized void reloadArguments() - throws ClassNotFoundException, IllegalArgumentException { + throws IllegalArgumentException { if (ds != null) { ds.close(); } diff --git a/src/main/java/fr/xephi/authme/security/crypts/BCRYPT2Y.java b/src/main/java/fr/xephi/authme/security/crypts/BCRYPT2Y.java index 63d10985..ee8d4e2a 100644 --- a/src/main/java/fr/xephi/authme/security/crypts/BCRYPT2Y.java +++ b/src/main/java/fr/xephi/authme/security/crypts/BCRYPT2Y.java @@ -36,9 +36,7 @@ public class BCRYPT2Y implements EncryptionMethod { public boolean comparePassword(String hash, String password, String playerName) throws NoSuchAlgorithmException { String ok = hash.substring(0, 29); - if (ok.length() != 29) - return false; - return hash.equals(getHash(password, ok, playerName)); + return ok.length() == 29 && hash.equals(getHash(password, ok, playerName)); } } diff --git a/src/main/java/fr/xephi/authme/security/crypts/WHIRLPOOL.java b/src/main/java/fr/xephi/authme/security/crypts/WHIRLPOOL.java index 6bf5d9f3..75129ac8 100644 --- a/src/main/java/fr/xephi/authme/security/crypts/WHIRLPOOL.java +++ b/src/main/java/fr/xephi/authme/security/crypts/WHIRLPOOL.java @@ -211,9 +211,7 @@ public class WHIRLPOOL implements EncryptionMethod { L[i] ^= C[t][(int) (K[(i - t) & 7] >>> s) & 0xff]; } } - for (int i = 0; i < 8; i++) { - K[i] = L[i]; - } + System.arraycopy(L, 0, K, 0, 8); K[0] ^= rc[r]; /* * apply the r-th round transformation: @@ -224,9 +222,7 @@ public class WHIRLPOOL implements EncryptionMethod { L[i] ^= C[t][(int) (state[(i - t) & 7] >>> s) & 0xff]; } } - for (int i = 0; i < 8; i++) { - state[i] = L[i]; - } + System.arraycopy(L, 0, state, 0, 8); } /* * apply the Miyaguchi-Preneel compression function: diff --git a/src/main/java/fr/xephi/authme/security/crypts/XF.java b/src/main/java/fr/xephi/authme/security/crypts/XF.java index a1fc45ce..8a2d7369 100644 --- a/src/main/java/fr/xephi/authme/security/crypts/XF.java +++ b/src/main/java/fr/xephi/authme/security/crypts/XF.java @@ -9,8 +9,6 @@ import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; -/** - */ public class XF implements EncryptionMethod { /** @@ -55,10 +53,6 @@ public class XF implements EncryptionMethod { MessageDigest md = MessageDigest.getInstance("SHA-256"); md.update(password.getBytes()); byte byteData[] = md.digest(); - StringBuilder sb = new StringBuilder(); - for (byte element : byteData) { - sb.append(Integer.toString((element & 0xff) + 0x100, 16).substring(1)); - } StringBuilder hexString = new StringBuilder(); for (byte element : byteData) { String hex = Integer.toHexString(0xff & element); diff --git a/src/main/java/fr/xephi/authme/security/pbkdf2/BinTools.java b/src/main/java/fr/xephi/authme/security/pbkdf2/BinTools.java index 0631bd5a..a553ba54 100644 --- a/src/main/java/fr/xephi/authme/security/pbkdf2/BinTools.java +++ b/src/main/java/fr/xephi/authme/security/pbkdf2/BinTools.java @@ -46,7 +46,7 @@ public class BinTools { if (b == null) { return ""; } - StringBuffer stringBuffer = new StringBuffer(2 * b.length); + StringBuilder stringBuffer = new StringBuilder(2 * b.length); for (byte aB : b) { int v = (256 + aB) % 256; stringBuffer.append(hex.charAt((v / 16) & 15));