mirror of
https://github.com/PlayPro/CoreProtect.git
synced 2024-11-24 12:16:36 +01:00
Added private constructors to utility classes
This commit is contained in:
parent
a7eb6a48c9
commit
f6f9c27f08
@ -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<Object> meta, String blockData) {
|
||||
try {
|
||||
if (ConfigHandler.blacklist.get(user.toLowerCase(Locale.ROOT)) != null || location == null) {
|
||||
|
@ -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<Object> meta, String blockData, String replaceBlockData) {
|
||||
try {
|
||||
if (user == null || ConfigHandler.blacklist.get(user.toLowerCase(Locale.ROOT)) != null) {
|
||||
|
@ -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) {
|
||||
|
@ -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) {
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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<Object> data, int type) {
|
||||
try {
|
||||
if (ConfigHandler.blacklist.get(user.toLowerCase(Locale.ROOT)) != null) {
|
||||
|
@ -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) {
|
||||
|
@ -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);
|
||||
|
@ -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) {
|
||||
|
@ -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) {
|
||||
|
@ -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) {
|
||||
|
@ -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) {
|
||||
|
@ -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) {
|
||||
|
@ -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) {
|
||||
|
@ -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<Object> meta, String blockData, int action, int rolledBack) {
|
||||
try {
|
||||
byte[] bBlockData = Util.stringToByteData(blockData, type);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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<Object> data) {
|
||||
try {
|
||||
ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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);
|
||||
|
@ -15,6 +15,10 @@ public class Selector {
|
||||
|
||||
final protected static Set<String> 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 {
|
||||
|
@ -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) {
|
||||
|
@ -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
|
||||
|
@ -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");
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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("-")) {
|
||||
|
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user