diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/WE_Anywhere.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/WE_Anywhere.java index 7c8a166e2..aa6519d35 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/WE_Anywhere.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/WE_Anywhere.java @@ -45,7 +45,7 @@ public class WE_Anywhere extends SubCommand { PlayerFunctions.sendMessage(plr, "&6Cleared your WorldEdit mask"); } else { - PWE.setMask(plr, plr.getLocation()); + PWE.setMask(plr, plr.getLocation(), true); PlayerFunctions.sendMessage(plr, "&6Updated your WorldEdit mask"); } return true; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/WorldEditListener.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/WorldEditListener.java index 0a7148612..2a1ca7ed2 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/WorldEditListener.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/WorldEditListener.java @@ -110,7 +110,7 @@ public class WorldEditListener implements Listener { final Plot plot = PlotHelper.getCurrentPlot(b.getLocation()); if (plot != null) { if (plot.hasOwner() && (plot.helpers != null) && (plot.helpers.contains(DBFunc.everyone) || plot.helpers.contains(UUIDHandler.getUUID(p)))) { - PWE.setMask(p, l); + PWE.setMask(p, l, false); } } } @@ -178,7 +178,7 @@ public class WorldEditListener implements Listener { return; } if (isPlotWorld(l)) { - PWE.setMask(p, l); + PWE.setMask(p, l, false); } else { PWE.removeMask(p); } @@ -192,17 +192,16 @@ public class WorldEditListener implements Listener { } final Location f = e.getFrom(); final Player p = e.getPlayer(); - if (PlotMain.hasPermission(p, "plots.worldedit.bypass") && !PWE.hasMask(p)) { - return; + if (PlotMain.hasPermission(p, "plots.worldedit.bypass")) { + if (!PWE.hasMask(p)) { + return; + } } if ((f.getBlockX() != t.getBlockX()) || (f.getBlockZ() != t.getBlockZ())) { final PlotId idF = PlayerFunctions.getPlot(f); final PlotId idT = PlayerFunctions.getPlot(t); - if ((!PWE.hasMask(e.getPlayer())) && PlotMain.hasPermission(e.getPlayer(), "plots.worldedit.bypass")) { - return; - } if ((idT != null) && !(idF == idT)) { - PWE.setMask(p, t); + PWE.setMask(p, t, false); } } } @@ -220,7 +219,7 @@ public class WorldEditListener implements Listener { return; } if (isPlotWorld(t)) { - PWE.setMask(p, t); + PWE.setMask(p, t, false); return; } if ((f != null) && isPlotWorld(f)) { @@ -230,10 +229,12 @@ public class WorldEditListener implements Listener { @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public void onTeleport(final PlayerTeleportEvent e) { - if (PlotMain.hasPermission(e.getPlayer(), "plots.worldedit.bypass")) { - return; - } final Player p = e.getPlayer(); + if (PlotMain.hasPermission(e.getPlayer(), "plots.worldedit.bypass")) { + if (!PWE.hasMask(p)) { + return; + } + } final Location t = e.getTo(); final Location q = new Location(t.getWorld(), t.getBlockX(), 64, t.getZ()); final Location f = e.getFrom(); @@ -243,6 +244,6 @@ public class WorldEditListener implements Listener { } return; } - PWE.setMask(p, q); + PWE.setMask(p, q, false); } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PWE.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PWE.java index c9809d674..61ddcbac3 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PWE.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PWE.java @@ -45,7 +45,7 @@ import com.sk89q.worldedit.regions.CuboidRegion; */ @SuppressWarnings("ALL") public class PWE { - public static void setMask(final Player p, final Location l) { + public static void setMask(final Player p, final Location l, boolean force) { try { LocalSession s; if (PlotMain.worldEdit == null) { @@ -63,15 +63,8 @@ import com.sk89q.worldedit.regions.CuboidRegion; if (FlagManager.isPlotFlagTrue(plot, "no-worldedit")) { return; } - boolean r; - r = ((plot.getOwner() != null) && plot.getOwner().equals(UUIDHandler.getUUID(p))) || plot.helpers.contains(DBFunc.everyone) || plot.helpers.contains(UUIDHandler.getUUID(p)); - if (!r) { - if (p.hasPermission("plots.worldedit.bypass")) { - removeMask(p, s); - return; - } - } else { - + boolean r = ((plot.getOwner() != null) && plot.getOwner().equals(UUIDHandler.getUUID(p))) || plot.helpers.contains(DBFunc.everyone) || plot.helpers.contains(UUIDHandler.getUUID(p)); + if (r) { final World w = p.getWorld(); final Location bloc = PlotHelper.getPlotBottomLoc(w, plot.id); @@ -89,12 +82,13 @@ import com.sk89q.worldedit.regions.CuboidRegion; } } } - if (noMask(s)) { + if (force ^ (noMask(s) && !PlotMain.hasPermission(p, "plots.worldedit.bypass"))) { final BukkitPlayer plr = PlotMain.worldEdit.wrapPlayer(p); final Vector p1 = new Vector(69, 69, 69), p2 = new Vector(69, 69, 69); s.setMask(new RegionMask(new CuboidRegion(plr.getWorld(), p1, p2))); } } catch (final Exception e) { + e.printStackTrace(); // throw new // PlotSquaredException(PlotSquaredException.PlotError.MISSING_DEPENDENCY, // "WorldEdit == Null?");