Skip to content

Commit

Permalink
Fix towns not rendering. (#36)
Browse files Browse the repository at this point in the history
  • Loading branch information
LlmDl authored Feb 8, 2024
1 parent cdb18f1 commit 647e665
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 15 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.dynmap</groupId>
<artifactId>Dynmap-Towny</artifactId>
<version>1.1.0</version>
<version>1.1.1</version>

<build>
<defaultGoal>clean package</defaultGoal>
Expand Down
28 changes: 14 additions & 14 deletions src/main/java/org/dynmap/towny/mapupdate/UpdateTowns.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ public void run() {
Map<String, AreaMarker> newmap = new HashMap<String, AreaMarker>(); /* Build new map */
Map<String, Marker> newmark = new HashMap<String, Marker>(); /* Build new map */

try {
/* Loop through towns */
for (Town t : TownyAPI.getInstance().getTowns()) {
/* Loop through towns */
for (Town t : TownyAPI.getInstance().getTowns()) {
try {
handleTown(t, newmap, newmark, null);
if (Settings.showingShops() && townHasTBsOfType(t, TownBlockType.COMMERCIAL)) {
handleTown(t, newmap, newmark, TownBlockType.COMMERCIAL);
Expand All @@ -63,17 +63,17 @@ public void run() {
if (Settings.showingWilds() && townHasTBsOfType(t, TownBlockType.WILDS)) {
handleTown(t, newmap, newmark, TownBlockType.WILDS);
}
} catch (Exception e) {
plugin.getLogger().info(e.getMessage());
}
/* Now, review old maps - anything left is removed */
existingAreaMarkers.values().forEach(a -> a.deleteMarker());
existingMarkers.values().forEach(m -> m.deleteMarker());

/* And replace with new map */
existingAreaMarkers = newmap;
existingMarkers = newmark;
} catch (Exception e) {
plugin.getLogger().info(e.getMessage());
}
/* Now, review old maps - anything left is removed */
existingAreaMarkers.values().forEach(a -> a.deleteMarker());
existingMarkers.values().forEach(m -> m.deleteMarker());

/* And replace with new map */
existingAreaMarkers = newmap;
existingMarkers = newmark;
}

private boolean townHasTBsOfType(Town t, TownBlockType tbType) {
Expand Down Expand Up @@ -329,11 +329,11 @@ private static int floodFillTarget(TileFlags src, TileFlags dest, int x, int y)

private static boolean isVisible(String id, String worldname) {

if (Settings.getVisibleRegions().size() > 0 &&
if (Settings.visibleRegionsAreSet() &&
(Settings.getVisibleRegions().contains("world:" + worldname) == false || Settings.getVisibleRegions().contains(id) == false))
return false;

if (Settings.getHiddenRegions().size() > 0 &&
if (Settings.hiddenRegionsAreSet() &&
(Settings.getHiddenRegions().contains(id) || Settings.getHiddenRegions().contains("world:" + worldname)))
return false;
return true;
Expand Down
12 changes: 12 additions & 0 deletions src/main/java/org/dynmap/towny/settings/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -359,9 +359,21 @@ public static Set<String> getVisibleRegions() {
return visibleRegions;
}

public static boolean visibleRegionsAreSet() {
Set<String> visibleRegions = getVisibleRegions();
// Pre-CommentedConfiguration configs will have their region set to [], which throws off the results.
return visibleRegions.size() > 0 && !(visibleRegions.size() == 1 && visibleRegions.contains("[]"));
}

public static Set<String> getHiddenRegions() {
if (hiddenRegions == null)
hiddenRegions = new HashSet<>(getStrArr(ConfigNodes.HIDDEN_ROOT));
return hiddenRegions;
}

public static boolean hiddenRegionsAreSet() {
Set<String> hiddenRegions = getHiddenRegions();
// Pre-CommentedConfiguration configs will have their region set to [], which throws off the results.
return hiddenRegions.size() > 0 && !(hiddenRegions.size() == 1 && hiddenRegions.contains("[]"));
}
}

0 comments on commit 647e665

Please sign in to comment.