diff options
author | Linnea Gräf <nea@nea.moe> | 2024-02-22 22:05:15 +0100 |
---|---|---|
committer | Linnea Gräf <nea@nea.moe> | 2024-02-22 22:06:01 +0100 |
commit | aef074886b587745bd814fe965d55e7b4cf11a07 (patch) | |
tree | acc62b9aaf9f95bdce17a85683c42cbec93fe800 /src/main/java/moe/nea/kowalski/KowalskiCommand.kt | |
parent | e8196b0b5e02ec21f75109ab7aba8d48220c8d05 (diff) | |
download | Kowalski-aef074886b587745bd814fe965d55e7b4cf11a07.tar.gz Kowalski-aef074886b587745bd814fe965d55e7b4cf11a07.tar.bz2 Kowalski-aef074886b587745bd814fe965d55e7b4cf11a07.zip |
Add event cancellation watcher
Diffstat (limited to 'src/main/java/moe/nea/kowalski/KowalskiCommand.kt')
-rw-r--r-- | src/main/java/moe/nea/kowalski/KowalskiCommand.kt | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/src/main/java/moe/nea/kowalski/KowalskiCommand.kt b/src/main/java/moe/nea/kowalski/KowalskiCommand.kt new file mode 100644 index 0000000..b2a975a --- /dev/null +++ b/src/main/java/moe/nea/kowalski/KowalskiCommand.kt @@ -0,0 +1,61 @@ +package moe.nea.kowalski + +import net.minecraft.client.Minecraft +import net.minecraft.command.CommandBase +import net.minecraft.command.ICommandSender +import net.minecraft.util.BlockPos +import net.minecraft.util.ChatComponentText + +object KowalskiCommand : CommandBase() { + override fun getCommandName(): String { + return "kowalski" + } + + override fun canCommandSenderUseCommand(sender: ICommandSender?): Boolean { + return true + } + + override fun getCommandUsage(sender: ICommandSender?): String { + return "" + } + + + override fun addTabCompletionOptions( + sender: ICommandSender?, + args: Array<out String>, + pos: BlockPos? + ): List<String> { + return when (args.size) { + 1 -> getListOfStringsMatchingLastWord(args, "whocancels") + 2 -> when (args[0]) { + "whocancels" -> getListOfStringsMatchingLastWord(args, "ClientChatReceivedEvent") + else -> emptyList() + } + else -> emptyList() + } + } + + fun chat(text: String) { + Minecraft.getMinecraft().ingameGUI.chatGUI.printChatMessage(ChatComponentText("§e[§fKW§e]§r $text")) + } + + override fun processCommand(sender: ICommandSender, args: Array<out String>) { + when (args.firstOrNull()) { + "whocancels" -> { + if (args.size != 2) { + chat("§cPlease provide an event to listen to: §bwhocancels <eventname>") + return + } + val eventName = args[1] + if (eventName in Kowalski.watchedEvents) { + Kowalski.watchedEvents.remove(eventName) + chat("§fRemoved §c$eventName §ffrom watched events") + } else { + Kowalski.watchedEvents.add(eventName) + chat("§fAdded §b$eventName §fto watched events") + } + } + } + } + +} |