Closed PizzaCrust closed 8 years ago
What are the use of dynamic commands? I think having immutable ones would be safer.
Dynamic commands allows for plugins like Skript, to register commands dynamically after they parse the scripting language.
I suggest that interfaces not be used as they are not safe. Please use an immutable object instead.
Hmm. Probably like this:
Fountain.getServer().getCommandManager().newCommand("test-command").invokeHandler(() -> println("meow").register()
Or an object. Objects are nice. We're using Java for a reason.
How would you propose to use an object for this?
Not called Command
but something like
public abstract class Command {
public abstract String getName();
public abstract void invoke(String[] args, CommandSender sender);
}
Which plugins can extend like
public class TestCommand extends Command {
public String getName() { return "test"; }
public void invoke(String args[], CommandSender sender) { System.out.println(Arrays.toString(args)); }
}
What's wrong with using builders?
Fountain.getServer().getCommandManager()
.newCommand("test")
.invokeHandler((args, sender) -> {})
.generate();
Ok, removing builders.
Replaced with an abstract class.
Added the lines.
This commit adds registration handlers for implementations to handle command registration at any time, than just startup. This commit also adds dynamic commands called ICommand. It also fixes calling the same command name multiple times.