mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-12-22 09:17:39 +00:00
fix(GriefDefender): invalidate mask on claim change (#2903)
This commit is contained in:
parent
378334bd75
commit
4b099d3588
@ -3,7 +3,9 @@ package com.fastasyncworldedit.bukkit.regions;
|
||||
import com.fastasyncworldedit.core.regions.FaweMask;
|
||||
import com.griefdefender.api.GriefDefender;
|
||||
import com.griefdefender.api.claim.Claim;
|
||||
import com.griefdefender.api.claim.ClaimManager;
|
||||
import com.griefdefender.api.claim.TrustTypes;
|
||||
import com.griefdefender.lib.flowpowered.math.vector.Vector3i;
|
||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||
import com.sk89q.worldedit.internal.util.LogManagerCompat;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
@ -17,8 +19,8 @@ public class GriefDefenderFeature extends BukkitMaskManager implements Listener
|
||||
|
||||
private static final Logger LOGGER = LogManagerCompat.getLogger();
|
||||
|
||||
public GriefDefenderFeature(final Plugin GriefDefenderPlugin) {
|
||||
super(GriefDefenderPlugin.getName());
|
||||
public GriefDefenderFeature(final Plugin plugin) {
|
||||
super(plugin.getName());
|
||||
LOGGER.info("Plugin 'GriefDefender' found. Using it now.");
|
||||
}
|
||||
|
||||
@ -44,9 +46,14 @@ public class GriefDefenderFeature extends BukkitMaskManager implements Listener
|
||||
);
|
||||
return new FaweMask(new CuboidRegion(pos1, pos2)) {
|
||||
|
||||
private final int[] bounds = new int[]{
|
||||
pos1.x(), pos1.y(), pos1.z(),
|
||||
pos2.x(), pos2.y(), pos2.z()
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean isValid(com.sk89q.worldedit.entity.Player wePlayer, MaskType type) {
|
||||
return isAllowed(player, claim, type);
|
||||
return validateClaimAgainstCache(claim, bounds) && isAllowed(player, claim, type);
|
||||
}
|
||||
};
|
||||
}
|
||||
@ -54,4 +61,20 @@ public class GriefDefenderFeature extends BukkitMaskManager implements Listener
|
||||
return null;
|
||||
}
|
||||
|
||||
private static boolean validateClaimAgainstCache(Claim claim, int[] bounds) {
|
||||
Vector3i min = claim.getLesserBoundaryCorner();
|
||||
Vector3i max = claim.getGreaterBoundaryCorner();
|
||||
if (min.getX() != bounds[0] || min.getY() != bounds[1] || min.getZ() != bounds[2]) {
|
||||
return false;
|
||||
}
|
||||
if (max.getX() != bounds[3] || max.getY() != bounds[4] || max.getZ() != bounds[5]) {
|
||||
return false;
|
||||
}
|
||||
final ClaimManager manager = GriefDefender.getCore().getClaimManager(claim.getWorldUniqueId());
|
||||
if (manager == null) {
|
||||
return false;
|
||||
}
|
||||
return manager.getClaimByUUID(claim.getUniqueId()) != null;
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user