修复dynmap渲染报错问题

This commit is contained in:
zhangyuheng 2024-07-18 10:44:02 +08:00
parent aa31a45cec
commit 6f1ae1a904

View File

@ -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 = "<div>" + dominion.getName() + "</div>";
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<DominionDTO> 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<String, List<String>> mca_files) {
Scheduler.runTaskAsync(() -> {
this.markerSet_mca.getAreaMarkers().forEach(AreaMarker::deleteMarker);
for (Map.Entry<String, List<String>> entry : mca_files.entrySet()) {
for (String file : entry.getValue()) {
String[] cords = file.split("\\.");
@ -69,7 +75,7 @@ public class DynmapConnect extends DynmapCommonAPIListener {
String nameLabel = "<div>" + file + "</div>";
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,