Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions src/main/java/world/bentobox/bentobox/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,18 @@ public class Settings implements ConfigObject {
@ConfigEntry(path = "panel.ticks-between-calls", since = "1.16.0", needsRestart = true)
private long ticksBetweenCalls = 10;

/* DYNMAP */
@ConfigComment("Toggle whether BentoBox shows a marker (house icon) on Dynmap at the center of every island.")
@ConfigComment("On worlds with many tightly-packed islands these icons can flood the map. Set to false to hide them.")
@ConfigComment("/!\\ Restart the server or use /bbox reload after changing this for it to take effect.")
@ConfigEntry(path = "dynmap.island-markers", since = "3.17.1")
private boolean dynmapIslandMarkers = true;

@ConfigComment("Toggle whether BentoBox draws the protected area border box of every island on Dynmap.")
@ConfigComment("/!\\ Restart the server or use /bbox reload after changing this for it to take effect.")
@ConfigEntry(path = "dynmap.island-areas", since = "3.17.1")
private boolean dynmapIslandAreas = true;

/*
* Logs
*/
Expand Down Expand Up @@ -982,6 +994,46 @@ public void setTicksBetweenCalls(long ticksBetweenCalls) {
this.ticksBetweenCalls = ticksBetweenCalls;
}

/**
* Whether BentoBox shows a marker (house icon) on Dynmap at the center of every island.
*
* @return true if island markers should be shown
* @since 3.17.1
*/
public boolean isDynmapIslandMarkers() {
return dynmapIslandMarkers;
}

/**
* Sets whether BentoBox shows a marker (house icon) on Dynmap at the center of every island.
*
* @param dynmapIslandMarkers whether island markers should be shown
* @since 3.17.1
*/
public void setDynmapIslandMarkers(boolean dynmapIslandMarkers) {
this.dynmapIslandMarkers = dynmapIslandMarkers;
}

/**
* Whether BentoBox draws the protected area border box of every island on Dynmap.
*
* @return true if island area boxes should be drawn
* @since 3.17.1
*/
public boolean isDynmapIslandAreas() {
return dynmapIslandAreas;
}

/**
* Sets whether BentoBox draws the protected area border box of every island on Dynmap.
*
* @param dynmapIslandAreas whether island area boxes should be drawn
* @since 3.17.1
*/
public void setDynmapIslandAreas(boolean dynmapIslandAreas) {
this.dynmapIslandAreas = dynmapIslandAreas;
}

/**
* @return the minPortalSearchRadius
*/
Expand Down
30 changes: 17 additions & 13 deletions src/main/java/world/bentobox/bentobox/hooks/DynmapHook.java
Original file line number Diff line number Diff line change
Expand Up @@ -121,20 +121,24 @@ private void setMarker(MarkerSet markerSet, Island island) {
existingArea.deleteMarker();
}
// Point marker at island center for the label/icon
markerSet.createMarker(id, label, worldName,
island.getCenter().getX(), island.getCenter().getY(), island.getCenter().getZ(),
markerAPI.getMarkerIcon("default"), true);
if (plugin.getSettings().isDynmapIslandMarkers()) {
markerSet.createMarker(id, label, worldName,
island.getCenter().getX(), island.getCenter().getY(), island.getCenter().getZ(),
markerAPI.getMarkerIcon("default"), true);
}
// Area marker showing the protected island border
double[] xCorners = { island.getMinProtectedX(), island.getMaxProtectedX(),
island.getMaxProtectedX(), island.getMinProtectedX() };
double[] zCorners = { island.getMinProtectedZ(), island.getMinProtectedZ(),
island.getMaxProtectedZ(), island.getMaxProtectedZ() };
AreaMarker area = markerSet.createAreaMarker(id + "_area", label, false, worldName,
xCorners, zCorners, true);
if (area != null) {
area.setRangeY(w.getMaxHeight(), w.getMinHeight());
area.setLineStyle(2, 0.8, 0x3388FF);
area.setFillStyle(0.15, 0x3388FF);
if (plugin.getSettings().isDynmapIslandAreas()) {
double[] xCorners = { island.getMinProtectedX(), island.getMaxProtectedX(),
island.getMaxProtectedX(), island.getMinProtectedX() };
double[] zCorners = { island.getMinProtectedZ(), island.getMinProtectedZ(),
island.getMaxProtectedZ(), island.getMaxProtectedZ() };
AreaMarker area = markerSet.createAreaMarker(id + "_area", label, false, worldName,
xCorners, zCorners, true);
if (area != null) {
area.setRangeY(w.getMaxHeight(), w.getMinHeight());
area.setLineStyle(2, 0.8, 0x3388FF);
area.setFillStyle(0.15, 0x3388FF);
}
}
}

Expand Down
10 changes: 10 additions & 0 deletions src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,16 @@ panel:
# Added since 1.16.0.
# /!\ In order to apply the changes made to this option, you must restart your server. Reloading BentoBox or the server won't work.
ticks-between-calls: 10
dynmap:
# Toggle whether BentoBox shows a marker (house icon) on Dynmap at the center of every island.
# On worlds with many tightly-packed islands these icons can flood the map. Set to false to hide them.
# /!\ Restart the server or use /bbox reload after changing this for it to take effect.
# Added since 3.17.1.
island-markers: true
# Toggle whether BentoBox draws the protected area border box of every island on Dynmap.
# /!\ Restart the server or use /bbox reload after changing this for it to take effect.
# Added since 3.17.1.
island-areas: true
logs:
# Toggle whether superflat chunks regeneration should be logged in the server logs or not.
# It can be spammy if there are a lot of superflat chunks to regenerate.
Expand Down
24 changes: 24 additions & 0 deletions src/test/java/world/bentobox/bentobox/hooks/DynmapHookTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,30 @@
eq("bskyblock_world"), eq(0.0), eq(64.0), eq(0.0), eq(defaultIcon), eq(true));
}

@Test
void testIslandMarkersDisabledNoPointMarker() {
plugin.getSettings().setDynmapIslandMarkers(false);
when(im.getIslands(overWorld)).thenReturn(List.of(island));
hookAndReady();
// No house icon, but the area box is still drawn
verify(markerSet, never()).createMarker(anyString(), anyString(), anyString(),
anyDouble(), anyDouble(), anyDouble(), any(MarkerIcon.class), anyBoolean());
verify(markerSet).createAreaMarker(eq(uuid.toString() + "_area"), eq("tastybento"), eq(false),
eq("bskyblock_world"), any(double[].class), any(double[].class), eq(true));
}

@Test
void testIslandAreasDisabledNoAreaMarker() {
plugin.getSettings().setDynmapIslandAreas(false);
when(im.getIslands(overWorld)).thenReturn(List.of(island));
hookAndReady();
// House icon still placed, but no area box
verify(markerSet).createMarker(eq(uuid.toString()), eq("tastybento"),

Check warning on line 231 in src/test/java/world/bentobox/bentobox/hooks/DynmapHookTest.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove this and every subsequent useless "eq(...)" invocation; pass the values directly.

See more on https://sonarcloud.io/project/issues?id=BentoBoxWorld_BentoBox&issues=AZ7LqDkNAEcTTWTfH0h1&open=AZ7LqDkNAEcTTWTfH0h1&pullRequest=2991
eq("bskyblock_world"), eq(0.0), eq(64.0), eq(0.0), eq(defaultIcon), eq(true));
verify(markerSet, never()).createAreaMarker(anyString(), anyString(), anyBoolean(), anyString(),
any(double[].class), any(double[].class), anyBoolean());
}

@Test
void testAreaMarkerYRangeSetToWorldHeight() {
when(im.getIslands(overWorld)).thenReturn(List.of(island));
Expand Down
Loading