mirror of
https://github.com/TotalFreedomMC/TF-PlotSquared.git
synced 2025-08-09 22:13:12 +00:00
Starting to convert commands to a smarter system :3
This commit is contained in:
parent
6b229ac504
commit
e1c8dcc4be
57 changed files with 1443 additions and 726 deletions
|
@ -0,0 +1,48 @@
|
|||
package com.intellectualsites.commands.test;
|
||||
|
||||
import com.intellectualsites.commands.*;
|
||||
import com.intellectualsites.commands.callers.CommandCaller;
|
||||
import com.intellectualsites.commands.callers.SystemCaller;
|
||||
|
||||
public class CommandTest {
|
||||
|
||||
public static void main(String[] args) {
|
||||
CommandCaller caller = new SystemCaller();
|
||||
CommandManager manager = new CommandManager();
|
||||
if(!manager.createCommand(new TestCommand())) {
|
||||
System.out.println("Failed to create command :(");
|
||||
}
|
||||
manager.handle(caller, "/test banana cow grass");
|
||||
}
|
||||
|
||||
@CommandDeclaration(command = "test", usage = "/test [word]")
|
||||
public static class TestCommand extends Command {
|
||||
TestCommand() {
|
||||
requiredArguments = new Argument[] {
|
||||
Argument.String, Argument.String, Argument.String
|
||||
};
|
||||
addCommand(new Command("banana", new String[0]) {
|
||||
@Override
|
||||
public boolean onCommand(CommandCaller caller, String[] arguments) {
|
||||
if (getCommands().isEmpty()) {
|
||||
addCommand(new Command("cow") {
|
||||
@Override
|
||||
public boolean onCommand(CommandCaller caller, String[] arguments) {
|
||||
caller.message("I eat " + arguments[0]);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
handle(caller, arguments);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandCaller caller, String[] arguments) {
|
||||
handle(caller, arguments);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue