From 3d868d47005840e5d458b3fa156f5abb3245a6a4 Mon Sep 17 00:00:00 2001 From: Mike Primm Date: Thu, 8 Sep 2011 22:02:32 -0500 Subject: [PATCH] Add hide-by-default attribute to marker sets, /dmarker updateset --- .../java/org/dynmap/markers/MarkerSet.java | 10 ++++ .../dynmap/markers/impl/MarkerAPIImpl.java | 55 +++++++++++++++++-- .../dynmap/markers/impl/MarkerSetImpl.java | 17 +++++- src/main/resources/configuration.txt | 2 - src/main/resources/plugin.yml | 4 ++ web/js/markers.js | 5 +- 6 files changed, 84 insertions(+), 9 deletions(-) diff --git a/src/main/java/org/dynmap/markers/MarkerSet.java b/src/main/java/org/dynmap/markers/MarkerSet.java index 9cdca429..5409517b 100644 --- a/src/main/java/org/dynmap/markers/MarkerSet.java +++ b/src/main/java/org/dynmap/markers/MarkerSet.java @@ -86,4 +86,14 @@ public interface MarkerSet { * Delete marker set */ public void deleteMarkerSet(); + /** + * Set hide/show default + * @param hide - if true, layer for set will be hidden by default + */ + public void setHideByDefault(boolean hide); + /** + * Get hide/show default + * @return true if layer for set will be hidden by default + */ + public boolean getHideByDefault(); } diff --git a/src/main/java/org/dynmap/markers/impl/MarkerAPIImpl.java b/src/main/java/org/dynmap/markers/impl/MarkerAPIImpl.java index 80266849..14f263a1 100644 --- a/src/main/java/org/dynmap/markers/impl/MarkerAPIImpl.java +++ b/src/main/java/org/dynmap/markers/impl/MarkerAPIImpl.java @@ -123,9 +123,11 @@ public class MarkerAPIImpl implements MarkerAPI, Event.Listener { /* Load persistence */ api.loadMarkers(); /* Initialize default marker set, if needed */ - if(api.getMarkerSet(MarkerSet.DEFAULT) == null) { - api.createMarkerSet(MarkerSet.DEFAULT, "Markers", null, true); + MarkerSet set = api.getMarkerSet(MarkerSet.DEFAULT); + if(set == null) { + set = api.createMarkerSet(MarkerSet.DEFAULT, "Markers", null, true); } + /* Build paths for markers */ api.markerdir = new File(plugin.getDataFolder(), "markers"); if(api.markerdir.isDirectory() == false) { @@ -404,7 +406,7 @@ public class MarkerAPIImpl implements MarkerAPI, Event.Listener { } private static final Set commands = new HashSet(Arrays.asList(new String[] { - "add", "movehere", "update", "delete", "list", "icons", "addset", "deleteset", "listsets", "addicon" + "add", "movehere", "update", "delete", "list", "icons", "addset", "updateset", "deleteset", "listsets", "addicon" })); /* Parse argument strings : handle 'attrib:value' and quoted strings */ @@ -708,6 +710,9 @@ public class MarkerAPIImpl implements MarkerAPI, Event.Listener { sender.sendMessage("Error creating marker set"); } else { + String h = parms.get("hide"); + if((h != null) && (h.equals("true"))) + set.setHideByDefault(true); sender.sendMessage("Added marker set id:'" + set.getMarkerSetID() + "' (" + set.getMarkerSetLabel() + ")"); } } @@ -715,6 +720,47 @@ public class MarkerAPIImpl implements MarkerAPI, Event.Listener { sender.sendMessage("