Skip to content

Commit e09a08d

Browse files
tastybentoclaude
andcommitted
feat: add config toggles for Dynmap island markers and area boxes
On worlds with many tightly-packed islands, the house icon marker and protected-area border box BentoBox draws on Dynmap for every island can flood the map. Add two config options under a new `dynmap` section: - dynmap.island-markers (default true): show the center house icon - dynmap.island-areas (default true): draw the protected area border box DynmapHook now checks these settings before creating each marker type. Defaults preserve existing behaviour. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 0710ecd commit e09a08d

4 files changed

Lines changed: 103 additions & 13 deletions

File tree

src/main/java/world/bentobox/bentobox/Settings.java

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,18 @@ public class Settings implements ConfigObject {
187187
@ConfigEntry(path = "panel.ticks-between-calls", since = "1.16.0", needsRestart = true)
188188
private long ticksBetweenCalls = 10;
189189

190+
/* DYNMAP */
191+
@ConfigComment("Toggle whether BentoBox shows a marker (house icon) on Dynmap at the center of every island.")
192+
@ConfigComment("On worlds with many tightly-packed islands these icons can flood the map. Set to false to hide them.")
193+
@ConfigComment("/!\\ Restart the server or use /bbox reload after changing this for it to take effect.")
194+
@ConfigEntry(path = "dynmap.island-markers", since = "3.17.1")
195+
private boolean dynmapIslandMarkers = true;
196+
197+
@ConfigComment("Toggle whether BentoBox draws the protected area border box of every island on Dynmap.")
198+
@ConfigComment("/!\\ Restart the server or use /bbox reload after changing this for it to take effect.")
199+
@ConfigEntry(path = "dynmap.island-areas", since = "3.17.1")
200+
private boolean dynmapIslandAreas = true;
201+
190202
/*
191203
* Logs
192204
*/
@@ -982,6 +994,46 @@ public void setTicksBetweenCalls(long ticksBetweenCalls) {
982994
this.ticksBetweenCalls = ticksBetweenCalls;
983995
}
984996

997+
/**
998+
* Whether BentoBox shows a marker (house icon) on Dynmap at the center of every island.
999+
*
1000+
* @return true if island markers should be shown
1001+
* @since 3.17.1
1002+
*/
1003+
public boolean isDynmapIslandMarkers() {
1004+
return dynmapIslandMarkers;
1005+
}
1006+
1007+
/**
1008+
* Sets whether BentoBox shows a marker (house icon) on Dynmap at the center of every island.
1009+
*
1010+
* @param dynmapIslandMarkers whether island markers should be shown
1011+
* @since 3.17.1
1012+
*/
1013+
public void setDynmapIslandMarkers(boolean dynmapIslandMarkers) {
1014+
this.dynmapIslandMarkers = dynmapIslandMarkers;
1015+
}
1016+
1017+
/**
1018+
* Whether BentoBox draws the protected area border box of every island on Dynmap.
1019+
*
1020+
* @return true if island area boxes should be drawn
1021+
* @since 3.17.1
1022+
*/
1023+
public boolean isDynmapIslandAreas() {
1024+
return dynmapIslandAreas;
1025+
}
1026+
1027+
/**
1028+
* Sets whether BentoBox draws the protected area border box of every island on Dynmap.
1029+
*
1030+
* @param dynmapIslandAreas whether island area boxes should be drawn
1031+
* @since 3.17.1
1032+
*/
1033+
public void setDynmapIslandAreas(boolean dynmapIslandAreas) {
1034+
this.dynmapIslandAreas = dynmapIslandAreas;
1035+
}
1036+
9851037
/**
9861038
* @return the minPortalSearchRadius
9871039
*/

src/main/java/world/bentobox/bentobox/hooks/DynmapHook.java

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -121,20 +121,24 @@ private void setMarker(MarkerSet markerSet, Island island) {
121121
existingArea.deleteMarker();
122122
}
123123
// Point marker at island center for the label/icon
124-
markerSet.createMarker(id, label, worldName,
125-
island.getCenter().getX(), island.getCenter().getY(), island.getCenter().getZ(),
126-
markerAPI.getMarkerIcon("default"), true);
124+
if (plugin.getSettings().isDynmapIslandMarkers()) {
125+
markerSet.createMarker(id, label, worldName,
126+
island.getCenter().getX(), island.getCenter().getY(), island.getCenter().getZ(),
127+
markerAPI.getMarkerIcon("default"), true);
128+
}
127129
// Area marker showing the protected island border
128-
double[] xCorners = { island.getMinProtectedX(), island.getMaxProtectedX(),
129-
island.getMaxProtectedX(), island.getMinProtectedX() };
130-
double[] zCorners = { island.getMinProtectedZ(), island.getMinProtectedZ(),
131-
island.getMaxProtectedZ(), island.getMaxProtectedZ() };
132-
AreaMarker area = markerSet.createAreaMarker(id + "_area", label, false, worldName,
133-
xCorners, zCorners, true);
134-
if (area != null) {
135-
area.setRangeY(w.getMaxHeight(), w.getMinHeight());
136-
area.setLineStyle(2, 0.8, 0x3388FF);
137-
area.setFillStyle(0.15, 0x3388FF);
130+
if (plugin.getSettings().isDynmapIslandAreas()) {
131+
double[] xCorners = { island.getMinProtectedX(), island.getMaxProtectedX(),
132+
island.getMaxProtectedX(), island.getMinProtectedX() };
133+
double[] zCorners = { island.getMinProtectedZ(), island.getMinProtectedZ(),
134+
island.getMaxProtectedZ(), island.getMaxProtectedZ() };
135+
AreaMarker area = markerSet.createAreaMarker(id + "_area", label, false, worldName,
136+
xCorners, zCorners, true);
137+
if (area != null) {
138+
area.setRangeY(w.getMaxHeight(), w.getMinHeight());
139+
area.setLineStyle(2, 0.8, 0x3388FF);
140+
area.setFillStyle(0.15, 0x3388FF);
141+
}
138142
}
139143
}
140144

src/main/resources/config.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,16 @@ panel:
117117
# Added since 1.16.0.
118118
# /!\ In order to apply the changes made to this option, you must restart your server. Reloading BentoBox or the server won't work.
119119
ticks-between-calls: 10
120+
dynmap:
121+
# Toggle whether BentoBox shows a marker (house icon) on Dynmap at the center of every island.
122+
# On worlds with many tightly-packed islands these icons can flood the map. Set to false to hide them.
123+
# /!\ Restart the server or use /bbox reload after changing this for it to take effect.
124+
# Added since 3.17.1.
125+
island-markers: true
126+
# Toggle whether BentoBox draws the protected area border box of every island on Dynmap.
127+
# /!\ Restart the server or use /bbox reload after changing this for it to take effect.
128+
# Added since 3.17.1.
129+
island-areas: true
120130
logs:
121131
# Toggle whether superflat chunks regeneration should be logged in the server logs or not.
122132
# It can be spammy if there are a lot of superflat chunks to regenerate.

src/test/java/world/bentobox/bentobox/hooks/DynmapHookTest.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,30 @@ void testRegisterGameModeWithIsland() {
210210
eq("bskyblock_world"), eq(0.0), eq(64.0), eq(0.0), eq(defaultIcon), eq(true));
211211
}
212212

213+
@Test
214+
void testIslandMarkersDisabledNoPointMarker() {
215+
plugin.getSettings().setDynmapIslandMarkers(false);
216+
when(im.getIslands(overWorld)).thenReturn(List.of(island));
217+
hookAndReady();
218+
// No house icon, but the area box is still drawn
219+
verify(markerSet, never()).createMarker(anyString(), anyString(), anyString(),
220+
anyDouble(), anyDouble(), anyDouble(), any(MarkerIcon.class), anyBoolean());
221+
verify(markerSet).createAreaMarker(eq(uuid.toString() + "_area"), eq("tastybento"), eq(false),
222+
eq("bskyblock_world"), any(double[].class), any(double[].class), eq(true));
223+
}
224+
225+
@Test
226+
void testIslandAreasDisabledNoAreaMarker() {
227+
plugin.getSettings().setDynmapIslandAreas(false);
228+
when(im.getIslands(overWorld)).thenReturn(List.of(island));
229+
hookAndReady();
230+
// House icon still placed, but no area box
231+
verify(markerSet).createMarker(eq(uuid.toString()), eq("tastybento"),
232+
eq("bskyblock_world"), eq(0.0), eq(64.0), eq(0.0), eq(defaultIcon), eq(true));
233+
verify(markerSet, never()).createAreaMarker(anyString(), anyString(), anyBoolean(), anyString(),
234+
any(double[].class), any(double[].class), anyBoolean());
235+
}
236+
213237
@Test
214238
void testAreaMarkerYRangeSetToWorldHeight() {
215239
when(im.getIslands(overWorld)).thenReturn(List.of(island));

0 commit comments

Comments
 (0)