From 8fe610311d92d06423efd7605832b0f35f2bbe9f Mon Sep 17 00:00:00 2001 From: dordsor21 Date: Thu, 23 Sep 2021 12:31:53 +0100 Subject: [PATCH] Comments --- .../bukkit/regions/WorldGuardFeature.java | 41 +++++++++---------- .../core/configuration/Settings.java | 2 +- .../platform/binding/ProvideBindings.java | 2 +- .../core/queue/IBatchProcessor.java | 2 + 4 files changed, 23 insertions(+), 24 deletions(-) diff --git a/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/regions/WorldGuardFeature.java b/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/regions/WorldGuardFeature.java index 4e3174b89..e956568d5 100644 --- a/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/regions/WorldGuardFeature.java +++ b/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/regions/WorldGuardFeature.java @@ -2,7 +2,6 @@ package com.fastasyncworldedit.bukkit.regions; import com.fastasyncworldedit.core.regions.FaweMask; import com.fastasyncworldedit.core.regions.RegionWrapper; -import com.google.common.collect.ImmutableSet; import com.sk89q.worldedit.bukkit.BukkitAdapter; import com.sk89q.worldedit.internal.util.LogManagerCompat; import com.sk89q.worldedit.math.BlockVector3; @@ -29,6 +28,7 @@ import org.bukkit.entity.Player; import org.bukkit.event.Listener; import org.bukkit.plugin.Plugin; +import java.util.Collection; import java.util.Collections; import java.util.HashSet; import java.util.Locale; @@ -73,6 +73,10 @@ public class WorldGuardFeature extends BukkitMaskManager implements Listener { return (WorldGuardPlugin) plugin; } + /** + * Get the WorldGuard regions a player is allowed in based on the current location, or if isWhitelist set to false, get the + * blacklisted regions for the world. + */ public Set getRegions(LocalPlayer player, Location location, boolean isWhitelist) { RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer(); if (container == null) { @@ -89,13 +93,13 @@ public class WorldGuardFeature extends BukkitMaskManager implements Listener { if (global != null && isAllowed(player, global) == isWhitelist) { return Collections.singleton(global); } - final ApplicableRegionSet regions = manager.getApplicableRegions(BlockVector3.at( - location.getX(), - location.getY(), - location.getZ() - )); //Merge WorldGuardFlag if (isWhitelist) { + final ApplicableRegionSet regions = manager.getApplicableRegions(BlockVector3.at( + location.getX(), + location.getY(), + location.getZ() + )); if (player.hasPermission("fawe.worldguardflag") && !regions.testState( player, Flags.BUILD, @@ -112,14 +116,7 @@ public class WorldGuardFeature extends BukkitMaskManager implements Listener { } return Collections.unmodifiableSet(protectedRegions); } else { - if (player.hasPermission("fawe.worldguardflag") && !regions.testState( - player, - Flags.BUILD, - Flags.BLOCK_PLACE, - Flags.BLOCK_BREAK - )) { - return ImmutableSet.copyOf(regions.getRegions()); - } + final Collection regions = manager.getRegions().values(); Set protectedRegions = new HashSet<>(); for (ProtectedRegion region : regions) { if (!isAllowed(player, region)) { @@ -161,19 +158,19 @@ public class WorldGuardFeature extends BukkitMaskManager implements Listener { final Set regions = this.getRegions(localplayer, location, isWhitelist); if (!regions.isEmpty()) { Set result = new HashSet<>(); - for (ProtectedRegion myregion : regions) { - if (myregion.getId().equals("__global__")) { + for (ProtectedRegion myRegion : regions) { + if (myRegion.getId().equals("__global__")) { return new FaweMask(RegionWrapper.GLOBAL()) { @Override public boolean isValid(com.sk89q.worldedit.entity.Player player, MaskType type) { - return isAllowed(worldguard.wrapPlayer(BukkitAdapter.adapt(player)), myregion); + return isAllowed(worldguard.wrapPlayer(BukkitAdapter.adapt(player)), myRegion); } }; } else { - if (myregion instanceof ProtectedCuboidRegion) { - result.add(new CuboidRegion(myregion.getMaximumPoint(), myregion.getMaximumPoint())); + if (myRegion instanceof ProtectedCuboidRegion) { + result.add(new CuboidRegion(myRegion.getMaximumPoint(), myRegion.getMaximumPoint())); } else { - result.add(adapt(myregion)); + result.add(adapt(myRegion)); } } } @@ -181,8 +178,8 @@ public class WorldGuardFeature extends BukkitMaskManager implements Listener { @Override public boolean isValid(com.sk89q.worldedit.entity.Player player, MaskType type) { final LocalPlayer localplayer = worldguard.wrapPlayer(BukkitAdapter.adapt(player)); - for (ProtectedRegion myregion : regions) { - if (!isAllowed(localplayer, myregion)) { + for (ProtectedRegion myRegion : regions) { + if (!isAllowed(localplayer, myRegion)) { return false; } } diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/configuration/Settings.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/configuration/Settings.java index 86bd99118..c3cf98af8 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/configuration/Settings.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/configuration/Settings.java @@ -127,7 +127,7 @@ public class Settings extends Config { public String MODE = "MEMBER"; @Comment({ "Allow region blacklists.", - " - Currently only implemented for WorldGuard ", + " - Currently only implemented for WorldGuard", " - see region-restrictions-options.worldguard-region-blacklist" }) public boolean ALLOW_BLACKLISTS = false; diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extension/platform/binding/ProvideBindings.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extension/platform/binding/ProvideBindings.java index 45067dae2..b296b5577 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extension/platform/binding/ProvideBindings.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extension/platform/binding/ProvideBindings.java @@ -83,7 +83,7 @@ public class ProvideBindings extends Bindings { return regions(player, FaweMaskManager.MaskType.MEMBER); } - public Region[] regions(Player player, FaweMaskManager.MaskType type) { + private Region[] regions(Player player, FaweMaskManager.MaskType type) { Region[] regions = player.getAllowedRegions(type); if (regions == null) { throw new IllegalArgumentException(Caption.toString(Caption.of("fawe.error.no.region"))); diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/IBatchProcessor.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/IBatchProcessor.java index f3240d0c2..1e9adf713 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/IBatchProcessor.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/IBatchProcessor.java @@ -6,7 +6,9 @@ import com.fastasyncworldedit.core.extent.processor.ProcessorScope; import com.sk89q.jnbt.CompoundTag; import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.extent.Extent; +import com.sk89q.worldedit.internal.util.LogManagerCompat; import com.sk89q.worldedit.math.BlockVector3; +import org.apache.logging.log4j.Logger; import javax.annotation.Nullable; import java.util.Map;