From 6f1ae1a90404a114baff09ae7ecc4a67d6234fe8 Mon Sep 17 00:00:00 2001 From: zhangyuheng Date: Thu, 18 Jul 2024 10:44:02 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Ddynmap=E6=B8=B2=E6=9F=93?= =?UTF-8?q?=E6=8A=A5=E9=94=99=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dominion/utils/DynmapConnect.java | 26 ++++++++++++------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/src/main/java/cn/lunadeer/dominion/utils/DynmapConnect.java b/src/main/java/cn/lunadeer/dominion/utils/DynmapConnect.java index 865fe44..0b29086 100644 --- a/src/main/java/cn/lunadeer/dominion/utils/DynmapConnect.java +++ b/src/main/java/cn/lunadeer/dominion/utils/DynmapConnect.java @@ -3,16 +3,12 @@ package cn.lunadeer.dominion.utils; import cn.lunadeer.dominion.dtos.DominionDTO; import cn.lunadeer.minecraftpluginutils.Scheduler; import cn.lunadeer.minecraftpluginutils.XLogger; -import com.flowpowered.math.vector.Vector2d; -import de.bluecolored.bluemap.api.math.Shape; import org.dynmap.DynmapCommonAPI; import org.dynmap.DynmapCommonAPIListener; import org.dynmap.markers.AreaMarker; import org.dynmap.markers.MarkerAPI; import org.dynmap.markers.MarkerSet; -import java.util.ArrayList; -import java.util.Collection; import java.util.List; import java.util.Map; @@ -20,14 +16,22 @@ public class DynmapConnect extends DynmapCommonAPIListener { public static DynmapConnect instance; - private MarkerSet markerSet; + private MarkerSet markerSet_dominion; + private MarkerSet markerSet_mca; + + public DynmapConnect() { + instance = this; + } @Override public void apiEnabled(DynmapCommonAPI dynmapCommonAPI) { MarkerAPI markerAPI = dynmapCommonAPI.getMarkerAPI(); - this.markerSet = markerAPI.getMarkerSet("dominion"); - if (this.markerSet == null) { - this.markerSet = markerAPI.createMarkerSet("dominion", "Dominion领地", null, false); + this.markerSet_dominion = markerAPI.getMarkerSet("dominion"); + if (this.markerSet_dominion == null) { + this.markerSet_dominion = markerAPI.createMarkerSet("dominion", "Dominion领地", null, false); + } + if (this.markerSet_mca == null) { + this.markerSet_mca = markerAPI.createMarkerSet("mca", "MCA文件", null, false); } } @@ -35,7 +39,7 @@ public class DynmapConnect extends DynmapCommonAPIListener { String nameLabel = "
" + dominion.getName() + "
"; double[] xx = {dominion.getX1(), dominion.getX2()}; double[] zz = {dominion.getZ1(), dominion.getZ2()}; - AreaMarker marker = this.markerSet.createAreaMarker( + AreaMarker marker = this.markerSet_dominion.createAreaMarker( dominion.getId().toString(), nameLabel, true, @@ -51,6 +55,7 @@ public class DynmapConnect extends DynmapCommonAPIListener { public void setDominionMarkers(List dominions) { Scheduler.runTaskAsync(() -> { + this.markerSet_dominion.getAreaMarkers().forEach(AreaMarker::deleteMarker); for (DominionDTO dominion : dominions) { this.setDominionMarker(dominion); } @@ -59,6 +64,7 @@ public class DynmapConnect extends DynmapCommonAPIListener { public void setMCAMarkers(Map> mca_files) { Scheduler.runTaskAsync(() -> { + this.markerSet_mca.getAreaMarkers().forEach(AreaMarker::deleteMarker); for (Map.Entry> entry : mca_files.entrySet()) { for (String file : entry.getValue()) { String[] cords = file.split("\\."); @@ -69,7 +75,7 @@ public class DynmapConnect extends DynmapCommonAPIListener { String nameLabel = "
" + file + "
"; double[] xx = {world_x1, world_x2}; double[] zz = {world_z1, world_z2}; - AreaMarker marker = this.markerSet.createAreaMarker( + AreaMarker marker = this.markerSet_mca.createAreaMarker( file, nameLabel, true,