mirror of
https://github.com/webbukkit/dynmap.git
synced 2024-11-08 03:29:43 +01:00
Add marker set commands - addset, deleteset, listsets
This commit is contained in:
parent
7bee1dcae5
commit
e7f30153b8
@ -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[] {
|
||||
"add", "movehere", "update", "delete", "list", "icons"
|
||||
"add", "movehere", "update", "delete", "list", "icons", "addset", "deleteset", "listsets"
|
||||
}));
|
||||
|
||||
/* 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());
|
||||
}
|
||||
}
|
||||
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 {
|
||||
return false;
|
||||
}
|
||||
|
@ -35,6 +35,11 @@ commands:
|
||||
/<command> delete id:<id> - delete marker with given ID
|
||||
/<command> list - list details of all markers
|
||||
/<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:
|
||||
dynmap.*:
|
||||
@ -59,6 +64,9 @@ permissions:
|
||||
dynmap.marker.list: true
|
||||
dynmap.marker.icons: true
|
||||
dynmap.marker.sign: true
|
||||
dynmap.marker.addset: true
|
||||
dynmap.marker.deleteset: true
|
||||
dynmap.marker.listsets: true
|
||||
dynmap.render:
|
||||
description: Allows /dynmap render command
|
||||
default: true
|
||||
@ -106,9 +114,20 @@ permissions:
|
||||
default: op
|
||||
dynmap.marker.list:
|
||||
description: Allows /dmarker list
|
||||
default: true
|
||||
dynmap.marker.icons:
|
||||
description: Allows /dmarker icons
|
||||
default: true
|
||||
dynmap.marker.sign:
|
||||
description: Allows creation of markers using signs
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user