2024-07-24 01:21:47 +00:00
|
|
|
/*
|
|
|
|
*
|
|
|
|
* 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;
|
|
|
|
|
|
|
|
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();
|
2024-07-29 00:13:48 +00:00
|
|
|
NoteCommands noteCommands = new NoteCommands();
|
2024-07-24 01:21:47 +00:00
|
|
|
|
|
|
|
// REGISTER COMMANDS BELOW
|
|
|
|
System.out.println("REGISTERING CUSTOM COMMAND EXTENSIONS BELOW");
|
|
|
|
shortcuts.RegisterShortcutCommands();
|
2024-07-29 00:13:48 +00:00
|
|
|
noteCommands.RegisterNoteCommands();
|
2024-07-24 01:21:47 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
public Text TestCallback(ServerCommandSource ctx) {
|
|
|
|
String stuff = ctx.getName();
|
|
|
|
return Text.literal("Callback called from " + stuff);
|
|
|
|
}
|
|
|
|
}
|