Reformatting, fix init issue in entryaction
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
package dev.heliosares.auxprotect.database;
|
||||
|
||||
import dev.heliosares.auxprotect.database.ConnectionPool.BusyException;
|
||||
import org.bukkit.Location;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
@@ -74,8 +73,8 @@ public class DbEntry {
|
||||
this(userLabel, action, state, location == null ? null : location.getWorld().getName(),
|
||||
location == null ? 0 : location.getBlockX(), location == null ? 0 : location.getBlockY(),
|
||||
location == null ? 0 : location.getBlockZ(),
|
||||
location == null ? 0 : (int) Math.round(location.getPitch()),
|
||||
location == null ? 0 : (int) Math.round(location.getYaw()), targetLabel, data);
|
||||
location == null ? 0 : Math.round(location.getPitch()),
|
||||
location == null ? 0 : Math.round(location.getYaw()), targetLabel, data);
|
||||
}
|
||||
|
||||
protected DbEntry(long time, int uid, EntryAction action, boolean state, String world, int x, int y, int z,
|
||||
|
||||
@@ -10,6 +10,7 @@ import dev.heliosares.auxprotect.core.PlatformType;
|
||||
import java.util.*;
|
||||
|
||||
public class EntryAction {
|
||||
private static final Set<Integer> usedids = new HashSet<>();
|
||||
// START MAIN (0)
|
||||
public static final EntryAction LEASH = new EntryAction("leash", 2, 3);
|
||||
public static final EntryAction SESSION = new EntryAction("session", 4, 5);
|
||||
@@ -89,10 +90,10 @@ public class EntryAction {
|
||||
public static final EntryAction NATIONDELETE = new EntryAction("nationdelete", 1402);
|
||||
public static final EntryAction NATIONJOIN = new EntryAction("nationjoin", 1403, 1404);
|
||||
public static final EntryAction NATIONBANK = new EntryAction("nationbank", 1405, 1406);
|
||||
// @formatter:off
|
||||
private static final Set<Integer> usedids = new HashSet<>();
|
||||
private static final HashMap<String, EntryAction> values = new HashMap<>();
|
||||
// END TOWNY (1499)
|
||||
|
||||
// @formatter:on
|
||||
public final boolean hasDual;
|
||||
public final int id;
|
||||
public final int idPos;
|
||||
@@ -199,9 +200,9 @@ public class EntryAction {
|
||||
}
|
||||
if (plugin.getPlatform() == PlatformType.BUNGEE) {
|
||||
return equals(MSG) || equals(COMMAND) || equals(IP) || equals(USERNAME) || equals(SESSION)
|
||||
|| equals(CONNECT);
|
||||
|| equals(CONNECT);
|
||||
} else if (plugin.getPlatform() == PlatformType.SPIGOT) {
|
||||
return id!=MSG.id && !equals(CONNECT);
|
||||
return id != MSG.id && !equals(CONNECT);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package dev.heliosares.auxprotect.database;
|
||||
|
||||
import dev.heliosares.auxprotect.core.IAuxProtect;
|
||||
import dev.heliosares.auxprotect.database.ConnectionPool.BusyException;
|
||||
import dev.heliosares.auxprotect.utils.InvSerialization;
|
||||
import dev.heliosares.auxprotect.utils.InvSerialization.PlayerInventoryRecord;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
@@ -13,6 +13,7 @@ import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
||||
public class LookupManager {
|
||||
private final SQLManager sql;
|
||||
@@ -29,9 +30,7 @@ public class LookupManager {
|
||||
String[] sqlstmts = param.toSQL(plugin);
|
||||
|
||||
ArrayList<String> writeparams = new ArrayList<>();
|
||||
for (int i = 1; i < sqlstmts.length; i++) {
|
||||
writeparams.add(sqlstmts[i]);
|
||||
}
|
||||
writeparams.addAll(Arrays.asList(sqlstmts).subList(1, sqlstmts.length));
|
||||
String stmt = "SELECT * FROM " + param.getTable().toString();
|
||||
if (sqlstmts[0].length() > 1) {
|
||||
stmt += "\nWHERE " + sqlstmts[0];
|
||||
@@ -57,9 +56,7 @@ public class LookupManager {
|
||||
String[] sqlstmts = param.toSQL(plugin);
|
||||
|
||||
ArrayList<String> writeparams = new ArrayList<>();
|
||||
for (int i = 1; i < sqlstmts.length; i++) {
|
||||
writeparams.add(sqlstmts[i]);
|
||||
}
|
||||
writeparams.addAll(Arrays.asList(sqlstmts).subList(1, sqlstmts.length));
|
||||
String stmt = sql.getCountStmt(param.getTable().toString());
|
||||
if (sqlstmts[0].length() > 1) {
|
||||
stmt += "\nWHERE " + sqlstmts[0];
|
||||
@@ -103,7 +100,7 @@ public class LookupManager {
|
||||
@SuppressWarnings("deprecation")
|
||||
public ArrayList<DbEntry> lookup(SQLManager sqlManager, Table table, String stmt, ArrayList<String> writeParams)
|
||||
throws LookupException {
|
||||
final boolean hasLocation = plugin.getPlatform() == PlatformType.SPIGOT ? table.hasLocation() : false;
|
||||
final boolean hasLocation = plugin.getPlatform() == PlatformType.SPIGOT && table.hasLocation();
|
||||
final boolean hasData = table.hasData();
|
||||
final boolean hasAction = table.hasActionId();
|
||||
final boolean hasLook = table.hasLook();
|
||||
@@ -172,10 +169,7 @@ public class LookupManager {
|
||||
plugin.debug("Unknown action_id: " + action_id, 1);
|
||||
continue;
|
||||
}
|
||||
boolean state = false;
|
||||
if (entryAction.hasDual && entryAction.id != action_id) {
|
||||
state = true;
|
||||
}
|
||||
boolean state = entryAction.hasDual && entryAction.id != action_id;
|
||||
DbEntry entry = null;
|
||||
String target = null;
|
||||
int target_id = -1;
|
||||
|
||||
@@ -2,7 +2,6 @@ package dev.heliosares.auxprotect.database;
|
||||
|
||||
import dev.heliosares.auxprotect.core.IAuxProtect;
|
||||
import dev.heliosares.auxprotect.core.PlatformType;
|
||||
import dev.heliosares.auxprotect.database.ConnectionPool.BusyException;
|
||||
import dev.heliosares.auxprotect.utils.InvSerialization;
|
||||
import org.yaml.snakeyaml.external.biz.base64Coder.Base64Coder;
|
||||
|
||||
@@ -39,7 +38,7 @@ public class MigrationManager {
|
||||
return isMigrating;
|
||||
}
|
||||
|
||||
void preTables() throws SQLException, IOException, BusyException {
|
||||
void preTables() throws SQLException, IOException {
|
||||
sql.execute(connection,
|
||||
"CREATE TABLE IF NOT EXISTS " + Table.AUXPROTECT_VERSION + " (time BIGINT,version INTEGER);");
|
||||
|
||||
@@ -88,7 +87,7 @@ public class MigrationManager {
|
||||
if (sql.getVersion() < 5) {
|
||||
try {
|
||||
sql.execute(connection, "ALTER TABLE " + SQLManager.getTablePrefix() + "auxprotect RENAME TO "
|
||||
+ Table.AUXPROTECT_MAIN.toString());
|
||||
+ Table.AUXPROTECT_MAIN);
|
||||
} catch (SQLException ignored) {
|
||||
plugin.warning(
|
||||
"Failed to rename auxprotect table for migration. This may cause errors. Migration continuing.");
|
||||
@@ -107,7 +106,7 @@ public class MigrationManager {
|
||||
}
|
||||
}
|
||||
|
||||
void postTables() throws SQLException, BusyException {
|
||||
void postTables() throws SQLException {
|
||||
if (sql.getVersion() < 3) {
|
||||
migrateToV3Part2();
|
||||
}
|
||||
@@ -138,7 +137,7 @@ public class MigrationManager {
|
||||
plugin.debug("Purging temporary tables");
|
||||
for (Table table : Table.values()) {
|
||||
sql.execute(connection, "DROP TABLE IF EXISTS " + table.toString() + "temp;");
|
||||
sql.execute(connection, "DROP TABLE IF EXISTS " + table.toString() + "_temp;");
|
||||
sql.execute(connection, "DROP TABLE IF EXISTS " + table + "_temp;");
|
||||
}
|
||||
|
||||
if (preMigrateDebug >= 0) {
|
||||
@@ -151,7 +150,7 @@ public class MigrationManager {
|
||||
isMigrating = false;
|
||||
}
|
||||
|
||||
int migrateToV3Part1() throws SQLException, BusyException {
|
||||
int migrateToV3Part1() throws SQLException {
|
||||
Table[] migrateTablesV3 = new Table[]{Table.AUXPROTECT_MAIN, Table.AUXPROTECT_SPAM, Table.AUXPROTECT_LONGTERM,
|
||||
Table.AUXPROTECT_ABANDONED, Table.AUXPROTECT_INVENTORY};
|
||||
if (plugin.getPlatform() == PlatformType.BUNGEE) {
|
||||
@@ -162,7 +161,7 @@ public class MigrationManager {
|
||||
for (Table table : migrateTablesV3) {
|
||||
try {
|
||||
sql.execute(connection,
|
||||
"ALTER TABLE " + table.toString() + " RENAME TO " + table.toString() + "_temp;");
|
||||
"ALTER TABLE " + table.toString() + " RENAME TO " + table + "_temp;");
|
||||
} catch (Exception ignored) {
|
||||
plugin.warning("Error renaming table, continuing anyway. This may cause errors.");
|
||||
}
|
||||
@@ -173,7 +172,7 @@ public class MigrationManager {
|
||||
return rowcountformerge;
|
||||
}
|
||||
|
||||
void migrateToV3Part2() throws SQLException, BusyException {
|
||||
void migrateToV3Part2() throws SQLException {
|
||||
Table[] migrateTablesV3 = new Table[]{Table.AUXPROTECT_MAIN, Table.AUXPROTECT_SPAM, Table.AUXPROTECT_LONGTERM,
|
||||
Table.AUXPROTECT_ABANDONED, Table.AUXPROTECT_INVENTORY};
|
||||
if (plugin.getPlatform() == PlatformType.BUNGEE) {
|
||||
@@ -186,11 +185,11 @@ public class MigrationManager {
|
||||
for (Table table : migrateTablesV3) {
|
||||
ArrayList<Object[]> output = new ArrayList<>();
|
||||
ArrayList<Object[]> commands = new ArrayList<>();
|
||||
final boolean hasLocation = plugin.getPlatform() == PlatformType.SPIGOT ? table.hasLocation() : false;
|
||||
final boolean hasLocation = plugin.getPlatform() == PlatformType.SPIGOT && table.hasLocation();
|
||||
final boolean hasData = table.hasData();
|
||||
final boolean hasStringTarget = table.hasStringTarget();
|
||||
plugin.info("Merging table: " + table.toString());
|
||||
String stmt = "SELECT * FROM " + table.toString() + "_temp;";
|
||||
plugin.info("Merging table: " + table);
|
||||
String stmt = "SELECT * FROM " + table + "_temp;";
|
||||
plugin.debug(stmt, 3);
|
||||
try (PreparedStatement pstmt = connection.prepareStatement(stmt)) {
|
||||
pstmt.setFetchSize(500);
|
||||
@@ -257,7 +256,7 @@ public class MigrationManager {
|
||||
plugin.info("Migrating database to v4. DO NOT INTERRUPT");
|
||||
if (plugin.getPlatform() == PlatformType.SPIGOT) {
|
||||
ArrayList<Object[]> output = new ArrayList<>();
|
||||
String stmt = "SELECT * FROM " + Table.AUXPROTECT_SPAM.toString() + " WHERE action_id = 256;";
|
||||
String stmt = "SELECT * FROM " + Table.AUXPROTECT_SPAM + " WHERE action_id = 256;";
|
||||
plugin.debug(stmt, 3);
|
||||
try (PreparedStatement pstmt = connection.prepareStatement(stmt)) {
|
||||
pstmt.setFetchSize(500);
|
||||
@@ -274,7 +273,7 @@ public class MigrationManager {
|
||||
String data = results.getString("data");
|
||||
|
||||
try {
|
||||
String parts[] = data.split("[^\\d-]+");
|
||||
String[] parts = data.split("[^\\d-]+");
|
||||
entry.add(Integer.parseInt(parts[2]));
|
||||
entry.add(Integer.parseInt(parts[1]));
|
||||
} catch (Exception e) {
|
||||
@@ -295,17 +294,17 @@ public class MigrationManager {
|
||||
putRaw(Table.AUXPROTECT_POSITION, output);
|
||||
}
|
||||
plugin.info("Deleting old entries.");
|
||||
sql.execute(connection, "DELETE FROM " + Table.AUXPROTECT_SPAM.toString() + " WHERE action_id = 256;");
|
||||
sql.execute(connection, "DELETE FROM " + Table.AUXPROTECT_SPAM + " WHERE action_id = 256;");
|
||||
}
|
||||
sql.migrationmanager.setVersion(connection, 4, sql);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
void migrateToV6() throws SQLException, BusyException {
|
||||
void migrateToV6() throws SQLException {
|
||||
if (plugin.getPlatform() == PlatformType.SPIGOT) {
|
||||
try {
|
||||
sql.execute(connection,
|
||||
"ALTER TABLE " + Table.AUXPROTECT_INVENTORY.toString() + " ADD COLUMN hasblob BOOL");
|
||||
"ALTER TABLE " + Table.AUXPROTECT_INVENTORY + " ADD COLUMN hasblob BOOL");
|
||||
} catch (SQLException e) {
|
||||
plugin.warning(
|
||||
"Error while modifying inventory table. This is probably due to a prior failed migration. You can ignore this if there are no further errors.");
|
||||
@@ -318,7 +317,7 @@ public class MigrationManager {
|
||||
long lastupdate = 0;
|
||||
int count = 0;
|
||||
|
||||
String stmt = "SELECT time, action_id, data FROM " + Table.AUXPROTECT_INVENTORY.toString()
|
||||
String stmt = "SELECT time, action_id, data FROM " + Table.AUXPROTECT_INVENTORY
|
||||
+ " WHERE (action_id=1024 OR data LIKE '%" + InvSerialization.ITEM_SEPARATOR
|
||||
+ "%') AND (hasblob!=TRUE OR hasblob IS NULL) LIMIT ";
|
||||
|
||||
@@ -387,13 +386,13 @@ public class MigrationManager {
|
||||
}
|
||||
plugin.info("Done migrating blobs, purging unneeded data");
|
||||
sql.execute(connection,
|
||||
"UPDATE " + Table.AUXPROTECT_INVENTORY.toString() + " SET data = '' where hasblob=true;");
|
||||
"UPDATE " + Table.AUXPROTECT_INVENTORY + " SET data = '' where hasblob=true;");
|
||||
}
|
||||
}
|
||||
sql.migrationmanager.setVersion(connection, 6, sql);
|
||||
}
|
||||
|
||||
void migrateToV7() throws SQLException, BusyException {
|
||||
void migrateToV7() throws SQLException {
|
||||
if (plugin.getPlatform() == PlatformType.SPIGOT) {
|
||||
|
||||
final int totalrows = sql.count(Table.AUXPROTECT_INVDIFFBLOB);
|
||||
@@ -401,12 +400,12 @@ public class MigrationManager {
|
||||
int count = 0;
|
||||
|
||||
try {
|
||||
sql.execute(connection, "ALTER TABLE " + Table.AUXPROTECT_INVDIFFBLOB.toString() + " ADD COLUMN hash INT");
|
||||
sql.execute(connection, "ALTER TABLE " + Table.AUXPROTECT_INVDIFFBLOB + " ADD COLUMN hash INT");
|
||||
} catch (SQLException e) {
|
||||
plugin.warning("Failed to alter table, if you are reattempting migration this is expected.");
|
||||
}
|
||||
|
||||
String stmt = "SELECT blobid, ablob FROM " + Table.AUXPROTECT_INVDIFFBLOB.toString()
|
||||
String stmt = "SELECT blobid, ablob FROM " + Table.AUXPROTECT_INVDIFFBLOB
|
||||
+ " WHERE (hash IS NULL) LIMIT ";
|
||||
|
||||
plugin.debug(stmt, 3);
|
||||
@@ -460,7 +459,7 @@ public class MigrationManager {
|
||||
void putRaw(Table table, ArrayList<Object[]> datas)
|
||||
throws SQLException, ClassCastException, IndexOutOfBoundsException {
|
||||
String stmt = "INSERT INTO " + table.toString() + " ";
|
||||
final boolean hasLocation = plugin.getPlatform() == PlatformType.SPIGOT ? table.hasLocation() : false;
|
||||
final boolean hasLocation = plugin.getPlatform() == PlatformType.SPIGOT && table.hasLocation();
|
||||
final boolean hasData = table.hasData();
|
||||
final boolean hasAction = table.hasActionId();
|
||||
final boolean hasLook = table.hasLook();
|
||||
@@ -532,7 +531,7 @@ public class MigrationManager {
|
||||
}
|
||||
where = where.substring(0, where.length() - 1) + ")";
|
||||
}
|
||||
sql.execute(connection, "UPDATE " + Table.AUXPROTECT_INVENTORY.toString() + " SET hasblob=1" + where);
|
||||
sql.execute(connection, "UPDATE " + Table.AUXPROTECT_INVENTORY + " SET hasblob=1" + where);
|
||||
}
|
||||
|
||||
private void setVersion(Connection connection, int version, SQLManager sql) throws SQLException {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package dev.heliosares.auxprotect.database;
|
||||
|
||||
import dev.heliosares.auxprotect.core.IAuxProtect;
|
||||
import dev.heliosares.auxprotect.database.ConnectionPool.BusyException;
|
||||
import dev.heliosares.auxprotect.utils.BidiMapCache;
|
||||
|
||||
import java.io.IOException;
|
||||
@@ -14,8 +13,8 @@ import java.util.UUID;
|
||||
public class SQLUserManager {
|
||||
private final IAuxProtect plugin;
|
||||
private final SQLManager sql;
|
||||
private BidiMapCache<Integer, String> uuids = new BidiMapCache<>(300000L, 300000L, true);
|
||||
private BidiMapCache<Integer, String> usernames = new BidiMapCache<>(300000L, 300000L, true);
|
||||
private final BidiMapCache<Integer, String> uuids = new BidiMapCache<>(300000L, 300000L, true);
|
||||
private final BidiMapCache<Integer, String> usernames = new BidiMapCache<>(300000L, 300000L, true);
|
||||
|
||||
public SQLUserManager(IAuxProtect plugin, SQLManager sql) {
|
||||
this.plugin = plugin;
|
||||
@@ -39,7 +38,7 @@ public class SQLUserManager {
|
||||
String newestusername = null;
|
||||
long newestusernametime = 0;
|
||||
boolean newip = true;
|
||||
String stmt = "SELECT * FROM " + Table.AUXPROTECT_LONGTERM.toString() + " WHERE uid=?;";
|
||||
String stmt = "SELECT * FROM " + Table.AUXPROTECT_LONGTERM + " WHERE uid=?;";
|
||||
plugin.debug(stmt, 3);
|
||||
try (PreparedStatement pstmt = connection.prepareStatement(stmt)) {
|
||||
pstmt.setInt(1, uid);
|
||||
@@ -93,7 +92,7 @@ public class SQLUserManager {
|
||||
* null) { usernames.put(uuid, player.getName()); return player.getName
|
||||
*/
|
||||
|
||||
String stmt = "SELECT * FROM " + Table.AUXPROTECT_LONGTERM.toString()
|
||||
String stmt = "SELECT * FROM " + Table.AUXPROTECT_LONGTERM
|
||||
+ " WHERE action_id=? AND uid=?\nORDER BY time DESC\nLIMIT 1;";
|
||||
plugin.debug(stmt, 3);
|
||||
|
||||
@@ -119,7 +118,7 @@ public class SQLUserManager {
|
||||
|
||||
public HashMap<Long, String> getUsernamesFromUID(int uid, boolean wait) throws SQLException {
|
||||
HashMap<Long, String> out = new HashMap<>();
|
||||
String stmt = "SELECT * FROM " + Table.AUXPROTECT_LONGTERM.toString() + " WHERE action_id=? AND uid=?;";
|
||||
String stmt = "SELECT * FROM " + Table.AUXPROTECT_LONGTERM + " WHERE action_id=? AND uid=?;";
|
||||
plugin.debug(stmt, 3);
|
||||
|
||||
Connection connection = sql.getConnection(wait);
|
||||
@@ -141,14 +140,14 @@ public class SQLUserManager {
|
||||
return out;
|
||||
}
|
||||
|
||||
public int getUIDFromUsername(String username, boolean wait) throws SQLException, BusyException {
|
||||
public int getUIDFromUsername(String username, boolean wait) throws SQLException {
|
||||
if (username == null) {
|
||||
return -1;
|
||||
}
|
||||
if (usernames.containsValue(username)) {
|
||||
return usernames.getKey(username);
|
||||
}
|
||||
String stmt = "SELECT * FROM " + Table.AUXPROTECT_LONGTERM.toString()
|
||||
String stmt = "SELECT * FROM " + Table.AUXPROTECT_LONGTERM
|
||||
+ " WHERE action_id=? AND lower(target)=?\nORDER BY time DESC\nLIMIT 1;";
|
||||
plugin.debug(stmt, 3);
|
||||
|
||||
@@ -179,7 +178,7 @@ public class SQLUserManager {
|
||||
return getUIDFromUUID(uuid, false, wait);
|
||||
}
|
||||
|
||||
public int getUIDFromUUID(String uuid, boolean insert, boolean wait) throws SQLException, BusyException {
|
||||
public int getUIDFromUUID(String uuid, boolean insert, boolean wait) throws SQLException {
|
||||
if (uuid == null || uuid.equalsIgnoreCase("#null")) {
|
||||
return -1;
|
||||
}
|
||||
@@ -191,7 +190,7 @@ public class SQLUserManager {
|
||||
return uuids.getKey(uuid);
|
||||
}
|
||||
|
||||
String stmt = "SELECT * FROM " + Table.AUXPROTECT_UIDS.toString() + " WHERE uuid=?;";
|
||||
String stmt = "SELECT * FROM " + Table.AUXPROTECT_UIDS + " WHERE uuid=?;";
|
||||
plugin.debug(stmt, 3);
|
||||
Connection connection = sql.getConnection(wait);
|
||||
try (PreparedStatement pstmt = connection.prepareStatement(stmt)) {
|
||||
@@ -208,7 +207,7 @@ public class SQLUserManager {
|
||||
}
|
||||
|
||||
if (insert) {
|
||||
stmt = "INSERT INTO " + Table.AUXPROTECT_UIDS.toString() + " (uuid) VALUES (?)";
|
||||
stmt = "INSERT INTO " + Table.AUXPROTECT_UIDS + " (uuid) VALUES (?)";
|
||||
int uid = sql.executeWriteReturnGenerated(stmt, uuid);
|
||||
uuids.put(uid, uuid);
|
||||
plugin.debug("New UUID: " + uuid + ":" + uid, 1);
|
||||
@@ -218,7 +217,7 @@ public class SQLUserManager {
|
||||
return -1;
|
||||
}
|
||||
|
||||
public String getUUIDFromUID(int uid, boolean wait) throws SQLException, BusyException {
|
||||
public String getUUIDFromUID(int uid, boolean wait) throws SQLException {
|
||||
if (uid < 0) {
|
||||
return "#null";
|
||||
}
|
||||
@@ -231,7 +230,7 @@ public class SQLUserManager {
|
||||
|
||||
Connection connection = sql.getConnection(wait);
|
||||
try (Statement statement = connection.createStatement()) {
|
||||
String stmt = "SELECT * FROM " + Table.AUXPROTECT_UIDS.toString() + " WHERE uid='" + uid + "';";
|
||||
String stmt = "SELECT * FROM " + Table.AUXPROTECT_UIDS + " WHERE uid='" + uid + "';";
|
||||
plugin.debug(stmt, 3);
|
||||
try (ResultSet results = statement.executeQuery(stmt)) {
|
||||
if (results.next()) {
|
||||
@@ -250,7 +249,7 @@ public class SQLUserManager {
|
||||
return Collections.unmodifiableCollection(usernames.values());
|
||||
}
|
||||
|
||||
public byte[] getPendingInventory(int uid) throws SQLException, IOException, BusyException {
|
||||
public byte[] getPendingInventory(int uid) throws SQLException, IOException {
|
||||
if (uid <= 0) {
|
||||
return null;
|
||||
}
|
||||
@@ -269,7 +268,7 @@ public class SQLUserManager {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setPendingInventory(int uid, byte[] blob) throws SQLException, BusyException {
|
||||
public void setPendingInventory(int uid, byte[] blob) throws SQLException {
|
||||
if (uid <= 0) {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
@@ -293,8 +292,8 @@ public class SQLUserManager {
|
||||
uuids.cleanup();
|
||||
}
|
||||
|
||||
public void init(Connection connection) throws SQLException, BusyException {
|
||||
String stmt = "CREATE TABLE IF NOT EXISTS " + Table.AUXPROTECT_UIDS.toString();
|
||||
public void init(Connection connection) throws SQLException {
|
||||
String stmt = "CREATE TABLE IF NOT EXISTS " + Table.AUXPROTECT_UIDS;
|
||||
if (sql.isMySQL()) {
|
||||
stmt += " (uid INTEGER AUTO_INCREMENT, uuid varchar(255), PRIMARY KEY (uid));";
|
||||
} else {
|
||||
@@ -302,7 +301,7 @@ public class SQLUserManager {
|
||||
}
|
||||
plugin.debug(stmt, 3);
|
||||
sql.execute(connection, stmt);
|
||||
sql.execute(connection, "CREATE TABLE IF NOT EXISTS " + Table.AUXPROTECT_USERDATA_PENDINV.toString()
|
||||
sql.execute(connection, "CREATE TABLE IF NOT EXISTS " + Table.AUXPROTECT_USERDATA_PENDINV
|
||||
+ " (time BIGINT, uid INTEGER PRIMARY KEY, pending MEDIUMBLOB)");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ public enum Table {
|
||||
AUXPROTECT_INVDIFF, AUXPROTECT_INVDIFFBLOB, AUXPROTECT_USERDATA_PENDINV;
|
||||
|
||||
public static final long MIN_PURGE_INTERVAL = 1000L * 60L * 60L * 24L * 14L;
|
||||
protected final ConcurrentLinkedQueue<DbEntry> queue = new ConcurrentLinkedQueue<>();
|
||||
final ConcurrentLinkedQueue<DbEntry> queue = new ConcurrentLinkedQueue<>();
|
||||
private long autopurgeinterval;
|
||||
|
||||
public static String getValuesTemplate(int numColumns) {
|
||||
@@ -55,10 +55,7 @@ public enum Table {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (!plugin.getAPConfig().isPrivate() && this == AUXPROTECT_ABANDONED) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return plugin.getAPConfig().isPrivate() || this != AUXPROTECT_ABANDONED;
|
||||
}
|
||||
|
||||
public boolean hasAPEntries() {
|
||||
@@ -111,12 +108,7 @@ public enum Table {
|
||||
}
|
||||
|
||||
public boolean hasLook() {
|
||||
switch (this) {
|
||||
case AUXPROTECT_POSITION:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
return this == Table.AUXPROTECT_POSITION;
|
||||
}
|
||||
|
||||
public boolean hasActionId() {
|
||||
@@ -143,10 +135,7 @@ public enum Table {
|
||||
if (this == Table.AUXPROTECT_LONGTERM) {
|
||||
return false;
|
||||
}
|
||||
if (this.hasAPEntries()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return this.hasAPEntries();
|
||||
}
|
||||
|
||||
public String getValuesHeader(PlatformType platform) {
|
||||
@@ -213,7 +202,7 @@ public enum Table {
|
||||
if (!this.hasAPEntries()) {
|
||||
return null;
|
||||
}
|
||||
String stmt = "CREATE TABLE IF NOT EXISTS " + toString() + " (\n";
|
||||
String stmt = "CREATE TABLE IF NOT EXISTS " + this + " (\n";
|
||||
stmt += " time BIGINT";
|
||||
stmt += ",\n uid integer";
|
||||
if (hasActionId()) {
|
||||
@@ -254,10 +243,7 @@ public enum Table {
|
||||
}
|
||||
|
||||
public boolean hasBlob() {
|
||||
if (this == AUXPROTECT_INVENTORY) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return this == AUXPROTECT_INVENTORY;
|
||||
}
|
||||
|
||||
public long getAutoPurgeInterval() {
|
||||
|
||||
@@ -7,10 +7,10 @@ import java.util.UUID;
|
||||
|
||||
public class XrayEntry extends DbEntry {
|
||||
|
||||
private final ArrayList<XrayEntry> children = new ArrayList<>();
|
||||
public UUID viewer;
|
||||
public long viewingStarted;
|
||||
private short rating;
|
||||
private ArrayList<XrayEntry> children = new ArrayList<>();
|
||||
|
||||
public XrayEntry(String user, Location location, String block) {
|
||||
super(user, EntryAction.VEIN, false, location, block, "");
|
||||
|
||||
Reference in New Issue
Block a user