Skip to content

Commit

Permalink
refactor: move packet register of chat to main
Browse files Browse the repository at this point in the history
  • Loading branch information
jimchen5209 committed Jun 16, 2024
1 parent 460d3bf commit 37136d6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
3 changes: 3 additions & 0 deletions src/main/kotlin/one/oktw/galaxy/Main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import one.oktw.galaxy.event.type.ProxyResponseEvent
import one.oktw.galaxy.item.event.CustomItemEventHandler
import one.oktw.galaxy.item.event.Wrench
import one.oktw.galaxy.network.ProxyAPIPayload
import one.oktw.galaxy.network.ProxyChatPayload
import one.oktw.galaxy.player.Harvest
import one.oktw.galaxy.proxy.api.ProxyAPI
import one.oktw.galaxy.recipe.RecipeRegistry
Expand Down Expand Up @@ -93,6 +94,8 @@ class Main : DedicatedServerModInitializer, CoroutineScope {
ServerPlayNetworking.registerGlobalReceiver(ProxyAPIPayload.ID) { payload, context ->
eventManager.emit(ProxyResponseEvent(context.player(), payload.packet))
}
// Register Proxy Chat Packet
PayloadTypeRegistry.playS2C().register(ProxyChatPayload.ID, ProxyChatPayload.CODEC)

//Events
eventManager.register(Exchange())
Expand Down
6 changes: 0 additions & 6 deletions src/main/kotlin/one/oktw/galaxy/chat/Exchange.kt
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,6 @@ import one.oktw.galaxy.proxy.api.ProxyAPI
import one.oktw.galaxy.proxy.api.packet.MessageSend

class Exchange {
companion object {
init {
PayloadTypeRegistry.playS2C().register(ProxyChatPayload.ID, ProxyChatPayload.CODEC)
}
}

@EventListener(true)
fun handleChat(event: PlayerChatEvent) {
if (Main.selfUUID == ProxyAPI.dummyUUID) return
Expand Down

0 comments on commit 37136d6

Please sign in to comment.