From 7cbb117215829da18a55ab4a89327f62032a3b98 Mon Sep 17 00:00:00 2001 From: Jesse Boyd Date: Sun, 15 Jul 2018 15:57:43 +1000 Subject: [PATCH] Check permission when using BrushTool --- .../boydti/fawe/object/brush/BrushSettings.java | 15 +++++++++++++++ .../sk89q/worldedit/command/tool/BrushTool.java | 8 +++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/com/boydti/fawe/object/brush/BrushSettings.java b/core/src/main/java/com/boydti/fawe/object/brush/BrushSettings.java index 6cfc03f4..96454f8c 100644 --- a/core/src/main/java/com/boydti/fawe/object/brush/BrushSettings.java +++ b/core/src/main/java/com/boydti/fawe/object/brush/BrushSettings.java @@ -48,6 +48,7 @@ public class BrushSettings { private double size = 1; private Set permissions; private ScrollAction scrollAction; + private String lastWorld; public BrushSettings() { this.permissions = new HashSet<>(); @@ -209,6 +210,20 @@ public class BrushSettings { return this; } + /** + * Set the world the brush is being used in + * @param world + * @return true if the world differs from the last used world + */ + public boolean setWorld(String world) { + boolean result = false; + if (this.lastWorld != null && !this.lastWorld.equalsIgnoreCase(world)) { + result = true; + } + this.lastWorld = world; + return result; + } + public Brush getBrush() { return brush; } diff --git a/core/src/main/java/com/sk89q/worldedit/command/tool/BrushTool.java b/core/src/main/java/com/sk89q/worldedit/command/tool/BrushTool.java index 71e8b6fd..bf0090ac 100644 --- a/core/src/main/java/com/sk89q/worldedit/command/tool/BrushTool.java +++ b/core/src/main/java/com/sk89q/worldedit/command/tool/BrushTool.java @@ -19,6 +19,7 @@ import com.boydti.fawe.object.mask.MaskedTargetBlock; import com.boydti.fawe.object.pattern.PatternTraverser; import com.boydti.fawe.util.EditSessionBuilder; import com.boydti.fawe.util.MaskTraverser; +import com.boydti.fawe.util.StringMan; import com.boydti.fawe.util.TaskManager; import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; @@ -441,12 +442,17 @@ public class BrushTool implements DoubleActionTraceTool, ScrollTool, MovableTool if (brush == null) return false; EditSession editSession = session.createEditSession(player); + if (current.setWorld(editSession.getWorld().getName()) && !current.canUse(player)) { + BBC.NO_PERM.send(player, StringMan.join(current.getPermissions(), ",")); + return false; + } + Vector target = getPosition(editSession, player); if (target == null) { editSession.cancel(); BBC.NO_BLOCK.send(player); - return true; + return false; } BlockBag bag = session.getBlockBag(player); Request.request().setEditSession(editSession);