mirror of
https://github.com/webbukkit/dynmap.git
synced 2025-04-14 07:56:22 +02:00
Initial work on greeting/farewall title support for areas
This commit is contained in:
parent
2be20f4c78
commit
14f55bd6a8
@ -13,4 +13,7 @@ public class DynmapLocation {
|
||||
world = w;
|
||||
this.x = x; this.y = y; this.z = z;
|
||||
}
|
||||
public String toString() {
|
||||
return String.format("{%s,%f,%f,%f}", world, x, y, z);
|
||||
}
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.CancellationException;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
@ -32,6 +33,9 @@ import org.dynmap.common.DynmapListenerManager.EventType;
|
||||
import org.dynmap.debug.Debug;
|
||||
import org.dynmap.exporter.OBJExport;
|
||||
import org.dynmap.hdmap.HDMapManager;
|
||||
import org.dynmap.markers.EnterExitMarker;
|
||||
import org.dynmap.markers.EnterExitMarker.EnterExitText;
|
||||
import org.dynmap.markers.impl.MarkerAPIImpl;
|
||||
import org.dynmap.renderer.DynmapBlockState;
|
||||
import org.dynmap.storage.MapStorage;
|
||||
import org.dynmap.storage.MapStorageBaseTileEnumCB;
|
||||
@ -930,7 +934,46 @@ public class MapManager {
|
||||
scheduleDelayedJob(this, 1000); /* Once per second */
|
||||
}
|
||||
}
|
||||
|
||||
private HashMap<UUID, HashSet<EnterExitMarker>> entersetstate = new HashMap<UUID, HashSet<EnterExitMarker>>();
|
||||
|
||||
private class DoUserMoveProcessing implements Runnable {
|
||||
public void run() {
|
||||
HashMap<UUID, HashSet<EnterExitMarker>> newstate = new HashMap<UUID, HashSet<EnterExitMarker>>();
|
||||
DynmapPlayer[] pl = core.playerList.getOnlinePlayers();
|
||||
for (DynmapPlayer player : pl) {
|
||||
if (player == null) continue;
|
||||
UUID puuid = player.getUUID();
|
||||
HashSet<EnterExitMarker> newset = new HashSet<EnterExitMarker>();
|
||||
DynmapLocation dl = player.getLocation();
|
||||
if (dl != null) {
|
||||
MarkerAPIImpl.getEnteredMarkers(dl.world, dl.x, dl.y, dl.z, newset);
|
||||
}
|
||||
HashSet<EnterExitMarker> oldset = entersetstate.get(puuid);
|
||||
// See which we just entered
|
||||
for (EnterExitMarker m : newset) {
|
||||
EnterExitText txt = m.getGreetingText();
|
||||
if ((txt != null) && ((oldset == null) || (oldset.contains(m) == false))) {
|
||||
Log.info(String.format("User %s enter: %s - %s", player.getName(), txt.title, txt.subtitle));
|
||||
}
|
||||
}
|
||||
// See which we just left
|
||||
if (oldset != null) {
|
||||
for (EnterExitMarker m : oldset) {
|
||||
EnterExitText txt = m.getFarewellText();
|
||||
if ((txt != null) && (newset.contains(m) == false)) {
|
||||
Log.info(String.format("User %s exit: %s - %s", player.getName(), txt.title, txt.subtitle));
|
||||
}
|
||||
}
|
||||
}
|
||||
newstate.put(puuid, newset);
|
||||
}
|
||||
entersetstate = newstate; // Replace old with new
|
||||
|
||||
scheduleDelayedJob(this, 1000); /* Once per second */
|
||||
}
|
||||
}
|
||||
|
||||
private void addNextTilesToUpdate(int cnt) {
|
||||
ArrayList<MapTile> tiles = new ArrayList<MapTile>();
|
||||
TileFlags.TileCoord coord = new TileFlags.TileCoord();
|
||||
@ -1458,6 +1501,7 @@ public class MapManager {
|
||||
scheduleDelayedJob(new DoZoomOutProcessing(), 60000);
|
||||
scheduleDelayedJob(new CheckWorldTimes(), 5000);
|
||||
scheduleDelayedJob(new DoTouchProcessing(), 1000);
|
||||
scheduleDelayedJob(new DoUserMoveProcessing(), 1000);
|
||||
/* Resume pending jobs */
|
||||
for(FullWorldRenderState job : active_renders.values()) {
|
||||
scheduleDelayedJob(job, 5000);
|
||||
|
@ -7,6 +7,7 @@ import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
@ -119,7 +120,11 @@ public class PlayerList {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public DynmapPlayer[] getOnlinePlayers() {
|
||||
return Arrays.copyOf(online, online.length);
|
||||
}
|
||||
|
||||
public List<DynmapPlayer> getVisiblePlayers(String worldName) {
|
||||
ArrayList<DynmapPlayer> visiblePlayers = new ArrayList<DynmapPlayer>();
|
||||
DynmapPlayer[] onlinePlayers = online; /* Use copied list - we don't call from server thread */
|
||||
|
@ -8,14 +8,16 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.dynmap.ConfigurationNode;
|
||||
import org.dynmap.DynmapWorld;
|
||||
import org.dynmap.Log;
|
||||
import org.dynmap.MapManager;
|
||||
import org.dynmap.hdmap.HDPerspective;
|
||||
import org.dynmap.markers.AreaMarker;
|
||||
import org.dynmap.markers.EnterExitMarker;
|
||||
import org.dynmap.markers.MarkerSet;
|
||||
import org.dynmap.markers.impl.MarkerAPIImpl.MarkerUpdate;
|
||||
import org.dynmap.utils.Vector3D;
|
||||
|
||||
class AreaMarkerImpl implements AreaMarker {
|
||||
class AreaMarkerImpl implements AreaMarker, EnterExitMarker {
|
||||
private String markerid;
|
||||
private String label;
|
||||
private boolean markup;
|
||||
@ -35,6 +37,9 @@ class AreaMarkerImpl implements AreaMarker {
|
||||
private boolean boostflag = false;
|
||||
private int minzoom;
|
||||
private int maxzoom;
|
||||
private EnterExitText greeting;
|
||||
private EnterExitText farewell;
|
||||
|
||||
|
||||
private static class Coord {
|
||||
double x, z;
|
||||
@ -85,6 +90,8 @@ class AreaMarkerImpl implements AreaMarker {
|
||||
}
|
||||
this.minzoom = -1;
|
||||
this.maxzoom = -1;
|
||||
this.greeting = null;
|
||||
this.farewell = null;
|
||||
}
|
||||
/**
|
||||
* Make bare area marker - used for persistence load
|
||||
@ -101,6 +108,8 @@ class AreaMarkerImpl implements AreaMarker {
|
||||
world = normalized_world = "world";
|
||||
this.minzoom = -1;
|
||||
this.maxzoom = -1;
|
||||
this.greeting = null;
|
||||
this.farewell = null;
|
||||
}
|
||||
/**
|
||||
* Load marker from configuration node
|
||||
@ -132,7 +141,21 @@ class AreaMarkerImpl implements AreaMarker {
|
||||
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 */
|
||||
|
||||
return true;
|
||||
@ -223,6 +246,23 @@ class AreaMarkerImpl implements AreaMarker {
|
||||
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
|
||||
@ -522,4 +562,80 @@ class AreaMarkerImpl implements AreaMarker {
|
||||
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;
|
||||
}
|
||||
// If Y is in range (if there is a range)
|
||||
if ((ytop != ybottom) && ((y < ybottom) || (y > ytop))) {
|
||||
return false;
|
||||
}
|
||||
// Test if inside polygon
|
||||
int nvert = corners.size();
|
||||
int i, j;
|
||||
Coord v0, v1;
|
||||
boolean c = false;
|
||||
if (nvert == 2) { // Diagonal corners (simple rectangle
|
||||
v0 = corners.get(0);
|
||||
v1 = corners.get(1);
|
||||
if (((v0.x > x) != (v1.x > x)) &&
|
||||
((v0.z > z) != (v1.z > z))) {
|
||||
c = true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (i = 0, j = nvert-1; i < nvert; j = i++) {
|
||||
v0 = corners.get(i);
|
||||
v1 = corners.get(j);
|
||||
if (((v0.z > z) != (v1.z > z)) &&
|
||||
(((x - v0.x) * (v1.z - v0.z)) <
|
||||
((v1.x - v0.x) * (z - v0.z)))) {
|
||||
c = !c;
|
||||
}
|
||||
}
|
||||
}
|
||||
return c;
|
||||
}
|
||||
}
|
||||
|
@ -36,6 +36,7 @@ import org.dynmap.common.DynmapPlayer;
|
||||
import org.dynmap.hdmap.HDPerspective;
|
||||
import org.dynmap.markers.AreaMarker;
|
||||
import org.dynmap.markers.CircleMarker;
|
||||
import org.dynmap.markers.EnterExitMarker;
|
||||
import org.dynmap.markers.Marker;
|
||||
import org.dynmap.markers.MarkerAPI;
|
||||
import org.dynmap.markers.MarkerDescription;
|
||||
@ -3216,4 +3217,18 @@ public class MarkerAPIImpl implements MarkerAPI, Event.Listener<DynmapWorld> {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* Build entered marker set based on given location
|
||||
* @param worldid - world
|
||||
* @param x
|
||||
* @param y
|
||||
* @param z
|
||||
* @param entered
|
||||
*/
|
||||
public static void getEnteredMarkers(String worldid, double x, double y, double z, Set<EnterExitMarker> entered) {
|
||||
if (api == null) return;
|
||||
for(MarkerSetImpl ms : api.markersets.values()) {
|
||||
ms.addEnteredMarkers(entered, worldid, x, y, z);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -14,6 +14,7 @@ import org.dynmap.Log;
|
||||
import org.dynmap.hdmap.HDPerspective;
|
||||
import org.dynmap.markers.AreaMarker;
|
||||
import org.dynmap.markers.CircleMarker;
|
||||
import org.dynmap.markers.EnterExitMarker;
|
||||
import org.dynmap.markers.PolyLineMarker;
|
||||
import org.dynmap.markers.Marker;
|
||||
import org.dynmap.markers.MarkerIcon;
|
||||
@ -27,6 +28,7 @@ class MarkerSetImpl implements MarkerSet {
|
||||
private ConcurrentHashMap<String, CircleMarkerImpl> circlemarkers = new ConcurrentHashMap<String, CircleMarkerImpl>();
|
||||
private ConcurrentHashMap<String, AreaMarkerImpl> boostingareamarkers = null;
|
||||
private ConcurrentHashMap<String, CircleMarkerImpl> boostingcirclemarkers = null;
|
||||
private ConcurrentHashMap<String, EnterExitMarker> enterexitmarkers = null;
|
||||
private String setid;
|
||||
private String label;
|
||||
private ConcurrentHashMap<String, MarkerIconImpl> allowedicons = null;
|
||||
@ -80,6 +82,10 @@ class MarkerSetImpl implements MarkerSet {
|
||||
boostingcirclemarkers.clear();
|
||||
boostingcirclemarkers = null;
|
||||
}
|
||||
if (enterexitmarkers != null) {
|
||||
enterexitmarkers.clear();
|
||||
enterexitmarkers = null;
|
||||
}
|
||||
deficon = null;
|
||||
}
|
||||
|
||||
@ -268,6 +274,12 @@ class MarkerSetImpl implements MarkerSet {
|
||||
}
|
||||
boostingareamarkers.put(marker.getMarkerID(), marker);
|
||||
}
|
||||
if ((marker.getGreetingText() != null) || (marker.getFarewellText() != null)) {
|
||||
if (enterexitmarkers == null) {
|
||||
enterexitmarkers = new ConcurrentHashMap<String, EnterExitMarker>();
|
||||
}
|
||||
enterexitmarkers.put(marker.getMarkerID(), marker);
|
||||
}
|
||||
if(ispersistent && marker.isPersistentMarker()) { /* If persistent */
|
||||
MarkerAPIImpl.saveMarkers(); /* Drive save */
|
||||
}
|
||||
@ -286,7 +298,13 @@ class MarkerSetImpl implements MarkerSet {
|
||||
boostingareamarkers = null;
|
||||
}
|
||||
}
|
||||
if(ispersistent && marker.isPersistentMarker()) { /* If persistent */
|
||||
if (enterexitmarkers != null) {
|
||||
enterexitmarkers.remove(marker.getMarkerID());
|
||||
if (enterexitmarkers.isEmpty()) {
|
||||
enterexitmarkers = null;
|
||||
}
|
||||
}
|
||||
if (ispersistent && marker.isPersistentMarker()) { /* If persistent */
|
||||
MarkerAPIImpl.saveMarkers(); /* Drive save */
|
||||
}
|
||||
MarkerAPIImpl.areaMarkerUpdated(marker, MarkerUpdate.DELETED);
|
||||
@ -446,6 +464,12 @@ class MarkerSetImpl implements MarkerSet {
|
||||
}
|
||||
boostingareamarkers.put(id, marker);
|
||||
}
|
||||
if ((marker.getGreetingText() != null) || (marker.getFarewellText() != null)) {
|
||||
if (enterexitmarkers == null) {
|
||||
enterexitmarkers = new ConcurrentHashMap<String, EnterExitMarker>();
|
||||
}
|
||||
enterexitmarkers.put(marker.getMarkerID(), marker);
|
||||
}
|
||||
}
|
||||
else {
|
||||
Log.info("Error loading area marker '" + id + "' for set '" + setid + "'");
|
||||
@ -745,5 +769,16 @@ class MarkerSetImpl implements MarkerSet {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add entered markers to set based on given coordinates
|
||||
*/
|
||||
@Override
|
||||
public void addEnteredMarkers(Set<EnterExitMarker> entered, String worldid, double x, double y, double z) {
|
||||
if (enterexitmarkers == null) return;
|
||||
for (EnterExitMarker m : enterexitmarkers.values()) {
|
||||
if (m.testIfPointWithinMarker(worldid, x, y, z)) {
|
||||
entered.add(m);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,28 @@
|
||||
package org.dynmap.markers;
|
||||
|
||||
public interface EnterExitMarker {
|
||||
public static class EnterExitText {
|
||||
public String title;
|
||||
public String subtitle;
|
||||
};
|
||||
/**
|
||||
* Greeting text, if defined
|
||||
*/
|
||||
public EnterExitText getGreetingText();
|
||||
/**
|
||||
* Farewell text, if defined
|
||||
*/
|
||||
public EnterExitText getFarewellText();
|
||||
/**
|
||||
* Set greeting text
|
||||
*/
|
||||
public void setGreetingText(String title, String subtitle);
|
||||
/**
|
||||
* Set greeting text
|
||||
*/
|
||||
public void setFarewellText(String title, String subtitle);
|
||||
/**
|
||||
* Test if point is inside marker volume
|
||||
*/
|
||||
public boolean testIfPointWithinMarker(String worldid, double x, double y, double z);
|
||||
};
|
@ -256,4 +256,8 @@ public interface MarkerSet {
|
||||
* @return default marker
|
||||
*/
|
||||
public MarkerIcon getDefaultMarkerIcon();
|
||||
/**
|
||||
* Add entered markers to set based on given coordinates
|
||||
*/
|
||||
public void addEnteredMarkers(Set<EnterExitMarker> entered, String worldid, double x, double y, double z);
|
||||
}
|
||||
|
@ -1,2 +1,13 @@
|
||||
connection.project.dir=..
|
||||
arguments=
|
||||
auto.sync=false
|
||||
build.scans.enabled=false
|
||||
connection.gradle.distribution=GRADLE_DISTRIBUTION(VERSION(6.3))
|
||||
connection.project.dir=
|
||||
eclipse.preferences.version=1
|
||||
gradle.user.home=
|
||||
java.home=/Library/Java/JavaVirtualMachines/jdk1.8.0_251.jdk/Contents/Home
|
||||
jvm.arguments=
|
||||
offline.mode=false
|
||||
override.workspace.settings=true
|
||||
show.console.view=true
|
||||
show.executions.view=true
|
||||
|
@ -62,9 +62,6 @@ shadowJar {
|
||||
}
|
||||
archiveName = "Dynmap-${parent.version}-forge-1.13.2.jar"
|
||||
destinationDir = file '../target'
|
||||
manifest {
|
||||
attributes 'FMLAT': 'dynmap_at.cfg'
|
||||
}
|
||||
}
|
||||
|
||||
shadowJar.doLast {
|
||||
|
@ -1,4 +0,0 @@
|
||||
public net.minecraft.world.gen.ChunkProviderServer field_73247_e # chunkLoader
|
||||
public net.minecraft.world.chunk.storage.AnvilChunkLoader field_75825_d # chunkSaveLocation
|
||||
public net.minecraft.world.biome.Biome field_76791_y # biomeName
|
||||
public net.minecraft.world.chunk.Chunk field_76641_n # lastSaveTime
|
@ -60,9 +60,6 @@ shadowJar {
|
||||
}
|
||||
archiveName = "Dynmap-${parent.version}-forge-1.14.4.jar"
|
||||
destinationDir = file '../target'
|
||||
manifest {
|
||||
attributes 'FMLAT': 'dynmap_at.cfg'
|
||||
}
|
||||
}
|
||||
|
||||
shadowJar.doLast {
|
||||
|
2
forge-1.15.2/.gitignore
vendored
2
forge-1.15.2/.gitignore
vendored
@ -1 +1,3 @@
|
||||
/build/
|
||||
/.gradle/
|
||||
/bin/
|
||||
|
@ -60,9 +60,6 @@ shadowJar {
|
||||
}
|
||||
archiveName = "Dynmap-${parent.version}-forge-1.15.2.jar"
|
||||
destinationDir = file '../target'
|
||||
manifest {
|
||||
attributes 'FMLAT': 'dynmap_at.cfg'
|
||||
}
|
||||
}
|
||||
|
||||
shadowJar.doLast {
|
||||
|
Loading…
Reference in New Issue
Block a user