diff --git a/src/main/java/fr/xephi/authme/api/API.java b/src/main/java/fr/xephi/authme/api/API.java index f63ac974..7fe3d43e 100644 --- a/src/main/java/fr/xephi/authme/api/API.java +++ b/src/main/java/fr/xephi/authme/api/API.java @@ -105,7 +105,7 @@ public class API { try { player.getInventory().setContents(content); player.getInventory().setArmorContents(armor); - } catch (NullPointerException npe) { + } catch (NullPointerException ignored) { } } diff --git a/src/main/java/fr/xephi/authme/datasource/FlatFile.java b/src/main/java/fr/xephi/authme/datasource/FlatFile.java index d6495b9d..2f0b3c47 100644 --- a/src/main/java/fr/xephi/authme/datasource/FlatFile.java +++ b/src/main/java/fr/xephi/authme/datasource/FlatFile.java @@ -73,7 +73,7 @@ public class FlatFile implements DataSource { if (br != null) { try { br.close(); - } catch (IOException ex) { + } catch (IOException ignored) { } } } @@ -103,7 +103,7 @@ public class FlatFile implements DataSource { if (bw != null) { try { bw.close(); - } catch (IOException ex) { + } catch (IOException ignored) { } } } @@ -165,7 +165,7 @@ public class FlatFile implements DataSource { if (br != null) { try { br.close(); - } catch (IOException ex) { + } catch (IOException ignored) { } } } @@ -231,7 +231,7 @@ public class FlatFile implements DataSource { if (br != null) { try { br.close(); - } catch (IOException ex) { + } catch (IOException ignored) { } } } @@ -276,7 +276,7 @@ public class FlatFile implements DataSource { if (br != null) { try { br.close(); - } catch (IOException ex) { + } catch (IOException ignored) { } } } @@ -318,7 +318,7 @@ public class FlatFile implements DataSource { if (br != null) { try { br.close(); - } catch (IOException ex) { + } catch (IOException ignored) { } } } @@ -364,13 +364,13 @@ public class FlatFile implements DataSource { if (br != null) { try { br.close(); - } catch (IOException ex) { + } catch (IOException ignored) { } } if (bw != null) { try { bw.close(); - } catch (IOException ex) { + } catch (IOException ignored) { } } } @@ -417,13 +417,13 @@ public class FlatFile implements DataSource { if (br != null) { try { br.close(); - } catch (IOException ex) { + } catch (IOException ignored) { } } if (bw != null) { try { bw.close(); - } catch (IOException ex) { + } catch (IOException ignored) { } } } @@ -468,13 +468,13 @@ public class FlatFile implements DataSource { if (br != null) { try { br.close(); - } catch (IOException ex) { + } catch (IOException ignored) { } } if (bw != null) { try { bw.close(); - } catch (IOException ex) { + } catch (IOException ignored) { } } } @@ -523,7 +523,7 @@ public class FlatFile implements DataSource { if (br != null) { try { br.close(); - } catch (IOException ex) { + } catch (IOException ignored) { } } } @@ -582,7 +582,7 @@ public class FlatFile implements DataSource { if (br != null) { try { br.close(); - } catch (IOException ex) { + } catch (IOException ignored) { } } } @@ -636,7 +636,7 @@ public class FlatFile implements DataSource { if (br != null) { try { br.close(); - } catch (IOException ex) { + } catch (IOException ignored) { } } } @@ -673,7 +673,7 @@ public class FlatFile implements DataSource { if (br != null) { try { br.close(); - } catch (IOException ex) { + } catch (IOException ignored) { } } } @@ -710,7 +710,7 @@ public class FlatFile implements DataSource { if (br != null) { try { br.close(); - } catch (IOException ex) { + } catch (IOException ignored) { } } } @@ -737,16 +737,13 @@ public class FlatFile implements DataSource { if (banned.contains(args[0])) { lines.add(line); } - } catch (NullPointerException | ArrayIndexOutOfBoundsException exc) { + } catch (NullPointerException | ArrayIndexOutOfBoundsException ignored) { } } bw = new BufferedWriter(new FileWriter(source)); for (String l : lines) { bw.write(l + "\n"); } - } catch (FileNotFoundException ex) { - ConsoleLogger.showError(ex.getMessage()); - return; } catch (IOException ex) { ConsoleLogger.showError(ex.getMessage()); return; @@ -754,13 +751,13 @@ public class FlatFile implements DataSource { if (br != null) { try { br.close(); - } catch (IOException ex) { + } catch (IOException ignored) { } } if (bw != null) { try { bw.close(); - } catch (IOException ex) { + } catch (IOException ignored) { } } } @@ -841,7 +838,7 @@ public class FlatFile implements DataSource { if (br != null) { try { br.close(); - } catch (IOException ex) { + } catch (IOException ignored) { } } } @@ -909,7 +906,7 @@ public class FlatFile implements DataSource { if (br != null) { try { br.close(); - } catch (IOException ex) { + } catch (IOException ignored) { } } } diff --git a/src/main/java/fr/xephi/authme/process/quit/ProcessSyncronousPlayerQuit.java b/src/main/java/fr/xephi/authme/process/quit/ProcessSyncronousPlayerQuit.java index fbbb88f8..5628c201 100644 --- a/src/main/java/fr/xephi/authme/process/quit/ProcessSyncronousPlayerQuit.java +++ b/src/main/java/fr/xephi/authme/process/quit/ProcessSyncronousPlayerQuit.java @@ -51,7 +51,7 @@ public class ProcessSyncronousPlayerQuit implements Runnable { } try { player.getVehicle().eject(); - } catch (Exception e) { + } catch (Exception ignored) { } } } diff --git a/src/main/java/fr/xephi/authme/security/crypts/BCRYPT.java b/src/main/java/fr/xephi/authme/security/crypts/BCRYPT.java index 0311d9f5..72fec9f0 100644 --- a/src/main/java/fr/xephi/authme/security/crypts/BCRYPT.java +++ b/src/main/java/fr/xephi/authme/security/crypts/BCRYPT.java @@ -98,7 +98,7 @@ public class BCRYPT implements EncryptionMethod { private static String encode_base64(byte d[], int len) throws IllegalArgumentException { int off = 0; - StringBuffer rs = new StringBuffer(); + StringBuilder rs = new StringBuilder(); int c1, c2; if (len <= 0 || len > d.length) @@ -154,7 +154,7 @@ public class BCRYPT implements EncryptionMethod { */ private static byte[] decode_base64(String s, int maxolen) throws IllegalArgumentException { - StringBuffer rs = new StringBuffer(); + StringBuilder rs = new StringBuilder(); int off = 0, slen = s.length(), olen = 0; byte ret[]; byte c1, c2, c3, c4, o; @@ -230,7 +230,7 @@ public class BCRYPT implements EncryptionMethod { byte passwordb[], saltb[], hashed[]; char minor = (char) 0; int rounds, off = 0; - StringBuffer rs = new StringBuffer(); + StringBuilder rs = new StringBuilder(); if (salt.charAt(0) != '$' || salt.charAt(1) != '2') throw new IllegalArgumentException("Invalid salt version"); @@ -283,7 +283,7 @@ public class BCRYPT implements EncryptionMethod { * @return an encoded salt value */ public static String gensalt(int log_rounds, SecureRandom random) { - StringBuffer rs = new StringBuffer(); + StringBuilder rs = new StringBuilder(); byte rnd[] = new byte[BCRYPT_SALT_LEN]; random.nextBytes(rnd); diff --git a/src/main/java/fr/xephi/authme/security/crypts/PHPFUSION.java b/src/main/java/fr/xephi/authme/security/crypts/PHPFUSION.java index 682bdc43..fc9440a6 100644 --- a/src/main/java/fr/xephi/authme/security/crypts/PHPFUSION.java +++ b/src/main/java/fr/xephi/authme/security/crypts/PHPFUSION.java @@ -50,9 +50,9 @@ public class PHPFUSION implements EncryptionMethod { Mac mac = Mac.getInstance(algo); mac.init(key); byte[] bytes = mac.doFinal(password.getBytes("ASCII")); - StringBuffer hash = new StringBuffer(); - for (int i = 0; i < bytes.length; i++) { - String hex = Integer.toHexString(0xFF & bytes[i]); + StringBuilder hash = new StringBuilder(); + for (byte aByte : bytes) { + String hex = Integer.toHexString(0xFF & aByte); if (hex.length() == 1) { hash.append('0'); } 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 bbfd5901..a1fc45ce 100644 --- a/src/main/java/fr/xephi/authme/security/crypts/XF.java +++ b/src/main/java/fr/xephi/authme/security/crypts/XF.java @@ -55,11 +55,11 @@ public class XF implements EncryptionMethod { MessageDigest md = MessageDigest.getInstance("SHA-256"); md.update(password.getBytes()); byte byteData[] = md.digest(); - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); for (byte element : byteData) { sb.append(Integer.toString((element & 0xff) + 0x100, 16).substring(1)); } - StringBuffer hexString = new StringBuffer(); + StringBuilder hexString = new StringBuilder(); for (byte element : byteData) { String hex = Integer.toHexString(0xff & element); if (hex.length() == 1) { 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 9db3150f..0631bd5a 100644 --- a/src/main/java/fr/xephi/authme/security/pbkdf2/BinTools.java +++ b/src/main/java/fr/xephi/authme/security/pbkdf2/BinTools.java @@ -46,13 +46,13 @@ public class BinTools { if (b == null) { return ""; } - StringBuffer sb = new StringBuffer(2 * b.length); - for (int i = 0; i < b.length; i++) { - int v = (256 + b[i]) % 256; - sb.append(hex.charAt((v / 16) & 15)); - sb.append(hex.charAt((v % 16) & 15)); + StringBuffer stringBuffer = new StringBuffer(2 * b.length); + for (byte aB : b) { + int v = (256 + aB) % 256; + stringBuffer.append(hex.charAt((v / 16) & 15)); + stringBuffer.append(hex.charAt((v % 16) & 15)); } - return sb.toString(); + return stringBuffer.toString(); } /** diff --git a/src/main/java/fr/xephi/authme/security/pbkdf2/PBKDF2Engine.java b/src/main/java/fr/xephi/authme/security/pbkdf2/PBKDF2Engine.java index 67b65f05..1ca3f4ce 100644 --- a/src/main/java/fr/xephi/authme/security/pbkdf2/PBKDF2Engine.java +++ b/src/main/java/fr/xephi/authme/security/pbkdf2/PBKDF2Engine.java @@ -363,7 +363,7 @@ public class PBKDF2Engine implements PBKDF2 { * 3. */ protected void INT(byte[] dest, int offset, int i) { - dest[offset + 0] = (byte) (i / (256 * 256 * 256)); + dest[offset] = (byte) (i / (256 * 256 * 256)); dest[offset + 1] = (byte) (i / (256 * 256)); dest[offset + 2] = (byte) (i / (256)); dest[offset + 3] = (byte) (i);