This repository was archived by the owner on Aug 10, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commands
Findlay Richardson edited this page Jun 23, 2023
·
4 revisions
The @Command annotation is used to indicate that there is a command
package net.zenoc.gallium.test.commands;
import net.zenoc.gallium.api.annotations.Command;
import net.zenoc.gallium.api.chat.ChatMessage;
import net.zenoc.gallium.commandsys.CommandContext;
public class TestCommand {
@Command(aliases = {"test"}, description = "A test command for testing")
public void testCommand(CommandContext ctx) {
ctx.getCaller().sendMessage(ChatMessage.from("Hey"));
}
}Commands have to be registered in your plugin!
package net.zenoc.gallium.test;
import net.zenoc.gallium.api.annotations.PluginLifecycleListener;
import net.zenoc.gallium.plugin.PluginLifecycleState;
import net.zenoc.gallium.plugin.java.JavaPlugin;
public class GalliumPlugin extends JavaPlugin {
@PluginLifecycleListener(PluginLifecycleState.ENABLED)
public void onPluginEnable() {
Gallium.getCommandManager().registerCommand(new TestCommand(), this);
}
}@Command(aliases = {"whatami"}, description = "Find out what type of command caller you are")
public void whatamiCommand(CommandContext ctx) {
ctx.ifPlayer(player -> {
player.sendMessage(ChatMessage.from("Hello, you're a player!"));
}).ifConsole(caller -> {
caller.sendMessage(ChatMessage.from("Hello, you're the console!"));
});
}