Makes all faction warps show up as markers
Some checks failed
EpicKnarvik97/Dynmap-Factions/pipeline/head There was a failure building this commit
Some checks failed
EpicKnarvik97/Dynmap-Factions/pipeline/head There was a failure building this commit
This commit is contained in:
parent
4ad841c867
commit
91fef8d349
@ -16,10 +16,12 @@ import org.jetbrains.annotations.Nullable;
|
||||
* @param fillOpacity <p>The opacity of the filled-in area</p>
|
||||
* @param homeMarker <p>The name of the icon to use for marking faction homes</p>
|
||||
* @param homeIcon <p>The icon to use for marking faction homes</p>
|
||||
* @param boost
|
||||
* @param warpIcon <p>The icon to use for marking other faction warps</p>
|
||||
* @param boost <p>Whether to boost the priority of this area style, I guess</p>
|
||||
*/
|
||||
public record AreaStyle(String strokeColor, double strokeOpacity, int strokeWeight, String fillColor,
|
||||
double fillOpacity, String homeMarker, MarkerIcon homeIcon, boolean boost) {
|
||||
double fillOpacity, String homeMarker, MarkerIcon homeIcon, MarkerIcon warpIcon,
|
||||
boolean boost) {
|
||||
|
||||
/**
|
||||
* Instantiates a new area style
|
||||
@ -38,6 +40,7 @@ public record AreaStyle(String strokeColor, double strokeOpacity, int strokeWeig
|
||||
cfg.getDouble(path + ".fillOpacity", def.fillOpacity),
|
||||
cfg.getString(path + ".homeIcon", def.homeMarker),
|
||||
getHomeIcon(dynmapFactionsPlugin, cfg.getString(path + ".homeIcon", def.homeMarker)),
|
||||
getWarpIcon(dynmapFactionsPlugin, cfg.getString(path + ".warpIcon", def.homeMarker)),
|
||||
cfg.getBoolean(path + ".boost", def.boost));
|
||||
}
|
||||
|
||||
@ -57,6 +60,7 @@ public record AreaStyle(String strokeColor, double strokeOpacity, int strokeWeig
|
||||
cfg.getDouble(path + ".fillOpacity", 0.35),
|
||||
cfg.getString(path + ".homeIcon", null),
|
||||
getHomeIcon(dynmapFactionsPlugin, cfg.getString(path + ".homeIcon", null)),
|
||||
getWarpIcon(dynmapFactionsPlugin, cfg.getString(path + ".warpIcon", null)),
|
||||
cfg.getBoolean(path + ".boost", false));
|
||||
}
|
||||
|
||||
@ -70,12 +74,38 @@ public record AreaStyle(String strokeColor, double strokeOpacity, int strokeWeig
|
||||
@Nullable
|
||||
private static MarkerIcon getHomeIcon(@NotNull DynmapFactionsPlugin dynmapFactionsPlugin,
|
||||
@Nullable String homeMarker) {
|
||||
return getIcon(dynmapFactionsPlugin, homeMarker, "redflag");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the icon to use for marking a faction warp
|
||||
*
|
||||
* @param dynmapFactionsPlugin <p>An instance of the dynmap factions plugin</p>
|
||||
* @param warpMarker <p>The name of the marker to get</p>
|
||||
* @return <p>The marker, or null if it does not exist</p>
|
||||
*/
|
||||
@Nullable
|
||||
private static MarkerIcon getWarpIcon(@NotNull DynmapFactionsPlugin dynmapFactionsPlugin,
|
||||
@Nullable String warpMarker) {
|
||||
return getIcon(dynmapFactionsPlugin, warpMarker, "orangeflag");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the icon to use for marking a faction warp
|
||||
*
|
||||
* @param dynmapFactionsPlugin <p>An instance of the dynmap factions plugin</p>
|
||||
* @param warpMarker <p>The name of the marker to get</p>
|
||||
* @return <p>The marker, or null if it does not exist</p>
|
||||
*/
|
||||
@Nullable
|
||||
private static MarkerIcon getIcon(@NotNull DynmapFactionsPlugin dynmapFactionsPlugin,
|
||||
@Nullable String warpMarker, @NotNull String defaultIcon) {
|
||||
MarkerIcon homeIcon = null;
|
||||
if (homeMarker != null) {
|
||||
homeIcon = dynmapFactionsPlugin.getMarkerAPI().getMarkerIcon(homeMarker);
|
||||
if (warpMarker != null) {
|
||||
homeIcon = dynmapFactionsPlugin.getMarkerAPI().getMarkerIcon(warpMarker);
|
||||
if (homeIcon == null) {
|
||||
DynmapFactionsPlugin.severe("Invalid home icon: " + homeMarker);
|
||||
homeIcon = dynmapFactionsPlugin.getMarkerAPI().getMarkerIcon("blueicon");
|
||||
DynmapFactionsPlugin.severe("Invalid icon: " + warpMarker);
|
||||
homeIcon = dynmapFactionsPlugin.getMarkerAPI().getMarkerIcon(defaultIcon);
|
||||
}
|
||||
}
|
||||
return homeIcon;
|
||||
|
@ -108,35 +108,9 @@ public class FactionsUpdate implements Runnable {
|
||||
|
||||
/* Now, add marker for home location */
|
||||
EntityInternalMap<Warp> warps = faction.getWarps();
|
||||
Warp home = null;
|
||||
for (String warp : warps.keySet()) {
|
||||
if (warp.equalsIgnoreCase("home")) {
|
||||
home = warps.get(warp);
|
||||
}
|
||||
}
|
||||
if (home == null) {
|
||||
continue;
|
||||
}
|
||||
PS homeLocation = home.getLocation();
|
||||
if (homeLocation != null) {
|
||||
String markId = fc.getUniverse() + "_" + factionName + "__home";
|
||||
MarkerIcon ico = getMarkerIcon(factionName);
|
||||
if (ico != null) {
|
||||
Marker homeMarker = dynmapFactionsPlugin.getFactionMarkers().remove(markId);
|
||||
String lbl = factionName + " [home]";
|
||||
if (homeMarker == null) {
|
||||
homeMarker = dynmapFactionsPlugin.getSet().createMarker(markId, lbl, homeLocation.getWorld(),
|
||||
homeLocation.getLocationX(), homeLocation.getLocationY(), homeLocation.getLocationZ(), ico, false);
|
||||
} else {
|
||||
homeMarker.setLocation(homeLocation.getWorld(), homeLocation.getLocationX(), homeLocation.getLocationY(), homeLocation.getLocationZ());
|
||||
homeMarker.setLabel(lbl); /* Update label */
|
||||
homeMarker.setMarkerIcon(ico);
|
||||
}
|
||||
if (homeMarker != null) {
|
||||
homeMarker.setDescription(formatInfoWindow(faction)); /* Set popup */
|
||||
newMarkers.put(markId, homeMarker);
|
||||
}
|
||||
}
|
||||
for (String warpId : warps.keySet()) {
|
||||
Warp warp = warps.get(warpId);
|
||||
markWarp(warp, fc, faction, newMarkers, warp.getName().equalsIgnoreCase("home"));
|
||||
}
|
||||
}
|
||||
blocksByFaction.clear();
|
||||
@ -151,7 +125,45 @@ public class FactionsUpdate implements Runnable {
|
||||
/* And replace with new map */
|
||||
dynmapFactionsPlugin.setFactionAreaMarkers(newMap);
|
||||
dynmapFactionsPlugin.setFactionMarkers(newMarkers);
|
||||
}
|
||||
|
||||
/**
|
||||
* Marks a faction warp with an icon
|
||||
*
|
||||
* @param warp <p>The warp to mark</p>
|
||||
* @param fc <p>The FactionColl to get info from</p>
|
||||
* @param faction <p>The faction the warp belongs to</p>
|
||||
* @param newMarkers <p>The new markers map to add the marker to</p>
|
||||
* @param isHome <p>Whether the warp is the home warp</p>
|
||||
*/
|
||||
private void markWarp(Warp warp, FactionColl fc, Faction faction, Map<String, Marker> newMarkers, boolean isHome) {
|
||||
String factionName = faction.getName();
|
||||
PS warpLocation = warp.getLocation();
|
||||
if (warpLocation == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
String markId = fc.getUniverse() + "_" + factionName + "__" + warp.getName();
|
||||
MarkerIcon markerIcon = getMarkerIcon(factionName, isHome);
|
||||
if (markerIcon == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Marker warpMarker = dynmapFactionsPlugin.getFactionMarkers().remove(markId);
|
||||
String label = factionName + " [" + warp.getName() + "]";
|
||||
if (warpMarker == null) {
|
||||
warpMarker = dynmapFactionsPlugin.getSet().createMarker(markId, label, warpLocation.getWorld(),
|
||||
warpLocation.getLocationX(), warpLocation.getLocationY(), warpLocation.getLocationZ(), markerIcon, false);
|
||||
} else {
|
||||
warpMarker.setLocation(warpLocation.getWorld(), warpLocation.getLocationX(), warpLocation.getLocationY(),
|
||||
warpLocation.getLocationZ());
|
||||
warpMarker.setLabel(label); /* Update label */
|
||||
warpMarker.setMarkerIcon(markerIcon);
|
||||
}
|
||||
if (warpMarker != null) {
|
||||
warpMarker.setDescription(formatInfoWindow(faction)); /* Set popup */
|
||||
newMarkers.put(markId, warpMarker);
|
||||
}
|
||||
}
|
||||
|
||||
/* Handle specific faction on specific world */
|
||||
@ -356,12 +368,16 @@ public class FactionsUpdate implements Runnable {
|
||||
areaMarker.setBoostFlag(as.boost());
|
||||
}
|
||||
|
||||
private MarkerIcon getMarkerIcon(String factionName) {
|
||||
private MarkerIcon getMarkerIcon(String factionName, boolean isHome) {
|
||||
AreaStyle as = dynmapFactionsPlugin.getCustomStyle().get(factionName);
|
||||
if (as == null) {
|
||||
as = dynmapFactionsPlugin.getDefaultStyle();
|
||||
}
|
||||
if (isHome) {
|
||||
return as.homeIcon();
|
||||
} else {
|
||||
return as.warpIcon();
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isVisible(String id, String worldName) {
|
||||
|
@ -19,6 +19,7 @@ infoWindow: '<div class="infoWindow"><span style="font-size:120%;">%regionName%<
|
||||
# Allow players in faction to see one another on dynmap (only relevant if dynmap has 'player-info-protected' enabled)
|
||||
visibilityByFaction: true
|
||||
|
||||
# The default style for all faction regions
|
||||
regionStyle:
|
||||
strokeColor: "#FF0000"
|
||||
strokeOpacity: 0.8
|
||||
@ -26,6 +27,7 @@ regionStyle:
|
||||
fillColor: "#FF0000"
|
||||
fillOpacity: 0.35
|
||||
homeIcon: "redflag"
|
||||
warpIcon: "orangeflag"
|
||||
boost: false
|
||||
|
||||
# Optional setting to limit which regions to show, by name - if commented out, all regions are shown
|
||||
|
Loading…
Reference in New Issue
Block a user