Fix mask wildcard

This commit is contained in:
Jesse Boyd 2017-05-10 08:29:15 +10:00
parent f8199a3b43
commit d0a0c0360e
No known key found for this signature in database
GPG Key ID: 59F1DE6293AF6E1F
5 changed files with 13 additions and 8 deletions

View File

@ -260,6 +260,7 @@ public class CreateFromImage extends Command {
return;
}
context.setPreferringWildcard(true);
context.setRestricted(false);
Set<BaseBlock> blocks;
if (argList.get(1).equalsIgnoreCase("#clipboard")) {
ClipboardHolder holder = fp.getSession().getClipboard();

View File

@ -218,6 +218,7 @@ public class DefaultBlockParser extends InputParser<BaseBlock> {
}
}
if (!context.isPreferringWildcard() && data == -1) {
// No wildcards allowed => eliminate them.
data = 0;
@ -230,7 +231,7 @@ public class DefaultBlockParser extends InputParser<BaseBlock> {
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<BaseBlock> {
for (Map.Entry<String, BundledBlockData.FaweStateValue> 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;
}
}

View File

@ -110,6 +110,8 @@ public class DefaultMaskParser extends FaweParser<Mask> {
}
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);

View File

@ -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<String> aliases = getPrimaryAliases();
if (aliases.isEmpty()) {
@ -140,7 +138,7 @@ public class SimpleDispatcher implements Dispatcher {
@Override
public List<String> 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] : "";

View File

@ -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<String> 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();