geforkt von Mirrors/FastAsyncWorldEdit
Passed a string of parent commands rather than just the current command.
Dieser Commit ist enthalten in:
Ursprung
10c45fcb22
Commit
3750190f2c
@ -216,7 +216,7 @@ public final class CommandManager {
|
|||||||
long start = System.currentTimeMillis();
|
long start = System.currentTimeMillis();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
dispatcher.call(null, Joiner.on(" ").join(split), locals);
|
dispatcher.call(Joiner.on(" ").join(split), locals, new String[0]);
|
||||||
} catch (CommandPermissionsException e) {
|
} catch (CommandPermissionsException e) {
|
||||||
actor.printError("You don't have permission to do this.");
|
actor.printError("You don't have permission to do this.");
|
||||||
} catch (InvalidUsageException e) {
|
} catch (InvalidUsageException e) {
|
||||||
|
@ -22,7 +22,6 @@ package com.sk89q.worldedit.util.command;
|
|||||||
import com.sk89q.minecraft.util.commands.CommandException;
|
import com.sk89q.minecraft.util.commands.CommandException;
|
||||||
import com.sk89q.minecraft.util.commands.CommandLocals;
|
import com.sk89q.minecraft.util.commands.CommandLocals;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
@ -43,14 +42,13 @@ public interface CommandCallable {
|
|||||||
* </p>
|
* </p>
|
||||||
* The implementing class must perform the necessary permission checks.
|
* The implementing class must perform the necessary permission checks.
|
||||||
*
|
*
|
||||||
* @param alias the alias that was used to invoke this command,
|
|
||||||
* which may be null if this is a "root" command
|
|
||||||
* @param arguments the arguments
|
* @param arguments the arguments
|
||||||
* @param locals the locals
|
* @param locals the locals
|
||||||
|
* @param parentCommands a list of parent commands, with the first most entry being the top-level command
|
||||||
* @return the called command, or null if there was no command found
|
* @return the called command, or null if there was no command found
|
||||||
* @throws CommandException thrown on a command error
|
* @throws CommandException thrown on a command error
|
||||||
*/
|
*/
|
||||||
boolean call(@Nullable String alias, String arguments, CommandLocals locals) throws CommandException;
|
boolean call(String arguments, CommandLocals locals, String[] parentCommands) throws CommandException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a list of suggestions based on input.
|
* Get a list of suggestions based on input.
|
||||||
|
@ -22,7 +22,6 @@ package com.sk89q.worldedit.util.command;
|
|||||||
import com.google.common.base.Joiner;
|
import com.google.common.base.Joiner;
|
||||||
import com.sk89q.minecraft.util.commands.*;
|
import com.sk89q.minecraft.util.commands.*;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -87,7 +86,7 @@ public class SimpleDispatcher implements Dispatcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean call(@Nullable String alias, String arguments, CommandLocals locals) throws CommandException {
|
public boolean call(String arguments, CommandLocals locals, String[] parentCommands) throws CommandException {
|
||||||
// We have permission for this command if we have permissions for subcommands
|
// We have permission for this command if we have permissions for subcommands
|
||||||
if (!testPermission(locals)) {
|
if (!testPermission(locals)) {
|
||||||
throw new CommandPermissionsException();
|
throw new CommandPermissionsException();
|
||||||
@ -101,11 +100,13 @@ public class SimpleDispatcher implements Dispatcher {
|
|||||||
} else if (split.length > 0) {
|
} else if (split.length > 0) {
|
||||||
String subCommand = split[0];
|
String subCommand = split[0];
|
||||||
String subArguments = Joiner.on(" ").join(Arrays.copyOfRange(split, 1, split.length));
|
String subArguments = Joiner.on(" ").join(Arrays.copyOfRange(split, 1, split.length));
|
||||||
|
String[] subParents = Arrays.copyOf(parentCommands, parentCommands.length + 1);
|
||||||
|
subParents[parentCommands.length] = subCommand;
|
||||||
CommandMapping mapping = get(subCommand);
|
CommandMapping mapping = get(subCommand);
|
||||||
|
|
||||||
if (mapping != null) {
|
if (mapping != null) {
|
||||||
try {
|
try {
|
||||||
mapping.getCallable().call(subCommand, subArguments, locals);
|
mapping.getCallable().call(subArguments, locals, subParents);
|
||||||
} catch (CommandException e) {
|
} catch (CommandException e) {
|
||||||
e.prependStack(subCommand);
|
e.prependStack(subCommand);
|
||||||
throw e;
|
throw e;
|
||||||
|
@ -23,7 +23,6 @@ import com.sk89q.minecraft.util.commands.*;
|
|||||||
import com.sk89q.worldedit.util.command.*;
|
import com.sk89q.worldedit.util.command.*;
|
||||||
import com.sk89q.worldedit.util.command.binding.Switch;
|
import com.sk89q.worldedit.util.command.binding.Switch;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
import java.lang.annotation.Annotation;
|
import java.lang.annotation.Annotation;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
@ -160,13 +159,14 @@ class ParametricCallable implements CommandCallable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean call(@Nullable String alias, String stringArguments, CommandLocals locals) throws CommandException {
|
public boolean call(String stringArguments, CommandLocals locals, String[] parentCommands) throws CommandException {
|
||||||
// Test permission
|
// Test permission
|
||||||
if (!testPermission(locals)) {
|
if (!testPermission(locals)) {
|
||||||
throw new CommandPermissionsException();
|
throw new CommandPermissionsException();
|
||||||
}
|
}
|
||||||
|
|
||||||
String[] split = CommandContext.split(alias + " " + stringArguments);
|
String calledCommand = parentCommands.length > 0 ? parentCommands[parentCommands.length - 1] : "_";
|
||||||
|
String[] split = CommandContext.split(calledCommand + " " + stringArguments);
|
||||||
CommandContext context = new CommandContext(split, getValueFlags(), false, locals);
|
CommandContext context = new CommandContext(split, getValueFlags(), false, locals);
|
||||||
|
|
||||||
Object[] args = new Object[parameters.length];
|
Object[] args = new Object[parameters.length];
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren