Add marker set commands - addset, deleteset, listsets

This commit is contained in:
Mike Primm 2011-09-06 14:13:37 +08:00 committed by mikeprimm
parent 7bee1dcae5
commit e7f30153b8
2 changed files with 97 additions and 1 deletions

View File

@ -404,7 +404,7 @@ public class MarkerAPIImpl implements MarkerAPI, Event.Listener<DynmapWorld> {
} }
private static final Set<String> commands = new HashSet<String>(Arrays.asList(new String[] { private static final Set<String> commands = new HashSet<String>(Arrays.asList(new String[] {
"add", "movehere", "update", "delete", "list", "icons" "add", "movehere", "update", "delete", "list", "icons", "addset", "deleteset", "listsets"
})); }));
/* Parse argument strings : handle 'attrib:value' and quoted strings */ /* Parse argument strings : handle 'attrib:value' and quoted strings */
@ -683,6 +683,83 @@ public class MarkerAPIImpl implements MarkerAPI, Event.Listener<DynmapWorld> {
sender.sendMessage(ico.getMarkerIconID() + ": label:\"" + ico.getMarkerIconLabel() + "\", builtin:" + ico.isBuiltIn()); sender.sendMessage(ico.getMarkerIconID() + ": label:\"" + ico.getMarkerIconLabel() + "\", builtin:" + ico.isBuiltIn());
} }
} }
else if(c.equals("addset") && plugin.checkPlayerPermission(sender, "marker.addset")) {
if(args.length > 1) {
/* Parse arguements */
Map<String,String> parms = parseArgs(args, sender);
if(parms == null) return true;
if((parms.get("id") == null) && (parms.get("label") == null)) {
sender.sendMessage("<label> or id:<marker-id> required");
return true;
}
if(parms.get("label") == null)
parms.put("label", parms.get("id"));
if(parms.get("id") == null)
parms.put("id", parms.get("label"));
/* See if marker set exists */
MarkerSet set = api.getMarkerSet(parms.get("id"));
if(set != null) {
sender.sendMessage("Error: set already exists - id:" + set.getMarkerSetID());
return true;
}
/* Create new set */
set = api.createMarkerSet(parms.get("id"), parms.get("label"), null, true);
if(set == null) {
sender.sendMessage("Error creating marker set");
}
else {
sender.sendMessage("Added marker set id:'" + set.getMarkerSetID() + "' (" + set.getMarkerSetLabel() + ")");
}
}
else {
sender.sendMessage("<label> or id:<set-id> required");
}
}
else if(c.equals("deleteset") && plugin.checkPlayerPermission(sender, "marker.deleteset")) {
if(args.length > 1) {
/* Parse arguements */
Map<String,String> parms = parseArgs(args, sender);
if(parms == null) return true;
if((parms.get("id") == null) && (parms.get("label") == null)) {
sender.sendMessage("<label> or id:<marker-id> required");
return true;
}
if(parms.get("id") != null) {
MarkerSet set = api.getMarkerSet(parms.get("id"));
if(set == null) {
sender.sendMessage("Error: set does not exist - id:" + set.getMarkerSetID());
return true;
}
set.deleteMarkerSet();
}
else {
Set<MarkerSet> sets = api.getMarkerSets();
MarkerSet set = null;
for(MarkerSet s : sets) {
if(s.getMarkerSetLabel().equals(parms.get("label"))) {
set = s;
break;
}
}
if(set == null) {
sender.sendMessage("Error: matching set not found");
return true;
}
set.deleteMarkerSet();
}
sender.sendMessage("Deleted marker set");
}
else {
sender.sendMessage("<label> or id:<set-id> required");
}
}
/* List sets */
else if(c.equals("listsets") && plugin.checkPlayerPermission(sender, "marker.listsets")) {
Set<MarkerSet> sets = api.getMarkerSets();
for(MarkerSet set : sets) {
sender.sendMessage(set.getMarkerSetID() + ": label:\"" + set.getMarkerSetLabel() + "\"");
}
}
else { else {
return false; return false;
} }

View File

@ -35,6 +35,11 @@ commands:
/<command> delete id:<id> - delete marker with given ID /<command> delete id:<id> - delete marker with given ID
/<command> list - list details of all markers /<command> list - list details of all markers
/<command> icons - list details of all icons /<command> icons - list details of all icons
/<command> addset <label> - add marker set with given label (ID=label)
/<command> addset id:<id> <label> - add marker set with given ID and label
/<command> deleteset <label> - delete marker set with given label
/<command> deleteset id:<id> - delete marker set with given ID
/<command> listsets - list all marker sets
permissions: permissions:
dynmap.*: dynmap.*:
@ -59,6 +64,9 @@ permissions:
dynmap.marker.list: true dynmap.marker.list: true
dynmap.marker.icons: true dynmap.marker.icons: true
dynmap.marker.sign: true dynmap.marker.sign: true
dynmap.marker.addset: true
dynmap.marker.deleteset: true
dynmap.marker.listsets: true
dynmap.render: dynmap.render:
description: Allows /dynmap render command description: Allows /dynmap render command
default: true default: true
@ -106,9 +114,20 @@ permissions:
default: op default: op
dynmap.marker.list: dynmap.marker.list:
description: Allows /dmarker list description: Allows /dmarker list
default: true
dynmap.marker.icons: dynmap.marker.icons:
description: Allows /dmarker icons description: Allows /dmarker icons
default: true
dynmap.marker.sign: dynmap.marker.sign:
description: Allows creation of markers using signs description: Allows creation of markers using signs
default: op default: op
dynmap.marker.addset:
description: Allows /dmarker addset
default: op
dynmap.marker.deleteset:
description: Allows /dmarker deleteset
default: op
dynmap.marker.listsets:
description: Allows /dmarker listsets
default: true