From adfaec8e55019f99cd70fad0c91a97f3cb1bc3e3 Mon Sep 17 00:00:00 2001 From: Heliosares Date: Mon, 7 Nov 2022 19:54:38 -0500 Subject: [PATCH] Reformatting, fix init issue in entryaction --- .../auxprotect/database/DbEntry.java | 5 +-- .../auxprotect/database/EntryAction.java | 9 ++-- .../auxprotect/database/InvDiffManager.java | 1 - .../auxprotect/database/LookupManager.java | 16 +++---- .../auxprotect/database/MigrationManager.java | 45 +++++++++---------- .../auxprotect/database/SQLUserManager.java | 35 +++++++-------- .../heliosares/auxprotect/database/Table.java | 26 +++-------- .../auxprotect/database/XrayEntry.java | 2 +- 8 files changed, 58 insertions(+), 81 deletions(-) diff --git a/src/dev/heliosares/auxprotect/database/DbEntry.java b/src/dev/heliosares/auxprotect/database/DbEntry.java index 98dfce7..30f1a72 100644 --- a/src/dev/heliosares/auxprotect/database/DbEntry.java +++ b/src/dev/heliosares/auxprotect/database/DbEntry.java @@ -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, diff --git a/src/dev/heliosares/auxprotect/database/EntryAction.java b/src/dev/heliosares/auxprotect/database/EntryAction.java index 80193dd..7ab3d0f 100644 --- a/src/dev/heliosares/auxprotect/database/EntryAction.java +++ b/src/dev/heliosares/auxprotect/database/EntryAction.java @@ -10,6 +10,7 @@ import dev.heliosares.auxprotect.core.PlatformType; import java.util.*; public class EntryAction { + private static final Set 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 usedids = new HashSet<>(); private static final HashMap 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; } diff --git a/src/dev/heliosares/auxprotect/database/InvDiffManager.java b/src/dev/heliosares/auxprotect/database/InvDiffManager.java index a13c9c8..68d9c0a 100644 --- a/src/dev/heliosares/auxprotect/database/InvDiffManager.java +++ b/src/dev/heliosares/auxprotect/database/InvDiffManager.java @@ -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; diff --git a/src/dev/heliosares/auxprotect/database/LookupManager.java b/src/dev/heliosares/auxprotect/database/LookupManager.java index 9d314f4..80efbbe 100644 --- a/src/dev/heliosares/auxprotect/database/LookupManager.java +++ b/src/dev/heliosares/auxprotect/database/LookupManager.java @@ -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 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 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 lookup(SQLManager sqlManager, Table table, String stmt, ArrayList 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; diff --git a/src/dev/heliosares/auxprotect/database/MigrationManager.java b/src/dev/heliosares/auxprotect/database/MigrationManager.java index 083ada7..9e74a79 100644 --- a/src/dev/heliosares/auxprotect/database/MigrationManager.java +++ b/src/dev/heliosares/auxprotect/database/MigrationManager.java @@ -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 output = new ArrayList<>(); ArrayList 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 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 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 { diff --git a/src/dev/heliosares/auxprotect/database/SQLUserManager.java b/src/dev/heliosares/auxprotect/database/SQLUserManager.java index 2796d8b..e114e58 100644 --- a/src/dev/heliosares/auxprotect/database/SQLUserManager.java +++ b/src/dev/heliosares/auxprotect/database/SQLUserManager.java @@ -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 uuids = new BidiMapCache<>(300000L, 300000L, true); - private BidiMapCache usernames = new BidiMapCache<>(300000L, 300000L, true); + private final BidiMapCache uuids = new BidiMapCache<>(300000L, 300000L, true); + private final BidiMapCache 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 getUsernamesFromUID(int uid, boolean wait) throws SQLException { HashMap 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)"); } } diff --git a/src/dev/heliosares/auxprotect/database/Table.java b/src/dev/heliosares/auxprotect/database/Table.java index 9ad3c8e..df1b204 100644 --- a/src/dev/heliosares/auxprotect/database/Table.java +++ b/src/dev/heliosares/auxprotect/database/Table.java @@ -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 queue = new ConcurrentLinkedQueue<>(); + final ConcurrentLinkedQueue 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() { diff --git a/src/dev/heliosares/auxprotect/database/XrayEntry.java b/src/dev/heliosares/auxprotect/database/XrayEntry.java index 9141fce..cbfc10d 100644 --- a/src/dev/heliosares/auxprotect/database/XrayEntry.java +++ b/src/dev/heliosares/auxprotect/database/XrayEntry.java @@ -7,10 +7,10 @@ import java.util.UUID; public class XrayEntry extends DbEntry { + private final ArrayList children = new ArrayList<>(); public UUID viewer; public long viewingStarted; private short rating; - private ArrayList children = new ArrayList<>(); public XrayEntry(String user, Location location, String block) { super(user, EntryAction.VEIN, false, location, block, "");