diff --git a/src/main/java/net/coreprotect/database/logger/BlockBreakLogger.java b/src/main/java/net/coreprotect/database/logger/BlockBreakLogger.java index aec654f..719e972 100644 --- a/src/main/java/net/coreprotect/database/logger/BlockBreakLogger.java +++ b/src/main/java/net/coreprotect/database/logger/BlockBreakLogger.java @@ -14,6 +14,10 @@ import net.coreprotect.utility.Util; public class BlockBreakLogger { + private BlockBreakLogger() { + throw new IllegalStateException("Database class"); + } + public static void log(PreparedStatement preparedStmt, int batchCount, String user, Location location, int type, int data, List meta, String blockData) { try { if (ConfigHandler.blacklist.get(user.toLowerCase(Locale.ROOT)) != null || location == null) { diff --git a/src/main/java/net/coreprotect/database/logger/BlockPlaceLogger.java b/src/main/java/net/coreprotect/database/logger/BlockPlaceLogger.java index 4e24629..36ebc25 100644 --- a/src/main/java/net/coreprotect/database/logger/BlockPlaceLogger.java +++ b/src/main/java/net/coreprotect/database/logger/BlockPlaceLogger.java @@ -21,6 +21,10 @@ import net.coreprotect.utility.Util; public class BlockPlaceLogger { + private BlockPlaceLogger() { + throw new IllegalStateException("Database class"); + } + public static void log(PreparedStatement preparedStmt, int batchCount, String user, BlockState block, int replacedType, int replacedData, Material forceType, int forceData, boolean force, List meta, String blockData, String replaceBlockData) { try { if (user == null || ConfigHandler.blacklist.get(user.toLowerCase(Locale.ROOT)) != null) { diff --git a/src/main/java/net/coreprotect/database/logger/ChatLogger.java b/src/main/java/net/coreprotect/database/logger/ChatLogger.java index f377f1e..59e3d75 100644 --- a/src/main/java/net/coreprotect/database/logger/ChatLogger.java +++ b/src/main/java/net/coreprotect/database/logger/ChatLogger.java @@ -11,6 +11,10 @@ import net.coreprotect.utility.Util; public class ChatLogger { + private ChatLogger() { + throw new IllegalStateException("Database class"); + } + public static void log(PreparedStatement preparedStmt, int batchCount, int time, Location location, String user, String message) { try { if (ConfigHandler.blacklist.get(user.toLowerCase(Locale.ROOT)) != null) { diff --git a/src/main/java/net/coreprotect/database/logger/CommandLogger.java b/src/main/java/net/coreprotect/database/logger/CommandLogger.java index fd6575d..d88f68b 100644 --- a/src/main/java/net/coreprotect/database/logger/CommandLogger.java +++ b/src/main/java/net/coreprotect/database/logger/CommandLogger.java @@ -11,6 +11,10 @@ import net.coreprotect.utility.Util; public class CommandLogger { + private CommandLogger() { + throw new IllegalStateException("Database class"); + } + public static void log(PreparedStatement preparedStmt, int batchCount, int time, Location location, String user, String message) { try { if (ConfigHandler.blacklist.get(user.toLowerCase(Locale.ROOT)) != null) { diff --git a/src/main/java/net/coreprotect/database/logger/ContainerBreakLogger.java b/src/main/java/net/coreprotect/database/logger/ContainerBreakLogger.java index f4f0374..752e8eb 100644 --- a/src/main/java/net/coreprotect/database/logger/ContainerBreakLogger.java +++ b/src/main/java/net/coreprotect/database/logger/ContainerBreakLogger.java @@ -12,6 +12,10 @@ import net.coreprotect.utility.Util; public class ContainerBreakLogger { + private ContainerBreakLogger() { + throw new IllegalStateException("Database class"); + } + public static void log(PreparedStatement preparedStmt, int batchCount, String player, Location l, Material type, ItemStack[] oldInventory) { try { Util.mergeItems(type, oldInventory); diff --git a/src/main/java/net/coreprotect/database/logger/ContainerLogger.java b/src/main/java/net/coreprotect/database/logger/ContainerLogger.java index abba93b..0f902aa 100644 --- a/src/main/java/net/coreprotect/database/logger/ContainerLogger.java +++ b/src/main/java/net/coreprotect/database/logger/ContainerLogger.java @@ -21,6 +21,10 @@ import net.coreprotect.utility.serialize.ItemMetaHandler; public class ContainerLogger extends Queue { + private ContainerLogger() { + throw new IllegalStateException("Database class"); + } + public static void log(PreparedStatement preparedStmtContainer, PreparedStatement preparedStmtItems, int batchCount, String player, Material type, Object container, Location location) { try { ItemStack[] contents = null; diff --git a/src/main/java/net/coreprotect/database/logger/EntityKillLogger.java b/src/main/java/net/coreprotect/database/logger/EntityKillLogger.java index f13fd57..af5cd7d 100644 --- a/src/main/java/net/coreprotect/database/logger/EntityKillLogger.java +++ b/src/main/java/net/coreprotect/database/logger/EntityKillLogger.java @@ -14,6 +14,10 @@ import net.coreprotect.utility.Util; public class EntityKillLogger { + private EntityKillLogger() { + throw new IllegalStateException("Database class"); + } + public static void log(PreparedStatement preparedStmt, PreparedStatement preparedStmt2, int batchCount, String user, BlockState block, List data, int type) { try { if (ConfigHandler.blacklist.get(user.toLowerCase(Locale.ROOT)) != null) { diff --git a/src/main/java/net/coreprotect/database/logger/ItemLogger.java b/src/main/java/net/coreprotect/database/logger/ItemLogger.java index 3b8f5a2..88b730f 100644 --- a/src/main/java/net/coreprotect/database/logger/ItemLogger.java +++ b/src/main/java/net/coreprotect/database/logger/ItemLogger.java @@ -23,6 +23,10 @@ public class ItemLogger { public static final int ITEM_REMOVE_ENDER = 4; public static final int ITEM_ADD_ENDER = 5; + private ItemLogger() { + throw new IllegalStateException("Database class"); + } + public static void log(PreparedStatement preparedStmt, int batchCount, Location location, String user) { try { if (ConfigHandler.blacklist.get(user.toLowerCase(Locale.ROOT)) != null) { diff --git a/src/main/java/net/coreprotect/database/logger/PlayerInteractLogger.java b/src/main/java/net/coreprotect/database/logger/PlayerInteractLogger.java index a500746..f37ce80 100644 --- a/src/main/java/net/coreprotect/database/logger/PlayerInteractLogger.java +++ b/src/main/java/net/coreprotect/database/logger/PlayerInteractLogger.java @@ -12,6 +12,10 @@ import net.coreprotect.utility.Util; public class PlayerInteractLogger { + private PlayerInteractLogger() { + throw new IllegalStateException("Database class"); + } + public static void log(PreparedStatement preparedStmt, int batchCount, String user, BlockState block) { try { int type = Util.getBlockId(block.getType().name(), true); diff --git a/src/main/java/net/coreprotect/database/logger/PlayerKillLogger.java b/src/main/java/net/coreprotect/database/logger/PlayerKillLogger.java index 2d1708a..fb2dd35 100644 --- a/src/main/java/net/coreprotect/database/logger/PlayerKillLogger.java +++ b/src/main/java/net/coreprotect/database/logger/PlayerKillLogger.java @@ -12,6 +12,10 @@ import net.coreprotect.utility.Util; public class PlayerKillLogger { + private PlayerKillLogger() { + throw new IllegalStateException("Database class"); + } + public static void log(PreparedStatement preparedStmt, int batchCount, String user, BlockState block, String player) { try { if (ConfigHandler.blacklist.get(user.toLowerCase(Locale.ROOT)) != null) { diff --git a/src/main/java/net/coreprotect/database/logger/PlayerSessionLogger.java b/src/main/java/net/coreprotect/database/logger/PlayerSessionLogger.java index 0aa744d..6c0e8d8 100644 --- a/src/main/java/net/coreprotect/database/logger/PlayerSessionLogger.java +++ b/src/main/java/net/coreprotect/database/logger/PlayerSessionLogger.java @@ -11,6 +11,10 @@ import net.coreprotect.utility.Util; public class PlayerSessionLogger { + private PlayerSessionLogger() { + throw new IllegalStateException("Database class"); + } + public static void log(PreparedStatement preparedStmt, int batchCount, String user, Location location, int time, int action) { try { if (ConfigHandler.blacklist.get(user.toLowerCase(Locale.ROOT)) != null) { diff --git a/src/main/java/net/coreprotect/database/logger/SignTextLogger.java b/src/main/java/net/coreprotect/database/logger/SignTextLogger.java index 8e7629c..0feaa30 100644 --- a/src/main/java/net/coreprotect/database/logger/SignTextLogger.java +++ b/src/main/java/net/coreprotect/database/logger/SignTextLogger.java @@ -11,6 +11,10 @@ import net.coreprotect.utility.Util; public class SignTextLogger { + private SignTextLogger() { + throw new IllegalStateException("Database class"); + } + public static void log(PreparedStatement preparedStmt, int batchCount, String user, Location location, int action, int color, int data, String line1, String line2, String line3, String line4, int timeOffset) { try { if (ConfigHandler.blacklist.get(user.toLowerCase(Locale.ROOT)) != null) { diff --git a/src/main/java/net/coreprotect/database/logger/SkullBreakLogger.java b/src/main/java/net/coreprotect/database/logger/SkullBreakLogger.java index 31fecd8..947e850 100644 --- a/src/main/java/net/coreprotect/database/logger/SkullBreakLogger.java +++ b/src/main/java/net/coreprotect/database/logger/SkullBreakLogger.java @@ -13,6 +13,10 @@ import net.coreprotect.utility.Util; public class SkullBreakLogger { + private SkullBreakLogger() { + throw new IllegalStateException("Database class"); + } + public static void log(PreparedStatement preparedStmt, PreparedStatement preparedStmt2, int batchCount, String user, BlockState block) { try { if (ConfigHandler.blacklist.get(user.toLowerCase(Locale.ROOT)) != null || block == null) { diff --git a/src/main/java/net/coreprotect/database/logger/SkullPlaceLogger.java b/src/main/java/net/coreprotect/database/logger/SkullPlaceLogger.java index 038b60b..ce39c5f 100644 --- a/src/main/java/net/coreprotect/database/logger/SkullPlaceLogger.java +++ b/src/main/java/net/coreprotect/database/logger/SkullPlaceLogger.java @@ -13,6 +13,10 @@ import net.coreprotect.database.statement.SkullStatement; public class SkullPlaceLogger { + private SkullPlaceLogger() { + throw new IllegalStateException("Database class"); + } + public static void log(PreparedStatement preparedStmt, PreparedStatement preparedStmt2, int batchCount, String user, BlockState block, int replaceType, int replaceData) { try { if (ConfigHandler.blacklist.get(user.toLowerCase(Locale.ROOT)) != null || block == null) { diff --git a/src/main/java/net/coreprotect/database/logger/UsernameLogger.java b/src/main/java/net/coreprotect/database/logger/UsernameLogger.java index e54f4b8..a639c14 100644 --- a/src/main/java/net/coreprotect/database/logger/UsernameLogger.java +++ b/src/main/java/net/coreprotect/database/logger/UsernameLogger.java @@ -9,6 +9,10 @@ import net.coreprotect.config.ConfigHandler; public class UsernameLogger { + private UsernameLogger() { + throw new IllegalStateException("Database class"); + } + public static void log(Connection connection, String user, String uuid, int configUsernames, int time) { try { if (ConfigHandler.blacklist.get(user.toLowerCase(Locale.ROOT)) != null) { diff --git a/src/main/java/net/coreprotect/database/statement/BlockStatement.java b/src/main/java/net/coreprotect/database/statement/BlockStatement.java index be77ab1..e7c8fbd 100644 --- a/src/main/java/net/coreprotect/database/statement/BlockStatement.java +++ b/src/main/java/net/coreprotect/database/statement/BlockStatement.java @@ -7,6 +7,10 @@ import net.coreprotect.utility.Util; public class BlockStatement { + private BlockStatement() { + throw new IllegalStateException("Database class"); + } + public static void insert(PreparedStatement preparedStmt, int batchCount, int time, int id, int wid, int x, int y, int z, int type, int data, List meta, String blockData, int action, int rolledBack) { try { byte[] bBlockData = Util.stringToByteData(blockData, type); diff --git a/src/main/java/net/coreprotect/database/statement/ChatStatement.java b/src/main/java/net/coreprotect/database/statement/ChatStatement.java index d7eed64..36224e5 100644 --- a/src/main/java/net/coreprotect/database/statement/ChatStatement.java +++ b/src/main/java/net/coreprotect/database/statement/ChatStatement.java @@ -4,6 +4,10 @@ import java.sql.PreparedStatement; public class ChatStatement { + private ChatStatement() { + throw new IllegalStateException("Database class"); + } + public static void insert(PreparedStatement preparedStmt, int batchCount, int time, int user, int wid, int x, int y, int z, String message) { try { preparedStmt.setInt(1, time); diff --git a/src/main/java/net/coreprotect/database/statement/CommandStatement.java b/src/main/java/net/coreprotect/database/statement/CommandStatement.java index 351de39..dd18e98 100644 --- a/src/main/java/net/coreprotect/database/statement/CommandStatement.java +++ b/src/main/java/net/coreprotect/database/statement/CommandStatement.java @@ -4,6 +4,10 @@ import java.sql.PreparedStatement; public class CommandStatement { + private CommandStatement() { + throw new IllegalStateException("Database class"); + } + public static void insert(PreparedStatement preparedStmt, int batchCount, int time, int user, int wid, int x, int y, int z, String message) { try { preparedStmt.setInt(1, time); diff --git a/src/main/java/net/coreprotect/database/statement/ContainerStatement.java b/src/main/java/net/coreprotect/database/statement/ContainerStatement.java index 2e03af5..45e9c64 100644 --- a/src/main/java/net/coreprotect/database/statement/ContainerStatement.java +++ b/src/main/java/net/coreprotect/database/statement/ContainerStatement.java @@ -6,6 +6,10 @@ import net.coreprotect.utility.Util; public class ContainerStatement { + private ContainerStatement() { + throw new IllegalStateException("Database class"); + } + public static void insert(PreparedStatement preparedStmt, int batchCount, int time, int id, int wid, int x, int y, int z, int type, int data, int amount, Object metadata, int action, int rolledBack) { try { byte[] byteData = Util.convertByteData(metadata); diff --git a/src/main/java/net/coreprotect/database/statement/EntityStatement.java b/src/main/java/net/coreprotect/database/statement/EntityStatement.java index f0e59ad..f5eea69 100644 --- a/src/main/java/net/coreprotect/database/statement/EntityStatement.java +++ b/src/main/java/net/coreprotect/database/statement/EntityStatement.java @@ -14,6 +14,10 @@ import org.bukkit.util.io.BukkitObjectOutputStream; public class EntityStatement { + private EntityStatement() { + throw new IllegalStateException("Database class"); + } + public static void insert(PreparedStatement preparedStmt, int time, List data) { try { ByteArrayOutputStream bos = new ByteArrayOutputStream(); diff --git a/src/main/java/net/coreprotect/database/statement/ItemStatement.java b/src/main/java/net/coreprotect/database/statement/ItemStatement.java index 5dc52b2..2bdd113 100644 --- a/src/main/java/net/coreprotect/database/statement/ItemStatement.java +++ b/src/main/java/net/coreprotect/database/statement/ItemStatement.java @@ -6,6 +6,10 @@ import net.coreprotect.utility.Util; public class ItemStatement { + private ItemStatement() { + throw new IllegalStateException("Database class"); + } + public static void insert(PreparedStatement preparedStmt, int batchCount, int time, int id, int wid, int x, int y, int z, int type, Object data, int amount, int action) { try { byte[] byteData = Util.convertByteData(data); diff --git a/src/main/java/net/coreprotect/database/statement/MaterialStatement.java b/src/main/java/net/coreprotect/database/statement/MaterialStatement.java index ef11a09..48559b8 100644 --- a/src/main/java/net/coreprotect/database/statement/MaterialStatement.java +++ b/src/main/java/net/coreprotect/database/statement/MaterialStatement.java @@ -6,6 +6,10 @@ import java.sql.Statement; public class MaterialStatement { + private MaterialStatement() { + throw new IllegalStateException("Database class"); + } + public static void insert(PreparedStatement preparedStmt, int batchCount, int id, String name) { try { preparedStmt.setInt(1, id); diff --git a/src/main/java/net/coreprotect/database/statement/SessionStatement.java b/src/main/java/net/coreprotect/database/statement/SessionStatement.java index a7119e4..0489c8a 100644 --- a/src/main/java/net/coreprotect/database/statement/SessionStatement.java +++ b/src/main/java/net/coreprotect/database/statement/SessionStatement.java @@ -4,6 +4,10 @@ import java.sql.PreparedStatement; public class SessionStatement { + private SessionStatement() { + throw new IllegalStateException("Database class"); + } + public static void insert(PreparedStatement preparedStmt, int batchCount, int time, int user, int wid, int x, int y, int z, int action) { try { preparedStmt.setInt(1, time); diff --git a/src/main/java/net/coreprotect/database/statement/SignStatement.java b/src/main/java/net/coreprotect/database/statement/SignStatement.java index 2bd84f0..4a712d4 100644 --- a/src/main/java/net/coreprotect/database/statement/SignStatement.java +++ b/src/main/java/net/coreprotect/database/statement/SignStatement.java @@ -13,6 +13,10 @@ import net.coreprotect.bukkit.BukkitAdapter; public class SignStatement { + private SignStatement() { + throw new IllegalStateException("Database class"); + } + public static void insert(PreparedStatement preparedStmt, int batchCount, int time, int id, int wid, int x, int y, int z, int action, int color, int data, String line1, String line2, String line3, String line4) { try { preparedStmt.setInt(1, time); diff --git a/src/main/java/net/coreprotect/database/statement/SkullStatement.java b/src/main/java/net/coreprotect/database/statement/SkullStatement.java index 6ea2562..b122179 100644 --- a/src/main/java/net/coreprotect/database/statement/SkullStatement.java +++ b/src/main/java/net/coreprotect/database/statement/SkullStatement.java @@ -11,6 +11,10 @@ import org.bukkit.block.Skull; public class SkullStatement { + private SkullStatement() { + throw new IllegalStateException("Database class"); + } + public static void insert(PreparedStatement preparedStmt, int time, String owner) { try { preparedStmt.setInt(1, time); diff --git a/src/main/java/net/coreprotect/database/statement/UserStatement.java b/src/main/java/net/coreprotect/database/statement/UserStatement.java index 65a5ee6..e84edab 100644 --- a/src/main/java/net/coreprotect/database/statement/UserStatement.java +++ b/src/main/java/net/coreprotect/database/statement/UserStatement.java @@ -11,6 +11,10 @@ import net.coreprotect.config.ConfigHandler; public class UserStatement { + private UserStatement() { + throw new IllegalStateException("Database class"); + } + public static int insert(Connection connection, String user) { int id = -1; diff --git a/src/main/java/net/coreprotect/database/statement/WorldStatement.java b/src/main/java/net/coreprotect/database/statement/WorldStatement.java index 0cdbc4c..2a3e58d 100644 --- a/src/main/java/net/coreprotect/database/statement/WorldStatement.java +++ b/src/main/java/net/coreprotect/database/statement/WorldStatement.java @@ -4,6 +4,10 @@ import java.sql.PreparedStatement; public class WorldStatement { + private WorldStatement() { + throw new IllegalStateException("Database class"); + } + public static void insert(PreparedStatement preparedStmt, int batchCount, int id, String world) { try { preparedStmt.setInt(1, id); diff --git a/src/main/java/net/coreprotect/language/Selector.java b/src/main/java/net/coreprotect/language/Selector.java index 97ba29d..38bc1db 100644 --- a/src/main/java/net/coreprotect/language/Selector.java +++ b/src/main/java/net/coreprotect/language/Selector.java @@ -15,6 +15,10 @@ public class Selector { final protected static Set SELECTORS = new HashSet<>(Arrays.asList(Selector.FIRST, Selector.SECOND, Selector.THIRD, Selector.FOURTH)); + private Selector() { + throw new IllegalStateException("Utility class"); + } + protected static String processSelection(String output, String param, String color) { String substring = output; try { diff --git a/src/main/java/net/coreprotect/utility/Chat.java b/src/main/java/net/coreprotect/utility/Chat.java index dea37ee..870996e 100644 --- a/src/main/java/net/coreprotect/utility/Chat.java +++ b/src/main/java/net/coreprotect/utility/Chat.java @@ -18,8 +18,8 @@ public final class Chat { public static final String COMPONENT_COMMAND = "COMMAND"; public static final String COMPONENT_POPUP = "POPUP"; - private Chat() throws RuntimeException { - throw new RuntimeException(); + private Chat() { + throw new IllegalStateException("Utility class"); } public static void sendComponent(CommandSender sender, String string, String bypass) { diff --git a/src/main/java/net/coreprotect/utility/ChatMessage.java b/src/main/java/net/coreprotect/utility/ChatMessage.java index ff30a3f..1a9df87 100644 --- a/src/main/java/net/coreprotect/utility/ChatMessage.java +++ b/src/main/java/net/coreprotect/utility/ChatMessage.java @@ -7,17 +7,17 @@ public class ChatMessage { /** * Returns the plugin name with the DARK_AQUA chat color. */ - final String COREPROTECT = Color.DARK_AQUA + "CoreProtect"; + String pluginName = Color.DARK_AQUA + "CoreProtect"; String message; String textColor = Color.WHITE; - String textStyle = new String(); + String textStyle = ""; String separator = "-"; boolean useTag = true; boolean useSpaces = true; public ChatMessage() { - this.message = new String(); + this.message = ""; } public ChatMessage setSeparator(String separator) { @@ -129,7 +129,7 @@ public class ChatMessage { } public String build() { - return (this.useTag ? COREPROTECT : createSpaces(COREPROTECT, true, this.useSpaces)) + this.textColor + " " + this.separator + " " + this.textStyle + this.message; + return (this.useTag ? pluginName : createSpaces(pluginName, true, this.useSpaces)) + this.textColor + " " + this.separator + " " + this.textStyle + this.message; } @Override diff --git a/src/main/java/net/coreprotect/utility/Color.java b/src/main/java/net/coreprotect/utility/Color.java index 6286bbc..a460e9d 100644 --- a/src/main/java/net/coreprotect/utility/Color.java +++ b/src/main/java/net/coreprotect/utility/Color.java @@ -5,7 +5,6 @@ import org.bukkit.ChatColor; public final class Color { // we define our own constants here to eliminate string concatenation - // javadoc taken from org.bukkit.ChatColor /** @@ -118,4 +117,8 @@ public final class Color { */ public static final String RESET = ChatColor.COLOR_CHAR + "r"; + private Color() { + throw new IllegalStateException("Utility class"); + } + } diff --git a/src/main/java/net/coreprotect/utility/Util.java b/src/main/java/net/coreprotect/utility/Util.java index 24c25b0..4c9b39b 100755 --- a/src/main/java/net/coreprotect/utility/Util.java +++ b/src/main/java/net/coreprotect/utility/Util.java @@ -110,6 +110,10 @@ public class Util extends Queue { public static final java.util.regex.Pattern tagParser = java.util.regex.Pattern.compile(Chat.COMPONENT_TAG_OPEN + "(.+?)" + Chat.COMPONENT_TAG_CLOSE + "|(.+?)", java.util.regex.Pattern.DOTALL); private static final String NAMESPACE = "minecraft:"; + private Util() { + throw new IllegalStateException("Utility class"); + } + public static String getPluginVersion() { String version = CoreProtect.getInstance().getDescription().getVersion(); if (version.contains("-")) { diff --git a/src/main/java/net/coreprotect/utility/Validate.java b/src/main/java/net/coreprotect/utility/Validate.java index 35fb9d3..414db38 100644 --- a/src/main/java/net/coreprotect/utility/Validate.java +++ b/src/main/java/net/coreprotect/utility/Validate.java @@ -8,6 +8,10 @@ import org.bukkit.inventory.InventoryHolder; public class Validate { + private Validate() { + throw new IllegalStateException("Utility class"); + } + public static boolean isHopper(InventoryHolder inventoryHolder) { return (inventoryHolder instanceof Hopper || inventoryHolder instanceof HopperMinecart); }