mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-12-23 01:37:37 +00:00
fix: invalidate cached FaweMask when a plot is unlinked (#2157)
* fix: invalidate cached FaweMask when a plot is unlinked - Fixes IntellectualSites/PlotSquared#3998 * Use a weakly-referenced copy of the copnncted plots set
This commit is contained in:
parent
da4d966d9e
commit
e4158ac084
@ -23,6 +23,7 @@ import com.sk89q.worldedit.world.World;
|
|||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
|
||||||
|
import java.lang.ref.WeakReference;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@ -176,15 +177,28 @@ public class PlotSquaredFeature extends FaweMaskManager {
|
|||||||
maskedRegion = new RegionIntersection(world, weRegions);
|
maskedRegion = new RegionIntersection(world, weRegions);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new FaweMask(maskedRegion) {
|
return new PlotSquaredMask(maskedRegion, finalPlot);
|
||||||
@Override
|
}
|
||||||
public boolean isValid(Player player, MaskType type) {
|
|
||||||
if (Settings.Done.RESTRICT_BUILDING && DoneFlag.isDone(finalPlot)) {
|
private final class PlotSquaredMask extends FaweMask {
|
||||||
return false;
|
|
||||||
}
|
private final Plot plot;
|
||||||
return isAllowed(player, finalPlot, type);
|
private final WeakReference<Set<Plot>> connectedPlots;
|
||||||
|
|
||||||
|
private PlotSquaredMask(Region region, Plot plot) {
|
||||||
|
super(region);
|
||||||
|
this.plot = plot;
|
||||||
|
connectedPlots = new WeakReference<>(plot.getConnectedPlots());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isValid(Player player, MaskType type) {
|
||||||
|
if (!connectedPlots.refersTo(plot.getConnectedPlots()) || (Settings.Done.RESTRICT_BUILDING && DoneFlag.isDone(plot))) {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
};
|
return isAllowed(player, plot, type);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user