mirror of
https://github.com/webbukkit/dynmap.git
synced 2024-11-24 03:05:28 +01:00
Fix 1.13 world border support, handle world border changes
This commit is contained in:
parent
3650dc7d2a
commit
95decf005c
@ -104,6 +104,7 @@ public class DynmapMapCommands {
|
||||
sb.append(", extrazoomout=").append(w.getExtraZoomOutLevels()).append(", sendhealth=").append(w.sendhealth);
|
||||
sb.append(", sendposition=").append(w.sendposition);
|
||||
sb.append(", protected=").append(w.is_protected);
|
||||
sb.append(", showborder=").append(w.showborder);
|
||||
if(w.tileupdatedelay > 0) {
|
||||
sb.append(", tileupdatedelay=").append(w.tileupdatedelay);
|
||||
}
|
||||
@ -172,6 +173,15 @@ public class DynmapMapCommands {
|
||||
core.updateWorldConfig(w);
|
||||
did_update = true;
|
||||
}
|
||||
else if(tok[0].equalsIgnoreCase("showborder")) {
|
||||
if(w == null) {
|
||||
sender.sendMessage("Cannot set sendworldborder on disabled or undefined world");
|
||||
return true;
|
||||
}
|
||||
w.showborder = tok[1].equals("true");
|
||||
core.updateWorldConfig(w);
|
||||
did_update = true;
|
||||
}
|
||||
else if(tok[0].equalsIgnoreCase("protected")) {
|
||||
if(w == null) {
|
||||
sender.sendMessage("Cannot set protected on disabled or undefined world");
|
||||
|
@ -37,6 +37,7 @@ public abstract class DynmapWorld {
|
||||
public int servertime;
|
||||
public boolean sendposition;
|
||||
public boolean sendhealth;
|
||||
public boolean showborder;
|
||||
private int extrazoomoutlevels; /* Number of additional zoom out levels to generate */
|
||||
private boolean cancelled;
|
||||
private final String wname;
|
||||
@ -326,6 +327,7 @@ public abstract class DynmapWorld {
|
||||
servertime = (int)(getTime() % 24000);
|
||||
sendposition = worldconfig.getBoolean("sendposition", true);
|
||||
sendhealth = worldconfig.getBoolean("sendhealth", true);
|
||||
showborder = worldconfig.getBoolean("showborder", true);
|
||||
is_protected = worldconfig.getBoolean("protected", false);
|
||||
setExtraZoomOutLevels(worldconfig.getInteger("extrazoomout", 0));
|
||||
setTileUpdateDelay(worldconfig.getInteger("tileupdatedelay", -1));
|
||||
@ -419,6 +421,7 @@ public abstract class DynmapWorld {
|
||||
node.put("title", getTitle());
|
||||
node.put("enabled", is_enabled);
|
||||
node.put("protected", is_protected);
|
||||
node.put("showborder", showborder);
|
||||
if(tileupdatedelay > 0) {
|
||||
node.put("tileupdatedelay", tileupdatedelay);
|
||||
}
|
||||
|
@ -27,11 +27,13 @@ import java.util.concurrent.atomic.AtomicLong;
|
||||
|
||||
import org.dynmap.common.DynmapCommandSender;
|
||||
import org.dynmap.common.DynmapPlayer;
|
||||
import org.dynmap.common.DynmapListenerManager.EventType;
|
||||
import org.dynmap.debug.Debug;
|
||||
import org.dynmap.exporter.OBJExport;
|
||||
import org.dynmap.hdmap.HDMapManager;
|
||||
import org.dynmap.renderer.DynmapBlockState;
|
||||
import org.dynmap.utils.MapChunkCache;
|
||||
import org.dynmap.utils.Polygon;
|
||||
import org.dynmap.utils.TileFlags;
|
||||
|
||||
public class MapManager {
|
||||
@ -775,6 +777,7 @@ public class MapManager {
|
||||
}
|
||||
|
||||
private class CheckWorldTimes implements Runnable {
|
||||
HashMap<String, Polygon> last_worldborder = new HashMap<String, Polygon>();
|
||||
public void run() {
|
||||
Future<Integer> f = core.getServer().callSyncMethod(new Callable<Integer>() {
|
||||
public Integer call() throws Exception {
|
||||
@ -789,6 +792,15 @@ public class MapManager {
|
||||
if(wasday != isday) {
|
||||
pushUpdate(w, new Client.DayNight(isday));
|
||||
}
|
||||
// Check world border
|
||||
Polygon wb = w.getWorldBorder();
|
||||
Polygon oldwb = last_worldborder.get(w.getName());
|
||||
if (((wb == null) && (oldwb == null)) ||
|
||||
wb.equals(oldwb)) { // No change
|
||||
}
|
||||
else {
|
||||
core.listenerManager.processWorldEvent(EventType.WORLD_SPAWN_CHANGE, w);
|
||||
}
|
||||
}
|
||||
/* Tick invalidated tiles processing */
|
||||
for(MapTypeState mts : w.mapstate) {
|
||||
|
@ -254,7 +254,7 @@ public class MarkersComponent extends ClientComponent {
|
||||
String borderid = "_worldborder_" + w.getName();
|
||||
AreaMarker am = ms.findAreaMarker(borderid);
|
||||
Polygon p = null;
|
||||
if (showBorder) {
|
||||
if (showBorder && w.showborder) {
|
||||
p = w.getWorldBorder();
|
||||
}
|
||||
if ((p != null) && (p.size() > 1)) {
|
||||
|
@ -15,8 +15,10 @@ import java.util.Set;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.ChunkSnapshot;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.WorldBorder;
|
||||
import org.dynmap.DynmapChunk;
|
||||
import org.dynmap.Log;
|
||||
import org.dynmap.bukkit.helper.BukkitVersionHelper;
|
||||
@ -169,4 +171,22 @@ public class BukkitVersionHelperSpigot113_1 extends BukkitVersionHelperCB {
|
||||
return ((BiomeBase)bb).n();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Polygon getWorldBorder(World world) {
|
||||
Polygon p = null;
|
||||
WorldBorder wb = world.getWorldBorder();
|
||||
if (wb != null) {
|
||||
Location c = wb.getCenter();
|
||||
double size = wb.getSize();
|
||||
if ((size > 1) && (size < 1E7)) {
|
||||
p = new Polygon();
|
||||
p.addVertex(c.getX()-size, c.getZ()-size);
|
||||
p.addVertex(c.getX()+size, c.getZ()-size);
|
||||
p.addVertex(c.getX()+size, c.getZ()+size);
|
||||
p.addVertex(c.getX()-size, c.getZ()+size);
|
||||
}
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -15,8 +15,10 @@ import java.util.Set;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.ChunkSnapshot;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.WorldBorder;
|
||||
import org.dynmap.DynmapChunk;
|
||||
import org.dynmap.Log;
|
||||
import org.dynmap.bukkit.helper.BukkitVersionHelper;
|
||||
@ -169,4 +171,22 @@ public class BukkitVersionHelperSpigot113_2 extends BukkitVersionHelperCB {
|
||||
return ((BiomeBase)bb).n();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Polygon getWorldBorder(World world) {
|
||||
Polygon p = null;
|
||||
WorldBorder wb = world.getWorldBorder();
|
||||
if (wb != null) {
|
||||
Location c = wb.getCenter();
|
||||
double size = wb.getSize();
|
||||
if ((size > 1) && (size < 1E7)) {
|
||||
p = new Polygon();
|
||||
p.addVertex(c.getX()-size, c.getZ()-size);
|
||||
p.addVertex(c.getX()+size, c.getZ()-size);
|
||||
p.addVertex(c.getX()+size, c.getZ()+size);
|
||||
p.addVertex(c.getX()-size, c.getZ()+size);
|
||||
}
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -15,8 +15,10 @@ import java.util.Set;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.ChunkSnapshot;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.WorldBorder;
|
||||
import org.dynmap.DynmapChunk;
|
||||
import org.dynmap.Log;
|
||||
import org.dynmap.bukkit.helper.BukkitVersionHelper;
|
||||
@ -163,4 +165,22 @@ public class BukkitVersionHelperSpigot113 extends BukkitVersionHelperCB {
|
||||
return ((BiomeBase)bb).n();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Polygon getWorldBorder(World world) {
|
||||
Polygon p = null;
|
||||
WorldBorder wb = world.getWorldBorder();
|
||||
if (wb != null) {
|
||||
Location c = wb.getCenter();
|
||||
double size = wb.getSize();
|
||||
if ((size > 1) && (size < 1E7)) {
|
||||
p = new Polygon();
|
||||
p.addVertex(c.getX()-size, c.getZ()-size);
|
||||
p.addVertex(c.getX()+size, c.getZ()-size);
|
||||
p.addVertex(c.getX()+size, c.getZ()+size);
|
||||
p.addVertex(c.getX()-size, c.getZ()+size);
|
||||
}
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user