mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-06-12 04:23:54 +00:00
Implement region blacklisting
This commit is contained in:
@ -1,42 +0,0 @@
|
||||
package com.fastasyncworldedit.bukkit.filter;
|
||||
|
||||
import com.fastasyncworldedit.core.regions.filter.CuboidRegionFilter;
|
||||
import com.fastasyncworldedit.core.util.TaskManager;
|
||||
import com.flowpowered.math.vector.Vector3i;
|
||||
import com.griefdefender.api.GriefDefender;
|
||||
import com.griefdefender.api.claim.Claim;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import org.bukkit.World;
|
||||
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.Collection;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
public class GriefDefenderFilter extends CuboidRegionFilter {
|
||||
|
||||
private final Collection<Claim> claims;
|
||||
private final World world;
|
||||
|
||||
public GriefDefenderFilter(World world) {
|
||||
checkNotNull(world);
|
||||
this.claims = TaskManager.IMP.sync(
|
||||
(Supplier<Collection<Claim>>) () -> new ArrayDeque<>(GriefDefender.getCore().getAllClaims()));
|
||||
this.world = world;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void calculateRegions() {
|
||||
for (Claim claim : claims) {
|
||||
Vector3i bot = claim.getGreaterBoundaryCorner();
|
||||
if (world.getUID().equals(claim.getWorldUniqueId())) {
|
||||
Vector3i top = claim.getGreaterBoundaryCorner();
|
||||
BlockVector2 pos1 = BlockVector2.at(bot.getX(), bot.getZ());
|
||||
BlockVector2 pos2 = BlockVector2.at(top.getX(), top.getZ());
|
||||
add(pos1, pos2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,41 +0,0 @@
|
||||
package com.fastasyncworldedit.bukkit.filter;
|
||||
|
||||
import com.fastasyncworldedit.core.regions.filter.CuboidRegionFilter;
|
||||
import com.fastasyncworldedit.core.util.TaskManager;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import me.ryanhamshire.GriefPrevention.Claim;
|
||||
import me.ryanhamshire.GriefPrevention.GriefPrevention;
|
||||
import org.bukkit.World;
|
||||
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.Collection;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
public class GriefPreventionFilter extends CuboidRegionFilter {
|
||||
|
||||
private final Collection<Claim> claims;
|
||||
private final World world;
|
||||
|
||||
public GriefPreventionFilter(World world) {
|
||||
checkNotNull(world);
|
||||
this.claims = TaskManager.IMP.sync(
|
||||
(Supplier<Collection<Claim>>) () -> new ArrayDeque<>(GriefPrevention.instance.dataStore.getClaims()));
|
||||
this.world = world;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void calculateRegions() {
|
||||
for (Claim claim : claims) {
|
||||
org.bukkit.Location bot = claim.getGreaterBoundaryCorner();
|
||||
if (world.equals(bot.getWorld())) {
|
||||
org.bukkit.Location top = claim.getGreaterBoundaryCorner();
|
||||
BlockVector2 pos1 = BlockVector2.at(bot.getBlockX(), bot.getBlockZ());
|
||||
BlockVector2 pos2 = BlockVector2.at(top.getBlockX(), top.getBlockZ());
|
||||
add(pos1, pos2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,73 +0,0 @@
|
||||
package com.fastasyncworldedit.bukkit.filter;
|
||||
|
||||
import com.fastasyncworldedit.core.Fawe;
|
||||
import com.fastasyncworldedit.core.regions.filter.CuboidRegionFilter;
|
||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||
import com.sk89q.worldedit.internal.util.LogManagerCompat;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldguard.WorldGuard;
|
||||
import com.sk89q.worldguard.protection.ApplicableRegionSet;
|
||||
import com.sk89q.worldguard.protection.managers.RegionManager;
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion;
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.bukkit.World;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
public class WorldGuardFilter extends CuboidRegionFilter {
|
||||
|
||||
private static final Logger LOGGER = LogManagerCompat.getLogger();
|
||||
|
||||
private final World world;
|
||||
private boolean large;
|
||||
private RegionManager manager;
|
||||
|
||||
public WorldGuardFilter(World world) {
|
||||
checkNotNull(world);
|
||||
this.world = world;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void calculateRegions() {
|
||||
Fawe.get().getQueueHandler().sync(() -> {
|
||||
WorldGuardFilter.this.manager = WorldGuard.getInstance().getPlatform().getRegionContainer().get(
|
||||
BukkitAdapter.adapt(world));
|
||||
for (ProtectedRegion region : manager.getRegions().values()) {
|
||||
BlockVector3 min = region.getMinimumPoint();
|
||||
BlockVector3 max = region.getMaximumPoint();
|
||||
if (max.getBlockX() - min.getBlockX() > 1024 || max.getBlockZ() - min.getBlockZ() > 1024) {
|
||||
LOGGER.info("Large or complex region shapes cannot be optimized. Filtering will be slower");
|
||||
large = true;
|
||||
break;
|
||||
}
|
||||
add(min.toBlockVector2(), max.toBlockVector2());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean containsChunk(int chunkX, int chunkZ) {
|
||||
if (!large) {
|
||||
return super.containsChunk(chunkX, chunkZ);
|
||||
}
|
||||
BlockVector3 pos1 = BlockVector3.at(chunkX << 4, 0, chunkZ << 4);
|
||||
BlockVector3 pos2 = BlockVector3.at(pos1.getBlockX() + 15, 255, pos1.getBlockZ() + 15);
|
||||
ProtectedCuboidRegion chunkRegion = new ProtectedCuboidRegion("unimportant", pos1, pos2);
|
||||
ApplicableRegionSet set = manager.getApplicableRegions(chunkRegion);
|
||||
return set.size() > 0 && !set.getRegions().iterator().next().getId().equals("__global__");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean containsRegion(int mcaX, int mcaZ) {
|
||||
if (!large) {
|
||||
return super.containsRegion(mcaX, mcaZ);
|
||||
}
|
||||
BlockVector3 pos1 = BlockVector3.at(mcaX << 9, 0, mcaZ << 9);
|
||||
BlockVector3 pos2 = BlockVector3.at(pos1.getBlockX() + 511, 255, pos1.getBlockZ() + 511);
|
||||
ProtectedCuboidRegion regionRegion = new ProtectedCuboidRegion("unimportant", pos1, pos2);
|
||||
ApplicableRegionSet set = manager.getApplicableRegions(regionRegion);
|
||||
return set.size() > 0 && !set.getRegions().iterator().next().getId().equals("__global__");
|
||||
}
|
||||
|
||||
}
|
@ -1,8 +1,6 @@
|
||||
package com.fastasyncworldedit.bukkit.regions;
|
||||
|
||||
import com.fastasyncworldedit.bukkit.filter.GriefDefenderFilter;
|
||||
import com.fastasyncworldedit.core.regions.FaweMask;
|
||||
import com.fastasyncworldedit.core.regions.filter.RegionFilter;
|
||||
import com.flowpowered.math.vector.Vector3i;
|
||||
import com.griefdefender.api.GriefDefender;
|
||||
import com.griefdefender.api.claim.Claim;
|
||||
@ -12,7 +10,6 @@ import com.sk89q.worldedit.internal.util.LogManagerCompat;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Listener;
|
||||
@ -65,9 +62,4 @@ public class GriefDefenderFeature extends BukkitMaskManager implements Listener
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RegionFilter getFilter(String world) {
|
||||
return new GriefDefenderFilter(Bukkit.getWorld(world));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,8 +1,6 @@
|
||||
package com.fastasyncworldedit.bukkit.regions;
|
||||
|
||||
import com.fastasyncworldedit.bukkit.filter.GriefPreventionFilter;
|
||||
import com.fastasyncworldedit.core.regions.FaweMask;
|
||||
import com.fastasyncworldedit.core.regions.filter.RegionFilter;
|
||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||
import com.sk89q.worldedit.internal.util.LogManagerCompat;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
@ -10,7 +8,6 @@ import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
import me.ryanhamshire.GriefPrevention.Claim;
|
||||
import me.ryanhamshire.GriefPrevention.GriefPrevention;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Listener;
|
||||
@ -61,9 +58,4 @@ public class GriefPreventionFeature extends BukkitMaskManager implements Listene
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RegionFilter getFilter(String world) {
|
||||
return new GriefPreventionFilter(Bukkit.getWorld(world));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,9 +1,8 @@
|
||||
package com.fastasyncworldedit.bukkit.regions;
|
||||
|
||||
import com.fastasyncworldedit.bukkit.filter.WorldGuardFilter;
|
||||
import com.fastasyncworldedit.core.regions.FaweMask;
|
||||
import com.fastasyncworldedit.core.regions.RegionWrapper;
|
||||
import com.fastasyncworldedit.core.regions.filter.RegionFilter;
|
||||
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;
|
||||
@ -11,6 +10,7 @@ import com.sk89q.worldedit.regions.AbstractRegion;
|
||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
import com.sk89q.worldedit.regions.Polygonal2DRegion;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.regions.RegionIntersection;
|
||||
import com.sk89q.worldguard.LocalPlayer;
|
||||
import com.sk89q.worldguard.WorldGuard;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||
@ -29,12 +29,38 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Locale;
|
||||
import java.util.Set;
|
||||
|
||||
public class WorldGuardFeature extends BukkitMaskManager implements Listener {
|
||||
|
||||
private final WorldGuardPlugin worldguard;
|
||||
private static final Logger LOGGER = LogManagerCompat.getLogger();
|
||||
private final WorldGuardPlugin worldguard;
|
||||
|
||||
public WorldGuardFeature(Plugin plugin) {
|
||||
super(plugin.getName());
|
||||
this.worldguard = this.getWorldGuard();
|
||||
LOGGER.info("Plugin 'WorldGuard' found. Using it now.");
|
||||
|
||||
}
|
||||
|
||||
private static Region adapt(ProtectedRegion region) {
|
||||
if (region instanceof ProtectedCuboidRegion) {
|
||||
return new CuboidRegion(region.getMinimumPoint(), region.getMaximumPoint());
|
||||
}
|
||||
if (region instanceof GlobalProtectedRegion) {
|
||||
return RegionWrapper.GLOBAL();
|
||||
}
|
||||
if (region instanceof ProtectedPolygonalRegion) {
|
||||
ProtectedPolygonalRegion casted = (ProtectedPolygonalRegion) region;
|
||||
BlockVector3 max = region.getMaximumPoint();
|
||||
BlockVector3 min = region.getMinimumPoint();
|
||||
return new Polygonal2DRegion(null, casted.getPoints(), min.getBlockY(), max.getBlockY());
|
||||
}
|
||||
return new AdaptedRegion(region);
|
||||
}
|
||||
|
||||
private WorldGuardPlugin getWorldGuard() {
|
||||
final Plugin plugin = Bukkit.getPluginManager().getPlugin("WorldGuard");
|
||||
@ -47,27 +73,21 @@ public class WorldGuardFeature extends BukkitMaskManager implements Listener {
|
||||
return (WorldGuardPlugin) plugin;
|
||||
}
|
||||
|
||||
public WorldGuardFeature(Plugin plugin) {
|
||||
super(plugin.getName());
|
||||
this.worldguard = this.getWorldGuard();
|
||||
LOGGER.info("Plugin 'WorldGuard' found. Using it now.");
|
||||
|
||||
}
|
||||
|
||||
public ProtectedRegion getRegion(LocalPlayer player, Location location) {
|
||||
public Set<ProtectedRegion> getRegions(LocalPlayer player, Location location, boolean isWhitelist) {
|
||||
RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer();
|
||||
if (container == null) {
|
||||
LOGGER.info("Region capability is not enabled for WorldGuard.");
|
||||
return null;
|
||||
return Collections.emptySet();
|
||||
}
|
||||
RegionManager manager = container.get(BukkitAdapter.adapt(location.getWorld()));
|
||||
if (manager == null) {
|
||||
LOGGER.info("Region capability is not enabled for that world.");
|
||||
return null;
|
||||
return Collections.emptySet();
|
||||
}
|
||||
final ProtectedRegion global = manager.getRegion("__global__");
|
||||
if (global != null && isAllowed(player, global)) {
|
||||
return global;
|
||||
// If they're allowed and it's a whitelist return, else if they're not allowed and it's a blacklist, return
|
||||
if (global != null && isAllowed(player, global) == isWhitelist) {
|
||||
return Collections.singleton(global);
|
||||
}
|
||||
final ApplicableRegionSet regions = manager.getApplicableRegions(BlockVector3.at(
|
||||
location.getX(),
|
||||
@ -75,20 +95,39 @@ public class WorldGuardFeature extends BukkitMaskManager implements Listener {
|
||||
location.getZ()
|
||||
));
|
||||
//Merge WorldGuardFlag
|
||||
if (player.hasPermission("fawe.worldguardflag") && !regions.testState(
|
||||
player,
|
||||
Flags.BUILD,
|
||||
Flags.BLOCK_PLACE,
|
||||
Flags.BLOCK_BREAK
|
||||
)) {
|
||||
return null;
|
||||
}
|
||||
for (ProtectedRegion region : regions) {
|
||||
if (isAllowed(player, region)) {
|
||||
return region;
|
||||
if (isWhitelist) {
|
||||
if (player.hasPermission("fawe.worldguardflag") && !regions.testState(
|
||||
player,
|
||||
Flags.BUILD,
|
||||
Flags.BLOCK_PLACE,
|
||||
Flags.BLOCK_BREAK
|
||||
)) {
|
||||
return Collections.emptySet();
|
||||
}
|
||||
Set<ProtectedRegion> protectedRegions = new HashSet<>();
|
||||
for (ProtectedRegion region : regions) {
|
||||
if (isAllowed(player, region)) {
|
||||
protectedRegions.add(region);
|
||||
}
|
||||
}
|
||||
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());
|
||||
}
|
||||
Set<ProtectedRegion> protectedRegions = new HashSet<>();
|
||||
for (ProtectedRegion region : regions) {
|
||||
if (!isAllowed(player, region)) {
|
||||
protectedRegions.add(region);
|
||||
}
|
||||
}
|
||||
return Collections.unmodifiableSet(protectedRegions);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean isAllowed(LocalPlayer localplayer, ProtectedRegion region) {
|
||||
@ -115,45 +154,45 @@ public class WorldGuardFeature extends BukkitMaskManager implements Listener {
|
||||
}
|
||||
|
||||
@Override
|
||||
public FaweMask getMask(com.sk89q.worldedit.entity.Player wePlayer, MaskType type) {
|
||||
public FaweMask getMask(com.sk89q.worldedit.entity.Player wePlayer, MaskType type, boolean isWhitelist) {
|
||||
final Player player = BukkitAdapter.adapt(wePlayer);
|
||||
final LocalPlayer localplayer = this.worldguard.wrapPlayer(player);
|
||||
final Location location = player.getLocation();
|
||||
final ProtectedRegion myregion = this.getRegion(localplayer, location);
|
||||
if (myregion != null) {
|
||||
final BlockVector3 pos1;
|
||||
final BlockVector3 pos2;
|
||||
if (myregion.getId().equals("__global__")) {
|
||||
pos1 = BlockVector3.at(Integer.MIN_VALUE, wePlayer.getWorld().getMinY(), Integer.MIN_VALUE);
|
||||
pos2 = BlockVector3.at(Integer.MAX_VALUE, wePlayer.getWorld().getMaxY(), Integer.MAX_VALUE);
|
||||
} else {
|
||||
if (myregion instanceof ProtectedCuboidRegion) {
|
||||
pos1 = myregion.getMinimumPoint();
|
||||
pos2 = myregion.getMaximumPoint();
|
||||
} else {
|
||||
return new FaweMask(adapt(myregion)) {
|
||||
final Set<ProtectedRegion> regions = this.getRegions(localplayer, location, isWhitelist);
|
||||
if (!regions.isEmpty()) {
|
||||
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);
|
||||
}
|
||||
};
|
||||
} else {
|
||||
if (myregion instanceof ProtectedCuboidRegion) {
|
||||
result.add(new CuboidRegion(myregion.getMaximumPoint(), myregion.getMaximumPoint()));
|
||||
} else {
|
||||
result.add(adapt(myregion));
|
||||
}
|
||||
}
|
||||
}
|
||||
return new FaweMask(new CuboidRegion(pos1, pos2)) {
|
||||
return new FaweMask(new RegionIntersection(wePlayer.getWorld(), result)) {
|
||||
@Override
|
||||
public boolean isValid(com.sk89q.worldedit.entity.Player player, MaskType type) {
|
||||
return isAllowed(worldguard.wrapPlayer(BukkitAdapter.adapt(player)), myregion);
|
||||
final LocalPlayer localplayer = worldguard.wrapPlayer(BukkitAdapter.adapt(player));
|
||||
for (ProtectedRegion myregion : regions) {
|
||||
if (!isAllowed(localplayer, myregion)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RegionFilter getFilter(String world) {
|
||||
return new WorldGuardFilter(Bukkit.getWorld(world));
|
||||
}
|
||||
|
||||
private static class AdaptedRegion extends AbstractRegion {
|
||||
|
||||
private final ProtectedRegion region;
|
||||
@ -190,20 +229,4 @@ public class WorldGuardFeature extends BukkitMaskManager implements Listener {
|
||||
|
||||
}
|
||||
|
||||
private static Region adapt(ProtectedRegion region) {
|
||||
if (region instanceof ProtectedCuboidRegion) {
|
||||
return new CuboidRegion(region.getMinimumPoint(), region.getMaximumPoint());
|
||||
}
|
||||
if (region instanceof GlobalProtectedRegion) {
|
||||
return RegionWrapper.GLOBAL();
|
||||
}
|
||||
if (region instanceof ProtectedPolygonalRegion) {
|
||||
ProtectedPolygonalRegion casted = (ProtectedPolygonalRegion) region;
|
||||
BlockVector3 max = region.getMaximumPoint();
|
||||
BlockVector3 min = region.getMinimumPoint();
|
||||
return new Polygonal2DRegion(null, casted.getPoints(), min.getBlockY(), max.getBlockY());
|
||||
}
|
||||
return new AdaptedRegion(region);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,32 +0,0 @@
|
||||
package com.fastasyncworldedit.bukkit.regions.plotsquared;
|
||||
|
||||
import com.fastasyncworldedit.core.regions.filter.CuboidRegionFilter;
|
||||
import com.plotsquared.core.location.Location;
|
||||
import com.plotsquared.core.plot.Plot;
|
||||
import com.plotsquared.core.plot.PlotArea;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
public class PlotRegionFilter extends CuboidRegionFilter {
|
||||
|
||||
private final PlotArea area;
|
||||
|
||||
public PlotRegionFilter(PlotArea area) {
|
||||
checkNotNull(area);
|
||||
this.area = area;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void calculateRegions() {
|
||||
ArrayList<Plot> plots = new ArrayList<>(area.getPlots());
|
||||
for (Plot plot : plots) {
|
||||
Location bottom = plot.getCorners()[0];
|
||||
Location top = plot.getCorners()[1];
|
||||
add(BlockVector2.at(bottom.getX(), bottom.getZ()), BlockVector2.at(top.getX(), top.getZ()));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -184,13 +184,4 @@ public class PlotSquaredFeature extends FaweMaskManager {
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public RegionFilter getFilter(String world) {
|
||||
PlotArea area = PlotSquared.get().getPlotAreaManager().getPlotArea(world, null);
|
||||
if (area != null) {
|
||||
return new PlotRegionFilter(area);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,32 +0,0 @@
|
||||
package com.fastasyncworldedit.bukkit.regions.plotsquaredv4;
|
||||
|
||||
import com.fastasyncworldedit.core.regions.filter.CuboidRegionFilter;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.Location;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
public class PlotRegionFilter extends CuboidRegionFilter {
|
||||
|
||||
private final PlotArea area;
|
||||
|
||||
public PlotRegionFilter(PlotArea area) {
|
||||
checkNotNull(area);
|
||||
this.area = area;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void calculateRegions() {
|
||||
ArrayList<Plot> plots = new ArrayList<>(area.getPlots());
|
||||
for (Plot plot : plots) {
|
||||
Location bottom = plot.getCorners()[0];
|
||||
Location top = plot.getCorners()[1];
|
||||
add(BlockVector2.at(bottom.getX(), bottom.getZ()), BlockVector2.at(top.getX(), top.getZ()));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -224,13 +224,4 @@ public class PlotSquaredFeature extends FaweMaskManager {
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public RegionFilter getFilter(String world) {
|
||||
PlotArea area = PlotSquared.get().getPlotArea(world, null);
|
||||
if (area != null) {
|
||||
return new PlotRegionFilter(area);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user