2015-07-26 16:51:12 +02:00
|
|
|
package com.plotsquared.bukkit.listeners.worldedit;
|
2015-04-18 15:47:13 +02:00
|
|
|
|
2015-07-30 16:25:16 +02:00
|
|
|
import java.util.HashSet;
|
|
|
|
import java.util.UUID;
|
|
|
|
|
2015-07-03 14:15:20 +02:00
|
|
|
import com.intellectualcrafters.plot.PS;
|
2015-06-11 09:12:39 +02:00
|
|
|
import com.intellectualcrafters.plot.config.Settings;
|
2015-08-13 19:22:32 +02:00
|
|
|
import com.intellectualcrafters.plot.flag.FlagManager;
|
2015-04-18 15:47:13 +02:00
|
|
|
import com.intellectualcrafters.plot.object.Location;
|
|
|
|
import com.intellectualcrafters.plot.object.Plot;
|
|
|
|
import com.intellectualcrafters.plot.object.PlotPlayer;
|
|
|
|
import com.intellectualcrafters.plot.object.RegionWrapper;
|
|
|
|
import com.intellectualcrafters.plot.util.MainUtil;
|
|
|
|
|
|
|
|
public class WEManager {
|
2015-08-18 15:20:11 +02:00
|
|
|
// public static HashSet<String> bypass = new HashSet<>();
|
2015-04-18 15:47:13 +02:00
|
|
|
|
|
|
|
public static boolean maskContains(HashSet<RegionWrapper> mask, int x, int z) {
|
|
|
|
for (RegionWrapper region : mask) {
|
|
|
|
if ((x >= region.minX) && (x <= region.maxX) && (z >= region.minZ) && (z <= region.maxZ)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static HashSet<RegionWrapper> getMask(PlotPlayer player) {
|
|
|
|
HashSet<RegionWrapper> regions = new HashSet<>();
|
|
|
|
UUID uuid = player.getUUID();
|
2015-08-06 18:05:15 +02:00
|
|
|
for (Plot plot : PS.get().getPlotsInWorld(player.getLocation().getWorld())) {
|
2015-08-18 22:44:32 +02:00
|
|
|
if (Settings.DONE_RESTRICTS_BUILDING && plot.isBasePlot() && FlagManager.getPlotFlag(plot, "done") == null) {
|
2015-07-21 20:31:12 +02:00
|
|
|
if (Settings.WE_ALLOW_HELPER ? plot.isAdded(uuid) : (plot.isOwner(uuid) || plot.getTrusted().contains(uuid))) {
|
2015-04-18 15:47:13 +02:00
|
|
|
Location pos1 = MainUtil.getPlotBottomLoc(plot.world, plot.id).add(1, 0, 1);
|
|
|
|
Location pos2 = MainUtil.getPlotTopLoc(plot.world, plot.id);
|
|
|
|
regions.add(new RegionWrapper(pos1.getX(), pos2.getX(), pos1.getZ(), pos2.getZ()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return regions;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static boolean intersects(RegionWrapper region1, RegionWrapper region2) {
|
2015-07-27 19:50:04 +02:00
|
|
|
return (region1.minX <= region2.maxX) && (region1.maxX >= region2.minX) && (region1.minZ <= region2.maxZ) && (region1.maxZ >= region2.minZ);
|
2015-04-18 15:47:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public static boolean regionContains(RegionWrapper selection, HashSet<RegionWrapper> mask) {
|
|
|
|
for (RegionWrapper region : mask) {
|
|
|
|
if (intersects(region, selection)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|