Improved various code bits
This commit is contained in:
parent
1dd540b9c0
commit
83e5d726af
@ -105,7 +105,7 @@ public class API {
|
|||||||
try {
|
try {
|
||||||
player.getInventory().setContents(content);
|
player.getInventory().setContents(content);
|
||||||
player.getInventory().setArmorContents(armor);
|
player.getInventory().setArmorContents(armor);
|
||||||
} catch (NullPointerException npe) {
|
} catch (NullPointerException ignored) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -73,7 +73,7 @@ public class FlatFile implements DataSource {
|
|||||||
if (br != null) {
|
if (br != null) {
|
||||||
try {
|
try {
|
||||||
br.close();
|
br.close();
|
||||||
} catch (IOException ex) {
|
} catch (IOException ignored) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -103,7 +103,7 @@ public class FlatFile implements DataSource {
|
|||||||
if (bw != null) {
|
if (bw != null) {
|
||||||
try {
|
try {
|
||||||
bw.close();
|
bw.close();
|
||||||
} catch (IOException ex) {
|
} catch (IOException ignored) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -165,7 +165,7 @@ public class FlatFile implements DataSource {
|
|||||||
if (br != null) {
|
if (br != null) {
|
||||||
try {
|
try {
|
||||||
br.close();
|
br.close();
|
||||||
} catch (IOException ex) {
|
} catch (IOException ignored) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -231,7 +231,7 @@ public class FlatFile implements DataSource {
|
|||||||
if (br != null) {
|
if (br != null) {
|
||||||
try {
|
try {
|
||||||
br.close();
|
br.close();
|
||||||
} catch (IOException ex) {
|
} catch (IOException ignored) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -276,7 +276,7 @@ public class FlatFile implements DataSource {
|
|||||||
if (br != null) {
|
if (br != null) {
|
||||||
try {
|
try {
|
||||||
br.close();
|
br.close();
|
||||||
} catch (IOException ex) {
|
} catch (IOException ignored) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -318,7 +318,7 @@ public class FlatFile implements DataSource {
|
|||||||
if (br != null) {
|
if (br != null) {
|
||||||
try {
|
try {
|
||||||
br.close();
|
br.close();
|
||||||
} catch (IOException ex) {
|
} catch (IOException ignored) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -364,13 +364,13 @@ public class FlatFile implements DataSource {
|
|||||||
if (br != null) {
|
if (br != null) {
|
||||||
try {
|
try {
|
||||||
br.close();
|
br.close();
|
||||||
} catch (IOException ex) {
|
} catch (IOException ignored) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (bw != null) {
|
if (bw != null) {
|
||||||
try {
|
try {
|
||||||
bw.close();
|
bw.close();
|
||||||
} catch (IOException ex) {
|
} catch (IOException ignored) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -417,13 +417,13 @@ public class FlatFile implements DataSource {
|
|||||||
if (br != null) {
|
if (br != null) {
|
||||||
try {
|
try {
|
||||||
br.close();
|
br.close();
|
||||||
} catch (IOException ex) {
|
} catch (IOException ignored) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (bw != null) {
|
if (bw != null) {
|
||||||
try {
|
try {
|
||||||
bw.close();
|
bw.close();
|
||||||
} catch (IOException ex) {
|
} catch (IOException ignored) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -468,13 +468,13 @@ public class FlatFile implements DataSource {
|
|||||||
if (br != null) {
|
if (br != null) {
|
||||||
try {
|
try {
|
||||||
br.close();
|
br.close();
|
||||||
} catch (IOException ex) {
|
} catch (IOException ignored) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (bw != null) {
|
if (bw != null) {
|
||||||
try {
|
try {
|
||||||
bw.close();
|
bw.close();
|
||||||
} catch (IOException ex) {
|
} catch (IOException ignored) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -523,7 +523,7 @@ public class FlatFile implements DataSource {
|
|||||||
if (br != null) {
|
if (br != null) {
|
||||||
try {
|
try {
|
||||||
br.close();
|
br.close();
|
||||||
} catch (IOException ex) {
|
} catch (IOException ignored) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -582,7 +582,7 @@ public class FlatFile implements DataSource {
|
|||||||
if (br != null) {
|
if (br != null) {
|
||||||
try {
|
try {
|
||||||
br.close();
|
br.close();
|
||||||
} catch (IOException ex) {
|
} catch (IOException ignored) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -636,7 +636,7 @@ public class FlatFile implements DataSource {
|
|||||||
if (br != null) {
|
if (br != null) {
|
||||||
try {
|
try {
|
||||||
br.close();
|
br.close();
|
||||||
} catch (IOException ex) {
|
} catch (IOException ignored) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -673,7 +673,7 @@ public class FlatFile implements DataSource {
|
|||||||
if (br != null) {
|
if (br != null) {
|
||||||
try {
|
try {
|
||||||
br.close();
|
br.close();
|
||||||
} catch (IOException ex) {
|
} catch (IOException ignored) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -710,7 +710,7 @@ public class FlatFile implements DataSource {
|
|||||||
if (br != null) {
|
if (br != null) {
|
||||||
try {
|
try {
|
||||||
br.close();
|
br.close();
|
||||||
} catch (IOException ex) {
|
} catch (IOException ignored) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -737,16 +737,13 @@ public class FlatFile implements DataSource {
|
|||||||
if (banned.contains(args[0])) {
|
if (banned.contains(args[0])) {
|
||||||
lines.add(line);
|
lines.add(line);
|
||||||
}
|
}
|
||||||
} catch (NullPointerException | ArrayIndexOutOfBoundsException exc) {
|
} catch (NullPointerException | ArrayIndexOutOfBoundsException ignored) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
bw = new BufferedWriter(new FileWriter(source));
|
bw = new BufferedWriter(new FileWriter(source));
|
||||||
for (String l : lines) {
|
for (String l : lines) {
|
||||||
bw.write(l + "\n");
|
bw.write(l + "\n");
|
||||||
}
|
}
|
||||||
} catch (FileNotFoundException ex) {
|
|
||||||
ConsoleLogger.showError(ex.getMessage());
|
|
||||||
return;
|
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
ConsoleLogger.showError(ex.getMessage());
|
ConsoleLogger.showError(ex.getMessage());
|
||||||
return;
|
return;
|
||||||
@ -754,13 +751,13 @@ public class FlatFile implements DataSource {
|
|||||||
if (br != null) {
|
if (br != null) {
|
||||||
try {
|
try {
|
||||||
br.close();
|
br.close();
|
||||||
} catch (IOException ex) {
|
} catch (IOException ignored) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (bw != null) {
|
if (bw != null) {
|
||||||
try {
|
try {
|
||||||
bw.close();
|
bw.close();
|
||||||
} catch (IOException ex) {
|
} catch (IOException ignored) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -841,7 +838,7 @@ public class FlatFile implements DataSource {
|
|||||||
if (br != null) {
|
if (br != null) {
|
||||||
try {
|
try {
|
||||||
br.close();
|
br.close();
|
||||||
} catch (IOException ex) {
|
} catch (IOException ignored) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -909,7 +906,7 @@ public class FlatFile implements DataSource {
|
|||||||
if (br != null) {
|
if (br != null) {
|
||||||
try {
|
try {
|
||||||
br.close();
|
br.close();
|
||||||
} catch (IOException ex) {
|
} catch (IOException ignored) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -51,7 +51,7 @@ public class ProcessSyncronousPlayerQuit implements Runnable {
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
player.getVehicle().eject();
|
player.getVehicle().eject();
|
||||||
} catch (Exception e) {
|
} catch (Exception ignored) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -98,7 +98,7 @@ public class BCRYPT implements EncryptionMethod {
|
|||||||
private static String encode_base64(byte d[], int len)
|
private static String encode_base64(byte d[], int len)
|
||||||
throws IllegalArgumentException {
|
throws IllegalArgumentException {
|
||||||
int off = 0;
|
int off = 0;
|
||||||
StringBuffer rs = new StringBuffer();
|
StringBuilder rs = new StringBuilder();
|
||||||
int c1, c2;
|
int c1, c2;
|
||||||
|
|
||||||
if (len <= 0 || len > d.length)
|
if (len <= 0 || len > d.length)
|
||||||
@ -154,7 +154,7 @@ public class BCRYPT implements EncryptionMethod {
|
|||||||
*/
|
*/
|
||||||
private static byte[] decode_base64(String s, int maxolen)
|
private static byte[] decode_base64(String s, int maxolen)
|
||||||
throws IllegalArgumentException {
|
throws IllegalArgumentException {
|
||||||
StringBuffer rs = new StringBuffer();
|
StringBuilder rs = new StringBuilder();
|
||||||
int off = 0, slen = s.length(), olen = 0;
|
int off = 0, slen = s.length(), olen = 0;
|
||||||
byte ret[];
|
byte ret[];
|
||||||
byte c1, c2, c3, c4, o;
|
byte c1, c2, c3, c4, o;
|
||||||
@ -230,7 +230,7 @@ public class BCRYPT implements EncryptionMethod {
|
|||||||
byte passwordb[], saltb[], hashed[];
|
byte passwordb[], saltb[], hashed[];
|
||||||
char minor = (char) 0;
|
char minor = (char) 0;
|
||||||
int rounds, off = 0;
|
int rounds, off = 0;
|
||||||
StringBuffer rs = new StringBuffer();
|
StringBuilder rs = new StringBuilder();
|
||||||
|
|
||||||
if (salt.charAt(0) != '$' || salt.charAt(1) != '2')
|
if (salt.charAt(0) != '$' || salt.charAt(1) != '2')
|
||||||
throw new IllegalArgumentException("Invalid salt version");
|
throw new IllegalArgumentException("Invalid salt version");
|
||||||
@ -283,7 +283,7 @@ public class BCRYPT implements EncryptionMethod {
|
|||||||
* @return an encoded salt value
|
* @return an encoded salt value
|
||||||
*/
|
*/
|
||||||
public static String gensalt(int log_rounds, SecureRandom random) {
|
public static String gensalt(int log_rounds, SecureRandom random) {
|
||||||
StringBuffer rs = new StringBuffer();
|
StringBuilder rs = new StringBuilder();
|
||||||
byte rnd[] = new byte[BCRYPT_SALT_LEN];
|
byte rnd[] = new byte[BCRYPT_SALT_LEN];
|
||||||
|
|
||||||
random.nextBytes(rnd);
|
random.nextBytes(rnd);
|
||||||
|
|||||||
@ -50,9 +50,9 @@ public class PHPFUSION implements EncryptionMethod {
|
|||||||
Mac mac = Mac.getInstance(algo);
|
Mac mac = Mac.getInstance(algo);
|
||||||
mac.init(key);
|
mac.init(key);
|
||||||
byte[] bytes = mac.doFinal(password.getBytes("ASCII"));
|
byte[] bytes = mac.doFinal(password.getBytes("ASCII"));
|
||||||
StringBuffer hash = new StringBuffer();
|
StringBuilder hash = new StringBuilder();
|
||||||
for (int i = 0; i < bytes.length; i++) {
|
for (byte aByte : bytes) {
|
||||||
String hex = Integer.toHexString(0xFF & bytes[i]);
|
String hex = Integer.toHexString(0xFF & aByte);
|
||||||
if (hex.length() == 1) {
|
if (hex.length() == 1) {
|
||||||
hash.append('0');
|
hash.append('0');
|
||||||
}
|
}
|
||||||
|
|||||||
@ -55,11 +55,11 @@ public class XF implements EncryptionMethod {
|
|||||||
MessageDigest md = MessageDigest.getInstance("SHA-256");
|
MessageDigest md = MessageDigest.getInstance("SHA-256");
|
||||||
md.update(password.getBytes());
|
md.update(password.getBytes());
|
||||||
byte byteData[] = md.digest();
|
byte byteData[] = md.digest();
|
||||||
StringBuffer sb = new StringBuffer();
|
StringBuilder sb = new StringBuilder();
|
||||||
for (byte element : byteData) {
|
for (byte element : byteData) {
|
||||||
sb.append(Integer.toString((element & 0xff) + 0x100, 16).substring(1));
|
sb.append(Integer.toString((element & 0xff) + 0x100, 16).substring(1));
|
||||||
}
|
}
|
||||||
StringBuffer hexString = new StringBuffer();
|
StringBuilder hexString = new StringBuilder();
|
||||||
for (byte element : byteData) {
|
for (byte element : byteData) {
|
||||||
String hex = Integer.toHexString(0xff & element);
|
String hex = Integer.toHexString(0xff & element);
|
||||||
if (hex.length() == 1) {
|
if (hex.length() == 1) {
|
||||||
|
|||||||
@ -46,13 +46,13 @@ public class BinTools {
|
|||||||
if (b == null) {
|
if (b == null) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
StringBuffer sb = new StringBuffer(2 * b.length);
|
StringBuffer stringBuffer = new StringBuffer(2 * b.length);
|
||||||
for (int i = 0; i < b.length; i++) {
|
for (byte aB : b) {
|
||||||
int v = (256 + b[i]) % 256;
|
int v = (256 + aB) % 256;
|
||||||
sb.append(hex.charAt((v / 16) & 15));
|
stringBuffer.append(hex.charAt((v / 16) & 15));
|
||||||
sb.append(hex.charAt((v % 16) & 15));
|
stringBuffer.append(hex.charAt((v % 16) & 15));
|
||||||
}
|
}
|
||||||
return sb.toString();
|
return stringBuffer.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -363,7 +363,7 @@ public class PBKDF2Engine implements PBKDF2 {
|
|||||||
* 3.</a>
|
* 3.</a>
|
||||||
*/
|
*/
|
||||||
protected void INT(byte[] dest, int offset, int i) {
|
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 + 1] = (byte) (i / (256 * 256));
|
||||||
dest[offset + 2] = (byte) (i / (256));
|
dest[offset + 2] = (byte) (i / (256));
|
||||||
dest[offset + 3] = (byte) (i);
|
dest[offset + 3] = (byte) (i);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user