fix: invalidate cached allowed regions if WG region deleted (#2572)

This commit is contained in:
Jordan 2024-02-05 22:44:45 +01:00 committed by GitHub
parent a502287906
commit d1e1d5105e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -163,13 +163,22 @@ public class WorldGuardFeature extends BukkitMaskManager implements Listener {
final Location location = player.getLocation();
final Set<ProtectedRegion> regions = this.getRegions(localplayer, location, isWhitelist);
if (!regions.isEmpty()) {
RegionManager manager = WorldGuard
.getInstance()
.getPlatform()
.getRegionContainer()
.get(BukkitAdapter.adapt(location.getWorld()));
if (manager == null) {
return null;
}
Set<Region> result = new HashSet<>();
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 manager.hasRegion(myRegion.getId())
&& isAllowed(worldguard.wrapPlayer(BukkitAdapter.adapt(player)), myRegion);
}
};
} else {
@ -185,7 +194,7 @@ public class WorldGuardFeature extends BukkitMaskManager implements Listener {
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)) {
if (!manager.hasRegion(myRegion.getId()) || !isAllowed(localplayer, myRegion)) {
return false;
}
}