forked from 2009Scape/Server
Another batch of preemptive bugfixing
This commit is contained in:
parent
62ab9e80a9
commit
13dce7226e
19 changed files with 84 additions and 84 deletions
|
|
@ -79,8 +79,9 @@ public final class PunishmentStorage {
|
|||
e.printStackTrace();
|
||||
SQLManager.close(connection);
|
||||
return;
|
||||
} finally {
|
||||
SQLManager.close(connection);
|
||||
}
|
||||
SQLManager.close(connection);
|
||||
return;
|
||||
case 2:
|
||||
ban(player.getIpAddress(), type);
|
||||
|
|
@ -152,8 +153,9 @@ public final class PunishmentStorage {
|
|||
e.printStackTrace();
|
||||
SQLManager.close(connection);
|
||||
return false;
|
||||
} finally {
|
||||
SQLManager.close(connection);
|
||||
}
|
||||
SQLManager.close(connection);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -175,8 +177,9 @@ public final class PunishmentStorage {
|
|||
e.printStackTrace();
|
||||
SQLManager.close(connection);
|
||||
return false;
|
||||
} finally {
|
||||
SQLManager.close(connection);
|
||||
}
|
||||
SQLManager.close(connection);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -239,8 +242,9 @@ public final class PunishmentStorage {
|
|||
e.printStackTrace();
|
||||
SQLManager.close(connection);
|
||||
return false;
|
||||
} finally {
|
||||
SQLManager.close(connection);
|
||||
}
|
||||
SQLManager.close(connection);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -252,9 +256,9 @@ public final class PunishmentStorage {
|
|||
private static String getDuration(long end) {
|
||||
String time = "indefinite time";
|
||||
if (end != Long.MAX_VALUE) {
|
||||
int days = (int) ((end -= System.currentTimeMillis()) / (24 * 60 * 60_000));
|
||||
int hours = (int) ((end -= (days * 24 * 60 * 60_000)) / (60 * 60_000));
|
||||
int minutes = (int) ((end -= (hours * (60 * 60_000))) / 60_000);
|
||||
int days = (int) ((System.currentTimeMillis()) / (24 * 60 * 60_000));
|
||||
int hours = (int) (((24L * days * 60 * 60_000)) / (60 * 60_000));
|
||||
int minutes = (int) (((hours * (60 * 60_000))) / 60_000);
|
||||
time = days + "d, " + hours + "h, " + minutes + "m";
|
||||
}
|
||||
return time;
|
||||
|
|
|
|||
|
|
@ -141,14 +141,20 @@ public final class CommunicationInfo {
|
|||
public void save(PreparedStatement statement) throws SQLException {
|
||||
String contacts = "";
|
||||
String blocked = "";
|
||||
StringBuilder blockedBuilder = new StringBuilder();
|
||||
for (int i = 0; i < this.blocked.size(); i++) {
|
||||
blocked += (i == 0 ? "" : ",") + this.blocked.get(i);
|
||||
String blockline = (i == 0 ? "" : ",") + this.blocked.get(i);
|
||||
blockedBuilder.append(blockline);
|
||||
}
|
||||
blocked = blockedBuilder.toString();
|
||||
int count = 0;
|
||||
StringBuilder contactBuilder = new StringBuilder();
|
||||
for (Entry<String, ClanRank> entry : this.contacts.entrySet()) {
|
||||
contacts += "{" + entry.getKey() + "," + entry.getValue().ordinal() + "}" + (count == this.contacts.size() - 1 ? "" : "~");
|
||||
String contactLine = "{" + entry.getKey() + "," + entry.getValue().ordinal() + "}" + (count == this.contacts.size() - 1 ? "" : "~");
|
||||
contactBuilder.append(contactLine);
|
||||
count++;
|
||||
}
|
||||
contacts = contactBuilder.toString();
|
||||
statement.setString(3, contacts);
|
||||
statement.setString(4, blocked);
|
||||
statement.setString(5, clanName);
|
||||
|
|
@ -211,6 +217,8 @@ public final class CommunicationInfo {
|
|||
case 3:
|
||||
lootRequirement = rank;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -239,9 +247,9 @@ public final class CommunicationInfo {
|
|||
*/
|
||||
public void save(ByteBuffer buffer) {
|
||||
buffer.put((byte) contacts.size());
|
||||
for (String name : contacts.keySet()) {
|
||||
ByteBufferUtils.putString(name, buffer);
|
||||
buffer.put((byte) contacts.get(name).ordinal());
|
||||
for(Entry<String,ClanRank> contact : contacts.entrySet()){
|
||||
ByteBufferUtils.putString(contact.getKey(), buffer);
|
||||
buffer.put((byte) contact.getValue().ordinal());
|
||||
}
|
||||
buffer.put((byte) blocked.size());
|
||||
for (String name : blocked) {
|
||||
|
|
|
|||
|
|
@ -52,12 +52,4 @@ public final class SQLTable {
|
|||
return updated;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the columns.
|
||||
* @return The columns.
|
||||
*/
|
||||
public SQLColumn[] getColumns() {
|
||||
return columns;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -31,12 +31,16 @@ public final class WorldListSQLHandler extends SQLEntryHandler<GameServer> {
|
|||
* Clears the world list.
|
||||
*/
|
||||
public static void clearWorldList() {
|
||||
Connection connection = SQLManager.getConnection();
|
||||
if(connection == null) return;
|
||||
try {
|
||||
Connection connection = SQLManager.getConnection();
|
||||
PreparedStatement statement = connection.prepareStatement("DELETE FROM " + TABLE);
|
||||
statement.executeUpdate();
|
||||
} catch (SQLException e) {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
SQLManager.close(connection);
|
||||
} finally {
|
||||
SQLManager.close(connection);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package ms.system.util;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
|
||||
/**
|
||||
|
|
@ -30,7 +31,7 @@ public final class ByteBufferUtils {
|
|||
* @param buffer The byte buffer.
|
||||
*/
|
||||
public static void putString(String s, ByteBuffer buffer) {
|
||||
buffer.put(s.getBytes()).put((byte) 0);
|
||||
buffer.put(s.getBytes(StandardCharsets.UTF_8)).put((byte) 0);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -484,7 +484,7 @@ public class EncryptionManager {
|
|||
* @return the decoded value of x
|
||||
*/
|
||||
private static byte char64(char x) {
|
||||
if ((int)x < 0 || (int)x > index_64.length)
|
||||
if ((int)x > index_64.length)
|
||||
return -1;
|
||||
return index_64[(int)x];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,26 +14,16 @@ public final class StringUtils {
|
|||
/**
|
||||
* The valid characters to be used in names/messages/...
|
||||
*/
|
||||
public static final char[] VALID_CHARS = {
|
||||
private static final char[] VALID_CHARS = {
|
||||
'_', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h',
|
||||
'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q',
|
||||
'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
|
||||
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'
|
||||
};
|
||||
/**
|
||||
* Character mapping.
|
||||
*/
|
||||
public static char[] mapping = {
|
||||
'\n',
|
||||
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
|
||||
'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
|
||||
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
|
||||
'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
|
||||
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ' ' };
|
||||
/**
|
||||
* The an int array241.
|
||||
*/
|
||||
public static int[] anIntArray241 = { 215, 203, 83, 158, 104, 101, 93, 84,
|
||||
private final static int[] anIntArray241 = { 215, 203, 83, 158, 104, 101, 93, 84,
|
||||
107, 103, 109, 95, 94, 98, 89, 86, 70, 41, 32, 27, 24, 23, -1, -2,
|
||||
26, -3, -4, 31, 30, -5, -6, -7, 37, 38, 36, -8, -9, -10, 40, -11,
|
||||
-12, 55, 48, 46, 47, -13, -14, -15, 52, 51, -16, -17, 54, -18, -19,
|
||||
|
|
@ -173,7 +163,7 @@ public final class StringUtils {
|
|||
boolean wasSpace = true;
|
||||
for (int i = 0; i < name.length(); i++) {
|
||||
if (wasSpace) {
|
||||
newName.append((new String() + name.charAt(i)).toUpperCase());
|
||||
newName.append(("" + name.charAt(i)).toUpperCase());
|
||||
wasSpace = false;
|
||||
} else {
|
||||
newName.append(name.charAt(i));
|
||||
|
|
@ -306,9 +296,8 @@ public final class StringUtils {
|
|||
* @return The string value.
|
||||
*/
|
||||
public static String getString(String s) {
|
||||
String string = s.replaceAll("\\<.*?>", "").replaceAll(" ", "")
|
||||
return s.replaceAll("\\<.*?>", "").replaceAll(" ", "")
|
||||
.replaceAll("Discontinued Item:", "");
|
||||
return string;
|
||||
}
|
||||
/**
|
||||
* Characters used to convert a String to a Long.
|
||||
|
|
@ -319,7 +308,7 @@ public final class StringUtils {
|
|||
't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2',
|
||||
'3', '4', '5', '6', '7', '8', '9'
|
||||
};
|
||||
public static int[] anIntArray233 = {
|
||||
private final static int[] anIntArray233 = {
|
||||
0, 1024, 2048, 3072, 4096, 5120,
|
||||
6144, 8192, 9216, 12288, 10240, 11264, 16384, 18432, 17408, 20480,
|
||||
21504, 22528, 23552, 24576, 25600, 26624, 27648, 28672, 29696,
|
||||
|
|
@ -362,7 +351,7 @@ public final class StringUtils {
|
|||
301188096, 301189120, 301190144, 301191168, 301193216, 301195264,
|
||||
301194240, 301197312, 301198336, 301199360, 301201408, 301202432
|
||||
};
|
||||
public static byte[] aByteArray235 = {
|
||||
private final static byte[] aByteArray235 = {
|
||||
22, 22, 22, 22, 22, 22, 21, 22, 22,
|
||||
20, 22, 22, 22, 21, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
|
||||
22, 22, 22, 22, 22, 22, 3, 8, 22, 16, 22, 16, 17, 7, 13, 13, 13,
|
||||
|
|
@ -387,16 +376,16 @@ public final class StringUtils {
|
|||
try {
|
||||
i_27_ += i_25_;
|
||||
int i_29_ = 0;
|
||||
int i_30_ = i_26_ << -2116795453;
|
||||
int i_30_ = i_26_ << 3;
|
||||
for (; i_27_ > i_25_; i_25_++) {
|
||||
int i_31_ = 0xff & is_28_[i_25_];
|
||||
int i_32_ = anIntArray233[i_31_];
|
||||
int i_33_ = aByteArray235[i_31_];
|
||||
int i_34_ = i_30_ >> -1445887805;
|
||||
int i_34_ = i_30_ >> 3;
|
||||
int i_35_ = i_30_ & 0x7;
|
||||
i_29_ &= (-i_35_ >> 473515839);
|
||||
i_29_ &= (-i_35_ >> 31);
|
||||
i_30_ += i_33_;
|
||||
int i_36_ = ((-1 + (i_35_ - -i_33_)) >> -1430991229) + i_34_;
|
||||
int i_36_ = ((-1 + (i_35_ - -i_33_)) >> 3) + i_34_;
|
||||
i_35_ += 24;
|
||||
is[i_34_] = (byte) (i_29_ = (i_29_ | (i_32_ >>> i_35_)));
|
||||
if ((i_36_ ^ 0xffffffff) < (i_34_ ^ 0xffffffff)) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue