Change UserActionHandler to handle /say broadcasts as well

This commit is contained in:
DaMachinator 2018-01-23 09:11:08 -05:00 committed by Arcanitor
parent 59fffab908
commit bd91a381cd
3 changed files with 14 additions and 4 deletions

View File

@ -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

View File

@ -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))
}
}
}

View File

@ -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."