Reformat and clean up "tools" package
This commit is contained in:
@@ -21,12 +21,7 @@
|
|||||||
*/
|
*/
|
||||||
package tools;
|
package tools;
|
||||||
|
|
||||||
import java.util.AbstractMap;
|
import java.util.*;
|
||||||
import java.util.AbstractSet;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
public class ArrayMap<K, V> extends AbstractMap<K, V> {
|
public class ArrayMap<K, V> extends AbstractMap<K, V> {
|
||||||
|
|
||||||
@@ -77,8 +72,9 @@ public class ArrayMap<K, V> extends AbstractMap<K, V> {
|
|||||||
return key + "=" + value;
|
return key + "=" + value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Set<? extends java.util.Map.Entry<K, V>> entries = null;
|
private Set<? extends java.util.Map.Entry<K, V>> entries = null;
|
||||||
private ArrayList<Entry<K, V>> list;
|
private final ArrayList<Entry<K, V>> list;
|
||||||
|
|
||||||
public ArrayMap() {
|
public ArrayMap() {
|
||||||
list = new ArrayList<>();
|
list = new ArrayList<>();
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
package tools;
|
package tools;
|
||||||
|
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.security.SecureRandom;
|
import java.security.SecureRandom;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
@@ -376,8 +376,8 @@ public class BCrypt {
|
|||||||
*
|
*
|
||||||
* @param d the byte array to encode
|
* @param d the byte array to encode
|
||||||
* @param len the number of bytes to encode
|
* @param len the number of bytes to encode
|
||||||
|
* @throws IllegalArgumentException if the length is invalid
|
||||||
* @return base64-encoded string
|
* @return base64-encoded string
|
||||||
* @exception IllegalArgumentException if the length is invalid
|
|
||||||
*/
|
*/
|
||||||
private static String encode_base64(byte[] d, int len)
|
private static String encode_base64(byte[] d, int len)
|
||||||
throws IllegalArgumentException {
|
throws IllegalArgumentException {
|
||||||
@@ -416,6 +416,7 @@ public class BCrypt {
|
|||||||
/**
|
/**
|
||||||
* Look up the 3 bits base64-encoded with the specified character,
|
* Look up the 3 bits base64-encoded with the specified character,
|
||||||
* range-checking againt conversion table
|
* range-checking againt conversion table
|
||||||
|
*
|
||||||
* @param x the base64-encoded value
|
* @param x the base64-encoded value
|
||||||
* @return the decoded value of x
|
* @return the decoded value of x
|
||||||
*/
|
*/
|
||||||
@@ -430,10 +431,11 @@ public class BCrypt {
|
|||||||
* Decode a string encoded using bcrypt's base64 scheme to a
|
* Decode a string encoded using bcrypt's base64 scheme to a
|
||||||
* byte array. Note that this is *not* compatible with
|
* byte array. Note that this is *not* compatible with
|
||||||
* the standard MIME-base64 encoding.
|
* the standard MIME-base64 encoding.
|
||||||
|
*
|
||||||
* @param s the string to decode
|
* @param s the string to decode
|
||||||
* @param maxolen the maximum number of bytes to decode
|
* @param maxolen the maximum number of bytes to decode
|
||||||
* @return an array containing the bytes decoded
|
|
||||||
* @throws IllegalArgumentException if maxolen is invalid
|
* @throws IllegalArgumentException if maxolen is invalid
|
||||||
|
* @return an array containing the bytes decoded
|
||||||
*/
|
*/
|
||||||
private static byte[] decode_base64(String s, int maxolen)
|
private static byte[] decode_base64(String s, int maxolen)
|
||||||
throws IllegalArgumentException {
|
throws IllegalArgumentException {
|
||||||
@@ -485,6 +487,7 @@ public class BCrypt {
|
|||||||
/**
|
/**
|
||||||
* Blowfish encipher a single 64-bit block encoded as
|
* Blowfish encipher a single 64-bit block encoded as
|
||||||
* two 32-bit halves
|
* two 32-bit halves
|
||||||
|
*
|
||||||
* @param lr an array containing the two 32-bit half blocks
|
* @param lr an array containing the two 32-bit half blocks
|
||||||
* @param off the position in the array of the blocks
|
* @param off the position in the array of the blocks
|
||||||
*/
|
*/
|
||||||
@@ -513,6 +516,7 @@ public class BCrypt {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Cycically extract a word of key material
|
* Cycically extract a word of key material
|
||||||
|
*
|
||||||
* @param data the string to extract the data from
|
* @param data the string to extract the data from
|
||||||
* @param offp a "pointer" (as a one-entry array) to the
|
* @param offp a "pointer" (as a one-entry array) to the
|
||||||
* current offset into data
|
* current offset into data
|
||||||
@@ -529,7 +533,9 @@ public class BCrypt {
|
|||||||
for (i = 0; i < 4; i++) {
|
for (i = 0; i < 4; i++) {
|
||||||
words[0] = (words[0] << 8) | (data[off] & 0xff);
|
words[0] = (words[0] << 8) | (data[off] & 0xff);
|
||||||
words[1] = (words[1] << 8) | (int) data[off];
|
words[1] = (words[1] << 8) | (int) data[off];
|
||||||
if (i > 0) sign |= words[1] & 0x80;
|
if (i > 0) {
|
||||||
|
sign |= words[1] & 0x80;
|
||||||
|
}
|
||||||
off = (off + 1) % data.length;
|
off = (off + 1) % data.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -540,6 +546,7 @@ public class BCrypt {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Cycically extract a word of key material
|
* Cycically extract a word of key material
|
||||||
|
*
|
||||||
* @param data the string to extract the data from
|
* @param data the string to extract the data from
|
||||||
* @param offp a "pointer" (as a one-entry array) to the
|
* @param offp a "pointer" (as a one-entry array) to the
|
||||||
* current offset into data
|
* current offset into data
|
||||||
@@ -552,6 +559,7 @@ public class BCrypt {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Cycically extract a word of key material, with sign-extension bug
|
* Cycically extract a word of key material, with sign-extension bug
|
||||||
|
*
|
||||||
* @param data the string to extract the data from
|
* @param data the string to extract the data from
|
||||||
* @param offp a "pointer" (as a one-entry array) to the
|
* @param offp a "pointer" (as a one-entry array) to the
|
||||||
* current offset into data
|
* current offset into data
|
||||||
@@ -572,6 +580,7 @@ public class BCrypt {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Key the Blowfish cipher
|
* Key the Blowfish cipher
|
||||||
|
*
|
||||||
* @param key an array containing the key
|
* @param key an array containing the key
|
||||||
* @param sign_ext_bug true to implement the 2x bug
|
* @param sign_ext_bug true to implement the 2x bug
|
||||||
*/
|
*/
|
||||||
@@ -582,11 +591,12 @@ public class BCrypt {
|
|||||||
int plen = P.length, slen = S.length;
|
int plen = P.length, slen = S.length;
|
||||||
|
|
||||||
for (i = 0; i < plen; i++) {
|
for (i = 0; i < plen; i++) {
|
||||||
if (!sign_ext_bug)
|
if (!sign_ext_bug) {
|
||||||
P[i] = P[i] ^ streamtoword(key, koffp);
|
P[i] = P[i] ^ streamtoword(key, koffp);
|
||||||
else
|
} else {
|
||||||
P[i] = P[i] ^ streamtoword_bug(key, koffp);
|
P[i] = P[i] ^ streamtoword_bug(key, koffp);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (i = 0; i < plen; i += 2) {
|
for (i = 0; i < plen; i += 2) {
|
||||||
encipher(lr, 0);
|
encipher(lr, 0);
|
||||||
@@ -605,6 +615,7 @@ public class BCrypt {
|
|||||||
* Perform the "enhanced key schedule" step described by
|
* Perform the "enhanced key schedule" step described by
|
||||||
* Provos and Mazieres in "A Future-Adaptable Password Scheme"
|
* Provos and Mazieres in "A Future-Adaptable Password Scheme"
|
||||||
* http://www.openbsd.org/papers/bcrypt-paper.ps
|
* http://www.openbsd.org/papers/bcrypt-paper.ps
|
||||||
|
*
|
||||||
* @param data salt information
|
* @param data salt information
|
||||||
* @param key password information
|
* @param key password information
|
||||||
* @param sign_ext_bug true to implement the 2x bug
|
* @param sign_ext_bug true to implement the 2x bug
|
||||||
@@ -675,6 +686,7 @@ public class BCrypt {
|
|||||||
/**
|
/**
|
||||||
* Perform the central password hashing step in the
|
* Perform the central password hashing step in the
|
||||||
* bcrypt scheme
|
* bcrypt scheme
|
||||||
|
*
|
||||||
* @param password the password to hash
|
* @param password the password to hash
|
||||||
* @param salt the binary salt to hash with the password
|
* @param salt the binary salt to hash with the password
|
||||||
* @param log_rounds the binary logarithm of the number
|
* @param log_rounds the binary logarithm of the number
|
||||||
@@ -723,23 +735,21 @@ public class BCrypt {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts given plaintext to byte representation.
|
* Converts given plaintext to byte representation.
|
||||||
|
*
|
||||||
* @param plaintext the plaintext password to convert
|
* @param plaintext the plaintext password to convert
|
||||||
* @return Byte representation of given plaintext.
|
* @return Byte representation of given plaintext.
|
||||||
*/
|
*/
|
||||||
private static byte[] stringToBytes(String plaintext) {
|
private static byte[] stringToBytes(String plaintext) {
|
||||||
byte[] plaintextb;
|
byte[] plaintextb;
|
||||||
|
|
||||||
try {
|
plaintextb = plaintext.getBytes(StandardCharsets.UTF_8);
|
||||||
plaintextb = plaintext.getBytes("UTF-8");
|
|
||||||
} catch (UnsupportedEncodingException uee) {
|
|
||||||
throw new AssertionError("UTF-8 is not supported");
|
|
||||||
}
|
|
||||||
|
|
||||||
return plaintextb;
|
return plaintextb;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hash a password using the OpenBSD bcrypt scheme
|
* Hash a password using the OpenBSD bcrypt scheme
|
||||||
|
*
|
||||||
* @param password the password to hash
|
* @param password the password to hash
|
||||||
* @param salt the salt to hash with (perhaps generated
|
* @param salt the salt to hash with (perhaps generated
|
||||||
* using BCrypt.gensalt)
|
* using BCrypt.gensalt)
|
||||||
@@ -753,6 +763,7 @@ public class BCrypt {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Hash a password using the OpenBSD bcrypt scheme
|
* Hash a password using the OpenBSD bcrypt scheme
|
||||||
|
*
|
||||||
* @param passwordb the password to hash, as a byte array
|
* @param passwordb the password to hash, as a byte array
|
||||||
* @param salt the salt to hash with (perhaps generated
|
* @param salt the salt to hash with (perhaps generated
|
||||||
* using BCrypt.gensalt)
|
* using BCrypt.gensalt)
|
||||||
@@ -791,7 +802,9 @@ public class BCrypt {
|
|||||||
saltb = decode_base64(real_salt, BCRYPT_SALT_LEN);
|
saltb = decode_base64(real_salt, BCRYPT_SALT_LEN);
|
||||||
|
|
||||||
if (minor >= 'a') // add null terminator
|
if (minor >= 'a') // add null terminator
|
||||||
|
{
|
||||||
passwordb = Arrays.copyOf(passwordb, passwordb.length + 1);
|
passwordb = Arrays.copyOf(passwordb, passwordb.length + 1);
|
||||||
|
}
|
||||||
|
|
||||||
B = new BCrypt();
|
B = new BCrypt();
|
||||||
hashed = B.crypt_raw(passwordb, saltb, rounds,
|
hashed = B.crypt_raw(passwordb, saltb, rounds,
|
||||||
@@ -821,13 +834,14 @@ public class BCrypt {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Generate a salt for use with the BCrypt.hashpw() method
|
* Generate a salt for use with the BCrypt.hashpw() method
|
||||||
|
*
|
||||||
* @param prefix the prefix value (default $2y)
|
* @param prefix the prefix value (default $2y)
|
||||||
* @param log_rounds the log2 of the number of rounds of
|
* @param log_rounds the log2 of the number of rounds of
|
||||||
* hashing to apply - the work factor therefore increases as
|
* hashing to apply - the work factor therefore increases as
|
||||||
* 2**log_rounds.
|
* 2**log_rounds.
|
||||||
* @param random an instance of SecureRandom to use
|
* @param random an instance of SecureRandom to use
|
||||||
|
* @throws IllegalArgumentException if prefix or log_rounds is invalid
|
||||||
* @return an encoded salt value
|
* @return an encoded salt value
|
||||||
* @exception IllegalArgumentException if prefix or log_rounds is invalid
|
|
||||||
*/
|
*/
|
||||||
public static String gensalt(String prefix, int log_rounds, SecureRandom random)
|
public static String gensalt(String prefix, int log_rounds, SecureRandom random)
|
||||||
throws IllegalArgumentException {
|
throws IllegalArgumentException {
|
||||||
@@ -863,12 +877,13 @@ public class BCrypt {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Generate a salt for use with the BCrypt.hashpw() method
|
* Generate a salt for use with the BCrypt.hashpw() method
|
||||||
|
*
|
||||||
* @param prefix the prefix value (default $2y)
|
* @param prefix the prefix value (default $2y)
|
||||||
* @param log_rounds the log2 of the number of rounds of
|
* @param log_rounds the log2 of the number of rounds of
|
||||||
* hashing to apply - the work factor therefore increases as
|
* hashing to apply - the work factor therefore increases as
|
||||||
* 2**log_rounds.
|
* 2**log_rounds.
|
||||||
|
* @throws IllegalArgumentException if prefix or log_rounds is invalid
|
||||||
* @return an encoded salt value
|
* @return an encoded salt value
|
||||||
* @exception IllegalArgumentException if prefix or log_rounds is invalid
|
|
||||||
*/
|
*/
|
||||||
public static String gensalt(String prefix, int log_rounds)
|
public static String gensalt(String prefix, int log_rounds)
|
||||||
throws IllegalArgumentException {
|
throws IllegalArgumentException {
|
||||||
@@ -877,12 +892,13 @@ public class BCrypt {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Generate a salt for use with the BCrypt.hashpw() method
|
* Generate a salt for use with the BCrypt.hashpw() method
|
||||||
|
*
|
||||||
* @param log_rounds the log2 of the number of rounds of
|
* @param log_rounds the log2 of the number of rounds of
|
||||||
* hashing to apply - the work factor therefore increases as
|
* hashing to apply - the work factor therefore increases as
|
||||||
* 2**log_rounds.
|
* 2**log_rounds.
|
||||||
* @param random an instance of SecureRandom to use
|
* @param random an instance of SecureRandom to use
|
||||||
|
* @throws IllegalArgumentException if prefix or log_rounds is invalid
|
||||||
* @return an encoded salt value
|
* @return an encoded salt value
|
||||||
* @exception IllegalArgumentException if prefix or log_rounds is invalid
|
|
||||||
*/
|
*/
|
||||||
public static String gensalt(int log_rounds, SecureRandom random)
|
public static String gensalt(int log_rounds, SecureRandom random)
|
||||||
throws IllegalArgumentException {
|
throws IllegalArgumentException {
|
||||||
@@ -891,11 +907,12 @@ public class BCrypt {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Generate a salt for use with the BCrypt.hashpw() method
|
* Generate a salt for use with the BCrypt.hashpw() method
|
||||||
|
*
|
||||||
* @param log_rounds the log2 of the number of rounds of
|
* @param log_rounds the log2 of the number of rounds of
|
||||||
* hashing to apply - the work factor therefore increases as
|
* hashing to apply - the work factor therefore increases as
|
||||||
* 2**log_rounds.
|
* 2**log_rounds.
|
||||||
|
* @throws IllegalArgumentException if prefix or log_rounds is invalid
|
||||||
* @return an encoded salt value
|
* @return an encoded salt value
|
||||||
* @exception IllegalArgumentException if prefix or log_rounds is invalid
|
|
||||||
*/
|
*/
|
||||||
public static String gensalt(int log_rounds)
|
public static String gensalt(int log_rounds)
|
||||||
throws IllegalArgumentException {
|
throws IllegalArgumentException {
|
||||||
@@ -906,8 +923,9 @@ public class BCrypt {
|
|||||||
* Generate a salt for use with the BCrypt.hashpw() method,
|
* Generate a salt for use with the BCrypt.hashpw() method,
|
||||||
* selecting a reasonable default for the number of hashing
|
* selecting a reasonable default for the number of hashing
|
||||||
* rounds to apply
|
* rounds to apply
|
||||||
|
*
|
||||||
|
* @throws IllegalArgumentException if prefix or log_rounds is invalid
|
||||||
* @return an encoded salt value
|
* @return an encoded salt value
|
||||||
* @exception IllegalArgumentException if prefix or log_rounds is invalid
|
|
||||||
*/
|
*/
|
||||||
public static String gensalt()
|
public static String gensalt()
|
||||||
throws IllegalArgumentException {
|
throws IllegalArgumentException {
|
||||||
@@ -917,6 +935,7 @@ public class BCrypt {
|
|||||||
/**
|
/**
|
||||||
* Check that a plaintext password matches a previously hashed
|
* Check that a plaintext password matches a previously hashed
|
||||||
* one
|
* one
|
||||||
|
*
|
||||||
* @param plaintext the plaintext password to verify
|
* @param plaintext the plaintext password to verify
|
||||||
* @param hashed the previously-hashed password
|
* @param hashed the previously-hashed password
|
||||||
* @return true if the passwords match, false otherwise
|
* @return true if the passwords match, false otherwise
|
||||||
@@ -929,6 +948,7 @@ public class BCrypt {
|
|||||||
/**
|
/**
|
||||||
* Check that a plaintext byte[] password matches a previously hashed
|
* Check that a plaintext byte[] password matches a previously hashed
|
||||||
* one
|
* one
|
||||||
|
*
|
||||||
* @param plaintext the plaintext password to verify
|
* @param plaintext the plaintext password to verify
|
||||||
* @param hashed the previously-hashed password
|
* @param hashed the previously-hashed password
|
||||||
* @return true if the passwords match, false otherwise
|
* @return true if the passwords match, false otherwise
|
||||||
@@ -936,18 +956,16 @@ public class BCrypt {
|
|||||||
public static boolean checkpw(byte[] plaintext, String hashed) {
|
public static boolean checkpw(byte[] plaintext, String hashed) {
|
||||||
byte[] hashed_bytes;
|
byte[] hashed_bytes;
|
||||||
byte[] try_bytes;
|
byte[] try_bytes;
|
||||||
try {
|
|
||||||
String try_pw = hashpw(plaintext, hashed);
|
String try_pw = hashpw(plaintext, hashed);
|
||||||
hashed_bytes = hashed.getBytes("UTF-8");
|
hashed_bytes = hashed.getBytes(StandardCharsets.UTF_8);
|
||||||
try_bytes = try_pw.getBytes("UTF-8");
|
try_bytes = try_pw.getBytes(StandardCharsets.UTF_8);
|
||||||
} catch (UnsupportedEncodingException uee) {
|
if (hashed_bytes.length != try_bytes.length) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (hashed_bytes.length != try_bytes.length)
|
|
||||||
return false;
|
|
||||||
byte ret = 0;
|
byte ret = 0;
|
||||||
for (int i = 0; i < try_bytes.length; i++)
|
for (int i = 0; i < try_bytes.length; i++) {
|
||||||
ret |= hashed_bytes[i] ^ try_bytes[i];
|
ret |= hashed_bytes[i] ^ try_bytes[i];
|
||||||
|
}
|
||||||
return ret == 0;
|
return ret == 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,10 +1,6 @@
|
|||||||
package tools;
|
package tools;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.*;
|
||||||
import java.io.FileOutputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.PrintWriter;
|
|
||||||
import java.io.StringWriter;
|
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
|
|
||||||
|
|||||||
@@ -31,12 +31,11 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author Ronan
|
* @author Ronan
|
||||||
*/
|
*/
|
||||||
public class IntervalBuilder {
|
public class IntervalBuilder {
|
||||||
|
|
||||||
private List<Line2D> intervalLimits = new ArrayList<>();
|
private final List<Line2D> intervalLimits = new ArrayList<>();
|
||||||
|
|
||||||
protected MonitoredReadLock intervalRlock;
|
protected MonitoredReadLock intervalRlock;
|
||||||
protected MonitoredWriteLock intervalWlock;
|
protected MonitoredWriteLock intervalWlock;
|
||||||
@@ -100,7 +99,9 @@ public class IntervalBuilder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int en = bsearchInterval(to);
|
int en = bsearchInterval(to);
|
||||||
if (en < st) en = st - 1;
|
if (en < st) {
|
||||||
|
en = st - 1;
|
||||||
|
}
|
||||||
|
|
||||||
refitOverlappedIntervals(st, en + 1, from, to);
|
refitOverlappedIntervals(st, en + 1, from, to);
|
||||||
} finally {
|
} finally {
|
||||||
|
|||||||
@@ -1,23 +1,19 @@
|
|||||||
package tools;
|
package tools;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author Shavit
|
* @author Shavit
|
||||||
*/
|
*/
|
||||||
public class LongTool {
|
public class LongTool {
|
||||||
|
|
||||||
// Converts 8 bytes to a long.
|
// Converts 8 bytes to a long.
|
||||||
public static long BytesToLong(byte[] aToConvert)
|
public static long BytesToLong(byte[] aToConvert) {
|
||||||
{
|
if (aToConvert.length != Long.BYTES) {
|
||||||
if(aToConvert.length != Long.BYTES)
|
|
||||||
{
|
|
||||||
throw new IllegalArgumentException(String.format("Size of input should be %d", (Long.SIZE / 8)));
|
throw new IllegalArgumentException(String.format("Size of input should be %d", (Long.SIZE / 8)));
|
||||||
}
|
}
|
||||||
|
|
||||||
long nResult = 0;
|
long nResult = 0;
|
||||||
|
|
||||||
for(int i = 0; i < Long.BYTES; i++)
|
for (int i = 0; i < Long.BYTES; i++) {
|
||||||
{
|
|
||||||
nResult <<= Byte.SIZE;
|
nResult <<= Byte.SIZE;
|
||||||
nResult |= (aToConvert[i] & 0xFF);
|
nResult |= (aToConvert[i] & 0xFF);
|
||||||
}
|
}
|
||||||
@@ -26,12 +22,10 @@ public class LongTool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Converts a long to 8 bytes.
|
// Converts a long to 8 bytes.
|
||||||
public static byte[] LongToBytes(long nToConvert)
|
public static byte[] LongToBytes(long nToConvert) {
|
||||||
{
|
|
||||||
byte[] aBytes = new byte[Long.BYTES];
|
byte[] aBytes = new byte[Long.BYTES];
|
||||||
|
|
||||||
for(int i = aBytes.length - 1; i >= 0; i--)
|
for (int i = aBytes.length - 1; i >= 0; i--) {
|
||||||
{
|
|
||||||
aBytes[i] = (byte) (nToConvert & 0xFF);
|
aBytes[i] = (byte) (nToConvert & 0xFF);
|
||||||
nToConvert >>= Byte.SIZE;
|
nToConvert >>= Byte.SIZE;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,12 +23,11 @@ package tools;
|
|||||||
/**
|
/**
|
||||||
* Represents a pair of values.
|
* Represents a pair of values.
|
||||||
*
|
*
|
||||||
* @author Frz
|
|
||||||
* @since Revision 333
|
|
||||||
* @version 1.0
|
|
||||||
*
|
|
||||||
* @param <E> The type of the left value.
|
* @param <E> The type of the left value.
|
||||||
* @param <F> The type of the right value.
|
* @param <F> The type of the right value.
|
||||||
|
* @author Frz
|
||||||
|
* @version 1.0
|
||||||
|
* @since Revision 333
|
||||||
*/
|
*/
|
||||||
public class Pair<E, F> {
|
public class Pair<E, F> {
|
||||||
|
|
||||||
@@ -110,12 +109,7 @@ public class Pair<E, F> {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (right == null) {
|
if (right == null) {
|
||||||
if (other.right != null) {
|
return other.right == null;
|
||||||
return false;
|
} else return right.equals(other.right);
|
||||||
}
|
|
||||||
} else if (!right.equals(other.right)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -23,7 +23,6 @@ import net.packet.InPacket;
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author Ronan
|
* @author Ronan
|
||||||
*/
|
*/
|
||||||
public class EmptyMovementException extends Exception {
|
public class EmptyMovementException extends Exception {
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ package tools.exceptions;
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author Ronan
|
* @author Ronan
|
||||||
*/
|
*/
|
||||||
public class EventInstanceInProgressException extends Exception {
|
public class EventInstanceInProgressException extends Exception {
|
||||||
|
|||||||
@@ -11,15 +11,13 @@ import java.nio.charset.StandardCharsets;
|
|||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author RonanLana
|
* @author RonanLana
|
||||||
|
* <p>
|
||||||
This application gathers info from the WZ.XML files, fetching all cosmetic coupons and tickets from there, and then
|
* This application gathers info from the WZ.XML files, fetching all cosmetic coupons and tickets from there, and then
|
||||||
searches the NPC script files, identifying the stylish NPCs that supposedly uses them. It will reports all NPCs that
|
* searches the NPC script files, identifying the stylish NPCs that supposedly uses them. It will reports all NPCs that
|
||||||
uses up a card, as well as report those currently unused.
|
* uses up a card, as well as report those currently unused.
|
||||||
|
* <p>
|
||||||
Estimated parse time: 10 seconds
|
* Estimated parse time: 10 seconds
|
||||||
|
|
||||||
*/
|
*/
|
||||||
public class CashCosmeticsFetcher {
|
public class CashCosmeticsFetcher {
|
||||||
private static final Map<Integer, String> scriptEntries = new HashMap<>(500);
|
private static final Map<Integer, String> scriptEntries = new HashMap<>(500);
|
||||||
|
|||||||
@@ -8,13 +8,12 @@ import java.util.HashSet;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author RonanLana
|
* @author RonanLana
|
||||||
*
|
* <p>
|
||||||
This application main objective is to read Vega-related information from
|
* This application main objective is to read Vega-related information from
|
||||||
the item's description report back missing nodes for these items.
|
* the item's description report back missing nodes for these items.
|
||||||
|
* <p>
|
||||||
Estimated parse time: 10 seconds
|
* Estimated parse time: 10 seconds
|
||||||
*/
|
*/
|
||||||
public class CashVegaChecker {
|
public class CashVegaChecker {
|
||||||
private static final File OUTPUT_FILE = ToolConstants.getOutputFile("vega_checker_report.txt");
|
private static final File OUTPUT_FILE = ToolConstants.getOutputFile("vega_checker_report.txt");
|
||||||
@@ -66,8 +65,7 @@ public class CashVegaChecker {
|
|||||||
while (status >= st && (line = bufferedReader.readLine()) != null) {
|
while (status >= st && (line = bufferedReader.readLine()) != null) {
|
||||||
simpleToken(line);
|
simpleToken(line);
|
||||||
}
|
}
|
||||||
}
|
} catch (Exception e) {
|
||||||
catch(Exception e) {
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -75,8 +73,7 @@ public class CashVegaChecker {
|
|||||||
private static void simpleToken(String token) {
|
private static void simpleToken(String token) {
|
||||||
if (token.contains("/imgdir")) {
|
if (token.contains("/imgdir")) {
|
||||||
status -= 1;
|
status -= 1;
|
||||||
}
|
} else if (token.contains("imgdir")) {
|
||||||
else if(token.contains("imgdir")) {
|
|
||||||
status += 1;
|
status += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -84,8 +81,7 @@ public class CashVegaChecker {
|
|||||||
private static void translateItemToken(String token) {
|
private static void translateItemToken(String token) {
|
||||||
if (token.contains("/imgdir")) {
|
if (token.contains("/imgdir")) {
|
||||||
status -= 1;
|
status -= 1;
|
||||||
}
|
} else if (token.contains("imgdir")) {
|
||||||
else if(token.contains("imgdir")) {
|
|
||||||
status += 1;
|
status += 1;
|
||||||
|
|
||||||
if (status == 2) {
|
if (status == 2) {
|
||||||
@@ -103,8 +99,7 @@ public class CashVegaChecker {
|
|||||||
private static void translateVegaToken(String token) {
|
private static void translateVegaToken(String token) {
|
||||||
if (token.contains("/imgdir")) {
|
if (token.contains("/imgdir")) {
|
||||||
status -= 1;
|
status -= 1;
|
||||||
}
|
} else if (token.contains("imgdir")) {
|
||||||
else if(token.contains("imgdir")) {
|
|
||||||
status += 1;
|
status += 1;
|
||||||
} else {
|
} else {
|
||||||
if (status == 2) {
|
if (status == 2) {
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ package tools.mapletools;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author RonanLana
|
* @author RonanLana
|
||||||
*/
|
*/
|
||||||
public class MakerItemEntry {
|
public class MakerItemEntry {
|
||||||
|
|||||||
@@ -29,7 +29,6 @@ import tools.PacketCreator;
|
|||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author FateJiki (RaGeZONE)
|
* @author FateJiki (RaGeZONE)
|
||||||
* @author Ronan - timing pattern
|
* @author Ronan - timing pattern
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ import java.util.List;
|
|||||||
* CField_Wedding, CField_WeddingPhoto, CWeddingMan, OnMarriageResult, and all Wedding/Marriage enum/structs.
|
* CField_Wedding, CField_WeddingPhoto, CWeddingMan, OnMarriageResult, and all Wedding/Marriage enum/structs.
|
||||||
*
|
*
|
||||||
* @author Eric
|
* @author Eric
|
||||||
*
|
* <p>
|
||||||
* Wishlists edited by Drago (Dragohe4rt)
|
* Wishlists edited by Drago (Dragohe4rt)
|
||||||
*/
|
*/
|
||||||
public class WeddingPackets extends PacketCreator {
|
public class WeddingPackets extends PacketCreator {
|
||||||
@@ -89,8 +89,9 @@ public class WeddingPackets extends PacketCreator {
|
|||||||
ENGAGED(0x1),
|
ENGAGED(0x1),
|
||||||
RESERVED(0x2),
|
RESERVED(0x2),
|
||||||
MARRIED(0x3);
|
MARRIED(0x3);
|
||||||
private int ms;
|
private final int ms;
|
||||||
private MarriageStatus(int ms) {
|
|
||||||
|
MarriageStatus(int ms) {
|
||||||
this.ms = ms;
|
this.ms = ms;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -107,8 +108,9 @@ public class WeddingPackets extends PacketCreator {
|
|||||||
AddReservation(0x4),
|
AddReservation(0x4),
|
||||||
DeleteReservation(0x5),
|
DeleteReservation(0x5),
|
||||||
GetReservation(0x6);
|
GetReservation(0x6);
|
||||||
private int req;
|
private final int req;
|
||||||
private MarriageRequest(int req) {
|
|
||||||
|
MarriageRequest(int req) {
|
||||||
this.req = req;
|
this.req = req;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -124,8 +126,9 @@ public class WeddingPackets extends PacketCreator {
|
|||||||
CATHEDRAL_NORMAL(0xB),
|
CATHEDRAL_NORMAL(0xB),
|
||||||
VEGAS_PREMIUM(0x14),
|
VEGAS_PREMIUM(0x14),
|
||||||
VEGAS_NORMAL(0x15);
|
VEGAS_NORMAL(0x15);
|
||||||
private int wt;
|
private final int wt;
|
||||||
private WeddingType(int wt) {
|
|
||||||
|
WeddingType(int wt) {
|
||||||
this.wt = wt;
|
this.wt = wt;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -140,8 +143,9 @@ public class WeddingPackets extends PacketCreator {
|
|||||||
CATHEDRAL_STARTMAP(680000210),
|
CATHEDRAL_STARTMAP(680000210),
|
||||||
PHOTOMAP(680000300),
|
PHOTOMAP(680000300),
|
||||||
EXITMAP(680000500);
|
EXITMAP(680000500);
|
||||||
private int wm;
|
private final int wm;
|
||||||
private WeddingMap(int wm) {
|
|
||||||
|
WeddingMap(int wm) {
|
||||||
this.wm = wm;
|
this.wm = wm;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -182,8 +186,9 @@ public class WeddingPackets extends PacketCreator {
|
|||||||
WT_VEGAS_NORMAL(5251001),
|
WT_VEGAS_NORMAL(5251001),
|
||||||
WT_VEGAS_PREMIUM(5251002),
|
WT_VEGAS_PREMIUM(5251002),
|
||||||
WT_CATHEDRAL_PREMIUM(5251003);
|
WT_CATHEDRAL_PREMIUM(5251003);
|
||||||
private int wi;
|
private final int wi;
|
||||||
private WeddingItem(int wi) {
|
|
||||||
|
WeddingItem(int wi) {
|
||||||
this.wi = wi;
|
this.wi = wi;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -217,7 +222,7 @@ public class WeddingPackets extends PacketCreator {
|
|||||||
* - Finally, after encoding all of our data, we send this packet out to a MapGen application server
|
* - Finally, after encoding all of our data, we send this packet out to a MapGen application server
|
||||||
* - The MapGen server will then retrieve the packet byte array and convert the bytes into a ImageIO 2D JPG output
|
* - The MapGen server will then retrieve the packet byte array and convert the bytes into a ImageIO 2D JPG output
|
||||||
* - The result after converting into a JPG will then be remotely uploaded to /weddings/ with ReservedGroomName_ReservedBrideName to be displayed on the web server.
|
* - The result after converting into a JPG will then be remotely uploaded to /weddings/ with ReservedGroomName_ReservedBrideName to be displayed on the web server.
|
||||||
*
|
* <p>
|
||||||
* - Will no longer continue Wedding Photos, needs a WvsMapGen :(
|
* - Will no longer continue Wedding Photos, needs a WvsMapGen :(
|
||||||
*
|
*
|
||||||
* @param ReservedGroomName The groom IGN of the wedding
|
* @param ReservedGroomName The groom IGN of the wedding
|
||||||
|
|||||||
Reference in New Issue
Block a user