Skip to content

Commit

Permalink
find_blocks_flagged: fix submapped flags
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Jul 24, 2021
1 parent 63aa0e0 commit 011d05d
Showing 1 changed file with 10 additions and 1 deletion.
@@ -1,5 +1,6 @@
package com.denizenscript.denizen.utilities.flags;

import com.denizenscript.denizen.objects.LocationTag;
import com.denizenscript.denizencore.utilities.CoreUtilities;
import org.bukkit.Chunk;
import org.bukkit.Location;
Expand All @@ -12,6 +13,12 @@
public class LocationFlagSearchHelper {

public static void getFlaggedLocations(Chunk chunk, String flagName, Consumer<Location> handleLocation) {
int subKeyIndex = flagName.indexOf('.');
String fullPath = null;
if (subKeyIndex != -1) {
fullPath = flagName;
flagName = flagName.substring(0, subKeyIndex);
}
PersistentDataContainer container = chunk.getPersistentDataContainer();
Location ref = new Location(chunk.getWorld(), 0, 0, 0);
for (NamespacedKey key : container.getKeys()) {
Expand All @@ -21,7 +28,9 @@ public static void getFlaggedLocations(Chunk chunk, String flagName, Consumer<Lo
ref.setX(Integer.parseInt(split.get(2)));
ref.setY(Integer.parseInt(split.get(3)));
ref.setZ(Integer.parseInt(split.get(4)));
handleLocation.accept(ref);
if (fullPath == null || new LocationTag(ref).getFlagTracker().hasFlag(fullPath)) {
handleLocation.accept(ref);
}
}
}
}
Expand Down

0 comments on commit 011d05d

Please sign in to comment.