Adding the names sub-command.

This commit is contained in:
Kristian S. Stangeland 2012-11-03 06:54:31 +01:00
parent 27104c7350
commit 72bfa3da9b
2 changed files with 13 additions and 3 deletions

View File

@ -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<Integer> 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.");
}

View File

@ -15,7 +15,7 @@ commands:
permission-message: You don't have <permission>
packet:
description: Add or remove a simple packet listener.
usage: /<command> add|remove client|server [ID start]-[ID stop] [detailed]
usage: /<command> add|remove|names client|server [ID start]-[ID stop] [detailed]
permission: experiencemod.admin
permission-message: You don't have <permission>