3
0
Mirror von https://github.com/IntellectualSites/FastAsyncWorldEdit.git synchronisiert 2024-11-09 13:00:05 +01:00

Renamed some command manager methods to be more descriptive.

Dieser Commit ist enthalten in:
sk89q 2014-06-28 16:39:20 -07:00
Ursprung 620a4a21a1
Commit 205fee3c36
6 geänderte Dateien mit 46 neuen und 46 gelöschten Zeilen

Datei anzeigen

@ -97,43 +97,43 @@ public final class CommandManager {
dispatcher = new CommandGraph()
.builder(builder)
.commands()
.build(new BiomeCommands(worldEdit))
.build(new ChunkCommands(worldEdit))
.build(new ClipboardCommands(worldEdit))
.build(new GeneralCommands(worldEdit))
.build(new GenerationCommands(worldEdit))
.build(new HistoryCommands(worldEdit))
.build(new NavigationCommands(worldEdit))
.build(new RegionCommands(worldEdit))
.build(new ScriptingCommands(worldEdit))
.build(new SelectionCommands(worldEdit))
.build(new SnapshotUtilCommands(worldEdit))
.build(new ToolUtilCommands(worldEdit))
.build(new ToolCommands(worldEdit))
.build(new UtilityCommands(worldEdit))
.registerMethods(new BiomeCommands(worldEdit))
.registerMethods(new ChunkCommands(worldEdit))
.registerMethods(new ClipboardCommands(worldEdit))
.registerMethods(new GeneralCommands(worldEdit))
.registerMethods(new GenerationCommands(worldEdit))
.registerMethods(new HistoryCommands(worldEdit))
.registerMethods(new NavigationCommands(worldEdit))
.registerMethods(new RegionCommands(worldEdit))
.registerMethods(new ScriptingCommands(worldEdit))
.registerMethods(new SelectionCommands(worldEdit))
.registerMethods(new SnapshotUtilCommands(worldEdit))
.registerMethods(new ToolUtilCommands(worldEdit))
.registerMethods(new ToolCommands(worldEdit))
.registerMethods(new UtilityCommands(worldEdit))
.group("worldedit", "we")
.describe("WorldEdit commands")
.build(new WorldEditCommands(worldEdit))
.describeAs("WorldEdit commands")
.registerMethods(new WorldEditCommands(worldEdit))
.parent()
.group("schematic", "schem", "/schematic", "/schem")
.describe("Schematic commands for saving/loading areas")
.build(new SchematicCommands(worldEdit))
.describeAs("Schematic commands for saving/loading areas")
.registerMethods(new SchematicCommands(worldEdit))
.parent()
.group("snapshot", "snap")
.describe("Schematic commands for saving/loading areas")
.build(new SnapshotCommands(worldEdit))
.describeAs("Schematic commands for saving/loading areas")
.registerMethods(new SnapshotCommands(worldEdit))
.parent()
.group("brush", "br")
.describe("Brushing commands")
.build(new BrushCommands(worldEdit))
.describeAs("Brushing commands")
.registerMethods(new BrushCommands(worldEdit))
.parent()
.group("superpickaxe", "pickaxe", "sp")
.describe("Super-pickaxe commands")
.build(new SuperPickaxeCommands(worldEdit))
.describeAs("Super-pickaxe commands")
.registerMethods(new SuperPickaxeCommands(worldEdit))
.parent()
.group("tool")
.describe("Bind functions to held items")
.build(new ToolCommands(worldEdit))
.describeAs("Bind functions to held items")
.registerMethods(new ToolCommands(worldEdit))
.parent()
.graph()
.getDispatcher();

Datei anzeigen

@ -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.

Datei anzeigen

@ -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];

Datei anzeigen

@ -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

Datei anzeigen

@ -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);
}

Datei anzeigen

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