From d82111a4fc9efe66f39232ed63c25d9d951393c2 Mon Sep 17 00:00:00 2001 From: aumgn Date: Thu, 15 Mar 2012 16:42:56 +0100 Subject: [PATCH] Fix a NPE with brush using a global mask and no brush mask --- .../com/sk89q/worldedit/tools/BrushTool.java | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/sk89q/worldedit/tools/BrushTool.java b/src/main/java/com/sk89q/worldedit/tools/BrushTool.java index e90b5e21a..121242118 100644 --- a/src/main/java/com/sk89q/worldedit/tools/BrushTool.java +++ b/src/main/java/com/sk89q/worldedit/tools/BrushTool.java @@ -177,15 +177,17 @@ public class BrushTool implements TraceTool { BlockBag bag = session.getBlockBag(player); EditSession editSession = session.createEditSession(player); - Mask existingMask = editSession.getMask(); - if (existingMask == null) { - editSession.setMask(mask); - } else if (existingMask instanceof CombinedMask) { - ((CombinedMask) existingMask).add(mask); - } else { - CombinedMask newMask = new CombinedMask(existingMask); - newMask.add(mask); - editSession.setMask(newMask); + if (mask != null) { + Mask existingMask = editSession.getMask(); + if (existingMask == null) { + editSession.setMask(mask); + } else if (existingMask instanceof CombinedMask) { + ((CombinedMask) existingMask).add(mask); + } else { + CombinedMask newMask = new CombinedMask(existingMask); + newMask.add(mask); + editSession.setMask(newMask); + } } try {