This commit is contained in:
boy0001
2015-09-01 08:51:51 +10:00
parent 9accbd5ea7
commit 29da0da8bb
16 changed files with 93 additions and 22 deletions

View File

@ -2101,7 +2101,7 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
}
}
PlotWorld pw = PS.get().getPlotWorld(loc.getWorld());
if (loc.getY() >= pw.MAX_BUILD_HEIGHT && !Permissions.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_HEIGHTLIMIT)) {
if ((loc.getY() > pw.MAX_BUILD_HEIGHT && loc.getY() < pw.MIN_BUILD_HEIGHT) && !Permissions.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_HEIGHTLIMIT)) {
event.setCancelled(true);
MainUtil.sendMessage(pp, C.HEIGHT_LIMIT.s().replace("{limit}", "" + pw.MAX_BUILD_HEIGHT));
}

View File

@ -0,0 +1,31 @@
package com.plotsquared.bukkit.listeners.worldedit;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
import com.sk89q.worldedit.extent.Extent;
public class HeightLimitExtent extends AbstractDelegateExtent {
private int max;
private int min;
public HeightLimitExtent(int min, int max, Extent child) {
super(child);
this.min = min;
this.max = max;
}
@Override
public boolean setBlock(Vector location, BaseBlock block) throws WorldEditException {
int y = location.getBlockY();
if (y < min || y > max) {
return false;
}
return super.setBlock(location, block);
}
}

View File

@ -91,7 +91,7 @@ public class ProcessedWEExtent extends AbstractDelegateExtent {
BSblocked = true;
PS.debug("&cPlotSquared detected unsafe WorldEdit: " + (location.getBlockX()) + "," + (location.getBlockZ()));
}
if (WEManager.maskContains(mask, location.getBlockX(), location.getBlockZ())) {
if (WEManager.maskContains(mask, location.getBlockX(), location.getBlockY(), location.getBlockZ())) {
if (count++ > max) {
if (parent != null) {
try {
@ -113,7 +113,7 @@ public class ProcessedWEExtent extends AbstractDelegateExtent {
int x = location.getBlockX();
int y = location.getBlockY();
int z = location.getBlockZ();
if (WEManager.maskContains(mask, location.getBlockX(), location.getBlockZ())) {
if (WEManager.maskContains(mask, location.getBlockX(), location.getBlockY(), location.getBlockZ())) {
if (count++ > max) {
if (parent != null) {
try {
@ -251,7 +251,7 @@ public class ProcessedWEExtent extends AbstractDelegateExtent {
Eblocked = true;
PS.debug("&cPlotSquared detected unsafe WorldEdit: " + (location.getBlockX()) + "," + (location.getBlockZ()));
}
if (WEManager.maskContains(mask, location.getBlockX(), location.getBlockZ())) {
if (WEManager.maskContains(mask, location.getBlockX(), location.getBlockY(), location.getBlockZ())) {
return super.createEntity(location, entity);
}
return null;

View File

@ -24,7 +24,7 @@ public class WEExtent extends AbstractDelegateExtent {
@Override
public boolean setBlock(Vector location, BaseBlock block) throws WorldEditException {
if (WEManager.maskContains(mask, location.getBlockX(), location.getBlockZ())) {
if (WEManager.maskContains(mask, location.getBlockX(), location.getBlockY(), location.getBlockZ())) {
return super.setBlock(location, block);
}
return false;
@ -32,7 +32,7 @@ public class WEExtent extends AbstractDelegateExtent {
@Override
public Entity createEntity(Location location, BaseEntity entity) {
if (WEManager.maskContains(mask, location.getBlockX(), location.getBlockZ())) {
if (WEManager.maskContains(mask, location.getBlockX(), location.getBlockY(), location.getBlockZ())) {
return super.createEntity(location, entity);
}
return null;

View File

@ -115,10 +115,10 @@ public class WEListener implements Listener {
if (!WEManager.regionContains(region, mask)) {
arg = "pos1 + pos2";
}
else if (!WEManager.maskContains(mask, pos1.getBlockX(), pos1.getBlockZ())) {
else if (!WEManager.maskContains(mask, pos1.getBlockX(), pos1.getBlockY(), pos1.getBlockZ())) {
arg = "pos1";
}
else if (!WEManager.maskContains(mask, pos2.getBlockX(), pos2.getBlockZ())) {
else if (!WEManager.maskContains(mask, pos2.getBlockX(), pos2.getBlockY(), pos2.getBlockZ())) {
arg = "pos2";
}
if (arg != null) {

View File

@ -15,9 +15,18 @@ import com.intellectualcrafters.plot.util.MainUtil;
public class WEManager {
// public static HashSet<String> bypass = new HashSet<>();
public static boolean maskContains(HashSet<RegionWrapper> mask, int x, int y, int z) {
for (RegionWrapper region : mask) {
if (region.isIn(x, y, z)) {
return true;
}
}
return false;
}
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)) {
if (region.isIn(x, z)) {
return true;
}
}
@ -40,7 +49,7 @@ public class WEManager {
if (Settings.WE_ALLOW_HELPER ? plot.isAdded(uuid) : (plot.isOwner(uuid) || plot.getTrusted().contains(uuid))) {
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()));
regions.add(new RegionWrapper(pos1.getX(), pos2.getX(), pos1.getY(), pos2.getY(), pos1.getZ(), pos2.getZ()));
}
}
return regions;

View File

@ -10,6 +10,7 @@ import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.config.Settings;
import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.object.PlotWorld;
import com.intellectualcrafters.plot.object.RegionWrapper;
import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.Permissions;
@ -62,14 +63,19 @@ public class WESubscriber {
PlotPlayer player = UUIDHandler.getPlayer(actor.getName());
HashSet<RegionWrapper> mask = WEManager.getMask(player);
PlotWorld plotworld = PS.get().getPlotWorld(world);
if (mask.size() == 0) {
if (Permissions.hasPermission(player, "plots.worldedit.bypass")) {
MainUtil.sendMessage(player, C.WORLDEDIT_BYPASS);
}
if (PS.get().isPlotWorld(world)) {
if (plotworld != null) {
event.setExtent(new NullExtent());
}
return;
}
HeightLimitExtent heightLimit = null;
if (plotworld != null) {
}
if (Settings.CHUNK_PROCESSOR) {
if (Settings.EXPERIMENTAL_FAST_ASYNC_WORLDEDIT) {

View File

@ -1016,8 +1016,8 @@ public class BukkitChunkManager extends ChunkManager {
// TODO clear all entities
clearAllEntities(plot1.getBottom().add(1, 0, 1), plot1.getTop());
clearAllEntities(plot2.getBottom().add(1, 0, 1), plot2.getTop());
clearAllEntities(plot1.getBottom(), plot1.getTop());
clearAllEntities(plot2.getBottom(), plot2.getTop());
}
@Override

View File

@ -33,7 +33,7 @@ public class SpongeChunkManager extends ChunkManager {
@Override
public int[] countEntities(Plot plot) {
Location pos1 = plot.getBottom().add(1, 0, 1);
Location pos1 = plot.getBottom();
Location pos2 = plot.getTop();
String worldname = pos1.getWorld();