Revert "Added the ability to register commands dynamically."

This reverts commit 737d6347b1d74e13191df7c521d8db30fa174c9b.
Because this is *NOT* how it should be.

By: Erik Broes <erikbroes@grum.nl>
This commit is contained in:
Bukkit/Spigot
2011-10-13 18:27:34 +02:00
parent f75105d723
commit 98583f6462
4 changed files with 3 additions and 181 deletions

View File

@@ -0,0 +1,62 @@
package org.bukkit.command;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import org.bukkit.plugin.Plugin;
public class PluginCommandYamlParser {
@SuppressWarnings("unchecked")
public static List<Command> parse(Plugin plugin) {
List<Command> pluginCmds = new ArrayList<Command>();
Object object = plugin.getDescription().getCommands();
if (object == null) {
return pluginCmds;
}
Map<String, Map<String, Object>> map = (Map<String, Map<String, Object>>) object;
if (map != null) {
for (Entry<String, Map<String, Object>> entry : map.entrySet()) {
Command newCmd = new PluginCommand(entry.getKey(), plugin);
Object description = entry.getValue().get("description");
Object usage = entry.getValue().get("usage");
Object aliases = entry.getValue().get("aliases");
Object permission = entry.getValue().get("permission");
if (description != null) {
newCmd.setDescription(description.toString());
}
if (usage != null) {
newCmd.setUsage(usage.toString());
}
if (aliases != null) {
List<String> aliasList = new ArrayList<String>();
if (aliases instanceof List) {
for (Object o : (List<Object>) aliases) {
aliasList.add(o.toString());
}
} else {
aliasList.add(aliases.toString());
}
newCmd.setAliases(aliasList);
}
if (permission != null) {
newCmd.setPermission(permission.toString());
}
pluginCmds.add(newCmd);
}
}
return pluginCmds;
}
}