From 846c4350e7c476a779351c4508d906933811dc66 Mon Sep 17 00:00:00 2001 From: business-goose Date: Mon, 21 Mar 2022 17:11:24 +0000 Subject: [PATCH] Cleanup code --- .../TotalFreedomMod/admin/Admin.java | 5 +--- .../TotalFreedomMod/admin/AdminList.java | 9 ++---- .../StevenLawson/TotalFreedomMod/ban/Ban.java | 13 +++------ .../command/CommandBlocker.java | 8 +++--- .../TotalFreedomMod/commands/AdminLevel.java | 2 +- .../commands/Command_adminworld.java | 2 +- .../commands/Command_cbtool.java | 6 ++-- .../commands/Command_cmdlist.java | 4 +-- .../TotalFreedomMod/commands/Command_fr.java | 2 +- .../commands/Command_fuckoff.java | 5 +--- .../commands/Command_gadmin.java | 2 +- .../commands/Command_jumppads.java | 2 +- .../commands/Command_list.java | 4 +-- .../commands/Command_logs.java | 6 ++-- .../TotalFreedomMod/commands/Command_nf.java | 2 +- .../commands/Command_nicknyan.java | 2 +- .../commands/Command_saconfig.java | 6 ++-- .../commands/Command_setlevel.java | 2 +- .../TotalFreedomMod/commands/Command_tag.java | 5 +--- .../commands/Command_tempban.java | 4 +-- .../commands/Command_tossmob.java | 2 +- .../commands/FreedomCommand.java | 19 ++----------- .../TotalFreedomMod/commands/SourceType.java | 2 +- .../config/ConfigurationEntry.java | 2 +- .../TotalFreedomMod/fun/JumpPads.java | 6 ++-- .../gamerule/GameRuleHandler.java | 6 ++-- .../TotalFreedomMod/httpd/HTTPDManager.java | 4 +-- .../httpd/HTTPDSchematicModule.java | 4 +-- .../TotalFreedomMod/httpd/NanoHTTPD.java | 28 ++++++++----------- .../listener/PlayerListener.java | 5 +--- .../TotalFreedomMod/player/PlayerData.java | 6 ++-- .../TotalFreedomMod/util/Utilities.java | 10 +++---- .../TotalFreedomMod/world/AdminWorld.java | 12 ++++---- .../world/CleanroomChunkGenerator.java | 8 +++--- .../world/RollbackManager.java | 7 ++--- src/main/java/me/husky/sqlite/SQLite.java | 2 +- 36 files changed, 86 insertions(+), 128 deletions(-) diff --git a/src/main/java/me/StevenLawson/TotalFreedomMod/admin/Admin.java b/src/main/java/me/StevenLawson/TotalFreedomMod/admin/Admin.java index 22f6f82..8a656cc 100644 --- a/src/main/java/me/StevenLawson/TotalFreedomMod/admin/Admin.java +++ b/src/main/java/me/StevenLawson/TotalFreedomMod/admin/Admin.java @@ -107,10 +107,7 @@ public class Admin public void removeIp(String ip) { - if (ips.contains(ip)) - { - ips.remove(ip); - } + ips.remove(ip); } public void clearIPs() diff --git a/src/main/java/me/StevenLawson/TotalFreedomMod/admin/AdminList.java b/src/main/java/me/StevenLawson/TotalFreedomMod/admin/AdminList.java index 3a5a2c9..5fc5143 100644 --- a/src/main/java/me/StevenLawson/TotalFreedomMod/admin/AdminList.java +++ b/src/main/java/me/StevenLawson/TotalFreedomMod/admin/AdminList.java @@ -153,7 +153,7 @@ public class AdminList adminList.remove(oldUuid); final Configuration config = new Configuration(TotalFreedomMod.plugin, TotalFreedomMod.SUPERADMIN_FILENAME, true); config.load(); - config.set("admins." + oldUuid.toString(), null); + config.set("admins." + oldUuid, null); config.save(); } @@ -433,12 +433,7 @@ public class AdminList return true; } - if (Bukkit.getOnlineMode() && superUUIDs.contains(UUIDManager.getUniqueId(player))) - { - return true; - } - - return false; + return Bukkit.getOnlineMode() && superUUIDs.contains(UUIDManager.getUniqueId(player)); } public static boolean isTelnetAdmin(CommandSender sender, boolean verifySuperadmin) diff --git a/src/main/java/me/StevenLawson/TotalFreedomMod/ban/Ban.java b/src/main/java/me/StevenLawson/TotalFreedomMod/ban/Ban.java index 52fa725..2f5b071 100644 --- a/src/main/java/me/StevenLawson/TotalFreedomMod/ban/Ban.java +++ b/src/main/java/me/StevenLawson/TotalFreedomMod/ban/Ban.java @@ -12,7 +12,7 @@ import java.util.regex.Pattern; public class Ban { - public static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd \'at\' HH:mm:ss z"); + public static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd 'at' HH:mm:ss z"); public static final Pattern IP_BAN_REGEX; public static final Pattern UUID_BAN_REGEX; @@ -93,10 +93,10 @@ public class Ban complete = true; } - public static enum BanType + public enum BanType { IP, - UUID; + UUID } public BanType getType() @@ -191,12 +191,7 @@ public class Ban return false; } - if (!getSubject().equals(ban.getSubject())) - { - return false; - } - - return true; + return getSubject().equals(ban.getSubject()); } @Override diff --git a/src/main/java/me/StevenLawson/TotalFreedomMod/command/CommandBlocker.java b/src/main/java/me/StevenLawson/TotalFreedomMod/command/CommandBlocker.java index df8e3b6..5d093e3 100644 --- a/src/main/java/me/StevenLawson/TotalFreedomMod/command/CommandBlocker.java +++ b/src/main/java/me/StevenLawson/TotalFreedomMod/command/CommandBlocker.java @@ -165,7 +165,7 @@ public class CommandBlocker return true; } - public static enum CommandBlockerRank + public enum CommandBlockerRank { ANYONE("a", 0), OP("o", 1), @@ -177,7 +177,7 @@ public class CommandBlocker private final String token; private final int level; - private CommandBlockerRank(String token, int level) + CommandBlockerRank(String token, int level) { this.token = token; this.level = level; @@ -231,14 +231,14 @@ public class CommandBlocker } } - public static enum CommandBlockerAction + public enum CommandBlockerAction { BLOCK("b"), BLOCK_AND_EJECT("a"), BLOCK_UNKNOWN("u"); private final String token; - private CommandBlockerAction(String token) + CommandBlockerAction(String token) { this.token = token; } diff --git a/src/main/java/me/StevenLawson/TotalFreedomMod/commands/AdminLevel.java b/src/main/java/me/StevenLawson/TotalFreedomMod/commands/AdminLevel.java index 3d4ddd1..9dd980e 100644 --- a/src/main/java/me/StevenLawson/TotalFreedomMod/commands/AdminLevel.java +++ b/src/main/java/me/StevenLawson/TotalFreedomMod/commands/AdminLevel.java @@ -5,7 +5,7 @@ public enum AdminLevel { // private final String friendlyName; - private AdminLevel(String friendlyName) { + AdminLevel(String friendlyName) { this.friendlyName = friendlyName; } diff --git a/src/main/java/me/StevenLawson/TotalFreedomMod/commands/Command_adminworld.java b/src/main/java/me/StevenLawson/TotalFreedomMod/commands/Command_adminworld.java index 979069e..6ca6022 100644 --- a/src/main/java/me/StevenLawson/TotalFreedomMod/commands/Command_adminworld.java +++ b/src/main/java/me/StevenLawson/TotalFreedomMod/commands/Command_adminworld.java @@ -11,7 +11,7 @@ import org.bukkit.entity.Player; @CommandPermissions(level = AdminLevel.OP, source = SourceType.BOTH) public class Command_adminworld extends FreedomCommand { private enum CommandMode { - TELEPORT, GUEST, TIME, WEATHER; + TELEPORT, GUEST, TIME, WEATHER } @Override diff --git a/src/main/java/me/StevenLawson/TotalFreedomMod/commands/Command_cbtool.java b/src/main/java/me/StevenLawson/TotalFreedomMod/commands/Command_cbtool.java index e9ef170..2f32d2a 100644 --- a/src/main/java/me/StevenLawson/TotalFreedomMod/commands/Command_cbtool.java +++ b/src/main/java/me/StevenLawson/TotalFreedomMod/commands/Command_cbtool.java @@ -72,7 +72,7 @@ public class Command_cbtool extends FreedomCommand { return SubCommand.getByName(args[0]).getExecutable().execute(ArrayUtils.remove(args, 0)); } - private static enum SubCommand + private enum SubCommand { PLAYER_DETECT("playerdetect", new SubCommandExecutable() { @@ -160,7 +160,7 @@ public class Command_cbtool extends FreedomCommand { private final String name; private final SubCommandExecutable executable; - private SubCommand(String subCommandName, SubCommandExecutable subCommandImpl) + SubCommand(String subCommandName, SubCommandExecutable subCommandImpl) { this.name = subCommandName; this.executable = subCommandImpl; @@ -192,7 +192,7 @@ public class Command_cbtool extends FreedomCommand { private interface SubCommandExecutable { - public String execute(String[] args) throws SubCommandFailureException; + String execute(String[] args) throws SubCommandFailureException; } private static class SubCommandFailureException extends Exception diff --git a/src/main/java/me/StevenLawson/TotalFreedomMod/commands/Command_cmdlist.java b/src/main/java/me/StevenLawson/TotalFreedomMod/commands/Command_cmdlist.java index 9d0e510..6d202d1 100644 --- a/src/main/java/me/StevenLawson/TotalFreedomMod/commands/Command_cmdlist.java +++ b/src/main/java/me/StevenLawson/TotalFreedomMod/commands/Command_cmdlist.java @@ -21,13 +21,13 @@ public class Command_cmdlist extends FreedomCommand { for (Plugin targetPlugin : server.getPluginManager().getPlugins()) { try { PluginDescriptionFile desc = targetPlugin.getDescription(); - Map> map = (Map>) desc.getCommands(); + Map> map = desc.getCommands(); if (map != null) { for (Entry> entry : map.entrySet()) { - String command_name = (String) entry.getKey(); + String command_name = entry.getKey(); commands.add(command_name); } } diff --git a/src/main/java/me/StevenLawson/TotalFreedomMod/commands/Command_fr.java b/src/main/java/me/StevenLawson/TotalFreedomMod/commands/Command_fr.java index 7274b0d..d0ff4e9 100644 --- a/src/main/java/me/StevenLawson/TotalFreedomMod/commands/Command_fr.java +++ b/src/main/java/me/StevenLawson/TotalFreedomMod/commands/Command_fr.java @@ -41,7 +41,7 @@ public class Command_fr extends FreedomCommand { } else { - if (args[0].toLowerCase().equals("purge")) + if (args[0].equalsIgnoreCase("purge")) { setAllFrozen(false); Utilities.adminAction(sender.getName(), "Unfreezing all players", false); diff --git a/src/main/java/me/StevenLawson/TotalFreedomMod/commands/Command_fuckoff.java b/src/main/java/me/StevenLawson/TotalFreedomMod/commands/Command_fuckoff.java index 3a42027..49a1c51 100644 --- a/src/main/java/me/StevenLawson/TotalFreedomMod/commands/Command_fuckoff.java +++ b/src/main/java/me/StevenLawson/TotalFreedomMod/commands/Command_fuckoff.java @@ -31,10 +31,7 @@ public class Command_fuckoff extends FreedomCommand { } } - if (TotalFreedomMod.fuckoffEnabledFor.containsKey(sender_p)) - { - TotalFreedomMod.fuckoffEnabledFor.remove(sender_p); - } + TotalFreedomMod.fuckoffEnabledFor.remove(sender_p); if (fuckoff_enabled) { diff --git a/src/main/java/me/StevenLawson/TotalFreedomMod/commands/Command_gadmin.java b/src/main/java/me/StevenLawson/TotalFreedomMod/commands/Command_gadmin.java index 82d2f72..5e8fdd7 100644 --- a/src/main/java/me/StevenLawson/TotalFreedomMod/commands/Command_gadmin.java +++ b/src/main/java/me/StevenLawson/TotalFreedomMod/commands/Command_gadmin.java @@ -26,7 +26,7 @@ public class Command_gadmin extends FreedomCommand { SMITE("smite"); private final String modeName; - private GadminMode(String command) + GadminMode(String command) { this.modeName = command; } diff --git a/src/main/java/me/StevenLawson/TotalFreedomMod/commands/Command_jumppads.java b/src/main/java/me/StevenLawson/TotalFreedomMod/commands/Command_jumppads.java index 982aaa0..7d0b350 100644 --- a/src/main/java/me/StevenLawson/TotalFreedomMod/commands/Command_jumppads.java +++ b/src/main/java/me/StevenLawson/TotalFreedomMod/commands/Command_jumppads.java @@ -73,7 +73,7 @@ public class Command_jumppads extends FreedomCommand { return true; } - Utilities.adminAction(sender.getName(), "Setting Jumppads strength to: " + String.valueOf(strength), false); + Utilities.adminAction(sender.getName(), "Setting Jumppads strength to: " + strength, false); JumpPads.setStrength((strength / 10) + 0.1F); } else diff --git a/src/main/java/me/StevenLawson/TotalFreedomMod/commands/Command_list.java b/src/main/java/me/StevenLawson/TotalFreedomMod/commands/Command_list.java index 59fb30c..aff3d31 100644 --- a/src/main/java/me/StevenLawson/TotalFreedomMod/commands/Command_list.java +++ b/src/main/java/me/StevenLawson/TotalFreedomMod/commands/Command_list.java @@ -14,10 +14,10 @@ import java.util.List; @CommandPermissions(level = AdminLevel.ALL, source = SourceType.BOTH) public class Command_list extends FreedomCommand { - private static enum ListFilter { + private enum ListFilter { ALL, ADMINS, - IMPOSTORS; + IMPOSTORS } @Override diff --git a/src/main/java/me/StevenLawson/TotalFreedomMod/commands/Command_logs.java b/src/main/java/me/StevenLawson/TotalFreedomMod/commands/Command_logs.java index 6d3c636..58b5c62 100644 --- a/src/main/java/me/StevenLawson/TotalFreedomMod/commands/Command_logs.java +++ b/src/main/java/me/StevenLawson/TotalFreedomMod/commands/Command_logs.java @@ -76,7 +76,7 @@ public class Command_logs extends FreedomCommand { { if (responseCode == 200) { - sender.sendMessage(ChatColor.GREEN + "Registration " + mode.toString() + "d."); + sender.sendMessage(ChatColor.GREEN + "Registration " + mode + "d."); } else { @@ -105,12 +105,12 @@ public class Command_logs extends FreedomCommand { return true; } - public static enum LogsRegistrationMode + public enum LogsRegistrationMode { UPDATE("update"), DELETE("delete"); private final String mode; - private LogsRegistrationMode(String mode) + LogsRegistrationMode(String mode) { this.mode = mode; } diff --git a/src/main/java/me/StevenLawson/TotalFreedomMod/commands/Command_nf.java b/src/main/java/me/StevenLawson/TotalFreedomMod/commands/Command_nf.java index 869f483..a4586ec 100644 --- a/src/main/java/me/StevenLawson/TotalFreedomMod/commands/Command_nf.java +++ b/src/main/java/me/StevenLawson/TotalFreedomMod/commands/Command_nf.java @@ -23,7 +23,7 @@ public class Command_nf extends FreedomCommand { final List outputCommand = new ArrayList(); if (args.length >= 1) { - final List argsList = Arrays.asList(args); + final String[] argsList = args; for (String arg : argsList) { Player player = null; diff --git a/src/main/java/me/StevenLawson/TotalFreedomMod/commands/Command_nicknyan.java b/src/main/java/me/StevenLawson/TotalFreedomMod/commands/Command_nicknyan.java index 4c160a1..50a7cc4 100644 --- a/src/main/java/me/StevenLawson/TotalFreedomMod/commands/Command_nicknyan.java +++ b/src/main/java/me/StevenLawson/TotalFreedomMod/commands/Command_nicknyan.java @@ -60,7 +60,7 @@ public class Command_nicknyan extends FreedomCommand { EssentialsBridge.setNickname(sender.getName(), newNick.toString()); - playerMsg(sender, "Your nickname is now: " + newNick.toString()); + playerMsg(sender, "Your nickname is now: " + newNick); return true; } diff --git a/src/main/java/me/StevenLawson/TotalFreedomMod/commands/Command_saconfig.java b/src/main/java/me/StevenLawson/TotalFreedomMod/commands/Command_saconfig.java index 1638018..367608d 100644 --- a/src/main/java/me/StevenLawson/TotalFreedomMod/commands/Command_saconfig.java +++ b/src/main/java/me/StevenLawson/TotalFreedomMod/commands/Command_saconfig.java @@ -187,7 +187,7 @@ public class Command_saconfig extends FreedomCommand { return true; } - private static enum SAConfigMode { + private enum SAConfigMode { LIST("list", AdminLevel.OP, SourceType.BOTH, 1, 1), CLEAN("clean", AdminLevel.SENIOR, SourceType.BOTH, 1, 1), CLEARME("clearme", AdminLevel.SUPER, SourceType.ONLY_IN_GAME, 1, 2), @@ -200,7 +200,7 @@ public class Command_saconfig extends FreedomCommand { private final int minArgs; private final int maxArgs; - private SAConfigMode(String modeName, AdminLevel adminLevel, SourceType sourceType, int minArgs, int maxArgs) { + SAConfigMode(String modeName, AdminLevel adminLevel, SourceType sourceType, int minArgs, int maxArgs) { this.modeName = modeName; this.adminLevel = adminLevel; this.sourceType = sourceType; @@ -216,7 +216,7 @@ public class Command_saconfig extends FreedomCommand { } boolean isSuperAdmin = AdminList.isSuperAdmin(sender); - boolean isSeniorAdmin = isSuperAdmin ? AdminList.isSeniorAdmin(sender, false) : false; + boolean isSeniorAdmin = isSuperAdmin && AdminList.isSeniorAdmin(sender, false); for (final SAConfigMode mode : values()) { diff --git a/src/main/java/me/StevenLawson/TotalFreedomMod/commands/Command_setlevel.java b/src/main/java/me/StevenLawson/TotalFreedomMod/commands/Command_setlevel.java index 01726b3..9af9da0 100644 --- a/src/main/java/me/StevenLawson/TotalFreedomMod/commands/Command_setlevel.java +++ b/src/main/java/me/StevenLawson/TotalFreedomMod/commands/Command_setlevel.java @@ -34,7 +34,7 @@ public class Command_setlevel extends FreedomCommand { sender_p.setLevel(new_level); - playerMsg(sender, "You have been set to level " + Integer.toString(new_level), ChatColor.AQUA); + playerMsg(sender, "You have been set to level " + new_level, ChatColor.AQUA); return true; } diff --git a/src/main/java/me/StevenLawson/TotalFreedomMod/commands/Command_tag.java b/src/main/java/me/StevenLawson/TotalFreedomMod/commands/Command_tag.java index 35bed1f..023fada 100644 --- a/src/main/java/me/StevenLawson/TotalFreedomMod/commands/Command_tag.java +++ b/src/main/java/me/StevenLawson/TotalFreedomMod/commands/Command_tag.java @@ -14,10 +14,7 @@ import java.util.List; @CommandPermissions(level = AdminLevel.OP, source = SourceType.BOTH) public class Command_tag extends FreedomCommand { - public static final List FORBIDDEN_WORDS = Arrays.asList(new String[] - { - "admin", "owner", "moderator", "developer", "console" - }); + public static final List FORBIDDEN_WORDS = Arrays.asList("admin", "owner", "moderator", "developer", "console"); @Override public boolean run(CommandSender sender, org.bukkit.entity.Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) { diff --git a/src/main/java/me/StevenLawson/TotalFreedomMod/commands/Command_tempban.java b/src/main/java/me/StevenLawson/TotalFreedomMod/commands/Command_tempban.java index ac992ca..ef3abc9 100644 --- a/src/main/java/me/StevenLawson/TotalFreedomMod/commands/Command_tempban.java +++ b/src/main/java/me/StevenLawson/TotalFreedomMod/commands/Command_tempban.java @@ -16,7 +16,7 @@ import java.util.Date; @CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH) public class Command_tempban extends FreedomCommand { - private static final SimpleDateFormat date_format = new SimpleDateFormat("yyyy-MM-dd \'at\' HH:mm:ss z"); + private static final SimpleDateFormat date_format = new SimpleDateFormat("yyyy-MM-dd 'at' HH:mm:ss z"); @Override public boolean run(CommandSender sender, org.bukkit.entity.Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) { @@ -67,7 +67,7 @@ public class Command_tempban extends FreedomCommand { BanManager.addIpBan(new Ban(Utilities.getIp(player), player.getName(), sender.getName(), expires, reason)); BanManager.addUuidBan(new Ban(UUIDManager.getUniqueId(player), player.getName(), sender.getName(), expires, reason)); - player.kickPlayer(sender.getName() + " - " + message.toString()); + player.kickPlayer(sender.getName() + " - " + message); return true; } diff --git a/src/main/java/me/StevenLawson/TotalFreedomMod/commands/Command_tossmob.java b/src/main/java/me/StevenLawson/TotalFreedomMod/commands/Command_tossmob.java index e3cf765..ec7237d 100644 --- a/src/main/java/me/StevenLawson/TotalFreedomMod/commands/Command_tossmob.java +++ b/src/main/java/me/StevenLawson/TotalFreedomMod/commands/Command_tossmob.java @@ -73,7 +73,7 @@ public class Command_tossmob extends FreedomCommand { playerData.enableMobThrower(creature, speed); playerMsg(sender, "MobThrower is enabled. Creature: " + creature + " - Speed: " + speed + ".", ChatColor.GREEN); - playerMsg(sender, "Left click while holding a " + Material.BONE.toString() + " to throw mobs!", ChatColor.GREEN); + playerMsg(sender, "Left click while holding a " + Material.BONE + " to throw mobs!", ChatColor.GREEN); playerMsg(sender, "Type '/tossmob off' to disable. -By Madgeek1450", ChatColor.GREEN); sender_p.setItemInHand(new ItemStack(Material.BONE, 1)); diff --git a/src/main/java/me/StevenLawson/TotalFreedomMod/commands/FreedomCommand.java b/src/main/java/me/StevenLawson/TotalFreedomMod/commands/FreedomCommand.java index 685b2a9..dc2421d 100644 --- a/src/main/java/me/StevenLawson/TotalFreedomMod/commands/FreedomCommand.java +++ b/src/main/java/me/StevenLawson/TotalFreedomMod/commands/FreedomCommand.java @@ -100,12 +100,7 @@ public abstract class FreedomCommand implements CommandExecutor { return false; } - if (blockHostConsole && Utilities.isFromHostConsole(commandSender.getName())) - { - return false; - } - - return true; + return !blockHostConsole || !Utilities.isFromHostConsole(commandSender.getName()); } final Player senderPlayer = (Player) commandSender; @@ -120,22 +115,14 @@ public abstract class FreedomCommand implements CommandExecutor { return false; } - if (!PlayerData.getPlayerData(senderPlayer).isSuperadminIdVerified()) { - return false; - } - - return true; + return PlayerData.getPlayerData(senderPlayer).isSuperadminIdVerified(); } if (level == AdminLevel.SUPER && !isSuper) { return false; } - if (level == AdminLevel.OP && !senderPlayer.isOp()) { - return false; - } - - return true; + return level != AdminLevel.OP || senderPlayer.isOp(); } public Player getPlayer(final String partialName) diff --git a/src/main/java/me/StevenLawson/TotalFreedomMod/commands/SourceType.java b/src/main/java/me/StevenLawson/TotalFreedomMod/commands/SourceType.java index 8e6863f..3935872 100644 --- a/src/main/java/me/StevenLawson/TotalFreedomMod/commands/SourceType.java +++ b/src/main/java/me/StevenLawson/TotalFreedomMod/commands/SourceType.java @@ -2,5 +2,5 @@ package me.StevenLawson.TotalFreedomMod.commands; public enum SourceType { - ONLY_IN_GAME, ONLY_CONSOLE, BOTH; + ONLY_IN_GAME, ONLY_CONSOLE, BOTH } diff --git a/src/main/java/me/StevenLawson/TotalFreedomMod/config/ConfigurationEntry.java b/src/main/java/me/StevenLawson/TotalFreedomMod/config/ConfigurationEntry.java index 95692c6..ae687ff 100644 --- a/src/main/java/me/StevenLawson/TotalFreedomMod/config/ConfigurationEntry.java +++ b/src/main/java/me/StevenLawson/TotalFreedomMod/config/ConfigurationEntry.java @@ -100,7 +100,7 @@ public enum ConfigurationEntry private final Class type; private final String configName; - private ConfigurationEntry(Class type, String configName) { + ConfigurationEntry(Class type, String configName) { this.type = type; this.configName = configName; } diff --git a/src/main/java/me/StevenLawson/TotalFreedomMod/fun/JumpPads.java b/src/main/java/me/StevenLawson/TotalFreedomMod/fun/JumpPads.java index 8c2134e..2146d10 100644 --- a/src/main/java/me/StevenLawson/TotalFreedomMod/fun/JumpPads.java +++ b/src/main/java/me/StevenLawson/TotalFreedomMod/fun/JumpPads.java @@ -115,12 +115,12 @@ public class JumpPads JumpPads.strength = strength; } - public static enum JumpPadMode + public enum JumpPadMode { OFF(false), NORMAL(true), NORMAL_AND_SIDEWAYS(true), MADGEEK(true); - private boolean on; + private final boolean on; - private JumpPadMode(boolean on) + JumpPadMode(boolean on) { this.on = on; } diff --git a/src/main/java/me/StevenLawson/TotalFreedomMod/gamerule/GameRuleHandler.java b/src/main/java/me/StevenLawson/TotalFreedomMod/gamerule/GameRuleHandler.java index 3027f7b..7c89370 100644 --- a/src/main/java/me/StevenLawson/TotalFreedomMod/gamerule/GameRuleHandler.java +++ b/src/main/java/me/StevenLawson/TotalFreedomMod/gamerule/GameRuleHandler.java @@ -74,7 +74,7 @@ public class GameRuleHandler private final String gameRuleName; private final TFM_GameRule_Value defaultValue; - private TFM_GameRule(String gameRuleName, TFM_GameRule_Value defaultValue) + TFM_GameRule(String gameRuleName, TFM_GameRule_Value defaultValue) { this.gameRuleName = gameRuleName; this.defaultValue = defaultValue; @@ -96,7 +96,7 @@ public class GameRuleHandler TRUE("true"), FALSE("false"); private final String value; - private TFM_GameRule_Value(String value) + TFM_GameRule_Value(String value) { this.value = value; } @@ -109,7 +109,7 @@ public class GameRuleHandler public boolean toBoolean() { - return (this.value.equals(TFM_GameRule_Value.TRUE.value) ? true : false); + return (this.value.equals(TFM_GameRule_Value.TRUE.value)); } public static TFM_GameRule_Value fromBoolean(boolean in) diff --git a/src/main/java/me/StevenLawson/TotalFreedomMod/httpd/HTTPDManager.java b/src/main/java/me/StevenLawson/TotalFreedomMod/httpd/HTTPDManager.java index d93fe41..6ad803b 100644 --- a/src/main/java/me/StevenLawson/TotalFreedomMod/httpd/HTTPDManager.java +++ b/src/main/java/me/StevenLawson/TotalFreedomMod/httpd/HTTPDManager.java @@ -129,7 +129,7 @@ public class HTTPDManager { } } - private static enum ModuleType { + private enum ModuleType { DUMP(new ModuleExecutable(false, "dump") { @Override public Response getResponse(HTTPSession session) { @@ -187,7 +187,7 @@ public class HTTPDManager { // private final ModuleExecutable moduleExecutable; - private ModuleType(ModuleExecutable moduleExecutable) + ModuleType(ModuleExecutable moduleExecutable) { this.moduleExecutable = moduleExecutable; } diff --git a/src/main/java/me/StevenLawson/TotalFreedomMod/httpd/HTTPDSchematicModule.java b/src/main/java/me/StevenLawson/TotalFreedomMod/httpd/HTTPDSchematicModule.java index ac5dbb1..08ffda4 100644 --- a/src/main/java/me/StevenLawson/TotalFreedomMod/httpd/HTTPDSchematicModule.java +++ b/src/main/java/me/StevenLawson/TotalFreedomMod/httpd/HTTPDSchematicModule.java @@ -261,7 +261,7 @@ public class HTTPDSchematicModule extends HTTPDModule { return (out == null ? null : (out.trim().isEmpty() ? null : out.trim())); } - private static enum ModuleMode + private enum ModuleMode { LIST("list"), UPLOAD("upload"), @@ -270,7 +270,7 @@ public class HTTPDSchematicModule extends HTTPDModule { // private final String modeName; - private ModuleMode(String modeName) + ModuleMode(String modeName) { this.modeName = modeName; } diff --git a/src/main/java/me/StevenLawson/TotalFreedomMod/httpd/NanoHTTPD.java b/src/main/java/me/StevenLawson/TotalFreedomMod/httpd/NanoHTTPD.java index 9759b0d..9ea59d7 100644 --- a/src/main/java/me/StevenLawson/TotalFreedomMod/httpd/NanoHTTPD.java +++ b/src/main/java/me/StevenLawson/TotalFreedomMod/httpd/NanoHTTPD.java @@ -21,6 +21,7 @@ import java.net.SocketException; import java.net.URLDecoder; import java.nio.ByteBuffer; import java.nio.channels.FileChannel; +import java.nio.charset.StandardCharsets; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Calendar; @@ -563,8 +564,8 @@ public abstract class NanoHTTPD */ public static class DefaultTempFile implements TempFile { - private File file; - private OutputStream fstream; + private final File file; + private final OutputStream fstream; public DefaultTempFile(String tempdir) throws IOException { @@ -612,7 +613,7 @@ public abstract class NanoHTTPD /** * Headers for the HTTP response. Use addHeader() to add lines. */ - private Map header = new HashMap(); + private final Map header = new HashMap(); /** * The request method that spawned this response. */ @@ -647,14 +648,7 @@ public abstract class NanoHTTPD { this.status = status; this.mimeType = mimeType; - try - { - this.data = txt != null ? new ByteArrayInputStream(txt.getBytes("UTF-8")) : null; - } - catch (java.io.UnsupportedEncodingException uee) - { - Log.severe(uee); - } + this.data = txt != null ? new ByteArrayInputStream(txt.getBytes(StandardCharsets.UTF_8)) : null; } /** @@ -1063,7 +1057,7 @@ public abstract class NanoHTTPD String boundaryStartString = "boundary="; int boundaryContentStart = contentTypeHeader.indexOf(boundaryStartString) + boundaryStartString.length(); - String boundary = contentTypeHeader.substring(boundaryContentStart, contentTypeHeader.length()); + String boundary = contentTypeHeader.substring(boundaryContentStart); if (boundary.startsWith("\"") && boundary.endsWith("\"")) { boundary = boundary.substring(1, boundary.length() - 1); @@ -1075,7 +1069,7 @@ public abstract class NanoHTTPD { // Handle application/x-www-form-urlencoded String postLine = ""; - char pbuf[] = new char[512]; + char[] pbuf = new char[512]; int read = in.read(pbuf); while (read >= 0 && !postLine.endsWith("\r\n")) { @@ -1448,7 +1442,9 @@ public abstract class NanoHTTPD public static class Cookie { - private String n, v, e; + private final String n; + private final String v; + private final String e; public Cookie(String name, String value, String expires) { @@ -1494,8 +1490,8 @@ public abstract class NanoHTTPD */ public class CookieHandler implements Iterable { - private HashMap cookies = new HashMap(); - private ArrayList queue = new ArrayList(); + private final HashMap cookies = new HashMap(); + private final ArrayList queue = new ArrayList(); public CookieHandler(Map httpHeaders) { diff --git a/src/main/java/me/StevenLawson/TotalFreedomMod/listener/PlayerListener.java b/src/main/java/me/StevenLawson/TotalFreedomMod/listener/PlayerListener.java index d53f45d..cf04092 100644 --- a/src/main/java/me/StevenLawson/TotalFreedomMod/listener/PlayerListener.java +++ b/src/main/java/me/StevenLawson/TotalFreedomMod/listener/PlayerListener.java @@ -742,10 +742,7 @@ public class PlayerListener implements Listener { private void playerLeave(org.bukkit.entity.Player player) { - if (TotalFreedomMod.fuckoffEnabledFor.containsKey(player)) - { - TotalFreedomMod.fuckoffEnabledFor.remove(player); - } + TotalFreedomMod.fuckoffEnabledFor.remove(player); final PlayerData playerdata = PlayerData.getPlayerData(player); diff --git a/src/main/java/me/StevenLawson/TotalFreedomMod/player/PlayerData.java b/src/main/java/me/StevenLawson/TotalFreedomMod/player/PlayerData.java index 8b5d7f6..3f7edd5 100644 --- a/src/main/java/me/StevenLawson/TotalFreedomMod/player/PlayerData.java +++ b/src/main/java/me/StevenLawson/TotalFreedomMod/player/PlayerData.java @@ -79,7 +79,7 @@ public class PlayerData { private int freecamPlaceCount = 0; private boolean isCaged = false; private Location cagePosition; - private List cageHistory = new ArrayList(); + private final List cageHistory = new ArrayList(); private Material cageOuterMaterial = Material.GLASS; private Material cageInnerMatterial = Material.AIR; private boolean isOrbiting = false; @@ -87,7 +87,7 @@ public class PlayerData { private boolean mobThrowerEnabled = false; private EntityType mobThrowerEntity = EntityType.PIG; private double mobThrowerSpeed = 4.0; - private List mobThrowerQueue = new ArrayList(); + private final List mobThrowerQueue = new ArrayList(); private BukkitTask mp44ScheduleTask = null; private boolean mp44Armed = false; private boolean mp44Firing = false; @@ -568,7 +568,7 @@ public class PlayerData { private class ArrowShooter extends BukkitRunnable { - private Player player; + private final Player player; private ArrowShooter(Player player) { diff --git a/src/main/java/me/StevenLawson/TotalFreedomMod/util/Utilities.java b/src/main/java/me/StevenLawson/TotalFreedomMod/util/Utilities.java index 63ecad9..8667ed1 100644 --- a/src/main/java/me/StevenLawson/TotalFreedomMod/util/Utilities.java +++ b/src/main/java/me/StevenLawson/TotalFreedomMod/util/Utilities.java @@ -453,7 +453,7 @@ public class Utilities method = EjectMethod.STRIKE_THREE; } - Log.info("AutoEject -> name: " + player.getName() + " - player ip: " + ip + " - method: " + method.toString()); + Log.info("AutoEject -> name: " + player.getName() + " - player ip: " + ip + " - method: " + method); player.setOp(false); player.setGameMode(GameMode.SURVIVAL); @@ -782,7 +782,7 @@ public class Utilities @SuppressWarnings("unchecked") public static boolean isFromHostConsole(String senderName) { - return ((List) ConfigurationEntry.HOST_SENDER_NAMES.getList()).contains(senderName.toLowerCase()); + return ConfigurationEntry.HOST_SENDER_NAMES.getList().contains(senderName.toLowerCase()); } public static List removeDuplicates(List oldList) @@ -890,7 +890,7 @@ public class Utilities if (verbose) { - Log.info("Downloaded " + url + " to " + output.toString() + "."); + Log.info("Downloaded " + url + " to " + output + "."); } } @@ -1060,9 +1060,9 @@ public class Utilities } } - public static enum EjectMethod + public enum EjectMethod { - STRIKE_ONE, STRIKE_TWO, STRIKE_THREE; + STRIKE_ONE, STRIKE_TWO, STRIKE_THREE } public static class MethodTimer diff --git a/src/main/java/me/StevenLawson/TotalFreedomMod/world/AdminWorld.java b/src/main/java/me/StevenLawson/TotalFreedomMod/world/AdminWorld.java index 1aac770..28bd233 100644 --- a/src/main/java/me/StevenLawson/TotalFreedomMod/world/AdminWorld.java +++ b/src/main/java/me/StevenLawson/TotalFreedomMod/world/AdminWorld.java @@ -28,7 +28,7 @@ public final class AdminWorld extends CustomWorld private final Map accessCache = new HashMap(); // private Long cacheLastCleared = null; - private Map guestList = new HashMap(); // Guest, Supervisor + private final Map guestList = new HashMap(); // Guest, Supervisor private WeatherMode weatherMode = WeatherMode.OFF; private TimeOfDay timeOfDay = TimeOfDay.INHERIT; @@ -215,7 +215,7 @@ public final class AdminWorld extends CustomWorld return cached; } - public static enum WeatherMode + public enum WeatherMode { OFF("off"), RAIN("rain"), @@ -223,7 +223,7 @@ public final class AdminWorld extends CustomWorld // private final List aliases; - private WeatherMode(String aliases) + WeatherMode(String aliases) { this.aliases = Arrays.asList(StringUtils.split(aliases, ",")); } @@ -251,7 +251,7 @@ public final class AdminWorld extends CustomWorld } } - public static enum TimeOfDay + public enum TimeOfDay { INHERIT(), SUNRISE("sunrise,morning", 0), @@ -262,13 +262,13 @@ public final class AdminWorld extends CustomWorld private final int timeTicks; private final List aliases; - private TimeOfDay() + TimeOfDay() { this.timeTicks = 0; this.aliases = null; } - private TimeOfDay(String aliases, int timeTicks) + TimeOfDay(String aliases, int timeTicks) { this.timeTicks = timeTicks; this.aliases = Arrays.asList(StringUtils.split(aliases, ",")); diff --git a/src/main/java/me/StevenLawson/TotalFreedomMod/world/CleanroomChunkGenerator.java b/src/main/java/me/StevenLawson/TotalFreedomMod/world/CleanroomChunkGenerator.java index fb2a44e..4ba388e 100644 --- a/src/main/java/me/StevenLawson/TotalFreedomMod/world/CleanroomChunkGenerator.java +++ b/src/main/java/me/StevenLawson/TotalFreedomMod/world/CleanroomChunkGenerator.java @@ -64,7 +64,7 @@ public class CleanroomChunkGenerator extends ChunkGenerator if (id.length() > 0) { - String tokens[] = id.split("[,]"); + String[] tokens = id.split("[,]"); if ((tokens.length % 2) != 0) { @@ -80,7 +80,7 @@ public class CleanroomChunkGenerator extends ChunkGenerator height = 64; } - String materialTokens[] = tokens[i + 1].split("[:]", 2); + String[] materialTokens = tokens[i + 1].split("[:]", 2); byte dataValue = 0; if (materialTokens.length == 2) { @@ -163,7 +163,7 @@ public class CleanroomChunkGenerator extends ChunkGenerator } catch (Exception e) { - log.severe("[CleanroomGenerator] Error parsing CleanroomGenerator ID '" + id + "'. using defaults '64,1': " + e.toString()); + log.severe("[CleanroomGenerator] Error parsing CleanroomGenerator ID '" + id + "'. using defaults '64,1': " + e); e.printStackTrace(); layerDataValues = null; layer = new short[65]; @@ -209,7 +209,7 @@ public class CleanroomChunkGenerator extends ChunkGenerator { if (layerDataValues != null) { - return Arrays.asList((BlockPopulator) new CleanroomBlockPopulator(layerDataValues)); + return Arrays.asList(new CleanroomBlockPopulator(layerDataValues)); } else { diff --git a/src/main/java/me/StevenLawson/TotalFreedomMod/world/RollbackManager.java b/src/main/java/me/StevenLawson/TotalFreedomMod/world/RollbackManager.java index 8a50738..48fb097 100644 --- a/src/main/java/me/StevenLawson/TotalFreedomMod/world/RollbackManager.java +++ b/src/main/java/me/StevenLawson/TotalFreedomMod/world/RollbackManager.java @@ -168,10 +168,7 @@ public class RollbackManager } } - if (REMOVE_ROLLBACK_HISTORY.contains(playerName.toLowerCase())) - { - REMOVE_ROLLBACK_HISTORY.remove(playerName.toLowerCase()); - } + REMOVE_ROLLBACK_HISTORY.remove(playerName.toLowerCase()); return count; } @@ -216,7 +213,7 @@ public class RollbackManager BLOCK_BREAK("broke"); private final String action; - private EntryType(String action) + EntryType(String action) { this.action = action; } diff --git a/src/main/java/me/husky/sqlite/SQLite.java b/src/main/java/me/husky/sqlite/SQLite.java index ec6858f..7d7c6fa 100644 --- a/src/main/java/me/husky/sqlite/SQLite.java +++ b/src/main/java/me/husky/sqlite/SQLite.java @@ -52,7 +52,7 @@ public class SQLite extends Database try { Class.forName("org.sqlite.JDBC"); - connection = DriverManager.getConnection("jdbc:sqlite:" + plugin.getDataFolder().toPath().toString() + "/" + dbLocation); + connection = DriverManager.getConnection("jdbc:sqlite:" + plugin.getDataFolder().toPath() + "/" + dbLocation); } catch (SQLException e) {