mirror of
https://github.com/webbukkit/dynmap.git
synced 2024-11-25 03:35:18 +01:00
Add /dmarker addicon command
This commit is contained in:
parent
009c3a9429
commit
8a4e1ebfc2
@ -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", "addset", "deleteset", "listsets"
|
"add", "movehere", "update", "delete", "list", "icons", "addset", "deleteset", "listsets", "addicon"
|
||||||
}));
|
}));
|
||||||
|
|
||||||
/* Parse argument strings : handle 'attrib:value' and quoted strings */
|
/* Parse argument strings : handle 'attrib:value' and quoted strings */
|
||||||
@ -760,6 +760,51 @@ public class MarkerAPIImpl implements MarkerAPI, Event.Listener<DynmapWorld> {
|
|||||||
sender.sendMessage(set.getMarkerSetID() + ": label:\"" + set.getMarkerSetLabel() + "\"");
|
sender.sendMessage(set.getMarkerSetID() + ": label:\"" + set.getMarkerSetLabel() + "\"");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/* Add new icon */
|
||||||
|
else if(c.equals("addicon") && plugin.checkPlayerPermission(sender, "marker.addicon")) {
|
||||||
|
if(args.length > 1) {
|
||||||
|
/* Parse arguements */
|
||||||
|
Map<String,String> parms = parseArgs(args, sender);
|
||||||
|
if(parms == null) return true;
|
||||||
|
if(parms.get("id") == null) {
|
||||||
|
sender.sendMessage("id:<icon-id> required");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if(parms.get("file") == null) {
|
||||||
|
sender.sendMessage("file:\"filename\" required");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
String id = parms.get("id");
|
||||||
|
if(parms.get("label") == null)
|
||||||
|
parms.put("label", id);
|
||||||
|
MarkerIcon ico = api.getMarkerIcon(id);
|
||||||
|
if(ico != null) {
|
||||||
|
sender.sendMessage("Icon '" + id + "' already defined.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
/* Open stream to filename */
|
||||||
|
File iconf = new File(parms.get("file"));
|
||||||
|
FileInputStream fis = null;
|
||||||
|
try {
|
||||||
|
fis = new FileInputStream(iconf);
|
||||||
|
/* Create new icon */
|
||||||
|
MarkerIcon mi = api.createMarkerIcon(parms.get("id"), parms.get("label"), fis);
|
||||||
|
if(mi == null) {
|
||||||
|
sender.sendMessage("Error creating icon");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
} catch (IOException iox) {
|
||||||
|
sender.sendMessage("Error loading icon file - " + iox);
|
||||||
|
} finally {
|
||||||
|
if(fis != null) {
|
||||||
|
try { fis.close(); } catch (IOException iox) {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
sender.sendMessage("id:<set-id> and file:\"filename\" required");
|
||||||
|
}
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -40,6 +40,7 @@ commands:
|
|||||||
/<command> deleteset <label> - delete marker set with given label
|
/<command> deleteset <label> - delete marker set with given label
|
||||||
/<command> deleteset id:<id> - delete marker set with given ID
|
/<command> deleteset id:<id> - delete marker set with given ID
|
||||||
/<command> listsets - list all marker sets
|
/<command> listsets - list all marker sets
|
||||||
|
/<command> addicon id:<id> <label> file:"filename" - install new icon
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
dynmap.*:
|
dynmap.*:
|
||||||
@ -67,6 +68,7 @@ permissions:
|
|||||||
dynmap.marker.addset: true
|
dynmap.marker.addset: true
|
||||||
dynmap.marker.deleteset: true
|
dynmap.marker.deleteset: true
|
||||||
dynmap.marker.listsets: true
|
dynmap.marker.listsets: true
|
||||||
|
dynmap.marker.addicon: true
|
||||||
dynmap.render:
|
dynmap.render:
|
||||||
description: Allows /dynmap render command
|
description: Allows /dynmap render command
|
||||||
default: true
|
default: true
|
||||||
@ -130,4 +132,7 @@ permissions:
|
|||||||
dynmap.marker.listsets:
|
dynmap.marker.listsets:
|
||||||
description: Allows /dmarker listsets
|
description: Allows /dmarker listsets
|
||||||
default: true
|
default: true
|
||||||
|
dynmap.marker.addicon:
|
||||||
|
description: Allows /dmarker addicon
|
||||||
|
default: op
|
||||||
|
|
Loading…
Reference in New Issue
Block a user