From bd91a381cd922e54acb38136f2ce20d57ffaf25b Mon Sep 17 00:00:00 2001 From: DaMachinator Date: Tue, 23 Jan 2018 09:11:08 -0500 Subject: [PATCH] Change UserActionHandler to handle /say broadcasts as well --- src/main/kotlin/civilengineering/CivilEngineering.kt | 4 ++-- .../{UserActionHandler.kt => CommandEventHandler.kt} | 12 +++++++++++- src/main/resources/mcmod.info | 2 +- 3 files changed, 14 insertions(+), 4 deletions(-) rename src/main/kotlin/civilengineering/eventhandlers/{UserActionHandler.kt => CommandEventHandler.kt} (66%) diff --git a/src/main/kotlin/civilengineering/CivilEngineering.kt b/src/main/kotlin/civilengineering/CivilEngineering.kt index ff1744d..5b7e7cc 100644 --- a/src/main/kotlin/civilengineering/CivilEngineering.kt +++ b/src/main/kotlin/civilengineering/CivilEngineering.kt @@ -5,7 +5,7 @@ import civilengineering.bridge.ServerChatHelper import civilengineering.command.BridgeCommand import civilengineering.eventhandlers.ChatMessageHandler import civilengineering.eventhandlers.DeathEventHandler -import civilengineering.eventhandlers.UserActionHandler +import civilengineering.eventhandlers.CommandEventHandler import net.minecraftforge.common.MinecraftForge import net.minecraftforge.fml.common.Mod import net.minecraftforge.fml.common.event.* @@ -65,7 +65,7 @@ object CivilEngineering { MinecraftForge.EVENT_BUS.register(ServerChatHelper()) MinecraftForge.EVENT_BUS.register(ChatMessageHandler()) MinecraftForge.EVENT_BUS.register(DeathEventHandler()) - MinecraftForge.EVENT_BUS.register(UserActionHandler()) + MinecraftForge.EVENT_BUS.register(CommandEventHandler()) } @Mod.EventHandler diff --git a/src/main/kotlin/civilengineering/eventhandlers/UserActionHandler.kt b/src/main/kotlin/civilengineering/eventhandlers/CommandEventHandler.kt similarity index 66% rename from src/main/kotlin/civilengineering/eventhandlers/UserActionHandler.kt rename to src/main/kotlin/civilengineering/eventhandlers/CommandEventHandler.kt index d657aa2..8ea2a4f 100644 --- a/src/main/kotlin/civilengineering/eventhandlers/UserActionHandler.kt +++ b/src/main/kotlin/civilengineering/eventhandlers/CommandEventHandler.kt @@ -1,13 +1,15 @@ package civilengineering.eventhandlers +import civilengineering.CivilEngineering import civilengineering.bridge.ApiMessage import civilengineering.bridge.MessageHandler +import net.minecraft.command.server.CommandBroadcast import net.minecraft.command.server.CommandEmote import net.minecraft.entity.player.EntityPlayer import net.minecraftforge.event.CommandEvent import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class UserActionHandler { +class CommandEventHandler { @SubscribeEvent fun handleCommandEvent(event: CommandEvent) { if (event.command is CommandEmote && event.sender is EntityPlayer) { @@ -22,6 +24,14 @@ class UserActionHandler { message = message.trim { it <= ' ' } MessageHandler.transmit(ApiMessage(username=user, text=message, event="user_action")) + } else if(event.command is CommandBroadcast) { + var message = "" + for (word in event.parameters) { + message = message + " " + word + } + message = message.trim { it <= ' ' } + + MessageHandler.transmit(ApiMessage(event.sender.name,message)) } } } diff --git a/src/main/resources/mcmod.info b/src/main/resources/mcmod.info index 0848682..1860497 100644 --- a/src/main/resources/mcmod.info +++ b/src/main/resources/mcmod.info @@ -2,7 +2,7 @@ "modid": "civilengineering", "name": "Civil Engineering", "description": "Minecraft Server Matterbridge link", - "version": "0.1.1", + "version": "0.1q.1", "mcversion": "1.12.2", "authorList":["Arcanitor", "NikkyAi"], "credits": "Blame Nikky for talking me into this."