From 4f7f439a2a5cc8501d0b78a62b1685b98e9e3070 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Thu, 18 Dec 2014 13:36:49 +1100 Subject: [PATCH] Fixed minor WorldEdit quirk --- .../plot/listeners/WorldEditListener.java | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) 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 4b57f93e8..ad3b88d05 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/WorldEditListener.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/WorldEditListener.java @@ -28,11 +28,13 @@ import java.util.Set; import org.bukkit.Location; import org.bukkit.Material; +import org.bukkit.World; import org.bukkit.block.Block; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerChangedWorldEvent; import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerJoinEvent; @@ -245,4 +247,23 @@ public class WorldEditListener implements Listener { } PWE.setMask(p, q); } + + @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) + public void onWorldChange(final PlayerChangedWorldEvent e) { + if (PlotMain.hasPermission(e.getPlayer(), "plots.worldedit.bypass")) { + return; + } + + final Player p = e.getPlayer(); + final Location t = p.getLocation(); + final World f = e.getFrom(); + if (!isPlotWorld(t)) { + if (PlotMain.isPlotWorld(f)) { + PWE.removeMask(p); + } + else { + return; + } + } + } }