summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWesley Wolfe <weswolf@aol.com>2012-09-28 03:01:40 -0500
committerWesley Wolfe <weswolf@aol.com>2012-09-28 16:50:32 -0500
commitb23edfd2d3f86b27d8b57d82830a64a94372906a (patch)
tree3a993db0e59ac226bc6fedea4713e465edabca3c
parent370274bf55e2e5788948ac275d11b8a56b225c6f (diff)
downloadbukkit-b23edfd2d3f86b27d8b57d82830a64a94372906a.tar
bukkit-b23edfd2d3f86b27d8b57d82830a64a94372906a.tar.gz
bukkit-b23edfd2d3f86b27d8b57d82830a64a94372906a.tar.lz
bukkit-b23edfd2d3f86b27d8b57d82830a64a94372906a.tar.xz
bukkit-b23edfd2d3f86b27d8b57d82830a64a94372906a.zip
Let version print partial matches for plugin name. Addresses BUKKIT-2383
If no plugin is found with the given name, the version command will search all loaded plugins to find a case insensitive partial match for the specified name and print to the sender all matches.
-rw-r--r--src/main/java/org/bukkit/command/defaults/VersionCommand.java55
1 files changed, 35 insertions, 20 deletions
diff --git a/src/main/java/org/bukkit/command/defaults/VersionCommand.java b/src/main/java/org/bukkit/command/defaults/VersionCommand.java
index 4dc7a076..4d3ba15b 100644
--- a/src/main/java/org/bukkit/command/defaults/VersionCommand.java
+++ b/src/main/java/org/bukkit/command/defaults/VersionCommand.java
@@ -5,7 +5,6 @@ import java.util.List;
import org.bukkit.ChatColor;
import org.bukkit.Bukkit;
-import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginDescriptionFile;
@@ -37,28 +36,23 @@ public class VersionCommand extends BukkitCommand {
name.append(arg);
}
- Plugin plugin = Bukkit.getPluginManager().getPlugin(name.toString());
-
- if (plugin != null) {
- PluginDescriptionFile desc = plugin.getDescription();
- sender.sendMessage(ChatColor.GREEN + desc.getName() + ChatColor.WHITE + " version " + ChatColor.GREEN + desc.getVersion());
-
- if (desc.getDescription() != null) {
- sender.sendMessage(desc.getDescription());
- }
+ String pluginName = name.toString();
+ Plugin exactPlugin = Bukkit.getPluginManager().getPlugin(pluginName);
+ if (exactPlugin != null) {
+ describeToSender(exactPlugin, sender);
+ return true;
+ }
- if (desc.getWebsite() != null) {
- sender.sendMessage("Website: " + ChatColor.GREEN + desc.getWebsite());
+ boolean found = false;
+ pluginName = pluginName.toLowerCase();
+ for (Plugin plugin : Bukkit.getPluginManager().getPlugins()) {
+ if (plugin.getName().toLowerCase().contains(pluginName)) {
+ describeToSender(plugin, sender);
+ found = true;
}
+ }
- if (!desc.getAuthors().isEmpty()) {
- if (desc.getAuthors().size() == 1) {
- sender.sendMessage("Author: " + getAuthors(desc));
- } else {
- sender.sendMessage("Authors: " + getAuthors(desc));
- }
- }
- } else {
+ if (!found) {
sender.sendMessage("This server is not running any plugin by that name.");
sender.sendMessage("Use /plugins to get a list of plugins.");
}
@@ -66,6 +60,27 @@ public class VersionCommand extends BukkitCommand {
return true;
}
+ private void describeToSender(Plugin plugin, CommandSender sender) {
+ PluginDescriptionFile desc = plugin.getDescription();
+ sender.sendMessage(ChatColor.GREEN + desc.getName() + ChatColor.WHITE + " version " + ChatColor.GREEN + desc.getVersion());
+
+ if (desc.getDescription() != null) {
+ sender.sendMessage(desc.getDescription());
+ }
+
+ if (desc.getWebsite() != null) {
+ sender.sendMessage("Website: " + ChatColor.GREEN + desc.getWebsite());
+ }
+
+ if (!desc.getAuthors().isEmpty()) {
+ if (desc.getAuthors().size() == 1) {
+ sender.sendMessage("Author: " + getAuthors(desc));
+ } else {
+ sender.sendMessage("Authors: " + getAuthors(desc));
+ }
+ }
+ }
+
private String getAuthors(final PluginDescriptionFile desc) {
StringBuilder result = new StringBuilder();
List<String> authors = desc.getAuthors();