diff options
author | EvilSeph <evilseph@unaligned.org> | 2011-02-05 04:30:18 -0500 |
---|---|---|
committer | EvilSeph <evilseph@unaligned.org> | 2011-02-05 04:30:18 -0500 |
commit | d167abe6d73eda182429cc4fc0c59496333f844b (patch) | |
tree | d0915f147f8a93ec5620b3b876b33d74338e21e4 /src | |
parent | 84f05ff32b6f7b6fb3fe5206c35fc731dc92e135 (diff) | |
download | bukkit-d167abe6d73eda182429cc4fc0c59496333f844b.tar bukkit-d167abe6d73eda182429cc4fc0c59496333f844b.tar.gz bukkit-d167abe6d73eda182429cc4fc0c59496333f844b.tar.lz bukkit-d167abe6d73eda182429cc4fc0c59496333f844b.tar.xz bukkit-d167abe6d73eda182429cc4fc0c59496333f844b.zip |
Moved the plugin list display out of the version command and into the plugins command.
Version should not display a list of plugins as a server running many
plugins will no longer be able to see the version output.
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/org/bukkit/command/SimpleCommandMap.java | 57 |
1 files changed, 38 insertions, 19 deletions
diff --git a/src/main/java/org/bukkit/command/SimpleCommandMap.java b/src/main/java/org/bukkit/command/SimpleCommandMap.java index 01452b69..20216503 100644 --- a/src/main/java/org/bukkit/command/SimpleCommandMap.java +++ b/src/main/java/org/bukkit/command/SimpleCommandMap.java @@ -24,6 +24,7 @@ public final class SimpleCommandMap implements CommandMap { private void setDefaultCommands(final Server server) { register("bukkit", new VersionCommand("version", server)); register("bukkit", new ReloadCommand("reload", server)); + register("bukkit", new PluginsCommand("plugins",server)); } /** @@ -102,7 +103,6 @@ public final class SimpleCommandMap implements CommandMap { sender.sendMessage("This server is running " + ChatColor.GREEN + server.getName() + ChatColor.WHITE + " version " + ChatColor.GREEN + server.getVersion()); sender.sendMessage("This server is also sporting some funky dev build of Bukkit!"); - sender.sendMessage("Plugins: " + getPluginList()); } else { StringBuilder name = new StringBuilder(); @@ -136,30 +136,13 @@ public final class SimpleCommandMap implements CommandMap { } } else { sender.sendMessage("This server is not running any plugin by that name."); - sender.sendMessage("Plugins: " + getPluginList()); + sender.sendMessage("Use /plugins to get a list of plugins."); } } return true; } - private String getPluginList() { - StringBuilder pluginList = new StringBuilder(); - Plugin[] plugins = server.getPluginManager().getPlugins(); - - for (Plugin plugin : plugins) { - if (pluginList.length() > 0) { - pluginList.append(ChatColor.WHITE); - pluginList.append(", "); - } - - pluginList.append(ChatColor.GREEN); - pluginList.append(plugin.getDescription().getName()); - } - - return pluginList.toString(); - } - private String getAuthors(final PluginDescriptionFile desc) { StringBuilder result = new StringBuilder(); ArrayList<String> authors = desc.getAuthors(); @@ -206,4 +189,40 @@ public final class SimpleCommandMap implements CommandMap { return true; } } + + private static class PluginsCommand extends Command { + + private final Server server; + + public PluginsCommand(String name, Server server) { + super(name); + this.server = server; + this.tooltip = "Gets a list of plugins running on the server"; + this.usageMessage = "/plugins"; + this.setAliases(Arrays.asList("pl")); + } + + @Override + public boolean execute(CommandSender sender, String currentAlias, String[] args) { + sender.sendMessage("Plugins: " + getPluginList()); + return true; + } + + private String getPluginList() { + StringBuilder pluginList = new StringBuilder(); + Plugin[] plugins = server.getPluginManager().getPlugins(); + + for (Plugin plugin : plugins) { + if (pluginList.length() > 0) { + pluginList.append(ChatColor.WHITE); + pluginList.append(", "); + } + + pluginList.append(ChatColor.GREEN); + pluginList.append(plugin.getDescription().getName()); + } + + return pluginList.toString(); + } + } }
\ No newline at end of file |