From fc869c0ec8c0a5cec0fdd4a7e737f561c3281d5e Mon Sep 17 00:00:00 2001 From: Jesse Boyd Date: Thu, 22 Jan 2015 16:26:16 -0800 Subject: [PATCH] added flag "no-worldedit" --- PlotSquared/pom.xml | 2 +- .../main/java/com/intellectualcrafters/plot/PlotMain.java | 2 +- .../com/intellectualcrafters/plot/flag/FlagManager.java | 8 ++++++++ .../intellectualcrafters/plot/listeners/PlayerEvents.java | 2 ++ .../main/java/com/intellectualcrafters/plot/util/PWE.java | 4 ++++ 5 files changed, 16 insertions(+), 2 deletions(-) diff --git a/PlotSquared/pom.xml b/PlotSquared/pom.xml index edf7bc38c..a61df6cea 100644 --- a/PlotSquared/pom.xml +++ b/PlotSquared/pom.xml @@ -8,7 +8,7 @@ UTF-8 PlotSquared - 2.5.11 + 2.5.12 PlotSquared jar diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotMain.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotMain.java index 850e52e37..1d2d5f43f 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotMain.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotMain.java @@ -1020,7 +1020,7 @@ public class PlotMain extends JavaPlugin implements Listener { } private static void addPlusFlags() { - final List booleanFlags = Arrays.asList("notify-enter", "notify-leave", "item-drop", "invincible", "instabreak", "drop-protection", "forcefield", "titles", "pve", "pvp"); + final List booleanFlags = Arrays.asList("notify-enter", "notify-leave", "item-drop", "invincible", "instabreak", "drop-protection", "forcefield", "titles", "pve", "pvp", "no-worldedit"); final List intervalFlags = Arrays.asList("feed", "heal"); final List stringFlags = Arrays.asList("greeting", "farewell"); for (final String flag : stringFlags) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/FlagManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/FlagManager.java index d54e1443a..3846bd77f 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/FlagManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/FlagManager.java @@ -86,6 +86,14 @@ import com.intellectualcrafters.plot.object.PlotWorld; return null; } + public static boolean isPlotFlagTrue(Plot plot, String strFlag) { + Flag flag = getPlotFlag(plot, strFlag); + if (flag == null) { + return false; + } + return flag.getValue().equals("true"); + } + /** * Get the value of a flag for a plot (ignores flag defaults) * @param plot diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java index 2a4c93810..e0614a501 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java @@ -244,6 +244,8 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi @EventHandler public static void onBigBoom(final EntityExplodeEvent event) { + // TODO allow tnt explosion within some plots + // TODO prevent entity velocity from explosion in plotworld final World world = event.getLocation().getWorld(); if (!isPlotWorld(world)) { return; 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 c5735387b..c9809d674 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PWE.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PWE.java @@ -27,6 +27,7 @@ import org.bukkit.entity.Player; import com.intellectualcrafters.plot.PlotMain; import com.intellectualcrafters.plot.database.DBFunc; +import com.intellectualcrafters.plot.flag.FlagManager; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; import com.sk89q.worldedit.LocalSession; @@ -59,6 +60,9 @@ import com.sk89q.worldedit.regions.CuboidRegion; if (id != null) { final Plot plot = PlotMain.getPlots(l.getWorld()).get(id); if (plot != null) { + 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) {