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 { public static List parse(Plugin plugin) { List pluginCmds = new ArrayList(); Object object = plugin.getDescription().getCommands(); if (object == null) return pluginCmds; @SuppressWarnings("unchecked") Map> map = (Map>)object; if (map != null) { for(Entry> 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"); if (description != null) newCmd.setTooltip(description.toString()); if (usage != null) { newCmd.setUsage(usage.toString()); } if (aliases != null) { List aliasList = new ArrayList(); for(String a : aliases.toString().split(",")) { aliasList.add(a); } newCmd.setAliases(aliasList); } pluginCmds.add(newCmd); } } return pluginCmds; } }