diff --git a/src/main/java/io/github/homchom/recode/Recode.kt b/src/main/java/io/github/homchom/recode/Recode.kt index 584f1e88..2a42ab77 100644 --- a/src/main/java/io/github/homchom/recode/Recode.kt +++ b/src/main/java/io/github/homchom/recode/Recode.kt @@ -5,10 +5,7 @@ import com.google.gson.GsonBuilder import io.github.homchom.recode.event.listenEach import io.github.homchom.recode.feature.automation.AutoCommands import io.github.homchom.recode.feature.meta.FDebugMode -import io.github.homchom.recode.feature.visual.FBuiltInResourcePacks -import io.github.homchom.recode.feature.visual.FCodeSearch -import io.github.homchom.recode.feature.visual.FMessageStacking -import io.github.homchom.recode.feature.visual.FSignRenderDistance +import io.github.homchom.recode.feature.visual.* import io.github.homchom.recode.game.QuitGameEvent import io.github.homchom.recode.hypercube.JoinDFDetector import io.github.homchom.recode.mod.commands.CommandHandler @@ -76,6 +73,7 @@ object Recode : ClientModInitializer, ModContainer { // Visual FBuiltInResourcePacks FCodeSearch + FLagSlayerHUD FMessageStacking FSignRenderDistance diff --git a/src/main/java/io/github/homchom/recode/event/trial/DetectorImpl.kt b/src/main/java/io/github/homchom/recode/event/trial/DetectorImpl.kt index 72158cf4..5c3029c0 100644 --- a/src/main/java/io/github/homchom/recode/event/trial/DetectorImpl.kt +++ b/src/main/java/io/github/homchom/recode/event/trial/DetectorImpl.kt @@ -11,7 +11,6 @@ import kotlinx.coroutines.* import kotlinx.coroutines.channels.Channel import kotlinx.coroutines.channels.SendChannel import kotlinx.coroutines.flow.* -import java.util.concurrent.CancellationException import java.util.concurrent.ConcurrentLinkedDeque import java.util.concurrent.atomic.AtomicBoolean import kotlin.time.Duration diff --git a/src/main/java/io/github/homchom/recode/feature/visual/LagSlayerHUD.kt b/src/main/java/io/github/homchom/recode/feature/visual/LagSlayerHUD.kt new file mode 100644 index 00000000..e6313e7b --- /dev/null +++ b/src/main/java/io/github/homchom/recode/feature/visual/LagSlayerHUD.kt @@ -0,0 +1,85 @@ +package io.github.homchom.recode.feature.visual + +import io.github.homchom.recode.Power +import io.github.homchom.recode.config.Config +import io.github.homchom.recode.config.Setting +import io.github.homchom.recode.event.listenEach +import io.github.homchom.recode.feature.AddsFeature +import io.github.homchom.recode.feature.registerFeature +import io.github.homchom.recode.game.TickCountdown +import io.github.homchom.recode.mc +import io.github.homchom.recode.multiplayer.ReceiveMessageEvent +import io.github.homchom.recode.render.AfterRenderHudEvent +import io.github.homchom.recode.ui.text.StyledString +import io.github.homchom.recode.ui.text.matchesPlain +import io.github.homchom.recode.ui.text.substring +import io.github.homchom.recode.ui.text.toVanillaComponent +import io.github.homchom.recode.util.regex.regex +import net.minecraft.client.gui.GuiGraphics + +@OptIn(AddsFeature::class) +object FLagSlayerHUD : Setting { + override val configString = "cpuOnScreen" + + private var regex: Regex? = null + + private var line1: StyledString? = null + private var line2: StyledString? = null + private var line3: StyledString? = null + private val renderCountdown = TickCountdown(30) + + init { + registerFeature("LagSlayer HUD") { + onEnable { + regex = regex { + str("CPU Usage: [") + str('▮') * 20 + str("] (") + digit; digit.optional() + period; digit.oneOrMore() + str("%)") + } + + interceptActionBarPackets() + render() + } + onDisable { + regex = null + } + } + } + + private fun Power.interceptActionBarPackets() = listenEach(ReceiveMessageEvent.ActionBar) l@{ message -> + if (Config[FLagSlayerHUD] == false) return@l + if (!regex!!.matchesPlain(message.value)) return@l + + message.invalidate() + + val text = StyledString(message.value) + line1 = text.substring(0, 11) + line2 = text.substring(11, 33) + line3 = text.substring(33) + renderCountdown.wind() + } + + private fun Power.render() = listenEach(AfterRenderHudEvent) l@{ (guiGraphics) -> + if (!renderCountdown.isActive) return@l + drawString(guiGraphics, line1!!, 3) + drawString(guiGraphics, line2!!, 2) + drawString(guiGraphics, line3!!, 1) + } + + // TODO: rework post-workflow + private fun drawString(guiGraphics: GuiGraphics, string: StyledString, index: Int) { + val font = mc.font + val window = mc.window + guiGraphics.drawString( + font, + string.toVanillaComponent(), + 4, + window.guiScaledHeight - (font.lineHeight * index + 4), + 0xffffff, + true + ) + } +} \ No newline at end of file diff --git a/src/main/java/io/github/homchom/recode/hypercube/CommandSenders.kt b/src/main/java/io/github/homchom/recode/hypercube/CommandSenders.kt index aa86294c..ba86a618 100644 --- a/src/main/java/io/github/homchom/recode/hypercube/CommandSenders.kt +++ b/src/main/java/io/github/homchom/recode/hypercube/CommandSenders.kt @@ -4,7 +4,7 @@ import io.github.homchom.recode.event.trial.requester import io.github.homchom.recode.event.trial.toggleRequesterGroup import io.github.homchom.recode.event.trial.trial import io.github.homchom.recode.hypercube.state.DFStateDetectors -import io.github.homchom.recode.multiplayer.ReceiveChatMessageEvent +import io.github.homchom.recode.multiplayer.ReceiveMessageEvent import io.github.homchom.recode.multiplayer.Sender import io.github.homchom.recode.ui.text.equalsPlain import io.github.homchom.recode.ui.text.matchesPlain @@ -15,7 +15,7 @@ import io.github.homchom.recode.util.regex.regex // TODO: replace more requesters with senders and update documentation object CommandSenders { val ChatLocal = requester("/chat local", DFStateDetectors, trial( - ReceiveChatMessageEvent, + ReceiveMessageEvent.Chat, Unit, start = { Sender.sendCommand("chat local") }, tests = { (text), _, _ -> @@ -33,7 +33,7 @@ object CommandSenders { // TODO: support time keywords through command suggestions (not enum) val ClientTime = requester("/time", DFStateDetectors, trial( - ReceiveChatMessageEvent, + ReceiveMessageEvent.Chat, null as Long?, start = { time -> Sender.sendCommand("time $time") }, tests = { context, time, _: Boolean -> @@ -42,7 +42,7 @@ object CommandSenders { )) val Flight = toggleRequesterGroup("/fly", DFStateDetectors, trial( - ReceiveChatMessageEvent, + ReceiveMessageEvent.Chat, Unit, start = { Sender.sendCommand("fly") }, tests = t@{ message, _, _ -> @@ -67,7 +67,7 @@ object CommandSenders { } val LagSlayer = toggleRequesterGroup("/lagslayer", DFStateDetectors, trial( - ReceiveChatMessageEvent, + ReceiveMessageEvent.Chat, Unit, start = { Sender.sendCommand("lagslayer") }, tests = t@{ (message), _, _ -> @@ -81,7 +81,7 @@ object CommandSenders { )) val NightVision = toggleRequesterGroup("/nightvis", DFStateDetectors, trial( - ReceiveChatMessageEvent, + ReceiveMessageEvent.Chat, Unit, start = { Sender.sendCommand("nightvis") }, tests = t@{ (message), _, _ -> diff --git a/src/main/java/io/github/homchom/recode/hypercube/HypercubeEvents.kt b/src/main/java/io/github/homchom/recode/hypercube/HypercubeEvents.kt index 8e8a408c..bb0b1575 100644 --- a/src/main/java/io/github/homchom/recode/hypercube/HypercubeEvents.kt +++ b/src/main/java/io/github/homchom/recode/hypercube/HypercubeEvents.kt @@ -10,7 +10,7 @@ import io.github.homchom.recode.hypercube.state.isOnDF import io.github.homchom.recode.mc import io.github.homchom.recode.multiplayer.DisconnectFromServerEvent import io.github.homchom.recode.multiplayer.JoinServerEvent -import io.github.homchom.recode.multiplayer.ReceiveChatMessageEvent +import io.github.homchom.recode.multiplayer.ReceiveMessageEvent import io.github.homchom.recode.multiplayer.username import io.github.homchom.recode.ui.text.matchEntirePlain import io.github.homchom.recode.util.Case @@ -28,7 +28,7 @@ val JoinDFDetector = detector("DF join", if (isOnDF) return@t null // if already on DF, this is a node switch and should not be tested if (!mc.currentServer.ipMatchesDF) return@t null - val messages = ReceiveChatMessageEvent.add() + val messages = ReceiveMessageEvent.Chat.add() val tipMessage = ActiveBoosterInfo.detect(null).map(::Case).addOptional() val disconnect = DisconnectFromServerEvent.add() diff --git a/src/main/java/io/github/homchom/recode/hypercube/message/MessageParser.kt b/src/main/java/io/github/homchom/recode/hypercube/message/MessageParser.kt index 61f2ef03..859948a9 100644 --- a/src/main/java/io/github/homchom/recode/hypercube/message/MessageParser.kt +++ b/src/main/java/io/github/homchom/recode/hypercube/message/MessageParser.kt @@ -7,7 +7,7 @@ import io.github.homchom.recode.event.SimpleValidated import io.github.homchom.recode.event.trial.detector import io.github.homchom.recode.event.trial.requester import io.github.homchom.recode.event.trial.trial -import io.github.homchom.recode.multiplayer.ReceiveChatMessageEvent +import io.github.homchom.recode.multiplayer.ReceiveMessageEvent import io.github.homchom.recode.util.Matcher import io.github.homchom.recode.util.matcherOf import io.github.homchom.recode.util.splitByHumps @@ -20,7 +20,7 @@ import net.kyori.adventure.text.Component sealed interface MessageParser : Matcher, Detector val ParsedMessageDetector = detector("parsed message", - trial(ReceiveChatMessageEvent, Unit) t@{ message, _ -> + trial(ReceiveMessageEvent.Chat, Unit) t@{ message, _ -> val parsed = ParsedMessage.match(message.value) ?: return@t null if (hidden) message.invalidate() instant(ParsedMessageContext(parsed, message)) diff --git a/src/main/java/io/github/homchom/recode/hypercube/message/ShopMessages.kt b/src/main/java/io/github/homchom/recode/hypercube/message/ShopMessages.kt index 24de83de..019d96a5 100644 --- a/src/main/java/io/github/homchom/recode/hypercube/message/ShopMessages.kt +++ b/src/main/java/io/github/homchom/recode/hypercube/message/ShopMessages.kt @@ -5,7 +5,7 @@ import io.github.homchom.recode.event.trial.detector import io.github.homchom.recode.event.trial.trial import io.github.homchom.recode.hypercube.BOOSTER_ARROW import io.github.homchom.recode.hypercube.TOKEN_NOTCH_CHAR -import io.github.homchom.recode.multiplayer.ReceiveChatMessageEvent +import io.github.homchom.recode.multiplayer.ReceiveMessageEvent import io.github.homchom.recode.multiplayer.username import io.github.homchom.recode.ui.text.matchEntirePlain import io.github.homchom.recode.ui.text.matchesPlain @@ -41,7 +41,7 @@ data class ActiveBoosterInfo(val player: String, val canTip: Boolean) { ShopMessages.BoosterActive, Unit, tests = { (player), _ -> - val subsequent = ReceiveChatMessageEvent.add() + val subsequent = ReceiveMessageEvent.Chat.add() suspending s@{ val (first) = subsequent.receive() diff --git a/src/main/java/io/github/homchom/recode/hypercube/state/DFStateDetectors.kt b/src/main/java/io/github/homchom/recode/hypercube/state/DFStateDetectors.kt index 2d1a7180..8a757f2f 100644 --- a/src/main/java/io/github/homchom/recode/hypercube/state/DFStateDetectors.kt +++ b/src/main/java/io/github/homchom/recode/hypercube/state/DFStateDetectors.kt @@ -92,7 +92,7 @@ object DFStateDetectors : StateListenable> by eventGroup { )) val ChangeMode = eventGroup.add(detector("mode change", - trial(ReceiveChatMessageEvent, Unit) t@{ (message), _ -> + trial(ReceiveMessageEvent.Chat, Unit) t@{ (message), _ -> enforceOnDF() val (mode, plotName, plotOwner) = PlotMode.ID.match(message) ?: return@t null suspending s@{ @@ -124,14 +124,14 @@ object DFStateDetectors : StateListenable> by eventGroup { )) val StartSession = eventGroup.add(detector("session start", - trial(ReceiveChatMessageEvent, Unit) t@{ (message), _ -> + trial(ReceiveMessageEvent.Chat, Unit) t@{ (message), _ -> enforceOnDF() if (currentDFState!!.session != null) return@t null val session = SupportSession.match(message) ?: return@t null - val subsequent = ReceiveChatMessageEvent.add() - val enforceChannel = ReceiveChatMessageEvent.add() + val subsequent = ReceiveMessageEvent.Chat.add() + val enforceChannel = ReceiveMessageEvent.Chat.add() suspending s@{ enforce(enforceChannel) { (text) -> SupportSession.match(text) == null } @@ -152,7 +152,7 @@ object DFStateDetectors : StateListenable> by eventGroup { )) val EndSession = eventGroup.add(detector("session end", - trial(ReceiveChatMessageEvent, Unit) t@{ (message), _ -> + trial(ReceiveMessageEvent.Chat, Unit) t@{ (message), _ -> enforceOnDF() if (currentDFState!!.session == null) return@t null diff --git a/src/main/java/io/github/homchom/recode/mixin/multiplayer/MClientPacketListener.java b/src/main/java/io/github/homchom/recode/mixin/multiplayer/MClientPacketListener.java index 5334515f..2ebb6407 100644 --- a/src/main/java/io/github/homchom/recode/mixin/multiplayer/MClientPacketListener.java +++ b/src/main/java/io/github/homchom/recode/mixin/multiplayer/MClientPacketListener.java @@ -1,10 +1,13 @@ package io.github.homchom.recode.mixin.multiplayer; +import io.github.homchom.recode.multiplayer.ReceiveMessageEvent; import io.github.homchom.recode.multiplayer.Sender; import io.github.homchom.recode.sys.hypercube.templates.TemplateStorageHandler; import io.github.homchom.recode.sys.hypercube.templates.TemplateUtil; import net.minecraft.client.multiplayer.ClientPacketListener; import net.minecraft.network.protocol.game.ClientboundContainerSetSlotPacket; +import net.minecraft.network.protocol.game.ClientboundSetActionBarTextPacket; +import net.minecraft.network.protocol.game.ClientboundSystemChatPacket; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; @@ -13,6 +16,26 @@ @Mixin(ClientPacketListener.class) public abstract class MClientPacketListener { + @Inject(method = "handleSystemChat", cancellable = true, at = @At(value = "INVOKE", + target = "Lnet/minecraft/network/protocol/PacketUtils;ensureRunningOnSameThread(Lnet/minecraft/network/protocol/Packet;Lnet/minecraft/network/PacketListener;Lnet/minecraft/util/thread/BlockableEventLoop;)V", + shift = At.Shift.AFTER + )) + private void runChatEvent(ClientboundSystemChatPacket packet, CallbackInfo ci) { + if (!ReceiveMessageEvent.Chat.INSTANCE.cacheAndRun(packet.content())) { + ci.cancel(); + } + } + + @Inject(method = "setActionBarText", cancellable = true, at = @At(value = "INVOKE", + target = "Lnet/minecraft/network/protocol/PacketUtils;ensureRunningOnSameThread(Lnet/minecraft/network/protocol/Packet;Lnet/minecraft/network/PacketListener;Lnet/minecraft/util/thread/BlockableEventLoop;)V", + shift = At.Shift.AFTER + )) + private void runActionBarEvent(ClientboundSetActionBarTextPacket packet, CallbackInfo ci) { + if (!ReceiveMessageEvent.ActionBar.INSTANCE.cacheAndRun(packet.getText())) { + ci.cancel(); + } + } + @Inject(method = "handleContainerSetSlot", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/protocol/PacketUtils;ensureRunningOnSameThread(Lnet/minecraft/network/protocol/Packet;Lnet/minecraft/network/PacketListener;Lnet/minecraft/util/thread/BlockableEventLoop;)V", shift = At.Shift.AFTER diff --git a/src/main/java/io/github/homchom/recode/mod/events/impl/LegacyReceiveChatMessageEvent.java b/src/main/java/io/github/homchom/recode/mod/events/impl/LegacyReceiveChatMessageEvent.java index b9818866..64ceb057 100644 --- a/src/main/java/io/github/homchom/recode/mod/events/impl/LegacyReceiveChatMessageEvent.java +++ b/src/main/java/io/github/homchom/recode/mod/events/impl/LegacyReceiveChatMessageEvent.java @@ -4,7 +4,7 @@ import io.github.homchom.recode.hypercube.state.DF; import io.github.homchom.recode.hypercube.state.PlotMode; import io.github.homchom.recode.mod.config.LegacyConfig; -import io.github.homchom.recode.multiplayer.ReceiveChatMessageEvent; +import io.github.homchom.recode.multiplayer.ReceiveMessageEvent; import io.github.homchom.recode.sys.player.chat.ChatType; import io.github.homchom.recode.sys.player.chat.ChatUtil; import io.github.homchom.recode.sys.util.TextUtil; @@ -20,7 +20,7 @@ public class LegacyReceiveChatMessageEvent { public LegacyReceiveChatMessageEvent() { - ReceiveChatMessageEvent.INSTANCE.register(this::run); + ReceiveMessageEvent.Chat.INSTANCE.register(this::run); } public static boolean pjoin = false; diff --git a/src/main/java/io/github/homchom/recode/mod/features/LagslayerHUD.java b/src/main/java/io/github/homchom/recode/mod/features/LagslayerHUD.java deleted file mode 100644 index 13710d0d..00000000 --- a/src/main/java/io/github/homchom/recode/mod/features/LagslayerHUD.java +++ /dev/null @@ -1,73 +0,0 @@ -package io.github.homchom.recode.mod.features; - -import com.google.gson.JsonArray; -import com.google.gson.JsonObject; -import com.mojang.blaze3d.platform.Window; -import io.github.homchom.recode.Logging; -import net.minecraft.ChatFormatting; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.Font; -import net.minecraft.client.gui.GuiGraphics; -import net.minecraft.network.chat.Component; -import net.minecraft.network.protocol.game.ClientboundSetActionBarTextPacket; - -public class LagslayerHUD { - private static final Font font = Minecraft.getInstance().font; - private static final Window mainWindow = Minecraft.getInstance().getWindow(); - private static Component barsComponent; - private static Component numberComponent; - private static long lastUpdate; - - public static void updateCPU(ClientboundSetActionBarTextPacket packet) { - JsonArray msgArray = Component.Serializer.toJsonTree(packet.getText()).getAsJsonObject().getAsJsonArray("extra"); - JsonObject msgPart = msgArray.get(2).getAsJsonObject(); - - barsComponent = packet.getText(); - - int siblings = barsComponent.getSiblings().size(); - - Component pComponent = barsComponent.getSiblings().get(siblings - 2); - pComponent.getSiblings().add(barsComponent.getSiblings().get(siblings - 1)); - - barsComponent.getSiblings().remove(siblings - 1); - barsComponent.getSiblings().remove(siblings - 2); - barsComponent.getSiblings().remove(0); - - String numberStr = pComponent.getString().replaceAll("\\(", "").replaceAll("\\)", ""); - String numberColor = msgPart.get("color").getAsString(); - - if (numberColor.equals("dark_gray")) numberColor = "white"; - - numberComponent = Component.Serializer.fromJson("{\"extra\":[{\"italic\":false,\"color\":\"white\",\"text\":\"(\"}," + - "{\"italic\":false,\"color\":\"" + numberColor + "\",\"text\":\"" + numberStr + "\"}," + - "{\"italic\":false,\"color\":\"white\",\"text\":\")\"}],\"text\":\"\"}"); - - lastUpdate = System.currentTimeMillis(); - } - - public static void onRender(GuiGraphics guiGraphics) { - if (barsComponent == null || numberComponent == null) return; - if ((System.currentTimeMillis() - lastUpdate) > 1200) { - barsComponent = null; - numberComponent = null; - return; - } - - try { - renderComponent(guiGraphics, Component.literal("CPU Usage:"), 3, ChatFormatting.GOLD.getColor()); - renderComponent(guiGraphics, barsComponent, 2); - renderComponent(guiGraphics, numberComponent, 1); - } catch (Exception e) { - Logging.logError("Error while trying to render LagSlayer HUD"); - e.printStackTrace(); - } - } - - private static void renderComponent(GuiGraphics guiGraphics, Component text, int line) { - renderComponent(guiGraphics, text, line, 0xffff); - } - - private static void renderComponent(GuiGraphics guiGraphics, Component text, int line, int color) { - guiGraphics.drawString(font, text, 4, mainWindow.getGuiScaledHeight() - (font.lineHeight * line + 4), color, true); - } -} diff --git a/src/main/java/io/github/homchom/recode/mod/mixin/message/MMessageListener.java b/src/main/java/io/github/homchom/recode/mod/mixin/message/MMessageListener.java index 5468fadd..00134c4b 100644 --- a/src/main/java/io/github/homchom/recode/mod/mixin/message/MMessageListener.java +++ b/src/main/java/io/github/homchom/recode/mod/mixin/message/MMessageListener.java @@ -2,39 +2,27 @@ import io.github.homchom.recode.Logging; import io.github.homchom.recode.hypercube.state.DF; -import io.github.homchom.recode.mod.config.LegacyConfig; -import io.github.homchom.recode.mod.features.LagslayerHUD; import io.github.homchom.recode.mod.features.social.chat.message.LegacyMessage; -import io.github.homchom.recode.multiplayer.ReceiveChatMessageEvent; import io.github.homchom.recode.sys.player.DFInfo; import net.minecraft.client.Minecraft; import net.minecraft.client.multiplayer.ClientPacketListener; import net.minecraft.network.chat.Component; -import net.minecraft.network.protocol.game.ClientboundSetActionBarTextPacket; import net.minecraft.network.protocol.game.ClientboundSystemChatPacket; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import java.util.regex.Pattern; - @Mixin(ClientPacketListener.class) public class MMessageListener { private static long lastPatchCheck = 0; //private boolean motdShown = false; - private final Pattern lsRegex = Pattern.compile("^CPU Usage: \\[▮▮▮▮▮▮▮▮▮▮▮▮▮▮▮▮▮▮▮▮] \\(.*%\\)$"); - @Inject(method = "handleSystemChat", cancellable = true, at = @At(value = "INVOKE", target = "Lnet/minecraft/network/protocol/PacketUtils;ensureRunningOnSameThread(Lnet/minecraft/network/protocol/Packet;Lnet/minecraft/network/PacketListener;Lnet/minecraft/util/thread/BlockableEventLoop;)V", shift = At.Shift.AFTER )) private void handleChat(ClientboundSystemChatPacket packet, CallbackInfo ci) { - if (!ReceiveChatMessageEvent.INSTANCE.cacheAndRun(packet.content())) { - ci.cancel(); - } - if (DF.isOnDF()) { // temporary, to preserve non-migrated side effects (like message grabbing) // TODO: remove after new message listener is 100% complete @@ -49,17 +37,6 @@ private void handleChat(ClientboundSystemChatPacket packet, CallbackInfo ci) { } } - @Inject(method = "setActionBarText", at = @At("HEAD"), cancellable = true) - private void setActionBarText(ClientboundSetActionBarTextPacket packet, CallbackInfo ci) { - if (Minecraft.getInstance().player == null) return; - if (lsRegex.matcher(packet.getText().getString()).matches()) { - if (LegacyConfig.getBoolean("cpuOnScreen")) { - //LagslayerHUD.updateCPU(packet); - ci.cancel(); - } - } - } - private void updateVersion(Component component) { if (Minecraft.getInstance().player == null) return; diff --git a/src/main/java/io/github/homchom/recode/multiplayer/MultiplayerEvents.kt b/src/main/java/io/github/homchom/recode/multiplayer/MultiplayerEvents.kt index f401c29e..638f34ce 100644 --- a/src/main/java/io/github/homchom/recode/multiplayer/MultiplayerEvents.kt +++ b/src/main/java/io/github/homchom/recode/multiplayer/MultiplayerEvents.kt @@ -28,7 +28,10 @@ data class ServerDisconnectContext(val handler: ClientPacketListener, val client val ReceiveGamePacketEvent = createEvent>() -object ReceiveChatMessageEvent : CustomEvent, Boolean> by createValidatedEvent() { +sealed class ReceiveMessageEvent : CustomEvent, Boolean> by createValidatedEvent() { + data object Chat : ReceiveMessageEvent() + data object ActionBar : ReceiveMessageEvent() + private val cache = CacheBuilder.newBuilder() .expireAfterAccess(JDuration.ofSeconds(1)) .build()