From 72bfa3da9b299d9088766aff32a39679b3fc31bb Mon Sep 17 00:00:00 2001 From: "Kristian S. Stangeland" Date: Sat, 3 Nov 2012 06:54:31 +0100 Subject: [PATCH] Adding the names sub-command. --- .../java/com/comphenix/protocol/CommandPacket.java | 14 ++++++++++++-- ProtocolLib/src/main/resources/plugin.yml | 2 +- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/CommandPacket.java b/ProtocolLib/src/main/java/com/comphenix/protocol/CommandPacket.java index c185d42e..9c735a92 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/CommandPacket.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/CommandPacket.java @@ -47,7 +47,7 @@ class CommandPacket implements CommandExecutor { } private enum SubCommand { - ADD, REMOVE; + ADD, REMOVE, NAMES; } /** @@ -202,7 +202,15 @@ class CommandPacket implements CommandExecutor { } sendMessageSilently(sender, ChatColor.BLUE + "Fully removed " + count + " listeners."); - } + } else if (subCommand == SubCommand.NAMES) { + + // Print the equivalent name of every given ID + for (Range range : ranges) { + for (int id : range.asSet(DiscreteDomains.integers())) { + sendMessageSilently(sender, ChatColor.BLUE + "" + id + ": " + Packets.getDeclaredName(id)); + } + } + } } catch (NumberFormatException e) { sendMessageSilently(sender, ChatColor.RED + "Cannot parse number: " + e.getMessage()); @@ -489,6 +497,8 @@ class CommandPacket implements CommandExecutor { return SubCommand.ADD; else if ("remove".startsWith(text)) return SubCommand.REMOVE; + else if ("names".startsWith(text)) + return SubCommand.NAMES; else throw new IllegalArgumentException(text + " is not a valid sub command. Must be add or remove."); } diff --git a/ProtocolLib/src/main/resources/plugin.yml b/ProtocolLib/src/main/resources/plugin.yml index 6088ff69..5089f4d8 100644 --- a/ProtocolLib/src/main/resources/plugin.yml +++ b/ProtocolLib/src/main/resources/plugin.yml @@ -15,7 +15,7 @@ commands: permission-message: You don't have packet: description: Add or remove a simple packet listener. - usage: / add|remove client|server [ID start]-[ID stop] [detailed] + usage: / add|remove|names client|server [ID start]-[ID stop] [detailed] permission: experiencemod.admin permission-message: You don't have