From 2712f5fea855e0e42320a7c275dec2c2f3662e7a Mon Sep 17 00:00:00 2001 From: Jesse Boyd Date: Tue, 25 Jul 2017 13:01:02 +1000 Subject: [PATCH] Fix changing visual mode not updating client --- .../worldedit/command/BrushOptionsCommands.java | 2 +- .../sk89q/worldedit/command/tool/BrushTool.java | 17 +++++++++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/core/src/main/java/com/sk89q/worldedit/command/BrushOptionsCommands.java b/core/src/main/java/com/sk89q/worldedit/command/BrushOptionsCommands.java index 199b4e86..f24e16b4 100644 --- a/core/src/main/java/com/sk89q/worldedit/command/BrushOptionsCommands.java +++ b/core/src/main/java/com/sk89q/worldedit/command/BrushOptionsCommands.java @@ -294,7 +294,7 @@ public class BrushOptionsCommands extends MethodCommands { } VisualMode[] modes = VisualMode.values(); VisualMode newMode = modes[MathMan.wrap(mode, 0, modes.length - 1)]; - tool.setVisualMode(newMode); + tool.setVisualMode(player, newMode); BBC.BRUSH_VISUAL_MODE_SET.send(player, newMode); } 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 7b571f2b..4133c6f6 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 @@ -474,8 +474,21 @@ public class BrushTool implements DoubleActionTraceTool, ScrollTool, MovableTool this.targetMask = mask; } - public void setVisualMode(VisualMode visualMode) { - this.visualMode = visualMode != null ? visualMode : VisualMode.NONE; + public void setVisualMode(Player player, VisualMode visualMode) { + if (visualMode == null) visualMode = VisualMode.NONE; + if (this.visualMode != visualMode) { + if (this.visualMode != VisualMode.NONE) { + clear(player); + } + this.visualMode = visualMode != null ? visualMode : VisualMode.NONE; + if (visualMode != VisualMode.NONE) { + try { + queueVisualization(FawePlayer.wrap(player)); + } catch (Throwable e) { + WorldEdit.getInstance().getPlatformManager().handleThrowable(e, player); + } + } + } } public TargetMode getTargetMode() {