From d0a0c0360ef78c8b65f9d9310bb1f276c2d5bc7c Mon Sep 17 00:00:00 2001 From: Jesse Boyd Date: Wed, 10 May 2017 08:29:15 +1000 Subject: [PATCH] Fix mask wildcard --- .../boydti/fawe/regions/general/plot/CreateFromImage.java | 1 + .../worldedit/extension/factory/DefaultBlockParser.java | 8 ++++++-- .../worldedit/extension/factory/DefaultMaskParser.java | 2 ++ .../sk89q/worldedit/util/command/SimpleDispatcher.java | 6 ++---- .../util/command/parametric/ParametricCallable.java | 4 ++-- 5 files changed, 13 insertions(+), 8 deletions(-) diff --git a/core/src/main/java/com/boydti/fawe/regions/general/plot/CreateFromImage.java b/core/src/main/java/com/boydti/fawe/regions/general/plot/CreateFromImage.java index dd913986..1379d5ac 100644 --- a/core/src/main/java/com/boydti/fawe/regions/general/plot/CreateFromImage.java +++ b/core/src/main/java/com/boydti/fawe/regions/general/plot/CreateFromImage.java @@ -260,6 +260,7 @@ public class CreateFromImage extends Command { return; } context.setPreferringWildcard(true); + context.setRestricted(false); Set blocks; if (argList.get(1).equalsIgnoreCase("#clipboard")) { ClipboardHolder holder = fp.getSession().getClipboard(); diff --git a/core/src/main/java/com/sk89q/worldedit/extension/factory/DefaultBlockParser.java b/core/src/main/java/com/sk89q/worldedit/extension/factory/DefaultBlockParser.java index 16e761b7..e0b09f8a 100644 --- a/core/src/main/java/com/sk89q/worldedit/extension/factory/DefaultBlockParser.java +++ b/core/src/main/java/com/sk89q/worldedit/extension/factory/DefaultBlockParser.java @@ -218,6 +218,7 @@ public class DefaultBlockParser extends InputParser { } } + if (!context.isPreferringWildcard() && data == -1) { // No wildcards allowed => eliminate them. data = 0; @@ -230,7 +231,7 @@ public class DefaultBlockParser extends InputParser { if (MathMan.isInteger(typeAndData[1])) { data = Integer.parseInt(typeAndData[1]); } else { - data = Integer.MAX_VALUE; // Some invalid value + data = -1; // Some invalid value BundledBlockData.BlockEntry block = BundledBlockData.getInstance().findById(blockId); if (block != null && block.states != null) { loop: @@ -238,7 +239,10 @@ public class DefaultBlockParser extends InputParser { for (Map.Entry valueEntry : stateEntry.getValue().valueMap().entrySet()) { String key = valueEntry.getKey(); if (key.equalsIgnoreCase(typeAndData[1])) { - data = valueEntry.getValue().data; + int newData = valueEntry.getValue().data; + if (newData != 0 || blockLocator.length > 1) { + data = valueEntry.getValue().data; + } break loop; } } diff --git a/core/src/main/java/com/sk89q/worldedit/extension/factory/DefaultMaskParser.java b/core/src/main/java/com/sk89q/worldedit/extension/factory/DefaultMaskParser.java index 92bedd96..7e1c6254 100644 --- a/core/src/main/java/com/sk89q/worldedit/extension/factory/DefaultMaskParser.java +++ b/core/src/main/java/com/sk89q/worldedit/extension/factory/DefaultMaskParser.java @@ -110,6 +110,8 @@ public class DefaultMaskParser extends FaweParser { } if (mask == null) { try { + context.setPreferringWildcard(true); + context.setRestricted(false); BaseBlock block = worldEdit.getBlockFactory().parseFromInput(command, context); if (pe.and) { mask = new BlockMask(extent, block); diff --git a/core/src/main/java/com/sk89q/worldedit/util/command/SimpleDispatcher.java b/core/src/main/java/com/sk89q/worldedit/util/command/SimpleDispatcher.java index 21e14b00..57226c70 100644 --- a/core/src/main/java/com/sk89q/worldedit/util/command/SimpleDispatcher.java +++ b/core/src/main/java/com/sk89q/worldedit/util/command/SimpleDispatcher.java @@ -22,12 +22,10 @@ package com.sk89q.worldedit.util.command; import com.boydti.fawe.Fawe; import com.boydti.fawe.util.StringMan; import com.google.common.base.Joiner; -import com.sk89q.minecraft.util.commands.CommandContext; import com.sk89q.minecraft.util.commands.CommandException; import com.sk89q.minecraft.util.commands.CommandLocals; import com.sk89q.minecraft.util.commands.CommandPermissionsException; import com.sk89q.minecraft.util.commands.WrappedCommandException; - import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; @@ -110,7 +108,7 @@ public class SimpleDispatcher implements Dispatcher { throw new CommandPermissionsException(); } - String[] split = CommandContext.split(arguments); + String[] split = arguments.split(" ", -1); Set aliases = getPrimaryAliases(); if (aliases.isEmpty()) { @@ -140,7 +138,7 @@ public class SimpleDispatcher implements Dispatcher { @Override public List getSuggestions(String arguments, CommandLocals locals) throws CommandException { - String[] split = CommandContext.split(arguments); + String[] split = arguments.split(" ", -1); if (split.length <= 1) { String prefix = split.length > 0 ? split[0] : ""; diff --git a/core/src/main/java/com/sk89q/worldedit/util/command/parametric/ParametricCallable.java b/core/src/main/java/com/sk89q/worldedit/util/command/parametric/ParametricCallable.java index bb1c980e..50247aaa 100644 --- a/core/src/main/java/com/sk89q/worldedit/util/command/parametric/ParametricCallable.java +++ b/core/src/main/java/com/sk89q/worldedit/util/command/parametric/ParametricCallable.java @@ -188,7 +188,7 @@ public class ParametricCallable implements CommandCallable { } String calledCommand = parentCommands.length > 0 ? parentCommands[parentCommands.length - 1] : "_"; - String[] split = CommandContext.split(calledCommand + " " + stringArguments); + String[] split = (calledCommand + " " + stringArguments).split(" ", -1); CommandContext context = new CommandContext(split, getValueFlags(), false, locals); // Provide help if -? is specified @@ -277,7 +277,7 @@ public class ParametricCallable implements CommandCallable { @Override public List getSuggestions(String arguments, CommandLocals locals) throws CommandException { - String[] split = CommandContext.split("ignored" + " " + arguments); + String[] split = ("ignored" + " " + arguments).split(" ", -1); CommandContext context = new CommandContext(split, getValueFlags(), !arguments.endsWith(" "), locals); ContextArgumentStack scoped = new ContextArgumentStack(context); SuggestionContext suggestable = context.getSuggestionContext();