-
Notifications
You must be signed in to change notification settings - Fork 396
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How can I use this on my java game? #85
Comments
create a dispatcher with a custom command sender class. |
Any example code? |
public interface CommandSender {
void sendMessage(String message);
} public final class App {
private final CommandDispatcher<CommandSender> dispatcher = new CommandDispatcher<>();
public static void main(final String[] args) {
new App().exec();
}
public void exec() {
this.dispatcher.register(LiteralArgumentBuilder.literal("testCommand")
.executes(context -> {
context.getSource().sendMessage("xxx");
return 0;
}));
final var client = new Client(this.dispatcher);
client.start();
}
} public final class Client implements CommandSender {
private final CommandDispatcher<CommandSender> dispatcher;
public Client(final CommandDispatcher<CommandSender> dispatcher) {
this.dispatcher = dispatcher;
}
@Overrider
public void sendMessage(final String message) {
System.out.println(message);
}
public void start() {
// Start client, initiate other things etc.
}
public int runCommand(final String command) {
return this.dispatcher.execute(command, this);
}
} |
@portlek ok cool. I'll try it. If there is no problem with that code, I will close this issue. |
actually, it works or not, you should understand the concept. |
@portlek okay |
probably you didn't register command or typing the wrong command, I can't say anything without any single code tho .-. |
Try and catch, see what in the stacktrace is causing it. |
I am making a 3D game using Java and I would like to use this on my game. But how can I do this?
The text was updated successfully, but these errors were encountered: