51 lines
1.7 KiB
Java
51 lines
1.7 KiB
Java
![]() |
/*
|
||
|
*
|
||
|
* CommandManager
|
||
|
*
|
||
|
* This class maintains all custom commands and executions throughout the mod
|
||
|
*
|
||
|
*/
|
||
|
|
||
|
package jesse.keeblarcraft.Commands;
|
||
|
|
||
|
import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback;
|
||
|
import net.minecraft.server.command.CommandManager;
|
||
|
import net.minecraft.server.command.ServerCommandSource;
|
||
|
import net.minecraft.text.Text;
|
||
|
import jesse.keeblarcraft.Commands.ShortcutCommands;
|
||
|
|
||
|
public class CustomCommandManager {
|
||
|
// Intentionally empty constructor since at object definition time it may not be possible to register commands
|
||
|
public CustomCommandManager() {}
|
||
|
|
||
|
// Registers all commands for the mod
|
||
|
public void RegisterCustomCommands() {
|
||
|
CommandRegistrationCallback.EVENT.register((dispatcher, registryAccess, environment) -> {
|
||
|
dispatcher.register(CommandManager.literal("amogus").executes(ctx -> {
|
||
|
ctx.getSource().sendFeedback(() -> Text.literal("AMOGOOOOOO"), false);
|
||
|
return 0;
|
||
|
}));
|
||
|
});
|
||
|
|
||
|
CommandRegistrationCallback.EVENT.register((dispatcher, registryAccess, environment) -> {
|
||
|
dispatcher.register(CommandManager.literal("cbtest").executes(ctx -> {
|
||
|
ctx.getSource().sendFeedback(() -> TestCallback(ctx.getSource()), false);
|
||
|
return 0;
|
||
|
}));
|
||
|
});
|
||
|
|
||
|
// CUSTOM COMMAND CLASS OBJECTS BELOW
|
||
|
ShortcutCommands shortcuts = new ShortcutCommands();
|
||
|
|
||
|
// REGISTER COMMANDS BELOW
|
||
|
System.out.println("REGISTERING CUSTOM COMMAND EXTENSIONS BELOW");
|
||
|
shortcuts.RegisterShortcutCommands();
|
||
|
|
||
|
}
|
||
|
|
||
|
public Text TestCallback(ServerCommandSource ctx) {
|
||
|
String stuff = ctx.getName();
|
||
|
return Text.literal("Callback called from " + stuff);
|
||
|
}
|
||
|
}
|