From 43485912b30895d5735a445d3ebd2f831df004af Mon Sep 17 00:00:00 2001 From: Cow Date: Thu, 17 Dec 2020 19:28:09 +0100 Subject: Various small, code inspection related changes --- .../java/de/cowtipper/cowlection/Cowlection.java | 4 +- .../cowtipper/cowlection/command/MooCommand.java | 48 +++++++++++----------- .../cowtipper/cowlection/command/ReplyCommand.java | 5 +-- .../de/cowtipper/cowlection/config/MooConfig.java | 2 +- .../config/gui/MooConfigCategoryScrolling.java | 2 - .../cowlection/config/gui/MooConfigMenuList.java | 4 -- .../cowlection/config/gui/MooConfigPreview.java | 4 ++ .../de/cowtipper/cowlection/data/DataHelper.java | 3 +- .../java/de/cowtipper/cowlection/data/Friend.java | 1 + .../de/cowtipper/cowlection/data/HyApiKey.java | 2 + .../de/cowtipper/cowlection/data/HyPlayerData.java | 4 ++ .../cowtipper/cowlection/data/HySkyBlockStats.java | 1 + .../cowtipper/cowlection/data/HyStalkingData.java | 4 ++ .../cowtipper/cowlection/handler/PlayerCache.java | 5 +-- .../cowlection/listener/ChatListener.java | 5 ++- .../cowlection/listener/PlayerListener.java | 2 +- .../listener/skyblock/DungeonsPartyListener.java | 5 ++- .../listener/skyblock/SkyBlockListener.java | 13 ++++-- .../cowtipper/cowlection/search/GuiDateField.java | 4 +- .../cowlection/search/LogFilesSearcher.java | 2 +- .../de/cowtipper/cowlection/util/ChatHelper.java | 2 +- .../de/cowtipper/cowlection/util/GuiHelper.java | 1 - .../de/cowtipper/cowlection/util/TickDelay.java | 2 +- .../java/de/cowtipper/cowlection/util/Utils.java | 7 ++-- .../cowtipper/cowlection/util/VersionChecker.java | 14 +++---- 25 files changed, 81 insertions(+), 65 deletions(-) diff --git a/src/main/java/de/cowtipper/cowlection/Cowlection.java b/src/main/java/de/cowtipper/cowlection/Cowlection.java index e15ab52..f278a1a 100644 --- a/src/main/java/de/cowtipper/cowlection/Cowlection.java +++ b/src/main/java/de/cowtipper/cowlection/Cowlection.java @@ -72,7 +72,7 @@ public class Cowlection { MinecraftForge.EVENT_BUS.register(new ChatListener(this)); MinecraftForge.EVENT_BUS.register(new PlayerListener(this)); ClientCommandHandler.instance.registerCommand(new MooCommand(this)); - ClientCommandHandler.instance.registerCommand(new ReplyCommand(this)); + ClientCommandHandler.instance.registerCommand(new ReplyCommand()); ClientCommandHandler.instance.registerCommand(new ShrugCommand(this)); for (String tabCompletableNamesCommand : MooConfig.tabCompletableNamesCommands) { ClientCommandHandler.instance.registerCommand(new TabCompletableCommand(this, tabCompletableNamesCommand)); @@ -89,7 +89,7 @@ public class Cowlection { @EventHandler public void postInit(FMLPostInitializationEvent e) { versionChecker = new VersionChecker(this); - playerCache = new PlayerCache(this); + playerCache = new PlayerCache(); } public MooConfig getConfig() { diff --git a/src/main/java/de/cowtipper/cowlection/command/MooCommand.java b/src/main/java/de/cowtipper/cowlection/command/MooCommand.java index 0e14a01..d9ed787 100644 --- a/src/main/java/de/cowtipper/cowlection/command/MooCommand.java +++ b/src/main/java/de/cowtipper/cowlection/command/MooCommand.java @@ -131,7 +131,7 @@ public class MooCommand extends CommandBase { Desktop.getDesktop().open(main.getModsDirectory()); } catch (IOException e) { e.printStackTrace(); - throw new MooCommandException("\u2716 An error occurred trying to open the mod's directory. I guess you have to open it manually \u00af\\_(\u30c4)_/\u00af"); + throw new MooCommandException("✖ An error occurred trying to open the mod's directory. I guess you have to open it manually ¯\\_(ツ)_/¯"); } } //endregion @@ -161,7 +161,7 @@ public class MooCommand extends CommandBase { } if (args.length != 2) { throw new WrongUsageException("/" + getCommandName() + " stalk "); - } else if (!Utils.isValidMcName(args[1])) { + } else if (Utils.isInvalidMcName(args[1])) { throw new InvalidPlayerNameException(args[1]); } else { String playerName = args[1]; @@ -238,7 +238,7 @@ public class MooCommand extends CommandBase { private void handleBestFriendAdd(String[] args) throws CommandException { if (args.length != 2) { throw new WrongUsageException("/" + getCommandName() + " add "); - } else if (!Utils.isValidMcName(args[1])) { + } else if (Utils.isInvalidMcName(args[1])) { throw new InvalidPlayerNameException(args[1]); } else if (main.getFriendsHandler().isBestFriend(args[1], true)) { throw new MooCommandException(EnumChatFormatting.DARK_RED + args[1] + EnumChatFormatting.RED + " is a best friend already."); @@ -254,7 +254,7 @@ public class MooCommand extends CommandBase { private void handleBestFriendRemove(String[] args) throws CommandException { if (args.length != 2) { throw new WrongUsageException("/" + getCommandName() + " remove "); - } else if (!Utils.isValidMcName(args[1])) { + } else if (Utils.isInvalidMcName(args[1])) { throw new InvalidPlayerNameException(args[1]); } String username = args[1]; @@ -270,7 +270,7 @@ public class MooCommand extends CommandBase { Set bestFriends = main.getFriendsHandler().getBestFriends(); // TODO show fancy gui with list of best friends; maybe with buttons to delete them - main.getChatHelper().sendMessage(EnumChatFormatting.GREEN, "\u279C Best friends" + main.getChatHelper().sendMessage(EnumChatFormatting.GREEN, "➜ Best friends" + (bestFriends.isEmpty() ? "" : " (" + EnumChatFormatting.DARK_GREEN + bestFriends.size() + EnumChatFormatting.GREEN + ")") + ": " + ((bestFriends.isEmpty()) ? EnumChatFormatting.ITALIC + "none :c" @@ -292,7 +292,7 @@ public class MooCommand extends CommandBase { private void handleNameChangeCheck(String[] args) throws CommandException { if (args.length != 2) { throw new WrongUsageException("/" + getCommandName() + " nameChangeCheck "); - } else if (!Utils.isValidMcName(args[1])) { + } else if (Utils.isInvalidMcName(args[1])) { throw new InvalidPlayerNameException(args[1]); } Friend bestFriend = main.getFriendsHandler().getBestFriend(args[1]); @@ -313,7 +313,7 @@ public class MooCommand extends CommandBase { } if (args.length != 2) { throw new WrongUsageException("/" + getCommandName() + " skyblockstalk "); - } else if (!Utils.isValidMcName(args[1])) { + } else if (Utils.isInvalidMcName(args[1])) { throw new InvalidPlayerNameException(args[1]); } else { String playerName = args[1]; @@ -440,7 +440,7 @@ public class MooCommand extends CommandBase { dungeonHover.appendFreshSibling(new MooChatComponent("Classes:").gold()); for (Map.Entry classEntry : classLevels.entrySet()) { String classLevel = (MooConfig.useRomanNumerals() ? Utils.convertArabicToRoman(classEntry.getValue()) : String.valueOf(classEntry.getValue())); - dungeonHover.appendFreshSibling(new MooChatComponent.KeyValueChatComponent((classEntry.getKey() == selectedClass ? "\u279C " : " ") + classEntry.getKey().getName(), classLevel)); + dungeonHover.appendFreshSibling(new MooChatComponent.KeyValueChatComponent((classEntry.getKey() == selectedClass ? "➜ " : " ") + classEntry.getKey().getName(), classLevel)); } } @@ -693,7 +693,7 @@ public class MooCommand extends CommandBase { GameSettings gameSettings = Minecraft.getMinecraft().gameSettings; int currentGuiScale = gameSettings.guiScale; if (args.length == 1) { - main.getChatHelper().sendMessage(EnumChatFormatting.GREEN, "\u279C Current GUI scale: " + EnumChatFormatting.DARK_GREEN + currentGuiScale); + main.getChatHelper().sendMessage(EnumChatFormatting.GREEN, "➜ Current GUI scale: " + EnumChatFormatting.DARK_GREEN + currentGuiScale); } else { int scale = MathHelper.parseIntWithDefault(args[1], -1); if (scale == -1 || scale > 10) { @@ -701,7 +701,7 @@ public class MooCommand extends CommandBase { } gameSettings.guiScale = scale; gameSettings.saveOptions(); - main.getChatHelper().sendMessage(EnumChatFormatting.GREEN, "\u2714 New GUI scale: " + EnumChatFormatting.DARK_GREEN + scale + EnumChatFormatting.GREEN + " (previous: " + EnumChatFormatting.DARK_GREEN + currentGuiScale + EnumChatFormatting.GREEN + ")"); + main.getChatHelper().sendMessage(EnumChatFormatting.GREEN, "✔ New GUI scale: " + EnumChatFormatting.DARK_GREEN + scale + EnumChatFormatting.GREEN + " (previous: " + EnumChatFormatting.DARK_GREEN + currentGuiScale + EnumChatFormatting.GREEN + ")"); } } @@ -741,29 +741,29 @@ public class MooCommand extends CommandBase { boolean updateCheckStarted = main.getVersionChecker().runUpdateCheck(true); if (updateCheckStarted) { - main.getChatHelper().sendMessage(EnumChatFormatting.GREEN, "\u279C Checking for a newer mod version..."); + main.getChatHelper().sendMessage(EnumChatFormatting.GREEN, "➜ Checking for a newer mod version..."); // VersionChecker#handleVersionStatus will run with a 5 seconds delay } else { long nextUpdate = main.getVersionChecker().getNextCheck(); String waitingTime = String.format("%02d:%02d", TimeUnit.MILLISECONDS.toMinutes(nextUpdate), TimeUnit.MILLISECONDS.toSeconds(nextUpdate) - TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes(nextUpdate))); - throw new MooCommandException("\u26A0 Update checker is on cooldown. Please wait " + EnumChatFormatting.GOLD + EnumChatFormatting.BOLD + waitingTime + EnumChatFormatting.RESET + EnumChatFormatting.RED + " more minutes before checking again."); + throw new MooCommandException("⚠ Update checker is on cooldown. Please wait " + EnumChatFormatting.GOLD + EnumChatFormatting.BOLD + waitingTime + EnumChatFormatting.RESET + EnumChatFormatting.RED + " more minutes before checking again."); } } private void handleUpdateHelp() { - main.getChatHelper().sendMessage(new ChatComponentText("\u279C Update instructions:").setChatStyle(new ChatStyle().setColor(EnumChatFormatting.GOLD).setBold(true)) - .appendSibling(new ChatComponentText("\n\u278A" + EnumChatFormatting.YELLOW + " download latest mod version").setChatStyle(new ChatStyle().setColor(EnumChatFormatting.GOLD).setBold(false) + main.getChatHelper().sendMessage(new ChatComponentText("➜ Update instructions:").setChatStyle(new ChatStyle().setColor(EnumChatFormatting.GOLD).setBold(true)) + .appendSibling(new ChatComponentText("\n➊" + EnumChatFormatting.YELLOW + " download latest mod version").setChatStyle(new ChatStyle().setColor(EnumChatFormatting.GOLD).setBold(false) .setChatClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, main.getVersionChecker().getDownloadUrl())) - .setChatHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ChatComponentText(EnumChatFormatting.YELLOW + "Download the latest version of " + Cowlection.MODNAME + "\n\u279C Click to download latest mod file"))))) - .appendSibling(new ChatComponentText("\n\u278B" + EnumChatFormatting.YELLOW + " exit Minecraft").setChatStyle(new ChatStyle().setColor(EnumChatFormatting.GOLD).setBold(false) - .setChatHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ChatComponentText(EnumChatFormatting.GOLD + "\u278B" + EnumChatFormatting.YELLOW + " Without closing Minecraft first,\n" + EnumChatFormatting.YELLOW + "you can't delete the old .jar file!"))))) - .appendSibling(new ChatComponentText("\n\u278C" + EnumChatFormatting.YELLOW + " copy " + EnumChatFormatting.GOLD + Cowlection.MODNAME.replace(" ", "") + "-" + main.getVersionChecker().getNewVersion() + ".jar" + EnumChatFormatting.YELLOW + " into mods directory").setChatStyle(new ChatStyle().setColor(EnumChatFormatting.GOLD).setBold(false) + .setChatHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ChatComponentText(EnumChatFormatting.YELLOW + "Download the latest version of " + Cowlection.MODNAME + "\n➜ Click to download latest mod file"))))) + .appendSibling(new ChatComponentText("\n➋" + EnumChatFormatting.YELLOW + " exit Minecraft").setChatStyle(new ChatStyle().setColor(EnumChatFormatting.GOLD).setBold(false) + .setChatHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ChatComponentText(EnumChatFormatting.GOLD + "➋" + EnumChatFormatting.YELLOW + " Without closing Minecraft first,\n" + EnumChatFormatting.YELLOW + "you can't delete the old .jar file!"))))) + .appendSibling(new ChatComponentText("\n➌" + EnumChatFormatting.YELLOW + " copy " + EnumChatFormatting.GOLD + Cowlection.MODNAME.replace(" ", "") + "-" + main.getVersionChecker().getNewVersion() + ".jar" + EnumChatFormatting.YELLOW + " into mods directory").setChatStyle(new ChatStyle().setColor(EnumChatFormatting.GOLD).setBold(false) .setChatClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/moo directory")) - .setChatHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ChatComponentText(EnumChatFormatting.YELLOW + "Open mods directory with command " + EnumChatFormatting.GOLD + "/moo directory\n\u279C Click to open mods directory"))))) - .appendSibling(new ChatComponentText("\n\u278D" + EnumChatFormatting.YELLOW + " delete old mod file " + EnumChatFormatting.GOLD + Cowlection.MODNAME.replace(" ", "") + "-" + Cowlection.VERSION + ".jar ").setChatStyle(new ChatStyle().setColor(EnumChatFormatting.GOLD).setBold(false))) - .appendSibling(new ChatComponentText("\n\u278E" + EnumChatFormatting.YELLOW + " start Minecraft again").setChatStyle(new ChatStyle().setColor(EnumChatFormatting.GOLD).setBold(false)))); + .setChatHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ChatComponentText(EnumChatFormatting.YELLOW + "Open mods directory with command " + EnumChatFormatting.GOLD + "/moo directory\n➜ Click to open mods directory"))))) + .appendSibling(new ChatComponentText("\n➍" + EnumChatFormatting.YELLOW + " delete old mod file " + EnumChatFormatting.GOLD + Cowlection.MODNAME.replace(" ", "") + "-" + Cowlection.VERSION + ".jar ").setChatStyle(new ChatStyle().setColor(EnumChatFormatting.GOLD).setBold(false))) + .appendSibling(new ChatComponentText("\n➎" + EnumChatFormatting.YELLOW + " start Minecraft again").setChatStyle(new ChatStyle().setColor(EnumChatFormatting.GOLD).setBold(false)))); } //endregion @@ -774,7 +774,7 @@ public class MooCommand extends CommandBase { } private void sendCommandUsage(ICommandSender sender) { - IChatComponent usage = new MooChatComponent("\u279C " + Cowlection.MODNAME + " commands:").gold().bold() + IChatComponent usage = new MooChatComponent("➜ " + Cowlection.MODNAME + " commands:").gold().bold() .appendSibling(createCmdHelpEntry("config", "Open mod's configuration")) .appendSibling(new MooChatComponent("\n").reset().gray().appendText(EnumChatFormatting.DARK_GREEN + " ❢" + EnumChatFormatting.GRAY + EnumChatFormatting.ITALIC + " Commands marked with §d§l⚷" + EnumChatFormatting.GRAY + EnumChatFormatting.ITALIC + " require a valid API key")) .appendSibling(createCmdHelpSection(1, "Best friends, friends & other players")) @@ -793,7 +793,7 @@ public class MooCommand extends CommandBase { .appendSibling(createCmdHelpEntry("search", "Open Minecraft log search")) .appendSibling(createCmdHelpEntry("guiScale", "Change GUI scale")) .appendSibling(createCmdHelpEntry("rr", "Alias for /r without auto-replacement to /msg")) - .appendSibling(createCmdHelpEntry("shrug", "\u00AF\\_(\u30C4)_/\u00AF")) // ¯\_(ツ)_/¯ + .appendSibling(createCmdHelpEntry("shrug", "¯\\_(ツ)_/¯")) .appendSibling(createCmdHelpSection(4, "Update mod")) .appendSibling(createCmdHelpEntry("update", "Check for new mod updates")) .appendSibling(createCmdHelpEntry("updateHelp", "Show mod update instructions")) @@ -810,7 +810,7 @@ public class MooCommand extends CommandBase { private IChatComponent createCmdHelpEntry(String cmd, String usage) { String command = "/" + this.getCommandName() + " " + cmd; - return new MooChatComponent("\n").reset().appendSibling(new MooChatComponent.KeyValueChatComponent(command, usage, " \u27A1 ").setSuggestCommand(command)); + return new MooChatComponent("\n").reset().appendSibling(new MooChatComponent.KeyValueChatComponent(command, usage, " ➡ ").setSuggestCommand(command)); } @Override diff --git a/src/main/java/de/cowtipper/cowlection/command/ReplyCommand.java b/src/main/java/de/cowtipper/cowlection/command/ReplyCommand.java index e37ce85..14af3bb 100644 --- a/src/main/java/de/cowtipper/cowlection/command/ReplyCommand.java +++ b/src/main/java/de/cowtipper/cowlection/command/ReplyCommand.java @@ -1,16 +1,13 @@ package de.cowtipper.cowlection.command; -import de.cowtipper.cowlection.Cowlection; import net.minecraft.client.Minecraft; import net.minecraft.command.CommandBase; import net.minecraft.command.CommandException; import net.minecraft.command.ICommandSender; public class ReplyCommand extends CommandBase { - private final Cowlection main; - public ReplyCommand(Cowlection main) { - this.main = main; + public ReplyCommand() { } @Override diff --git a/src/main/java/de/cowtipper/cowlection/config/MooConfig.java b/src/main/java/de/cowtipper/cowlection/config/MooConfig.java index 728631e..8dadc83 100644 --- a/src/main/java/de/cowtipper/cowlection/config/MooConfig.java +++ b/src/main/java/de/cowtipper/cowlection/config/MooConfig.java @@ -621,7 +621,7 @@ public class MooConfig { // date format: yyyy-mm-dd return LocalDate.parse(defaultStartDate); } catch (DateTimeParseException e) { - // fallthrough + // fall-through } try { int months = Integer.parseInt(defaultStartDate); diff --git a/src/main/java/de/cowtipper/cowlection/config/gui/MooConfigCategoryScrolling.java b/src/main/java/de/cowtipper/cowlection/config/gui/MooConfigCategoryScrolling.java index e20a146..c73e27e 100644 --- a/src/main/java/de/cowtipper/cowlection/config/gui/MooConfigCategoryScrolling.java +++ b/src/main/java/de/cowtipper/cowlection/config/gui/MooConfigCategoryScrolling.java @@ -41,7 +41,6 @@ public class MooConfigCategoryScrolling extends GuiListExtended { private final List listEntries; private final Map> explanations; private final MooConfigGui parent; - private final int marginLeft; private int maxListLabelWidth = 0; private KeyBindingConfigEntry currentKeyBindingConfigEntry = null; /** @@ -52,7 +51,6 @@ public class MooConfigCategoryScrolling extends GuiListExtended { public MooConfigCategoryScrolling(MooConfigGui parent, Minecraft mc, MooConfigCategory currentConfigCategory, int marginLeft) { super(mc, parent.width - marginLeft, parent.height, 32, parent.height - 5, 20); this.parent = parent; - this.marginLeft = marginLeft; setSlotXBoundsFromLeft(marginLeft); this.mc = mc; listEntriesPreviews = new TreeMap<>(); diff --git a/src/main/java/de/cowtipper/cowlection/config/gui/MooConfigMenuList.java b/src/main/java/de/cowtipper/cowlection/config/gui/MooConfigMenuList.java index 310e09e..e72d27b 100644 --- a/src/main/java/de/cowtipper/cowlection/config/gui/MooConfigMenuList.java +++ b/src/main/java/de/cowtipper/cowlection/config/gui/MooConfigMenuList.java @@ -63,8 +63,4 @@ public class MooConfigMenuList extends GuiScrollingList { protected int getRight() { return this.right; } - - public int getLeft() { - return this.left; - } } diff --git a/src/main/java/de/cowtipper/cowlection/config/gui/MooConfigPreview.java b/src/main/java/de/cowtipper/cowlection/config/gui/MooConfigPreview.java index 3499fdd..66a751b 100644 --- a/src/main/java/de/cowtipper/cowlection/config/gui/MooConfigPreview.java +++ b/src/main/java/de/cowtipper/cowlection/config/gui/MooConfigPreview.java @@ -45,6 +45,10 @@ public class MooConfigPreview { break; case CHAT: drawChatPreview(x, y, mouseX, mouseY, enablePreview); + break; + default: + // do nothing + break; } } diff --git a/src/main/java/de/cowtipper/cowlection/data/DataHelper.java b/src/main/java/de/cowtipper/cowlection/data/DataHelper.java index 95c2133..028fe62 100644 --- a/src/main/java/de/cowtipper/cowlection/data/DataHelper.java +++ b/src/main/java/de/cowtipper/cowlection/data/DataHelper.java @@ -38,6 +38,7 @@ public final class DataHelper { } // TODO replace with api request: https://github.com/HypixelDev/PublicAPI/blob/master/Documentation/misc/GameType.md + @SuppressWarnings("unused") public enum GameType { QUAKECRAFT("Quakecraft"), WALLS("Walls"), @@ -126,7 +127,7 @@ public final class DataHelper { public static Map getMinions() { // key = skin id, value = minion type and tier Map minions = new HashMap<>(); - // TODO currently Fishing VI + VII and Creeper V + VI each use the same skull texture (server-side) - thus can't be distinguished + // TODO currently Fishing VI + VII use the same skull texture (server-side) - thus can't be distinguished minions.put("2f93289a82bd2a06cbbe61b733cfdc1f1bd93c4340f7a90abd9bdda774109071", "Cobblestone I"); minions.put("3fd87486dc94cb8cd04a3d7d06f191f027f38dad7b4ed34c6681fb4d08834c06", "Cobblestone II"); minions.put("cc088ed6bb8763af4eb7d006e00fda7dc11d7681e97c983b7011c3e872f6aab9", "Cobblestone III"); diff --git a/src/main/java/de/cowtipper/cowlection/data/Friend.java b/src/main/java/de/cowtipper/cowlection/data/Friend.java index 81d93d7..9ef368e 100644 --- a/src/main/java/de/cowtipper/cowlection/data/Friend.java +++ b/src/main/java/de/cowtipper/cowlection/data/Friend.java @@ -5,6 +5,7 @@ import java.util.UUID; public class Friend { public static final Friend FRIEND_NOT_FOUND = new Friend(); + @SuppressWarnings("unused") private UUID id; private String name; private long lastChecked; diff --git a/src/main/java/de/cowtipper/cowlection/data/HyApiKey.java b/src/main/java/de/cowtipper/cowlection/data/HyApiKey.java index 96b391a..ca7152c 100644 --- a/src/main/java/de/cowtipper/cowlection/data/HyApiKey.java +++ b/src/main/java/de/cowtipper/cowlection/data/HyApiKey.java @@ -1,7 +1,9 @@ package de.cowtipper.cowlection.data; public class HyApiKey { + @SuppressWarnings("unused") private boolean success; + @SuppressWarnings("unused") private String cause; /** diff --git a/src/main/java/de/cowtipper/cowlection/data/HyPlayerData.java b/src/main/java/de/cowtipper/cowlection/data/HyPlayerData.java index 22e1eaa..96c3325 100644 --- a/src/main/java/de/cowtipper/cowlection/data/HyPlayerData.java +++ b/src/main/java/de/cowtipper/cowlection/data/HyPlayerData.java @@ -2,6 +2,7 @@ package de.cowtipper.cowlection.data; import net.minecraft.util.EnumChatFormatting; +@SuppressWarnings("unused") public class HyPlayerData { private String displayname; private String rank; @@ -74,6 +75,9 @@ public class HyPlayerData { return EnumChatFormatting.RED + "[ADMIN]"; case "YOUTUBER": return EnumChatFormatting.RED + "[" + EnumChatFormatting.WHITE + "YOUTUBE" + EnumChatFormatting.RED + "]"; + default: + // unknown rank, fall-through + break; } } if (rankPlusColor == null) { diff --git a/src/main/java/de/cowtipper/cowlection/data/HySkyBlockStats.java b/src/main/java/de/cowtipper/cowlection/data/HySkyBlockStats.java index b268406..7ebd894 100644 --- a/src/main/java/de/cowtipper/cowlection/data/HySkyBlockStats.java +++ b/src/main/java/de/cowtipper/cowlection/data/HySkyBlockStats.java @@ -16,6 +16,7 @@ import java.io.ByteArrayInputStream; import java.io.IOException; import java.util.*; +@SuppressWarnings({"FieldCanBeLocal", "FieldMayBeFinal", "unused", "MismatchedQueryAndUpdateOfCollection"}) public class HySkyBlockStats { private boolean success; private String cause; diff --git a/src/main/java/de/cowtipper/cowlection/data/HyStalkingData.java b/src/main/java/de/cowtipper/cowlection/data/HyStalkingData.java index 45f3344..14c2c4b 100644 --- a/src/main/java/de/cowtipper/cowlection/data/HyStalkingData.java +++ b/src/main/java/de/cowtipper/cowlection/data/HyStalkingData.java @@ -3,6 +3,7 @@ package de.cowtipper.cowlection.data; import de.cowtipper.cowlection.util.Utils; import org.apache.commons.lang3.StringUtils; +@SuppressWarnings("unused") public class HyStalkingData { private boolean success; private String cause; @@ -108,6 +109,9 @@ public class HyStalkingData { return "Gold Mine"; case "mining_2": return "Deep Caverns"; + default: + // fall-through + break; } } return Utils.fancyCase(mode); diff --git a/src/main/java/de/cowtipper/cowlection/handler/PlayerCache.java b/src/main/java/de/cowtipper/cowlection/handler/PlayerCache.java index 0092670..6eb7904 100644 --- a/src/main/java/de/cowtipper/cowlection/handler/PlayerCache.java +++ b/src/main/java/de/cowtipper/cowlection/handler/PlayerCache.java @@ -1,7 +1,6 @@ package de.cowtipper.cowlection.handler; import com.google.common.collect.EvictingQueue; -import de.cowtipper.cowlection.Cowlection; import java.util.SortedSet; import java.util.TreeSet; @@ -10,10 +9,8 @@ import java.util.TreeSet; public class PlayerCache { private final EvictingQueue nameCache = EvictingQueue.create(50); private final EvictingQueue bestFriendCache = EvictingQueue.create(100); - private final Cowlection main; - public PlayerCache(Cowlection main) { - this.main = main; + public PlayerCache() { } public void add(String name) { diff --git a/src/main/java/de/cowtipper/cowlection/listener/ChatListener.java b/src/main/java/de/cowtipper/cowlection/listener/ChatListener.java index 0c601d7..e7d2fdb 100644 --- a/src/main/java/de/cowtipper/cowlection/listener/ChatListener.java +++ b/src/main/java/de/cowtipper/cowlection/listener/ChatListener.java @@ -71,6 +71,9 @@ public class ChatListener { case "left": main.getPlayerCache().removeBestFriend(playerName); break; + default: + // player neither left nor joined?! + return; } if (MooConfig.showBestFriendNotifications) { // replace default (friend/guild) notification with best friend notification @@ -115,7 +118,7 @@ public class ChatListener { } } GuiControls.setClipboardString(chatData); - main.getChatHelper().sendAboveChatMessage(EnumChatFormatting.YELLOW + "Copied chat component to clipboard:", "" + EnumChatFormatting.BOLD + EnumChatFormatting.GOLD + "\u276E" + EnumChatFormatting.RESET + (copyWithFormatting ? chatComponent.getUnformattedText() : chatData) + EnumChatFormatting.BOLD + EnumChatFormatting.GOLD + "\u276F"); + main.getChatHelper().sendAboveChatMessage(EnumChatFormatting.YELLOW + "Copied chat component to clipboard:", "" + EnumChatFormatting.BOLD + EnumChatFormatting.GOLD + "❮" + EnumChatFormatting.RESET + (copyWithFormatting ? chatComponent.getUnformattedText() : chatData) + EnumChatFormatting.BOLD + EnumChatFormatting.GOLD + "❯"); } } } diff --git a/src/main/java/de/cowtipper/cowlection/listener/PlayerListener.java b/src/main/java/de/cowtipper/cowlection/listener/PlayerListener.java index 0925d38..0507766 100644 --- a/src/main/java/de/cowtipper/cowlection/listener/PlayerListener.java +++ b/src/main/java/de/cowtipper/cowlection/listener/PlayerListener.java @@ -126,7 +126,7 @@ public class PlayerListener { public static boolean registerSkyBlockListeners() { if (dungeonsListener == null && skyBlockListener == null) { MinecraftForge.EVENT_BUS.register(dungeonsListener = new DungeonsListener(Cowlection.getInstance())); - MinecraftForge.EVENT_BUS.register(skyBlockListener = new SkyBlockListener(Cowlection.getInstance())); + MinecraftForge.EVENT_BUS.register(skyBlockListener = new SkyBlockListener()); return true; } return false; diff --git a/src/main/java/de/cowtipper/cowlection/listener/skyblock/DungeonsPartyListener.java b/src/main/java/de/cowtipper/cowlection/listener/skyblock/DungeonsPartyListener.java index 4693b10..a37d546 100644 --- a/src/main/java/de/cowtipper/cowlection/listener/skyblock/DungeonsPartyListener.java +++ b/src/main/java/de/cowtipper/cowlection/listener/skyblock/DungeonsPartyListener.java @@ -91,7 +91,7 @@ public class DungeonsPartyListener { nextStep = Step.API_REQUESTS; break; } - // fallthrough: + // fall-through: case MODERATORS_OR_MEMBERS: matcher = PARTY_MEMBERS_OR_MODERATORS_PATTERN.matcher(text); boolean isPartyMods = text.startsWith("Party Moderators: "); @@ -103,6 +103,9 @@ public class DungeonsPartyListener { nextStep = isPartyMods ? Step.MEMBERS_OR_END : Step.API_REQUESTS; } break; + default: + // do nothing + break; } if (nextStep == Step.API_REQUESTS) { diff --git a/src/main/java/de/cowtipper/cowlection/listener/skyblock/SkyBlockListener.java b/src/main/java/de/cowtipper/cowlection/listener/skyblock/SkyBlockListener.java index 11f2cda..27be613 100644 --- a/src/main/java/de/cowtipper/cowlection/listener/skyblock/SkyBlockListener.java +++ b/src/main/java/de/cowtipper/cowlection/listener/skyblock/SkyBlockListener.java @@ -1,6 +1,5 @@ package de.cowtipper.cowlection.listener.skyblock; -import de.cowtipper.cowlection.Cowlection; import de.cowtipper.cowlection.config.MooConfig; import de.cowtipper.cowlection.util.Utils; import net.minecraft.client.Minecraft; @@ -31,15 +30,13 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; public class SkyBlockListener { - private final Cowlection main; /** * timestamp example: 4/20/20 4:20 AM */ private final Pattern SB_TIMESTAMP_PATTERN = Pattern.compile("^(\\d{1,2})/(\\d{1,2})/(\\d{2}) (\\d{1,2}):(\\d{2}) (AM|PM)$"); private final NumberFormat numberFormatter; - public SkyBlockListener(Cowlection main) { - this.main = main; + public SkyBlockListener() { numberFormatter = NumberFormat.getNumberInstance(Locale.US); numberFormatter.setMaximumFractionDigits(0); } @@ -95,6 +92,10 @@ public class SkyBlockListener { } case ALWAYS: e.toolTip.add(index, "Timestamp: " + EnumChatFormatting.DARK_GRAY + dateTimeFormatted); + break; + default: + // do nothing + break; } switch (tooltipItemAgeDisplay) { case SPECIAL: @@ -103,6 +104,10 @@ public class SkyBlockListener { } case ALWAYS: e.toolTip.add(index, "Item age: " + EnumChatFormatting.DARK_GRAY + ((MooConfig.tooltipItemAgeShortened) ? Utils.getDurationAsWord(dateTime.toEpochSecond() * 1000) : Utils.getDurationAsWords(dateTime.toEpochSecond() * 1000).first())); + break; + default: + // do nothing + break; } } } diff --git a/src/main/java/de/cowtipper/cowlection/search/GuiDateField.java b/src/main/java/de/cowtipper/cowlection/search/GuiDateField.java index 5289841..9e3a3ff 100644 --- a/src/main/java/de/cowtipper/cowlection/search/GuiDateField.java +++ b/src/main/java/de/cowtipper/cowlection/search/GuiDateField.java @@ -7,8 +7,8 @@ import java.time.LocalDate; import java.time.format.DateTimeParseException; class GuiDateField extends GuiTextField { - GuiDateField(int componentId, FontRenderer fontrendererObj, int x, int y, int width, int height) { - super(componentId, fontrendererObj, x, y, width, height); + GuiDateField(int componentId, FontRenderer fontRendererObj, int x, int y, int width, int height) { + super(componentId, fontRendererObj, x, y, width, height); } LocalDate getDate() { diff --git a/src/main/java/de/cowtipper/cowlection/search/LogFilesSearcher.java b/src/main/java/de/cowtipper/cowlection/search/LogFilesSearcher.java index 2e811ef..5390073 100644 --- a/src/main/java/de/cowtipper/cowlection/search/LogFilesSearcher.java +++ b/src/main/java/de/cowtipper/cowlection/search/LogFilesSearcher.java @@ -48,7 +48,7 @@ class LogFilesSearcher { } if (files.isEmpty()) { - throw new FileNotFoundException(EnumChatFormatting.DARK_RED + "ERROR: Couldn't find any Minecraft log files. Please check if the log file directories are set correctly (Log Search \u27A1 Settings)."); + throw new FileNotFoundException(EnumChatFormatting.DARK_RED + "ERROR: Couldn't find any Minecraft log files. Please check if the log file directories are set correctly (Log Search ➡ Settings)."); } else { List searchResults = analyzeFiles(files, searchQuery, chatOnly, matchCase, removeFormatting) .stream().sorted(Comparator.comparing(LogEntry::getTime)).collect(Collectors.toList()); diff --git a/src/main/java/de/cowtipper/cowlection/util/ChatHelper.java b/src/main/java/de/cowtipper/cowlection/util/ChatHelper.java index 0f06bec..42a5790 100644 --- a/src/main/java/de/cowtipper/cowlection/util/ChatHelper.java +++ b/src/main/java/de/cowtipper/cowlection/util/ChatHelper.java @@ -74,7 +74,7 @@ public class ChatHelper { } public void sendShrug(String... args) { - String chatMsg = "\u00AF\\_(\u30C4)_/\u00AF"; // ¯\\_(ツ)_/¯" + String chatMsg = "¯\\_(ツ)_/¯"; if (args.length > 0) { chatMsg = String.join(" ", args) + " " + chatMsg; } diff --git a/src/main/java/de/cowtipper/cowlection/util/GuiHelper.java b/src/main/java/de/cowtipper/cowlection/util/GuiHelper.java index a80b1ba..b904670 100644 --- a/src/main/java/de/cowtipper/cowlection/util/GuiHelper.java +++ b/src/main/java/de/cowtipper/cowlection/util/GuiHelper.java @@ -164,7 +164,6 @@ public final class GuiHelper extends GuiScreen { tooltipY = screenHeight - tooltipHeight - 6; } - final int zLevel = 300; final int backgroundColor = 0xF0100010; Gui.drawRect(tooltipX - 3, tooltipY - 4, tooltipX + tooltipTextWidth + 3, tooltipY - 3, backgroundColor); Gui.drawRect(tooltipX - 3, tooltipY + tooltipHeight + 3, tooltipX + tooltipTextWidth + 3, tooltipY + tooltipHeight + 4, backgroundColor); diff --git a/src/main/java/de/cowtipper/cowlection/util/TickDelay.java b/src/main/java/de/cowtipper/cowlection/util/TickDelay.java index cbb21c5..a07a452 100644 --- a/src/main/java/de/cowtipper/cowlection/util/TickDelay.java +++ b/src/main/java/de/cowtipper/cowlection/util/TickDelay.java @@ -5,7 +5,7 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.gameevent.TickEvent; public class TickDelay { - private Runnable task; + private final Runnable task; private int waitingTicks; public TickDelay(Runnable task, int ticks) { diff --git a/src/main/java/de/cowtipper/cowlection/util/Utils.java b/src/main/java/de/cowtipper/cowlection/util/Utils.java index b4d62f8..8e8723c 100644 --- a/src/main/java/de/cowtipper/cowlection/util/Utils.java +++ b/src/main/java/de/cowtipper/cowlection/util/Utils.java @@ -29,8 +29,8 @@ public final class Utils { return VALID_UUID_PATTERN.matcher(uuid).matches(); } - public static boolean isValidMcName(String username) { - return VALID_USERNAME.matcher(username).matches(); + public static boolean isInvalidMcName(String username) { + return !VALID_USERNAME.matcher(username).matches(); } public static String fancyCase(String string) { @@ -215,8 +215,9 @@ public final class Utils { return five + one + one + one; case 9: return one + ten; + default: + return ""; } - return ""; } /** diff --git a/src/main/java/de/cowtipper/cowlection/util/VersionChecker.java b/src/main/java/de/cowtipper/cowlection/util/VersionChecker.java index d463d04..7f859a6 100644 --- a/src/main/java/de/cowtipper/cowlection/util/VersionChecker.java +++ b/src/main/java/de/cowtipper/cowlection/util/VersionChecker.java @@ -69,21 +69,21 @@ public class VersionChecker { if (isCommandTriggered) { if (versionResult.status == ForgeVersion.Status.UP_TO_DATE) { // up to date - statusMsg = new ChatComponentText("\u2714 You're running the latest version (" + Cowlection.VERSION + ").").setChatStyle(new ChatStyle().setColor(EnumChatFormatting.GREEN)); + statusMsg = new ChatComponentText("✔ You're running the latest version (" + Cowlection.VERSION + ").").setChatStyle(new ChatStyle().setColor(EnumChatFormatting.GREEN)); } else if (versionResult.status == ForgeVersion.Status.PENDING) { // pending - statusMsg = new ChatComponentText("\u279C " + "Version check either failed or is still running.").setChatStyle(new ChatStyle().setColor(EnumChatFormatting.YELLOW)) - .appendSibling(new ChatComponentText("\n \u278A Check for results again in a few seconds with " + EnumChatFormatting.GOLD + "/moo version").setChatStyle(new ChatStyle() + statusMsg = new ChatComponentText("➜ " + "Version check either failed or is still running.").setChatStyle(new ChatStyle().setColor(EnumChatFormatting.YELLOW)) + .appendSibling(new ChatComponentText("\n ➊ Check for results again in a few seconds with " + EnumChatFormatting.GOLD + "/moo version").setChatStyle(new ChatStyle() .setColor(EnumChatFormatting.YELLOW) .setChatClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/moo version")) .setChatHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ChatComponentText(EnumChatFormatting.YELLOW + "Run " + EnumChatFormatting.GOLD + "/moo version"))))) - .appendSibling(new ChatComponentText("\n \u278B Re-run update check with " + EnumChatFormatting.GOLD + "/moo update").setChatStyle(new ChatStyle() + .appendSibling(new ChatComponentText("\n ➋ Re-run update check with " + EnumChatFormatting.GOLD + "/moo update").setChatStyle(new ChatStyle() .setColor(EnumChatFormatting.YELLOW) .setChatClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/moo update")) .setChatHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ChatComponentText(EnumChatFormatting.YELLOW + "Run " + EnumChatFormatting.GOLD + "/moo update"))))); } else if (versionResult.status == ForgeVersion.Status.FAILED) { // check failed - statusMsg = new ChatComponentText("\u2716 Version check failed for an unknown reason. Check again in a few seconds with ").setChatStyle(new ChatStyle().setColor(EnumChatFormatting.RED)) + statusMsg = new ChatComponentText("✖ Version check failed for an unknown reason. Check again in a few seconds with ").setChatStyle(new ChatStyle().setColor(EnumChatFormatting.RED)) .appendSibling(new ChatComponentText("/moo update").setChatStyle(new ChatStyle() .setColor(EnumChatFormatting.GOLD) .setChatClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/moo update")) @@ -94,7 +94,7 @@ public class VersionChecker { // outdated IChatComponent spacer = new ChatComponentText(" ").setChatStyle(new ChatStyle().setParentStyle(null)); - IChatComponent text = new ChatComponentText("\u279C New version of " + EnumChatFormatting.DARK_GREEN + Cowlection.MODNAME + " " + EnumChatFormatting.GREEN + "available (" + Cowlection.VERSION + " \u27A1 " + newVersion + ")\n").setChatStyle(new ChatStyle().setColor(EnumChatFormatting.GREEN)); + IChatComponent text = new ChatComponentText("➜ New version of " + EnumChatFormatting.DARK_GREEN + Cowlection.MODNAME + " " + EnumChatFormatting.GREEN + "available (" + Cowlection.VERSION + " ➡ " + newVersion + ")\n").setChatStyle(new ChatStyle().setColor(EnumChatFormatting.GREEN)); IChatComponent download = new ChatComponentText("[Download]").setChatStyle(new ChatStyle() .setColor(EnumChatFormatting.DARK_GREEN).setBold(true) @@ -114,7 +114,7 @@ public class VersionChecker { IChatComponent openModsDirectory = new ChatComponentText("\n[Open Mods directory]").setChatStyle(new ChatStyle() .setColor(EnumChatFormatting.GREEN).setBold(true) .setChatClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/moo directory")) - .setChatHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ChatComponentText(EnumChatFormatting.YELLOW + "Open mods directory with command " + EnumChatFormatting.GOLD + "/moo directory\n\u279C Click to open mods directory")))); + .setChatHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ChatComponentText(EnumChatFormatting.YELLOW + "Open mods directory with command " + EnumChatFormatting.GOLD + "/moo directory\n➜ Click to open mods directory")))); statusMsg = text.appendSibling(download).appendSibling(spacer).appendSibling(changelog).appendSibling(spacer).appendSibling(updateInstructions).appendSibling(spacer).appendSibling(openModsDirectory); } -- cgit