From bb23655af8f9539c764b3c8cb19d979f7e3f4f84 Mon Sep 17 00:00:00 2001 From: Auxilor Date: Wed, 3 Mar 2021 14:23:40 +0000 Subject: [PATCH] Changed /ecodebug to only send the held item - /ecodebug full now sends full output --- .../command/commands/CommandEcodebug.java | 167 ++++++++++-------- 1 file changed, 89 insertions(+), 78 deletions(-) diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/command/commands/CommandEcodebug.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/command/commands/CommandEcodebug.java index 5381d8e6..a88f5a2f 100644 --- a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/command/commands/CommandEcodebug.java +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/command/commands/CommandEcodebug.java @@ -37,92 +37,103 @@ public class CommandEcodebug extends AbstractCommand { @Override public void onExecute(@NotNull final CommandSender sender, @NotNull final List args) { - Bukkit.getLogger().info("--------------- BEGIN DEBUG ----------------"); - if (sender instanceof Player) { - Player player = (Player) sender; - player.sendMessage("Held Item: " + player.getInventory().getItemInMainHand().toString()); + if (!args.isEmpty() && args.get(0).equalsIgnoreCase("full")) { + Bukkit.getLogger().info("--------------- BEGIN DEBUG ----------------"); + if (sender instanceof Player) { + Player player = (Player) sender; + player.sendMessage("Held Item: " + player.getInventory().getItemInMainHand().toString()); + Bukkit.getLogger().info(""); + + Bukkit.getLogger().info("Held Item: " + player.getInventory().getItemInMainHand().toString()); + Bukkit.getLogger().info(""); + } + + Bukkit.getLogger().info("Running Version: " + this.getPlugin().getDescription().getVersion()); Bukkit.getLogger().info(""); - Bukkit.getLogger().info("Held Item: " + player.getInventory().getItemInMainHand().toString()); + Bukkit.getLogger().info("Loaded Extensions: " + this.getPlugin().getExtensionLoader().getLoadedExtensions().stream() + .map(extension -> extension.getName() + " v" + extension.getVersion()) + .collect(Collectors.joining())); Bukkit.getLogger().info(""); - } - Bukkit.getLogger().info("Running Version: " + this.getPlugin().getDescription().getVersion()); - Bukkit.getLogger().info(""); + Bukkit.getLogger().info("EcoEnchants.getAll(): " + EcoEnchants.values().toString()); + Bukkit.getLogger().info(""); - Bukkit.getLogger().info("Loaded Extensions: " + this.getPlugin().getExtensionLoader().getLoadedExtensions().stream() - .map(extension -> extension.getName() + " v" + extension.getVersion()) - .collect(Collectors.joining())); - Bukkit.getLogger().info(""); + Bukkit.getLogger().info("Enchantment.values(): " + Arrays.toString(Enchantment.values())); + Bukkit.getLogger().info(""); - Bukkit.getLogger().info("EcoEnchants.getAll(): " + EcoEnchants.values().toString()); - Bukkit.getLogger().info(""); + Bukkit.getLogger().info("Enchantment Cache: " + EnchantmentCache.getCache().toString()); + Bukkit.getLogger().info(""); - Bukkit.getLogger().info("Enchantment.values(): " + Arrays.toString(Enchantment.values())); - Bukkit.getLogger().info(""); - - Bukkit.getLogger().info("Enchantment Cache: " + EnchantmentCache.getCache().toString()); - Bukkit.getLogger().info(""); - - try { - Field byNameField = Enchantment.class.getDeclaredField("byName"); - byNameField.setAccessible(true); - Map byName = (Map) byNameField.get(null); - Bukkit.getLogger().info("Enchantment.byName: " + byName.toString()); - } catch (NoSuchFieldException | IllegalAccessException e) { - e.printStackTrace(); - } - Bukkit.getLogger().info(""); - - - List extern = Arrays.stream(Enchantment.values()).collect(Collectors.toList()); - extern.removeAll(EcoEnchants.values().stream().map(EcoEnchant::getEnchantment).collect(Collectors.toList())); - extern.removeIf(enchantment -> enchantment.getClass().toString().toLowerCase().contains("craftbukkit")); - String external = extern.stream().map(enchantment -> "{" + enchantment.toString() + ", Provider: " + enchantment.getClass().toString() + "}").collect(Collectors.joining(", ")); - Bukkit.getLogger().info("External Enchantments: " + external); - Bukkit.getLogger().info(""); - - List uncached = Arrays.stream(Enchantment.values()).collect(Collectors.toList()); - uncached.removeAll(EnchantmentCache.getCache().values().stream().map(EnchantmentCache.CacheEntry::getEnchantment).collect(Collectors.toList())); - Bukkit.getLogger().info("Uncached Enchantments: " + uncached.toString()); - Bukkit.getLogger().info(""); - - List brokenCache = Arrays.stream(Enchantment.values()).collect(Collectors.toList()); - brokenCache.removeIf(enchantment -> !( - EnchantmentCache.getEntry(enchantment).getName().equalsIgnoreCase("null") - || EnchantmentCache.getEntry(enchantment).getRawName().equalsIgnoreCase("null") - || EnchantmentCache.getEntry(enchantment).getStringDescription().equalsIgnoreCase("null"))); - Bukkit.getLogger().info("Enchantments with broken cache: " + brokenCache.toString()); - Bukkit.getLogger().info(""); - - Bukkit.getLogger().info("Installed Plugins: " + Arrays.stream(Bukkit.getPluginManager().getPlugins()).map(Plugin::getName).collect(Collectors.toList()).toString()); - Bukkit.getLogger().info(""); - - Set withIssues = new HashSet<>(); - EcoEnchants.values().forEach(enchant -> { - if (enchant.getRarity() == null) { - withIssues.add(enchant); + try { + Field byNameField = Enchantment.class.getDeclaredField("byName"); + byNameField.setAccessible(true); + Map byName = (Map) byNameField.get(null); + Bukkit.getLogger().info("Enchantment.byName: " + byName.toString()); + } catch (NoSuchFieldException | IllegalAccessException e) { + e.printStackTrace(); } - if (enchant.getTargets().isEmpty()) { - withIssues.add(enchant); + Bukkit.getLogger().info(""); + + + List extern = Arrays.stream(Enchantment.values()).collect(Collectors.toList()); + extern.removeAll(EcoEnchants.values().stream().map(EcoEnchant::getEnchantment).collect(Collectors.toList())); + extern.removeIf(enchantment -> enchantment.getClass().toString().toLowerCase().contains("craftbukkit")); + String external = extern.stream().map(enchantment -> "{" + enchantment.toString() + ", Provider: " + enchantment.getClass().toString() + "}").collect(Collectors.joining(", ")); + Bukkit.getLogger().info("External Enchantments: " + external); + Bukkit.getLogger().info(""); + + List uncached = Arrays.stream(Enchantment.values()).collect(Collectors.toList()); + uncached.removeAll(EnchantmentCache.getCache().values().stream().map(EnchantmentCache.CacheEntry::getEnchantment).collect(Collectors.toList())); + Bukkit.getLogger().info("Uncached Enchantments: " + uncached.toString()); + Bukkit.getLogger().info(""); + + List brokenCache = Arrays.stream(Enchantment.values()).collect(Collectors.toList()); + brokenCache.removeIf(enchantment -> !( + EnchantmentCache.getEntry(enchantment).getName().equalsIgnoreCase("null") + || EnchantmentCache.getEntry(enchantment).getRawName().equalsIgnoreCase("null") + || EnchantmentCache.getEntry(enchantment).getStringDescription().equalsIgnoreCase("null"))); + Bukkit.getLogger().info("Enchantments with broken cache: " + brokenCache.toString()); + Bukkit.getLogger().info(""); + + Bukkit.getLogger().info("Installed Plugins: " + Arrays.stream(Bukkit.getPluginManager().getPlugins()).map(Plugin::getName).collect(Collectors.toList()).toString()); + Bukkit.getLogger().info(""); + + Set withIssues = new HashSet<>(); + EcoEnchants.values().forEach(enchant -> { + if (enchant.getRarity() == null) { + withIssues.add(enchant); + } + if (enchant.getTargets().isEmpty()) { + withIssues.add(enchant); + } + }); + Bukkit.getLogger().info("Enchantments with evident issues: " + withIssues.toString()); + Bukkit.getLogger().info(""); + + Bukkit.getLogger().info("Packets: " + ProtocolLibrary.getProtocolManager().getPacketListeners().stream() + .filter(packetListener -> packetListener.getSendingWhitelist().getPriority().equals(ListenerPriority.MONITOR)) + .collect(Collectors.toList()).toString()); + Bukkit.getLogger().info(""); + + Bukkit.getLogger().info("Server Information: "); + Bukkit.getLogger().info("Players Online: " + Bukkit.getServer().getOnlinePlayers().size()); + Bukkit.getLogger().info("Bukkit IP: " + Bukkit.getIp()); + Bukkit.getLogger().info("Running Version: " + Bukkit.getVersion() + + ", Bukkit Version: " + Bukkit.getBukkitVersion() + + ", Alt Version: " + Bukkit.getServer().getVersion() + + ", NMS: " + ProxyConstants.NMS_VERSION); + Bukkit.getLogger().info("Motd: " + Bukkit.getServer().getMotd()); + Bukkit.getLogger().info("--------------- END DEBUG ----------------"); + } else { + if (sender instanceof Player) { + Player player = (Player) sender; + player.sendMessage("Held Item: " + player.getInventory().getItemInMainHand().toString()); + Bukkit.getLogger().info(""); + + Bukkit.getLogger().info("Held Item: " + player.getInventory().getItemInMainHand().toString()); + Bukkit.getLogger().info(""); } - }); - Bukkit.getLogger().info("Enchantments with evident issues: " + withIssues.toString()); - Bukkit.getLogger().info(""); - - Bukkit.getLogger().info("Packets: " + ProtocolLibrary.getProtocolManager().getPacketListeners().stream() - .filter(packetListener -> packetListener.getSendingWhitelist().getPriority().equals(ListenerPriority.MONITOR)) - .collect(Collectors.toList()).toString()); - Bukkit.getLogger().info(""); - - Bukkit.getLogger().info("Server Information: "); - Bukkit.getLogger().info("Players Online: " + Bukkit.getServer().getOnlinePlayers().size()); - Bukkit.getLogger().info("Bukkit IP: " + Bukkit.getIp()); - Bukkit.getLogger().info("Running Version: " + Bukkit.getVersion() - + ", Bukkit Version: " + Bukkit.getBukkitVersion() - + ", Alt Version: " + Bukkit.getServer().getVersion() - + ", NMS: " + ProxyConstants.NMS_VERSION); - Bukkit.getLogger().info("Motd: " + Bukkit.getServer().getMotd()); - Bukkit.getLogger().info("--------------- END DEBUG ----------------"); + } } }