Added command registration to plugin config file. Registered commands are sent to the corresponding plugin.onCommand method when executed.

By: VictorD <victor.danell@gmail.com>
This commit is contained in:
Bukkit/Spigot
2011-01-16 16:30:34 +01:00
parent c72a7064d8
commit a17e7470e8
9 changed files with 184 additions and 0 deletions

View File

@@ -17,6 +17,7 @@ public final class PluginDescriptionFile {
private String name = null;
private String main = null;
private String version = null;
private Object commands = null;
@SuppressWarnings("unchecked")
public PluginDescriptionFile(final InputStream stream) throws InvalidDescriptionException {
@@ -79,6 +80,10 @@ public final class PluginDescriptionFile {
public String getMain() {
return main;
}
public Object getCommands() {
return commands;
}
private void loadMap(Map<String, Object> map) throws InvalidDescriptionException {
try {
@@ -104,6 +109,14 @@ public final class PluginDescriptionFile {
} catch (ClassCastException ex) {
throw new InvalidDescriptionException(ex, "main is of wrong type");
}
try {
commands = map.get("commands");
} catch (NullPointerException ex) {
throw new InvalidDescriptionException(ex, "command is not defined");
} catch (ClassCastException ex) {
throw new InvalidDescriptionException(ex, "command is of wrong type");
}
}
private Map<String, Object> saveMap() {
@@ -111,6 +124,7 @@ public final class PluginDescriptionFile {
map.put("name", name);
map.put("main", main);
map.put("version", version);
map.put("command", commands);
return map;
}
}