Connection messages to discord - #9
Conversation
bson: 5.6.3 -> 5.7.0 JEmoji: 1.7.5 -> 1.7.6
5.2.0 -> 1e25aec
org.jetbrains.gradle.plugin.idea-ext: 1.3 -> 1.4.1 Annoying API: e35bfdb -> db46b2b JEmoji: 1.7.6 -> 2.0.0
So that main class isn't flooded
There was a problem hiding this comment.
Pull request overview
Adds Minecraft → Discord player join/quit syncing via a new WebSocket endpoint, restructures the config under a unified syncing section (with both Discord→Minecraft messages and Minecraft→Discord connections), and refactors the socket/object layer (record-based IpPort, reflective EAObject.toJson(), renamed handle → onMessage, extracted IDMappings, shared Heads).
Changes:
- New
PlayerConnectionobject +PlayerConnectionClientsocket;PlayerListener(renamed fromJoinListener) sends JOIN/QUIT to Discord. - Config restructured to
syncing.discord-to-minecraft.messagesandsyncing.minecraft-to-discord.connections, with correspondingSyncingGui/MessagesGuiandChatListenerinput handling. EAObjectnow exposes a generic reflectivetoJson()andtoString()instead of holding the rawJsonObject;SocketClientadds a typedsend(T)and abstractonMessagedefault;IpPortbecomes a record;IDMappingsand head textures moved to dedicated classes.
Reviewed changes
Copilot reviewed 44 out of 45 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/main/resources/config.yml | New syncing config layout replacing discord-message-syncing. |
| EventAlertsIntegration.java | Adds shared GSON; removes inline ID mappings. |
| IDMappings.java | New file containing the ID→name map. |
| config/ConfigYml.java | Adds Syncing / DiscordToMinecraft.Messages / MinecraftToDiscord sections with reconnect hooks. |
| objects/EAObject.java | Replaces stored json with reflective toJson()/toString(). |
| objects/PlayerConnection.java | New outbound payload object (uuid/username/timestamp/type). |
| objects/{Server,Event,EventThreadMessage,EAPlayer,FamousEvent,CrossBan}.java | Drop super(json) since EAObject no longer stores it. |
| socket/SocketClient.java | Adds send(T), uses CloseFrame constants, renames handle → onMessage, gates stack traces on logs. |
| socket/SocketEndpoint.java | Adds PLAYER_CONNECTION endpoint. |
| socket/WebSockets.java | Exposes clients map publicly for listener use. |
| socket/clients/PlayerConnectionClient.java | New client for the player-connection endpoint. |
| socket/clients/{EventChat,EventPosted,FamousEventPosted,Link,CrossBan}Client.java | Rename handle → onMessage; updated config paths and IDMappings reference. |
| listeners/PlayerListener.java | Renamed from JoinListener; adds JOIN/QUIT handlers using PlayerLoginEvent/PlayerQuitEvent. |
| listeners/ChatListener.java | New input branch for the messages format and shared reopenGui helper. |
| utility/EAStringUtility.java | Converts IpPort to a record; tightens JEmoji loading. |
| utility/EventMessageUtility.java | Updates to record accessors for IpPort. |
| gui/EAGui.java, gui/Heads.java | Move textures to Heads; rename uninitialize → unitalicize. |
| gui/config/ConfigGui.java + others | Wire up new SyncingGui/MessagesGui and rename method calls. |
| gui/config/syncing/{SyncingGui,discordtominecraft/MessagesGui}.java | New GUIs for the syncing config tree. |
| build.gradle.kts | Bumps annoyingAPI to a commit hash, jEmoji to 2.0.0, bson to 5.7.0, idea-ext plugin. |
Comments suppressed due to low confidence (1)
src/main/java/gg/eventalerts/eventalertsintegration/listeners/PlayerListener.java:58
- Using
PlayerLoginEventto send the JOIN message has two issues:
-
PlayerLoginEventfires during the login/auth stage, before the player has actually entered the world. The connection can still fail or be denied after this event (e.g., by other MONITOR-priority handlers callingevent.setResult(...), or by client-side disconnects between login and play). When that happens, a spurious JOIN will be sent to Discord with no matching QUIT. The conventional event for "player joined" isPlayerJoinEvent, which only fires once the player is actually in the world. -
ignoreCancelled = truehas no effect here becausePlayerLoginEventis notCancellable— it usesResultinstead. The flag is misleading and can be removed.
Consider switching onPlayerJoin to listen on PlayerJoinEvent (and dropping ignoreCancelled).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
TypeAdapters and such No idea why I didn't initially use this... Also added message attachments support
Depends on https://github.com/Event-Alerts/event-alerts-bot/pull/6