From a9e1d5009cb0c823484ff29dcd6879bac561e162 Mon Sep 17 00:00:00 2001 From: Jordan Date: Fri, 31 Mar 2023 19:45:34 +0100 Subject: [PATCH] fix: add null-check for brush in traceMask (#2160) * fix: add null-check for brush in traceMask - Fixes #2149 * Switch to print from printError Co-authored-by: Alexander Brandes --------- Co-authored-by: Alexander Brandes --- .../com/sk89q/worldedit/command/ToolUtilCommands.java | 9 +++++++-- worldedit-core/src/main/resources/lang/strings.json | 1 + 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/ToolUtilCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/ToolUtilCommands.java index 181711550..6f47132f7 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/ToolUtilCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/ToolUtilCommands.java @@ -169,9 +169,14 @@ public class ToolUtilCommands { public void traceMask( Player player, LocalSession session, @Arg(desc = "The trace mask to set", def = "") - Mask maskOpt + Mask maskOpt ) throws WorldEditException { - session.getBrushTool(player, false).setTraceMask(maskOpt); + BrushTool brushTool = session.getBrushTool(player, false); + if (brushTool == null) { + player.print(Caption.of("worldedit.brush.none.equipped")); + return; + } + brushTool.setTraceMask(maskOpt); if (maskOpt == null) { player.print(Caption.of("worldedit.tool.tracemask.disabled")); } else { diff --git a/worldedit-core/src/main/resources/lang/strings.json b/worldedit-core/src/main/resources/lang/strings.json index 5c6a411d2..ac3c2d3ac 100644 --- a/worldedit-core/src/main/resources/lang/strings.json +++ b/worldedit-core/src/main/resources/lang/strings.json @@ -283,6 +283,7 @@ "worldedit.brush.butcher.equip": "Butcher brush equipped ({0}).", "worldedit.brush.operation.equip": "Set brush to {0}.", "worldedit.brush.none.equip": "Brush unbound from your current item.", + "worldedit.brush.none.equipped": "You have no brush bound to your current item. Try /brush sphere for a basic brush.", "worldedit.setbiome.changed": "Biomes were changed in {0} columns. You may have to rejoin your game (or close and reopen your world) to see a change.", "worldedit.setbiome.not-locatable": "Command sender must be present in the world to use the -p flag.", "worldedit.drawsel.disabled": "Server CUI disabled.",