Skip to content

Commit

Permalink
configurable default inclusive for polygons
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Oct 17, 2022
1 parent 14635aa commit 5cb6915
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
Expand Up @@ -73,6 +73,8 @@ public class PolygonTag implements ObjectTag, Cloneable, Notable, Adjustable, Ar

public AbstractFlagTracker flagTracker = null;

public static boolean preferInclusive = false;

public static class Corner {
public double x, z;

Expand Down Expand Up @@ -220,6 +222,10 @@ public String getNoteName() {

@Override
public boolean doesContainLocation(Location loc) {
return preferInclusive ? containsInclusive(loc) : containsPrecise(loc);
}

public boolean containsPrecise(Location loc) {
if (loc.getWorld() == null) {
return false;
}
Expand Down Expand Up @@ -304,7 +310,7 @@ public List<LocationTag> generateFlatBlockShell(double y, boolean inclusive) {
for (int x = (int) Math.floor(boxMin.x); x < boxMax.x; x++) {
for (int z = (int) Math.floor(boxMin.z); z < boxMax.z; z++) {
LocationTag possible = new LocationTag(x + 0.5, y, z + 0.5, world.getName());
if (inclusive ? containsInclusive(possible) : doesContainLocation(possible)) {
if (inclusive ? containsInclusive(possible) : containsPrecise(possible)) {
toOutput.add(possible);
}
max--;
Expand All @@ -318,7 +324,7 @@ public List<LocationTag> generateFlatBlockShell(double y, boolean inclusive) {

@Override
public ListTag getShell() {
return getShellInternal(false);
return getShellInternal(preferInclusive);
}

public ListTag getShellInternal(boolean inclusive) {
Expand Down Expand Up @@ -379,7 +385,7 @@ public ListTag getShellInternal(boolean inclusive) {

@Override
public ListTag getBlocks(Predicate<Location> test) {
return getBlocksInternal(test, false);
return getBlocksInternal(test, preferInclusive);
}

public ListTag getBlocksInternal(Predicate<Location> test, boolean inclusive) {
Expand Down
@@ -1,6 +1,7 @@
package com.denizenscript.denizen.utilities;

import com.denizenscript.denizen.Denizen;
import com.denizenscript.denizen.objects.PolygonTag;
import com.denizenscript.denizen.scripts.commands.entity.RemoveCommand;
import com.denizenscript.denizen.tags.core.CustomColorTagBase;
import com.denizenscript.denizen.utilities.flags.PlayerFlagHandler;
Expand Down Expand Up @@ -73,6 +74,7 @@ public static void refillCache() {
}
}
// Spigot
PolygonTag.preferInclusive = config.getBoolean("Tags.Polygon default inclusive", false);
skipChunkFlagCleaning = config.getBoolean("Saves.Skip chunk flag cleaning", false);
nullifySkullSkinIds = config.getBoolean("Tags.Nullify skull skin ids", false);
cache_overrideHelp = config.getBoolean("Debug.Override help", true);
Expand Down
2 changes: 2 additions & 0 deletions plugin/src/main/resources/config.yml
Expand Up @@ -255,6 +255,8 @@ Tags:
# The benefit of enabling this is it prevents locking the server thread to download the data from Mojang servers.
# The risk is that it may interfere with other plugins or systems that expect correct data to be set.
Nullify skull skin ids: false
# If true, polygons default to WorldEdit style block-inclusive logic. If false, use precise 'exclusive' logic.
Polygon default inclusive: false

# Java Reflection is the toolkit for accessing raw underlying Java data.
# Denizen partially exposes this, for example in 'JavaReflectedObjectTag', as some scripts may have use for this.
Expand Down

0 comments on commit 5cb6915

Please sign in to comment.