From a1bfac4cd6c5f6ab38b96f56b9b6da03745a7196 Mon Sep 17 00:00:00 2001 From: Destro174 <40720638+destro174@users.noreply.github.com> Date: Sun, 11 Oct 2020 11:51:47 +0200 Subject: [PATCH] remove debug options and unused code --- .../destro174/custommotd/CustomMOTD.java | 17 +---- .../commands/custommotdCommand.java | 26 -------- .../custommotd/listener/PingListener.java | 62 ------------------- 3 files changed, 1 insertion(+), 104 deletions(-) diff --git a/src/main/java/com/alttd/destro174/custommotd/CustomMOTD.java b/src/main/java/com/alttd/destro174/custommotd/CustomMOTD.java index 2148492..97a55e5 100644 --- a/src/main/java/com/alttd/destro174/custommotd/CustomMOTD.java +++ b/src/main/java/com/alttd/destro174/custommotd/CustomMOTD.java @@ -44,10 +44,8 @@ public class CustomMOTD extends JavaPlugin { @Override public void onEnable() { - // TODO Insert logic to be performed when the plugin is enabled try { CustomMOTD = this; - //getLogger().info("Altitude Custom MOTD starting"); loadConfig(); reloadConfig(); @@ -72,17 +70,13 @@ public class CustomMOTD extends JavaPlugin { counterfile = new MOTDConfig(this, "counter.yml", "counter.yml"); counter = counterfile.getInt("counter"); - //motd = motdfile.getStringList("MOTD"); setmotd(motdfile.getString("MOTD")); - //getLogger().info("setting motd to - " + motdfile.getString("MOTD")); - //getLogger().info("setting Counter to - " + counter); for(String line : this.getConfig().getKeys(false)) { if(!line.equalsIgnoreCase("mcmmo")) { Options += line + " "; } } useproxyonlinecount = motdfile.getBoolean("useproxyonline", false); - //getLogger().info(Options); } public void reloadsettings() { @@ -93,8 +87,6 @@ public class CustomMOTD extends JavaPlugin { counter = 0; counter = counterfile.getInt("counter"); loadmotd(motdfile.getString("MOTD")); - //getLogger().info("setting MOTD to - " + motdfile.getString("MOTD")); - //getLogger().info("setting Counter to - " + counter); Options = ""; for(String line : this.getConfig().getKeys(false)) { @@ -154,13 +146,10 @@ public class CustomMOTD extends JavaPlugin { public void setmotd(String motdname) { if(motdname.equalsIgnoreCase("default") || motdname.equalsIgnoreCase("mcmmo")) { - //getLogger().info("MOTD - Checking for MCMMO counter: " + counter); if(counter > 0) { getLogger().info(" - Activating mcmmo MOTD"); List lines = this.colorList(this.getConfig().getStringList("mcmmo")); - //getLogger().info(lines.get(0) + "\n" + lines.get(1)); motd = lines; - //motd = this.getConfig().getStringList(motd + ".LINES"); motdfile.set("MOTD", "default"); motdfile.save(); motdfile.reload(); @@ -168,9 +157,7 @@ public class CustomMOTD extends JavaPlugin { } else { List lines = this.colorList(this.getConfig().getStringList(motdname)); - //getLogger().info(lines.get(0) + "\n" + lines.get(1)); motd = lines; - //motd = this.getConfig().getStringList(motd + ".LINES"); motdfile.set("MOTD", "default"); motdfile.save(); motdfile.reload(); @@ -179,9 +166,7 @@ public class CustomMOTD extends JavaPlugin { } else { List lines = this.colorList(this.getConfig().getStringList(motdname)); - //getLogger().info(lines.get(0) + "\n" + lines.get(1)); motd = lines; - //motd = this.getConfig().getStringList(motd + ".LINES"); motdfile.set("MOTD", motdname); motdfile.save(); motdfile.reload(); @@ -227,6 +212,6 @@ public class CustomMOTD extends JavaPlugin { private void registerCommands() { // TODO add all commands getCommand("custommotd").setExecutor(new custommotdCommand()); - //getCommand("customicon").setExecutor(new customIconCommand()); } + } \ No newline at end of file diff --git a/src/main/java/com/alttd/destro174/custommotd/commands/custommotdCommand.java b/src/main/java/com/alttd/destro174/custommotd/commands/custommotdCommand.java index bad16f2..64d1d4a 100644 --- a/src/main/java/com/alttd/destro174/custommotd/commands/custommotdCommand.java +++ b/src/main/java/com/alttd/destro174/custommotd/commands/custommotdCommand.java @@ -74,30 +74,4 @@ public class custommotdCommand implements CommandExecutor/*, TabCompleter*/ { return false; } - /*@Override - public List onTabComplete(CommandSender sender, Command cmd, String label, String[] args) { - List completions = new ArrayList<>(); - List commands = new ArrayList<>(); - - if(args.length == 1) { - commands.add("set"); - commands.add("reload"); - commands.add("counter"); - StringUtil.copyPartialMatches(args[0], commands, completions); - } - if(args.length == 2) { - if (args[0].equals("set")) { - completions = CustomMOTD.getmotdlist().stream() - .filter(wrapper -> !wrapper.isRestricted()) - .map(wrapper -> wrapper.getTitle()) - .collect(Collectors.toList()); - } else if (args[0].equals("counter")) { - commands.add("up"); - commands.add("down"); - StringUtil.copyPartialMatches(args[1], commands, completions); - } - } - return completions; - }*/ - } \ No newline at end of file diff --git a/src/main/java/com/alttd/destro174/custommotd/listener/PingListener.java b/src/main/java/com/alttd/destro174/custommotd/listener/PingListener.java index b3f56f9..6c7cfcc 100644 --- a/src/main/java/com/alttd/destro174/custommotd/listener/PingListener.java +++ b/src/main/java/com/alttd/destro174/custommotd/listener/PingListener.java @@ -1,8 +1,6 @@ package com.alttd.destro174.custommotd.listener; import com.alttd.destro174.custommotd.CustomMOTD; -import com.alttd.destro174.custommotd.MotdWrapper; -import org.bukkit.ChatColor; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.server.ServerListPingEvent; @@ -16,64 +14,4 @@ public class PingListener implements Listener { event.setMotd(CustomMOTD.motd.get(0) + "\n" + CustomMOTD.motd.get(1)); } - /*private List colorList(List list){ - List lines = new ArrayList(); - - for (String s : list) { - lines.add(ChatColor.translateAlternateColorCodes('&', s)); - } - - return lines; - }*/ - - /*@EventHandler - public void onPing(ServerListPingEvent event) { - //event.setMotd(instance.getActiveMotd()); - for(MotdWrapper wrapper : CustomMOTD.getmotdlist()) { - if(wrapper.getTitle().equalsIgnoreCase("default")) { - event.setMotd(ChatColor.translateAlternateColorCodes('&', - centerText(wrapper.getLine1(), 60) - + "\n" + centerText(wrapper.getLine2(), 60) - )); - } - } - - }*/ - - // lineLength = 80 (Chat Length) - // lineLength = 45 (MOTD Length) - public String centerText(String text, int lineLength) { - char[] chars = text.toCharArray(); // Get a list of all characters in text - boolean isBold = false; - double length = 0; - ChatColor pholder = null; - for (int i = 0; i < chars.length; i++) { // Loop through all characters - // Check if the character is a ColorCode.. - if (chars[i] == '&' && chars.length != (i + 1) && (pholder = ChatColor.getByChar(chars[i + 1])) != null) { - if (pholder != ChatColor.UNDERLINE && pholder != ChatColor.ITALIC - && pholder != ChatColor.STRIKETHROUGH && pholder != ChatColor.MAGIC) { - isBold = (chars[i + 1] == 'l'); // Setting bold to true or false, depending on if the ChatColor is Bold. - length--; // Removing one from the length, of the string, because we don't wanna count color codes. - i += isBold ? 1 : 0; - } - } else { - // If the character is not a color code: - length++; // Adding a space - length += (isBold ? (chars[i] != ' ' ? 0.1555555555555556 : 0) : 0); // Adding 0.156 spaces if the character is bold. - } - } - - double spaces = (lineLength - length) / 3; // Getting the spaces to add by (max line length - length) / 2 - - // Adding the spaces - StringBuilder builder = new StringBuilder(); - for (int i = 0; i < spaces; i++) { - builder.append(' '); - } - String copy = builder.toString(); - builder.append(text).append(copy); - - return builder.toString(); - } - } \ No newline at end of file