mirror of
https://github.com/webbukkit/dynmap.git
synced 2024-12-24 17:47:40 +01:00
Add support for greeting/farewell on circle markers
This commit is contained in:
parent
7c021d32c9
commit
395f45b0f9
@ -170,6 +170,16 @@ class AreaMarkerImpl implements AreaMarker, EnterExitMarker {
|
||||
bb_cache = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUniqueMarkerID() {
|
||||
if (markerset != null) {
|
||||
return markerset + ":area:" + markerid;
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMarkerID() {
|
||||
return markerid;
|
||||
|
@ -8,11 +8,13 @@ import org.dynmap.ConfigurationNode;
|
||||
import org.dynmap.DynmapWorld;
|
||||
import org.dynmap.hdmap.HDPerspective;
|
||||
import org.dynmap.markers.CircleMarker;
|
||||
import org.dynmap.markers.EnterExitMarker;
|
||||
import org.dynmap.markers.MarkerSet;
|
||||
import org.dynmap.markers.EnterExitMarker.EnterExitText;
|
||||
import org.dynmap.markers.impl.MarkerAPIImpl.MarkerUpdate;
|
||||
import org.dynmap.utils.Vector3D;
|
||||
|
||||
class CircleMarkerImpl implements CircleMarker {
|
||||
class CircleMarkerImpl implements CircleMarker, EnterExitMarker {
|
||||
private String markerid;
|
||||
private String label;
|
||||
private boolean markup;
|
||||
@ -34,6 +36,8 @@ class CircleMarkerImpl implements CircleMarker {
|
||||
private boolean boostflag = false;
|
||||
private int minzoom = -1;
|
||||
private int maxzoom = -1;
|
||||
private EnterExitText greeting;
|
||||
private EnterExitText farewell;
|
||||
|
||||
private static class BoundingBox {
|
||||
double xmin, xmax;
|
||||
@ -118,6 +122,20 @@ class CircleMarkerImpl implements CircleMarker {
|
||||
boostflag = node.getBoolean("boostFlag", false);
|
||||
minzoom = node.getInteger("minzoom", -1);
|
||||
maxzoom = node.getInteger("maxzoom", -1);
|
||||
String gt = node.getString("greeting", null);
|
||||
String gst = node.getString("greetingsub", null);
|
||||
if ((gt != null) || (gst != null)) {
|
||||
greeting = new EnterExitText();
|
||||
greeting.title = gt;
|
||||
greeting.subtitle = gst;
|
||||
}
|
||||
String ft = node.getString("farewell", null);
|
||||
String fst = node.getString("farewellsub", null);
|
||||
if ((ft != null) || (fst != null)) {
|
||||
farewell = new EnterExitText();
|
||||
farewell.title = ft;
|
||||
farewell.subtitle = fst;
|
||||
}
|
||||
|
||||
ispersistent = true; /* Loaded from config, so must be */
|
||||
|
||||
@ -129,6 +147,16 @@ class CircleMarkerImpl implements CircleMarker {
|
||||
bb_cache = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUniqueMarkerID() {
|
||||
if (markerset != null) {
|
||||
return markerset + ":circle:" + markerid;
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMarkerID() {
|
||||
return markerid;
|
||||
@ -202,6 +230,22 @@ class CircleMarkerImpl implements CircleMarker {
|
||||
if (maxzoom >= 0) {
|
||||
node.put("maxzoom", maxzoom);
|
||||
}
|
||||
if (greeting != null) {
|
||||
if (greeting.title != null) {
|
||||
node.put("greeting", greeting.title);
|
||||
}
|
||||
if (greeting.subtitle != null) {
|
||||
node.put("greetingsub", greeting.subtitle);
|
||||
}
|
||||
}
|
||||
if (farewell != null) {
|
||||
if (farewell.title != null) {
|
||||
node.put("farewell", farewell.title);
|
||||
}
|
||||
if (farewell.subtitle != null) {
|
||||
node.put("farewellsub", farewell.subtitle);
|
||||
}
|
||||
}
|
||||
return node;
|
||||
}
|
||||
@Override
|
||||
@ -450,4 +494,55 @@ class CircleMarkerImpl implements CircleMarker {
|
||||
if(ispersistent)
|
||||
MarkerAPIImpl.saveMarkers();
|
||||
}
|
||||
@Override
|
||||
public EnterExitText getGreetingText() {
|
||||
return greeting;
|
||||
}
|
||||
@Override
|
||||
public EnterExitText getFarewellText() {
|
||||
return farewell;
|
||||
}
|
||||
@Override
|
||||
public void setGreetingText(String title, String subtitle) {
|
||||
if ((title != null) || (subtitle != null)) {
|
||||
greeting = new EnterExitText();
|
||||
greeting.title = title;
|
||||
greeting.subtitle = subtitle;
|
||||
}
|
||||
else {
|
||||
greeting = null;
|
||||
}
|
||||
if (markerset != null) {
|
||||
setMarkerSet(markerset);
|
||||
}
|
||||
if(ispersistent)
|
||||
MarkerAPIImpl.saveMarkers();
|
||||
}
|
||||
@Override
|
||||
public void setFarewellText(String title, String subtitle) {
|
||||
if ((title != null) || (subtitle != null)) {
|
||||
farewell = new EnterExitText();
|
||||
farewell.title = title;
|
||||
farewell.subtitle = subtitle;
|
||||
}
|
||||
else {
|
||||
farewell = null;
|
||||
}
|
||||
if (markerset != null) {
|
||||
setMarkerSet(markerset);
|
||||
}
|
||||
if(ispersistent)
|
||||
MarkerAPIImpl.saveMarkers();
|
||||
}
|
||||
@Override
|
||||
public boolean testIfPointWithinMarker(String worldid, double x, double y, double z) {
|
||||
// Wrong world
|
||||
if (!worldid.equals(this.world)) {
|
||||
return false;
|
||||
}
|
||||
// Test if inside ellipse
|
||||
double dx = ((x - this.x) * (x - this.x)) / (xr * xr);
|
||||
double dz = ((z - this.z) * (z - this.z)) / (zr * zr);
|
||||
return (dx + dz) <= 1.0;
|
||||
}
|
||||
}
|
||||
|
@ -948,7 +948,7 @@ public class MarkerAPIImpl implements MarkerAPI, Event.Listener<DynmapWorld> {
|
||||
}
|
||||
|
||||
private static boolean processCircleArgs(DynmapCommandSender sender, CircleMarker marker, Map<String,String> parms) {
|
||||
String val = null;
|
||||
String val = null, val2 = null;
|
||||
try {
|
||||
int scolor = marker.getLineColor();
|
||||
int fcolor = marker.getFillColor();
|
||||
@ -964,6 +964,8 @@ public class MarkerAPIImpl implements MarkerAPI, Event.Listener<DynmapWorld> {
|
||||
boolean boost = marker.getBoostFlag();
|
||||
int minzoom = marker.getMinZoom();
|
||||
int maxzoom = marker.getMaxZoom();
|
||||
EnterExitText greet = marker.getGreetingText();
|
||||
EnterExitText farew = marker.getFarewellText();
|
||||
|
||||
val = parms.get(ARG_STROKECOLOR);
|
||||
if(val != null)
|
||||
@ -1026,6 +1028,23 @@ public class MarkerAPIImpl implements MarkerAPI, Event.Listener<DynmapWorld> {
|
||||
marker.setBoostFlag(boost);
|
||||
marker.setMinZoom(minzoom);
|
||||
marker.setMaxZoom(maxzoom);
|
||||
// Handle greeting
|
||||
val = parms.get(ARG_GREETING);
|
||||
val2 = parms.get(ARG_GREETINGSUB);
|
||||
if ((val != null) || (val2 != null)) {
|
||||
String title = (val != null) ? ((val.length() > 0) ? val : null) : ((greet != null) ? greet.title : null);
|
||||
String subtitle = (val2 != null) ? ((val2.length() > 0) ? val2 : null) : ((greet != null) ? greet.subtitle : null);
|
||||
marker.setGreetingText(title, subtitle);
|
||||
}
|
||||
// Handle farewell
|
||||
val = parms.get(ARG_FAREWELL);
|
||||
val2 = parms.get(ARG_FAREWELLSUB);
|
||||
if ((val != null) || (val2 != null)) {
|
||||
String title = (val != null) ? ((val.length() > 0) ? val : null) : ((farew != null) ? farew.title : null);
|
||||
String subtitle = (val2 != null) ? ((val2.length() > 0) ? val2 : null) : ((farew != null) ? farew.subtitle : null);
|
||||
marker.setFarewellText(title, subtitle);
|
||||
}
|
||||
|
||||
} catch (NumberFormatException nfx) {
|
||||
sender.sendMessage("Invalid parameter format: " + val);
|
||||
return false;
|
||||
@ -2625,7 +2644,7 @@ public class MarkerAPIImpl implements MarkerAPI, Event.Listener<DynmapWorld> {
|
||||
CircleMarker m = sortmarkers.get(s);
|
||||
String msg = m.getMarkerID() + ": label:\"" + m.getLabel() + "\", set:" + m.getMarkerSet().getMarkerSetID() +
|
||||
", world:" + m.getWorld() + ", center:" + m.getCenterX() + "/" + m.getCenterY() + "/" + m.getCenterZ() +
|
||||
", radius:" + m.getRadiusX() + "/" + m.getRadiusZ() +
|
||||
", radiusx:" + m.getRadiusX() + ", radiusz:" + m.getRadiusZ() +
|
||||
", weight: " + m.getLineWeight() + ", color:" + String.format("%06x", m.getLineColor()) +
|
||||
", opacity: " + m.getLineOpacity() + ", fillcolor: " + String.format("%06x", m.getFillColor()) +
|
||||
", fillopacity: " + m.getFillOpacity() + ", boost:" + m.getBoostFlag() + ", markup:" + m.isLabelMarkup();
|
||||
@ -2635,6 +2654,16 @@ public class MarkerAPIImpl implements MarkerAPI, Event.Listener<DynmapWorld> {
|
||||
if (m.getMaxZoom() >= 0) {
|
||||
msg += ", maxzoom:" + m.getMaxZoom();
|
||||
}
|
||||
EnterExitText t = m.getGreetingText();
|
||||
if (t != null) {
|
||||
if (t.title != null) msg += ", greeting='" + t.title + "'";
|
||||
if (t.subtitle != null) msg += ", greetingsub='" + t.subtitle + "'";
|
||||
}
|
||||
t = m.getFarewellText();
|
||||
if (t != null) {
|
||||
if (t.title != null) msg += ", farewell='" + t.title + "'";
|
||||
if (t.subtitle != null) msg += ", farewellsub='" + t.subtitle + "'";
|
||||
}
|
||||
sender.sendMessage(msg);
|
||||
}
|
||||
return true;
|
||||
|
@ -98,6 +98,16 @@ class MarkerImpl implements Marker {
|
||||
markerset = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUniqueMarkerID() {
|
||||
if (markerset != null) {
|
||||
return markerset + ":marker:" + markerid;
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMarkerID() {
|
||||
return markerid;
|
||||
|
@ -278,7 +278,7 @@ class MarkerSetImpl implements MarkerSet {
|
||||
if (enterexitmarkers == null) {
|
||||
enterexitmarkers = new ConcurrentHashMap<String, EnterExitMarker>();
|
||||
}
|
||||
enterexitmarkers.put(marker.getMarkerID(), marker);
|
||||
enterexitmarkers.put(marker.getUniqueMarkerID(), marker);
|
||||
}
|
||||
if(ispersistent && marker.isPersistentMarker()) { /* If persistent */
|
||||
MarkerAPIImpl.saveMarkers(); /* Drive save */
|
||||
@ -299,7 +299,7 @@ class MarkerSetImpl implements MarkerSet {
|
||||
}
|
||||
}
|
||||
if (enterexitmarkers != null) {
|
||||
enterexitmarkers.remove(marker.getMarkerID());
|
||||
enterexitmarkers.remove(marker.getUniqueMarkerID());
|
||||
if (enterexitmarkers.isEmpty()) {
|
||||
enterexitmarkers = null;
|
||||
}
|
||||
@ -346,6 +346,12 @@ class MarkerSetImpl implements MarkerSet {
|
||||
}
|
||||
boostingcirclemarkers.put(marker.getMarkerID(), marker);
|
||||
}
|
||||
if ((marker.getGreetingText() != null) || (marker.getFarewellText() != null)) {
|
||||
if (enterexitmarkers == null) {
|
||||
enterexitmarkers = new ConcurrentHashMap<String, EnterExitMarker>();
|
||||
}
|
||||
enterexitmarkers.put(marker.getUniqueMarkerID(), marker);
|
||||
}
|
||||
if(ispersistent && marker.isPersistentMarker()) { /* If persistent */
|
||||
MarkerAPIImpl.saveMarkers(); /* Drive save */
|
||||
}
|
||||
@ -364,6 +370,12 @@ class MarkerSetImpl implements MarkerSet {
|
||||
boostingcirclemarkers = null;
|
||||
}
|
||||
}
|
||||
if (enterexitmarkers != null) {
|
||||
enterexitmarkers.remove(marker.getUniqueMarkerID());
|
||||
if (enterexitmarkers.isEmpty()) {
|
||||
enterexitmarkers = null;
|
||||
}
|
||||
}
|
||||
if(ispersistent && marker.isPersistentMarker()) { /* If persistent */
|
||||
MarkerAPIImpl.saveMarkers(); /* Drive save */
|
||||
}
|
||||
@ -468,7 +480,7 @@ class MarkerSetImpl implements MarkerSet {
|
||||
if (enterexitmarkers == null) {
|
||||
enterexitmarkers = new ConcurrentHashMap<String, EnterExitMarker>();
|
||||
}
|
||||
enterexitmarkers.put(marker.getMarkerID(), marker);
|
||||
enterexitmarkers.put(marker.getUniqueMarkerID(), marker);
|
||||
}
|
||||
}
|
||||
else {
|
||||
@ -502,6 +514,12 @@ class MarkerSetImpl implements MarkerSet {
|
||||
}
|
||||
boostingcirclemarkers.put(id, marker);
|
||||
}
|
||||
if ((marker.getGreetingText() != null) || (marker.getFarewellText() != null)) {
|
||||
if (enterexitmarkers == null) {
|
||||
enterexitmarkers = new ConcurrentHashMap<String, EnterExitMarker>();
|
||||
}
|
||||
enterexitmarkers.put(marker.getUniqueMarkerID(), marker);
|
||||
}
|
||||
}
|
||||
else {
|
||||
Log.info("Error loading circle marker '" + id + "' for set '" + setid + "'");
|
||||
|
@ -118,6 +118,16 @@ class PolyLineMarkerImpl implements PolyLineMarker {
|
||||
markerset = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUniqueMarkerID() {
|
||||
if (markerset != null) {
|
||||
return markerset + ":poly:" + markerid;
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMarkerID() {
|
||||
return markerid;
|
||||
|
@ -3,7 +3,7 @@ package org.dynmap.markers;
|
||||
/**
|
||||
* This defines the public interface to a circle marker object, for use with the MarkerAPI
|
||||
*/
|
||||
public interface CircleMarker extends MarkerDescription {
|
||||
public interface CircleMarker extends MarkerDescription, EnterExitMarker {
|
||||
/**
|
||||
* Get center X coordinate
|
||||
* @return x coordinate
|
||||
|
@ -4,6 +4,10 @@ package org.dynmap.markers;
|
||||
* This defines the public interface to a generic marker object, for use with the MarkerAPI
|
||||
*/
|
||||
public interface GenericMarker {
|
||||
/**
|
||||
* Get unique ID of the marker (markersetid:type:markerid)
|
||||
*/
|
||||
public String getUniqueMarkerID();
|
||||
/**
|
||||
* Get ID of the marker (unique string within the MarkerSet)
|
||||
* @return id of marker
|
||||
|
Loading…
Reference in New Issue
Block a user