Reformat and clean up "tools" package
This commit is contained in:
@@ -21,12 +21,7 @@
|
||||
*/
|
||||
package tools;
|
||||
|
||||
import java.util.AbstractMap;
|
||||
import java.util.AbstractSet;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
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() {
|
||||
list = new ArrayList<>();
|
||||
@@ -94,7 +90,7 @@ public class ArrayMap<K, V> extends AbstractMap<K, V> {
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings ("unchecked")
|
||||
@SuppressWarnings("unchecked")
|
||||
public Set<java.util.Map.Entry<K, V>> entrySet() {
|
||||
if (entries == null) {
|
||||
entries = new AbstractSet<Entry<K, V>>() {
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
package tools;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.security.SecureRandom;
|
||||
import java.util.Arrays;
|
||||
|
||||
@@ -376,8 +376,8 @@ public class BCrypt {
|
||||
*
|
||||
* @param d the byte array to encode
|
||||
* @param len the number of bytes to encode
|
||||
* @throws IllegalArgumentException if the length is invalid
|
||||
* @return base64-encoded string
|
||||
* @exception IllegalArgumentException if the length is invalid
|
||||
*/
|
||||
private static String encode_base64(byte[] d, int len)
|
||||
throws IllegalArgumentException {
|
||||
@@ -416,6 +416,7 @@ public class BCrypt {
|
||||
/**
|
||||
* Look up the 3 bits base64-encoded with the specified character,
|
||||
* range-checking againt conversion table
|
||||
*
|
||||
* @param x the base64-encoded value
|
||||
* @return the decoded value of x
|
||||
*/
|
||||
@@ -430,10 +431,11 @@ public class BCrypt {
|
||||
* Decode a string encoded using bcrypt's base64 scheme to a
|
||||
* byte array. Note that this is *not* compatible with
|
||||
* the standard MIME-base64 encoding.
|
||||
*
|
||||
* @param s the string to decode
|
||||
* @param maxolen the maximum number of bytes to decode
|
||||
* @return an array containing the bytes decoded
|
||||
* @throws IllegalArgumentException if maxolen is invalid
|
||||
* @return an array containing the bytes decoded
|
||||
*/
|
||||
private static byte[] decode_base64(String s, int maxolen)
|
||||
throws IllegalArgumentException {
|
||||
@@ -485,6 +487,7 @@ public class BCrypt {
|
||||
/**
|
||||
* Blowfish encipher a single 64-bit block encoded as
|
||||
* two 32-bit halves
|
||||
*
|
||||
* @param lr an array containing the two 32-bit half blocks
|
||||
* @param off the position in the array of the blocks
|
||||
*/
|
||||
@@ -492,7 +495,7 @@ public class BCrypt {
|
||||
int i, n, l = lr[off], r = lr[off + 1];
|
||||
|
||||
l ^= P[0];
|
||||
for (i = 0; i <= BLOWFISH_NUM_ROUNDS - 2;) {
|
||||
for (i = 0; i <= BLOWFISH_NUM_ROUNDS - 2; ) {
|
||||
// Feistel substitution on left word
|
||||
n = S[(l >> 24) & 0xff];
|
||||
n += S[0x100 | ((l >> 16) & 0xff)];
|
||||
@@ -513,6 +516,7 @@ public class BCrypt {
|
||||
|
||||
/**
|
||||
* Cycically extract a word of key material
|
||||
*
|
||||
* @param data the string to extract the data from
|
||||
* @param offp a "pointer" (as a one-entry array) to the
|
||||
* current offset into data
|
||||
@@ -522,14 +526,16 @@ public class BCrypt {
|
||||
*/
|
||||
private static int[] streamtowords(byte[] data, int[] offp, int[] signp) {
|
||||
int i;
|
||||
int[] words = { 0, 0 };
|
||||
int[] words = {0, 0};
|
||||
int off = offp[0];
|
||||
int sign = signp[0];
|
||||
|
||||
for (i = 0; i < 4; i++) {
|
||||
words[0] = (words[0] << 8) | (data[off] & 0xff);
|
||||
words[1] = (words[1] << 8) | (int)data[off];
|
||||
if (i > 0) sign |= words[1] & 0x80;
|
||||
words[1] = (words[1] << 8) | (int) data[off];
|
||||
if (i > 0) {
|
||||
sign |= words[1] & 0x80;
|
||||
}
|
||||
off = (off + 1) % data.length;
|
||||
}
|
||||
|
||||
@@ -540,25 +546,27 @@ public class BCrypt {
|
||||
|
||||
/**
|
||||
* Cycically extract a word of key material
|
||||
*
|
||||
* @param data the string to extract the data from
|
||||
* @param offp a "pointer" (as a one-entry array) to the
|
||||
* current offset into data
|
||||
* @return the next word of material from data
|
||||
*/
|
||||
private static int streamtoword(byte[] data, int[] offp) {
|
||||
int[] signp = { 0 };
|
||||
int[] signp = {0};
|
||||
return streamtowords(data, offp, signp)[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* Cycically extract a word of key material, with sign-extension bug
|
||||
*
|
||||
* @param data the string to extract the data from
|
||||
* @param offp a "pointer" (as a one-entry array) to the
|
||||
* current offset into data
|
||||
* @return the next word of material from data
|
||||
*/
|
||||
private static int streamtoword_bug(byte[] data, int[] offp) {
|
||||
int[] signp = { 0 };
|
||||
int[] signp = {0};
|
||||
return streamtowords(data, offp, signp)[1];
|
||||
}
|
||||
|
||||
@@ -572,6 +580,7 @@ public class BCrypt {
|
||||
|
||||
/**
|
||||
* Key the Blowfish cipher
|
||||
*
|
||||
* @param key an array containing the key
|
||||
* @param sign_ext_bug true to implement the 2x bug
|
||||
*/
|
||||
@@ -582,11 +591,12 @@ public class BCrypt {
|
||||
int plen = P.length, slen = S.length;
|
||||
|
||||
for (i = 0; i < plen; i++) {
|
||||
if (!sign_ext_bug)
|
||||
if (!sign_ext_bug) {
|
||||
P[i] = P[i] ^ streamtoword(key, koffp);
|
||||
else
|
||||
} else {
|
||||
P[i] = P[i] ^ streamtoword_bug(key, koffp);
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < plen; i += 2) {
|
||||
encipher(lr, 0);
|
||||
@@ -605,6 +615,7 @@ public class BCrypt {
|
||||
* Perform the "enhanced key schedule" step described by
|
||||
* Provos and Mazieres in "A Future-Adaptable Password Scheme"
|
||||
* http://www.openbsd.org/papers/bcrypt-paper.ps
|
||||
*
|
||||
* @param data salt information
|
||||
* @param key password information
|
||||
* @param sign_ext_bug true to implement the 2x bug
|
||||
@@ -616,7 +627,7 @@ public class BCrypt {
|
||||
int[] koffp = {0}, doffp = {0};
|
||||
int[] lr = {0, 0};
|
||||
int plen = P.length, slen = S.length;
|
||||
int[] signp = { 0 }; // non-benign sign-extension flag
|
||||
int[] signp = {0}; // non-benign sign-extension flag
|
||||
int diff = 0; // zero iff correct and buggy are same
|
||||
|
||||
for (i = 0; i < plen; i++) {
|
||||
@@ -675,6 +686,7 @@ public class BCrypt {
|
||||
/**
|
||||
* Perform the central password hashing step in the
|
||||
* bcrypt scheme
|
||||
*
|
||||
* @param password the password to hash
|
||||
* @param salt the binary salt to hash with the password
|
||||
* @param log_rounds the binary logarithm of the number
|
||||
@@ -723,23 +735,21 @@ public class BCrypt {
|
||||
|
||||
/**
|
||||
* Converts given plaintext to byte representation.
|
||||
*
|
||||
* @param plaintext the plaintext password to convert
|
||||
* @return Byte representation of given plaintext.
|
||||
*/
|
||||
private static byte[] stringToBytes(String plaintext) {
|
||||
byte[] plaintextb;
|
||||
|
||||
try {
|
||||
plaintextb = plaintext.getBytes("UTF-8");
|
||||
} catch (UnsupportedEncodingException uee) {
|
||||
throw new AssertionError("UTF-8 is not supported");
|
||||
}
|
||||
plaintextb = plaintext.getBytes(StandardCharsets.UTF_8);
|
||||
|
||||
return plaintextb;
|
||||
}
|
||||
|
||||
/**
|
||||
* Hash a password using the OpenBSD bcrypt scheme
|
||||
*
|
||||
* @param password the password to hash
|
||||
* @param salt the salt to hash with (perhaps generated
|
||||
* using BCrypt.gensalt)
|
||||
@@ -753,6 +763,7 @@ public class BCrypt {
|
||||
|
||||
/**
|
||||
* Hash a password using the OpenBSD bcrypt scheme
|
||||
*
|
||||
* @param passwordb the password to hash, as a byte array
|
||||
* @param salt the salt to hash with (perhaps generated
|
||||
* using BCrypt.gensalt)
|
||||
@@ -791,7 +802,9 @@ public class BCrypt {
|
||||
saltb = decode_base64(real_salt, BCRYPT_SALT_LEN);
|
||||
|
||||
if (minor >= 'a') // add null terminator
|
||||
{
|
||||
passwordb = Arrays.copyOf(passwordb, passwordb.length + 1);
|
||||
}
|
||||
|
||||
B = new BCrypt();
|
||||
hashed = B.crypt_raw(passwordb, saltb, rounds,
|
||||
@@ -821,13 +834,14 @@ public class BCrypt {
|
||||
|
||||
/**
|
||||
* Generate a salt for use with the BCrypt.hashpw() method
|
||||
*
|
||||
* @param prefix the prefix value (default $2y)
|
||||
* @param log_rounds the log2 of the number of rounds of
|
||||
* hashing to apply - the work factor therefore increases as
|
||||
* 2**log_rounds.
|
||||
* @param random an instance of SecureRandom to use
|
||||
* @throws IllegalArgumentException if prefix or log_rounds is invalid
|
||||
* @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)
|
||||
throws IllegalArgumentException {
|
||||
@@ -837,10 +851,10 @@ public class BCrypt {
|
||||
if (!prefix.startsWith("$2") ||
|
||||
(prefix.charAt(2) != 'a' && prefix.charAt(2) != 'y') &&
|
||||
prefix.charAt(2) != 'b') {
|
||||
throw new IllegalArgumentException ("Invalid prefix");
|
||||
throw new IllegalArgumentException("Invalid prefix");
|
||||
}
|
||||
if (log_rounds < 4 || log_rounds > 31) {
|
||||
throw new IllegalArgumentException ("Invalid log_rounds");
|
||||
throw new IllegalArgumentException("Invalid log_rounds");
|
||||
}
|
||||
|
||||
random.nextBytes(rnd);
|
||||
@@ -863,12 +877,13 @@ public class BCrypt {
|
||||
|
||||
/**
|
||||
* Generate a salt for use with the BCrypt.hashpw() method
|
||||
*
|
||||
* @param prefix the prefix value (default $2y)
|
||||
* @param log_rounds the log2 of the number of rounds of
|
||||
* hashing to apply - the work factor therefore increases as
|
||||
* 2**log_rounds.
|
||||
* @throws IllegalArgumentException if prefix or log_rounds is invalid
|
||||
* @return an encoded salt value
|
||||
* @exception IllegalArgumentException if prefix or log_rounds is invalid
|
||||
*/
|
||||
public static String gensalt(String prefix, int log_rounds)
|
||||
throws IllegalArgumentException {
|
||||
@@ -877,12 +892,13 @@ public class BCrypt {
|
||||
|
||||
/**
|
||||
* Generate a salt for use with the BCrypt.hashpw() method
|
||||
*
|
||||
* @param log_rounds the log2 of the number of rounds of
|
||||
* hashing to apply - the work factor therefore increases as
|
||||
* 2**log_rounds.
|
||||
* @param random an instance of SecureRandom to use
|
||||
* @throws IllegalArgumentException if prefix or log_rounds is invalid
|
||||
* @return an encoded salt value
|
||||
* @exception IllegalArgumentException if prefix or log_rounds is invalid
|
||||
*/
|
||||
public static String gensalt(int log_rounds, SecureRandom random)
|
||||
throws IllegalArgumentException {
|
||||
@@ -891,11 +907,12 @@ public class BCrypt {
|
||||
|
||||
/**
|
||||
* Generate a salt for use with the BCrypt.hashpw() method
|
||||
*
|
||||
* @param log_rounds the log2 of the number of rounds of
|
||||
* hashing to apply - the work factor therefore increases as
|
||||
* 2**log_rounds.
|
||||
* @throws IllegalArgumentException if prefix or log_rounds is invalid
|
||||
* @return an encoded salt value
|
||||
* @exception IllegalArgumentException if prefix or log_rounds is invalid
|
||||
*/
|
||||
public static String gensalt(int log_rounds)
|
||||
throws IllegalArgumentException {
|
||||
@@ -906,8 +923,9 @@ public class BCrypt {
|
||||
* Generate a salt for use with the BCrypt.hashpw() method,
|
||||
* selecting a reasonable default for the number of hashing
|
||||
* rounds to apply
|
||||
*
|
||||
* @throws IllegalArgumentException if prefix or log_rounds is invalid
|
||||
* @return an encoded salt value
|
||||
* @exception IllegalArgumentException if prefix or log_rounds is invalid
|
||||
*/
|
||||
public static String gensalt()
|
||||
throws IllegalArgumentException {
|
||||
@@ -917,6 +935,7 @@ public class BCrypt {
|
||||
/**
|
||||
* Check that a plaintext password matches a previously hashed
|
||||
* one
|
||||
*
|
||||
* @param plaintext the plaintext password to verify
|
||||
* @param hashed the previously-hashed password
|
||||
* @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
|
||||
* one
|
||||
*
|
||||
* @param plaintext the plaintext password to verify
|
||||
* @param hashed the previously-hashed password
|
||||
* @return true if the passwords match, false otherwise
|
||||
@@ -936,18 +956,16 @@ public class BCrypt {
|
||||
public static boolean checkpw(byte[] plaintext, String hashed) {
|
||||
byte[] hashed_bytes;
|
||||
byte[] try_bytes;
|
||||
try {
|
||||
String try_pw = hashpw(plaintext, hashed);
|
||||
hashed_bytes = hashed.getBytes("UTF-8");
|
||||
try_bytes = try_pw.getBytes("UTF-8");
|
||||
} catch (UnsupportedEncodingException uee) {
|
||||
hashed_bytes = hashed.getBytes(StandardCharsets.UTF_8);
|
||||
try_bytes = try_pw.getBytes(StandardCharsets.UTF_8);
|
||||
if (hashed_bytes.length != try_bytes.length) {
|
||||
return false;
|
||||
}
|
||||
if (hashed_bytes.length != try_bytes.length)
|
||||
return false;
|
||||
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];
|
||||
}
|
||||
return ret == 0;
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,6 @@
|
||||
package tools;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
import java.io.*;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
|
||||
|
||||
@@ -58,7 +58,7 @@ public class HexTool {
|
||||
int nextb = 0;
|
||||
boolean highoc = true;
|
||||
outer:
|
||||
for (;;) {
|
||||
for (; ; ) {
|
||||
int number = -1;
|
||||
while (number == -1) {
|
||||
if (nexti == hex.length()) {
|
||||
|
||||
@@ -31,12 +31,11 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Ronan
|
||||
*/
|
||||
public class IntervalBuilder {
|
||||
|
||||
private List<Line2D> intervalLimits = new ArrayList<>();
|
||||
private final List<Line2D> intervalLimits = new ArrayList<>();
|
||||
|
||||
protected MonitoredReadLock intervalRlock;
|
||||
protected MonitoredWriteLock intervalWlock;
|
||||
@@ -100,7 +99,9 @@ public class IntervalBuilder {
|
||||
}
|
||||
|
||||
int en = bsearchInterval(to);
|
||||
if (en < st) en = st - 1;
|
||||
if (en < st) {
|
||||
en = st - 1;
|
||||
}
|
||||
|
||||
refitOverlappedIntervals(st, en + 1, from, to);
|
||||
} finally {
|
||||
|
||||
@@ -20,13 +20,13 @@ public class LogHelper {
|
||||
String log = "TRADE BETWEEN " + name1 + " AND " + name2 + "\r\n";
|
||||
//Trade 1 to trade 2
|
||||
log += trade1.getExchangeMesos() + " mesos from " + name1 + " to " + name2 + " \r\n";
|
||||
for (Item item : trade1.getItems()){
|
||||
for (Item item : trade1.getItems()) {
|
||||
String itemName = ItemInformationProvider.getInstance().getName(item.getItemId()) + "(" + item.getItemId() + ")";
|
||||
log += item.getQuantity() + " " + itemName + " from " + name1 + " to " + name2 + " \r\n";
|
||||
}
|
||||
//Trade 2 to trade 1
|
||||
log += trade2.getExchangeMesos() + " mesos from " + name2 + " to " + name1 + " \r\n";
|
||||
for (Item item : trade2.getItems()){
|
||||
for (Item item : trade2.getItems()) {
|
||||
String itemName = ItemInformationProvider.getInstance().getName(item.getItemId()) + "(" + item.getItemId() + ")";
|
||||
log += item.getQuantity() + " " + itemName + " from " + name2 + " to " + name1 + " \r\n";
|
||||
}
|
||||
@@ -40,21 +40,21 @@ public class LogHelper {
|
||||
String log = expedition.getType().toString() + " EXPEDITION\r\n";
|
||||
log += getTimeString(expedition.getStartTime()) + "\r\n";
|
||||
|
||||
for (String memberName : expedition.getMembers().values()){
|
||||
for (String memberName : expedition.getMembers().values()) {
|
||||
log += ">>" + memberName + "\r\n";
|
||||
}
|
||||
log += "BOSS KILLS\r\n";
|
||||
for (String message: expedition.getBossLogs()){
|
||||
for (String message : expedition.getBossLogs()) {
|
||||
log += message;
|
||||
}
|
||||
log += "\r\n";
|
||||
FilePrinter.print(FilePrinter.LOG_EXPEDITION, log);
|
||||
}
|
||||
|
||||
public static String getTimeString(long then){
|
||||
public static String getTimeString(long then) {
|
||||
long duration = System.currentTimeMillis() - then;
|
||||
int seconds = (int) (duration / 1000) % 60 ;
|
||||
int minutes = (int) ((duration / (1000*60)) % 60);
|
||||
int seconds = (int) (duration / 1000) % 60;
|
||||
int minutes = (int) ((duration / (1000 * 60)) % 60);
|
||||
return minutes + " Minutes and " + seconds + " Seconds";
|
||||
}
|
||||
|
||||
@@ -71,9 +71,9 @@ public class LogHelper {
|
||||
FilePrinter.print(FilePrinter.LOG_GACHAPON, log);
|
||||
}
|
||||
|
||||
public static void logChat(Client player, String chatType, String text){
|
||||
public static void logChat(Client player, String chatType, String text) {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy HH:mm");
|
||||
FilePrinter.print(FilePrinter.LOG_CHAT, "[" + sdf.format(Calendar.getInstance().getTime()) + "] (" + chatType + ") " +player.getPlayer().getName() + ": " + text);
|
||||
FilePrinter.print(FilePrinter.LOG_CHAT, "[" + sdf.format(Calendar.getInstance().getTime()) + "] (" + chatType + ") " + player.getPlayer().getName() + ": " + text);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,23 +1,19 @@
|
||||
package tools;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Shavit
|
||||
*/
|
||||
public class LongTool {
|
||||
|
||||
// Converts 8 bytes to a long.
|
||||
public static long BytesToLong(byte[] aToConvert)
|
||||
{
|
||||
if(aToConvert.length != Long.BYTES)
|
||||
{
|
||||
public static long BytesToLong(byte[] aToConvert) {
|
||||
if (aToConvert.length != Long.BYTES) {
|
||||
throw new IllegalArgumentException(String.format("Size of input should be %d", (Long.SIZE / 8)));
|
||||
}
|
||||
|
||||
long nResult = 0;
|
||||
|
||||
for(int i = 0; i < Long.BYTES; i++)
|
||||
{
|
||||
for (int i = 0; i < Long.BYTES; i++) {
|
||||
nResult <<= Byte.SIZE;
|
||||
nResult |= (aToConvert[i] & 0xFF);
|
||||
}
|
||||
@@ -26,12 +22,10 @@ public class LongTool {
|
||||
}
|
||||
|
||||
// Converts a long to 8 bytes.
|
||||
public static byte[] LongToBytes(long nToConvert)
|
||||
{
|
||||
public static byte[] LongToBytes(long nToConvert) {
|
||||
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);
|
||||
nToConvert >>= Byte.SIZE;
|
||||
}
|
||||
|
||||
@@ -23,12 +23,11 @@ package tools;
|
||||
/**
|
||||
* Represents a pair of values.
|
||||
*
|
||||
* @author Frz
|
||||
* @since Revision 333
|
||||
* @version 1.0
|
||||
*
|
||||
* @param <E> The type of the left value.
|
||||
* @param <F> The type of the right value.
|
||||
* @author Frz
|
||||
* @version 1.0
|
||||
* @since Revision 333
|
||||
*/
|
||||
public class Pair<E, F> {
|
||||
|
||||
@@ -110,12 +109,7 @@ public class Pair<E, F> {
|
||||
return false;
|
||||
}
|
||||
if (right == null) {
|
||||
if (other.right != null) {
|
||||
return false;
|
||||
}
|
||||
} else if (!right.equals(other.right)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return other.right == null;
|
||||
} else return right.equals(other.right);
|
||||
}
|
||||
}
|
||||
@@ -23,7 +23,6 @@ import net.packet.InPacket;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Ronan
|
||||
*/
|
||||
public class EmptyMovementException extends Exception {
|
||||
|
||||
@@ -21,7 +21,6 @@ package tools.exceptions;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Ronan
|
||||
*/
|
||||
public class EventInstanceInProgressException extends Exception {
|
||||
|
||||
@@ -11,15 +11,13 @@ import java.nio.charset.StandardCharsets;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author RonanLana
|
||||
|
||||
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
|
||||
uses up a card, as well as report those currently unused.
|
||||
|
||||
Estimated parse time: 10 seconds
|
||||
|
||||
* <p>
|
||||
* 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
|
||||
* uses up a card, as well as report those currently unused.
|
||||
* <p>
|
||||
* Estimated parse time: 10 seconds
|
||||
*/
|
||||
public class CashCosmeticsFetcher {
|
||||
private static final Map<Integer, String> scriptEntries = new HashMap<>(500);
|
||||
@@ -41,7 +39,7 @@ public class CashCosmeticsFetcher {
|
||||
private static int getNpcIdFromFilename(String name) {
|
||||
try {
|
||||
return Integer.parseInt(name.substring(0, name.indexOf('.')));
|
||||
} catch(Exception e) {
|
||||
} catch (Exception e) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@@ -50,7 +48,7 @@ public class CashCosmeticsFetcher {
|
||||
ArrayList<File> files = new ArrayList<>();
|
||||
listFiles(ToolConstants.SCRIPTS_PATH + "/npc", files);
|
||||
|
||||
for(File f : files) {
|
||||
for (File f : files) {
|
||||
Integer npcid = getNpcIdFromFilename(f.getName());
|
||||
|
||||
//System.out.println("Parsing " + f.getAbsolutePath());
|
||||
@@ -60,7 +58,7 @@ public class CashCosmeticsFetcher {
|
||||
StringBuilder stringBuffer = new StringBuilder();
|
||||
String line;
|
||||
|
||||
while((line = bufferedReader.readLine())!=null){
|
||||
while ((line = bufferedReader.readLine()) != null) {
|
||||
stringBuffer.append(line).append("\n");
|
||||
}
|
||||
|
||||
@@ -108,7 +106,7 @@ public class CashCosmeticsFetcher {
|
||||
System.out.println("Loaded scripts");
|
||||
|
||||
reportCosmeticCouponResults();
|
||||
} catch(Exception e) {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,13 +8,12 @@ import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author RonanLana
|
||||
*
|
||||
This application main objective is to read Vega-related information from
|
||||
the item's description report back missing nodes for these items.
|
||||
|
||||
Estimated parse time: 10 seconds
|
||||
* <p>
|
||||
* This application main objective is to read Vega-related information from
|
||||
* the item's description report back missing nodes for these items.
|
||||
* <p>
|
||||
* Estimated parse time: 10 seconds
|
||||
*/
|
||||
public class CashVegaChecker {
|
||||
private static final File OUTPUT_FILE = ToolConstants.getOutputFile("vega_checker_report.txt");
|
||||
@@ -40,7 +39,7 @@ public class CashVegaChecker {
|
||||
token.getChars(i, j, dest, 0);
|
||||
|
||||
d = new String(dest);
|
||||
return(d.trim());
|
||||
return (d.trim());
|
||||
}
|
||||
|
||||
private static String getValue(String token) {
|
||||
@@ -56,36 +55,33 @@ public class CashVegaChecker {
|
||||
token.getChars(i, j, dest, 0);
|
||||
|
||||
d = new String(dest);
|
||||
return(d.trim());
|
||||
return (d.trim());
|
||||
}
|
||||
|
||||
private static void forwardCursor(int st) {
|
||||
String line = null;
|
||||
|
||||
try {
|
||||
while(status >= st && (line = bufferedReader.readLine()) != null) {
|
||||
while (status >= st && (line = bufferedReader.readLine()) != null) {
|
||||
simpleToken(line);
|
||||
}
|
||||
}
|
||||
catch(Exception e) {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private static void simpleToken(String token) {
|
||||
if(token.contains("/imgdir")) {
|
||||
if (token.contains("/imgdir")) {
|
||||
status -= 1;
|
||||
}
|
||||
else if(token.contains("imgdir")) {
|
||||
} else if (token.contains("imgdir")) {
|
||||
status += 1;
|
||||
}
|
||||
}
|
||||
|
||||
private static void translateItemToken(String token) {
|
||||
if(token.contains("/imgdir")) {
|
||||
if (token.contains("/imgdir")) {
|
||||
status -= 1;
|
||||
}
|
||||
else if(token.contains("imgdir")) {
|
||||
} else if (token.contains("imgdir")) {
|
||||
status += 1;
|
||||
|
||||
if (status == 2) {
|
||||
@@ -101,10 +97,9 @@ public class CashVegaChecker {
|
||||
}
|
||||
|
||||
private static void translateVegaToken(String token) {
|
||||
if(token.contains("/imgdir")) {
|
||||
if (token.contains("/imgdir")) {
|
||||
status -= 1;
|
||||
}
|
||||
else if(token.contains("imgdir")) {
|
||||
} else if (token.contains("imgdir")) {
|
||||
status += 1;
|
||||
} else {
|
||||
if (status == 2) {
|
||||
@@ -122,7 +117,7 @@ public class CashVegaChecker {
|
||||
bufferedReader = new BufferedReader(fileReader);
|
||||
|
||||
String line;
|
||||
while((line = bufferedReader.readLine())!=null){
|
||||
while ((line = bufferedReader.readLine()) != null) {
|
||||
translateItemToken(line);
|
||||
}
|
||||
|
||||
@@ -141,7 +136,7 @@ public class CashVegaChecker {
|
||||
bufferedReader = new BufferedReader(fileReader);
|
||||
|
||||
String line;
|
||||
while((line = bufferedReader.readLine())!=null){
|
||||
while ((line = bufferedReader.readLine()) != null) {
|
||||
translateVegaToken(line);
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,6 @@ package tools.mapletools;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author RonanLana
|
||||
*/
|
||||
public class MakerItemEntry {
|
||||
|
||||
@@ -121,7 +121,7 @@ public class MonsterStatFetcher {
|
||||
}
|
||||
|
||||
monsterStats.put(mid, stats);
|
||||
} catch(NullPointerException npe) {
|
||||
} catch (NullPointerException npe) {
|
||||
//System.out.println("[SEVERE] " + mFile.getName() + " failed to load. Issue: " + npe.getMessage() + "\n\n");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,7 +29,6 @@ import tools.PacketCreator;
|
||||
import java.util.Calendar;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author FateJiki (RaGeZONE)
|
||||
* @author Ronan - timing pattern
|
||||
*/
|
||||
@@ -65,7 +64,7 @@ public class Fishing {
|
||||
return (0.23 * yearLikelihood) + (0.77 * timeLikelihood) + (baitLikelihood) > 57.777;
|
||||
}
|
||||
|
||||
public static void doFishing(Character chr, int baitLevel, double yearLikelihood, double timeLikelihood){
|
||||
public static void doFishing(Character chr, int baitLevel, double yearLikelihood, double timeLikelihood) {
|
||||
// thanks Fadi, Vcoc for suggesting a custom fishing system
|
||||
|
||||
if (!chr.isLoggedinWorld() || !chr.isAlive()) {
|
||||
@@ -89,16 +88,16 @@ public class Fishing {
|
||||
String rewardStr = "";
|
||||
fishingEffect = "Effect/BasicEff.img/Catch/Success";
|
||||
|
||||
int rand = (int)(3.0 * Math.random());
|
||||
switch(rand){
|
||||
int rand = (int) (3.0 * Math.random());
|
||||
switch (rand) {
|
||||
case 0:
|
||||
int mesoAward = (int)(1400.0 * Math.random() + 1201) * chr.getMesoRate() + (15 * chr.getLevel() / 5);
|
||||
int mesoAward = (int) (1400.0 * Math.random() + 1201) * chr.getMesoRate() + (15 * chr.getLevel() / 5);
|
||||
chr.gainMeso(mesoAward, true, true, true);
|
||||
|
||||
rewardStr = mesoAward + " mesos.";
|
||||
break;
|
||||
case 1:
|
||||
int expAward = (int)(645.0 * Math.random() + 620.0) * chr.getExpRate() + (15 * chr.getLevel() / 4);
|
||||
int expAward = (int) (645.0 * Math.random() + 620.0) * chr.getExpRate() + (15 * chr.getLevel() / 4);
|
||||
chr.gainExp(expAward, true, true);
|
||||
|
||||
rewardStr = expAward + " EXP.";
|
||||
@@ -123,18 +122,18 @@ public class Fishing {
|
||||
chr.getMap().broadcastMessage(chr, PacketCreator.showForeignInfo(chr.getId(), fishingEffect), false);
|
||||
}
|
||||
|
||||
public static int getRandomItem(){
|
||||
int rand = (int)(100.0 * Math.random());
|
||||
public static int getRandomItem() {
|
||||
int rand = (int) (100.0 * Math.random());
|
||||
int[] commons = {1002851, 2002020, 2002020, 2000006, 2000018, 2002018, 2002024, 2002027, 2002027, 2000018, 2000018, 2000018, 2000018, 2002030, 2002018, 2000016}; // filler' up
|
||||
int[] uncommons = {1000025, 1002662, 1002812, 1002850, 1002881, 1002880, 1012072, 4020009, 2043220, 2043022, 2040543, 2044420, 2040943, 2043713, 2044220, 2044120, 2040429, 2043220, 2040943}; // filler' uptoo
|
||||
int[] rares = {1002859, 1002553, 1002762, 1002763, 1002764, 1002765, 1002766, 1002663, 1002788, 1002949, 2049100, 2340000, 2040822, 2040822, 2040822, 2040822}; // filler' uplast
|
||||
|
||||
if(rand >= 25){
|
||||
return commons[(int)(commons.length * Math.random())];
|
||||
} else if(rand <= 7 && rand >= 4){
|
||||
return uncommons[(int)(uncommons.length * Math.random())];
|
||||
if (rand >= 25) {
|
||||
return commons[(int) (commons.length * Math.random())];
|
||||
} else if (rand <= 7 && rand >= 4) {
|
||||
return uncommons[(int) (uncommons.length * Math.random())];
|
||||
} else {
|
||||
return rares[(int)(rares.length * Math.random())];
|
||||
return rares[(int) (rares.length * Math.random())];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ import java.util.List;
|
||||
* CField_Wedding, CField_WeddingPhoto, CWeddingMan, OnMarriageResult, and all Wedding/Marriage enum/structs.
|
||||
*
|
||||
* @author Eric
|
||||
*
|
||||
* <p>
|
||||
* Wishlists edited by Drago (Dragohe4rt)
|
||||
*/
|
||||
public class WeddingPackets extends PacketCreator {
|
||||
@@ -89,8 +89,9 @@ public class WeddingPackets extends PacketCreator {
|
||||
ENGAGED(0x1),
|
||||
RESERVED(0x2),
|
||||
MARRIED(0x3);
|
||||
private int ms;
|
||||
private MarriageStatus(int ms) {
|
||||
private final int ms;
|
||||
|
||||
MarriageStatus(int ms) {
|
||||
this.ms = ms;
|
||||
}
|
||||
|
||||
@@ -107,8 +108,9 @@ public class WeddingPackets extends PacketCreator {
|
||||
AddReservation(0x4),
|
||||
DeleteReservation(0x5),
|
||||
GetReservation(0x6);
|
||||
private int req;
|
||||
private MarriageRequest(int req) {
|
||||
private final int req;
|
||||
|
||||
MarriageRequest(int req) {
|
||||
this.req = req;
|
||||
}
|
||||
|
||||
@@ -124,8 +126,9 @@ public class WeddingPackets extends PacketCreator {
|
||||
CATHEDRAL_NORMAL(0xB),
|
||||
VEGAS_PREMIUM(0x14),
|
||||
VEGAS_NORMAL(0x15);
|
||||
private int wt;
|
||||
private WeddingType(int wt) {
|
||||
private final int wt;
|
||||
|
||||
WeddingType(int wt) {
|
||||
this.wt = wt;
|
||||
}
|
||||
|
||||
@@ -140,8 +143,9 @@ public class WeddingPackets extends PacketCreator {
|
||||
CATHEDRAL_STARTMAP(680000210),
|
||||
PHOTOMAP(680000300),
|
||||
EXITMAP(680000500);
|
||||
private int wm;
|
||||
private WeddingMap(int wm) {
|
||||
private final int wm;
|
||||
|
||||
WeddingMap(int wm) {
|
||||
this.wm = wm;
|
||||
}
|
||||
|
||||
@@ -182,8 +186,9 @@ public class WeddingPackets extends PacketCreator {
|
||||
WT_VEGAS_NORMAL(5251001),
|
||||
WT_VEGAS_PREMIUM(5251002),
|
||||
WT_CATHEDRAL_PREMIUM(5251003);
|
||||
private int wi;
|
||||
private WeddingItem(int wi) {
|
||||
private final int wi;
|
||||
|
||||
WeddingItem(int 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
|
||||
* - 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.
|
||||
*
|
||||
* <p>
|
||||
* - Will no longer continue Wedding Photos, needs a WvsMapGen :(
|
||||
*
|
||||
* @param ReservedGroomName The groom IGN of the wedding
|
||||
|
||||
Reference in New Issue
Block a user