mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-04 03:56:41 +00:00
Renamed some command manager methods to be more descriptive.
This commit is contained in:
@ -19,6 +19,7 @@
|
||||
|
||||
package com.sk89q.worldedit.util.command;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
@ -32,7 +33,7 @@ public interface Dispatcher extends CommandCallable {
|
||||
* @param callable the command executor
|
||||
* @param alias a list of aliases, where the first alias is the primary name
|
||||
*/
|
||||
void register(CommandCallable callable, String... alias);
|
||||
void registerCommand(CommandCallable callable, String... alias);
|
||||
|
||||
/**
|
||||
* Get a list of command registrations.
|
||||
@ -53,22 +54,23 @@ public interface Dispatcher extends CommandCallable {
|
||||
Collection<String> getPrimaryAliases();
|
||||
|
||||
/**
|
||||
* Get a list of all the command aliases.
|
||||
* Get a list of all the command aliases, which includes the primary alias.
|
||||
*
|
||||
* <p>A command may have more than one alias assigned to it. The returned
|
||||
* collection cannot be modified.</p>
|
||||
*
|
||||
* @return a list of aliases
|
||||
*/
|
||||
Collection<String> getAllAliases();
|
||||
Collection<String> getAliases();
|
||||
|
||||
/**
|
||||
* Get the {@link CommandCallable} associated with an alias.
|
||||
* Get the {@link CommandCallable} associated with an alias. Returns
|
||||
* null if no command is named by the given alias.
|
||||
*
|
||||
* @param alias the alias
|
||||
* @return the command mapping
|
||||
* @return the command mapping (null if not found)
|
||||
*/
|
||||
CommandMapping get(String alias);
|
||||
@Nullable CommandMapping get(String alias);
|
||||
|
||||
/**
|
||||
* Returns whether the dispatcher contains a registered command for the given alias.
|
||||
|
@ -37,7 +37,7 @@ public class SimpleDispatcher implements Dispatcher {
|
||||
private final SimpleDescription description = new SimpleDescription();
|
||||
|
||||
@Override
|
||||
public void register(CommandCallable callable, String... alias) {
|
||||
public void registerCommand(CommandCallable callable, String... alias) {
|
||||
CommandMapping mapping = new CommandMapping(callable, alias);
|
||||
|
||||
// Check for replacements
|
||||
@ -61,7 +61,7 @@ public class SimpleDispatcher implements Dispatcher {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> getAllAliases() {
|
||||
public Set<String> getAliases() {
|
||||
return Collections.unmodifiableSet(commands.keySet());
|
||||
}
|
||||
|
||||
@ -124,13 +124,13 @@ public class SimpleDispatcher implements Dispatcher {
|
||||
String[] split = CommandContext.split(arguments);
|
||||
|
||||
if (split.length == 0) {
|
||||
return new ArrayList<String>(getAllAliases());
|
||||
return new ArrayList<String>(getAliases());
|
||||
} else if (split.length == 1) {
|
||||
String prefix = split[0];
|
||||
if (!prefix.isEmpty()) {
|
||||
List<String> suggestions = new ArrayList<String>();
|
||||
|
||||
for (String alias : getAllAliases()) {
|
||||
for (String alias : getAliases()) {
|
||||
if (alias.startsWith(prefix)) {
|
||||
suggestions.add(alias);
|
||||
}
|
||||
@ -138,7 +138,7 @@ public class SimpleDispatcher implements Dispatcher {
|
||||
|
||||
return suggestions;
|
||||
} else {
|
||||
return new ArrayList<String>(getAllAliases());
|
||||
return new ArrayList<String>(getAliases());
|
||||
}
|
||||
} else {
|
||||
String subCommand = split[0];
|
||||
|
@ -62,7 +62,7 @@ public class CommandGraph {
|
||||
|
||||
/**
|
||||
* Set the {@link ParametricBuilder} used for calls to
|
||||
* {@link DispatcherNode#build(Object)}.
|
||||
* {@link DispatcherNode#registerMethods(Object)}.
|
||||
*
|
||||
* @param builder the builder, or null
|
||||
* @return this object
|
||||
|
@ -56,10 +56,8 @@ public class DispatcherNode {
|
||||
* @param description the description
|
||||
* @return this object
|
||||
*/
|
||||
public DispatcherNode describe(String description) {
|
||||
if (dispatcher instanceof SimpleDispatcher) {
|
||||
((SimpleDispatcher) dispatcher).getDescription().setDescription(description);
|
||||
}
|
||||
public DispatcherNode describeAs(String description) {
|
||||
dispatcher.getDescription().setDescription(description);
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -70,7 +68,7 @@ public class DispatcherNode {
|
||||
* @param alias the list of aliases, where the first alias is the primary one
|
||||
*/
|
||||
public void register(CommandCallable callable, String... alias) {
|
||||
dispatcher.register(callable, alias);
|
||||
dispatcher.registerCommand(callable, alias);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -81,7 +79,7 @@ public class DispatcherNode {
|
||||
* @return this object
|
||||
* @see ParametricBuilder#registerMethodsAsCommands(com.sk89q.worldedit.util.command.Dispatcher, Object)
|
||||
*/
|
||||
public DispatcherNode build(Object object) {
|
||||
public DispatcherNode registerMethods(Object object) {
|
||||
ParametricBuilder builder = graph.getBuilder();
|
||||
if (builder == null) {
|
||||
throw new RuntimeException("No ParametricBuilder set");
|
||||
@ -101,7 +99,7 @@ public class DispatcherNode {
|
||||
*/
|
||||
public DispatcherNode group(String... alias) {
|
||||
SimpleDispatcher command = new SimpleDispatcher();
|
||||
getDispatcher().register(command, alias);
|
||||
getDispatcher().registerCommand(command, alias);
|
||||
return new DispatcherNode(graph, this, command);
|
||||
}
|
||||
|
||||
|
@ -151,7 +151,7 @@ public class ParametricBuilder {
|
||||
Command definition = method.getAnnotation(Command.class);
|
||||
if (definition != null) {
|
||||
CommandCallable callable = build(object, method, definition);
|
||||
dispatcher.register(callable, definition.aliases());
|
||||
dispatcher.registerCommand(callable, definition.aliases());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user