From 2dd2f3eb5c3a25218ce9e58b616e190e8bae7adc Mon Sep 17 00:00:00 2001 From: HypherionMC Date: Tue, 21 Nov 2023 18:33:59 +0200 Subject: [PATCH] [BREAK] Split Join/Leave and Start/Stop messages --- .../sdlink/core/config/SDLinkConfig.java | 2 +- .../config/impl/MessageChannelConfig.java | 20 +++++++++++----- .../slash/setup/SetChannelCommand.java | 4 ++++ .../sdlink/core/messaging/MessageType.java | 6 +++-- .../messaging/discord/DiscordMessage.java | 24 +++++++++++++++---- 5 files changed, 43 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/hypherionmc/sdlink/core/config/SDLinkConfig.java b/src/main/java/com/hypherionmc/sdlink/core/config/SDLinkConfig.java index 09ca0b1..4f0a498 100644 --- a/src/main/java/com/hypherionmc/sdlink/core/config/SDLinkConfig.java +++ b/src/main/java/com/hypherionmc/sdlink/core/config/SDLinkConfig.java @@ -24,7 +24,7 @@ public class SDLinkConfig extends ModuleConfig { // DO NOT REMOVE TRANSIENT HERE... OTHERWISE, THE STUPID CONFIG LIBRARY // WILL TRY TO WRITE THESE TO THE CONFIG public transient static SDLinkConfig INSTANCE; - public transient static int configVer = 12; + public transient static int configVer = 13; @Path("general") @SpecComment("General Mod Config") diff --git a/src/main/java/com/hypherionmc/sdlink/core/config/impl/MessageChannelConfig.java b/src/main/java/com/hypherionmc/sdlink/core/config/impl/MessageChannelConfig.java index 12f8382..69a731c 100644 --- a/src/main/java/com/hypherionmc/sdlink/core/config/impl/MessageChannelConfig.java +++ b/src/main/java/com/hypherionmc/sdlink/core/config/impl/MessageChannelConfig.java @@ -18,13 +18,21 @@ public class MessageChannelConfig { @SpecComment("Control where CHAT messages are delivered") public DestinationObject chat = DestinationObject.of(MessageDestination.CHAT, false, "default"); - @Path("startStop") - @SpecComment("Control where START/STOP messages are delivered") - public DestinationObject startStop = DestinationObject.of(MessageDestination.EVENT, false, "default"); + @Path("start") + @SpecComment("Control where START messages are delivered") + public DestinationObject start = DestinationObject.of(MessageDestination.EVENT, false, "default"); - @Path("joinLeave") - @SpecComment("Control where JOIN/LEAVE messages are delivered") - public DestinationObject joinLeave = DestinationObject.of(MessageDestination.EVENT, false, "default"); + @Path("stop") + @SpecComment("Control where STOP messages are delivered") + public DestinationObject stop = DestinationObject.of(MessageDestination.EVENT, false, "default"); + + @Path("join") + @SpecComment("Control where JOIN messages are delivered") + public DestinationObject join = DestinationObject.of(MessageDestination.EVENT, false, "default"); + + @Path("leave") + @SpecComment("Control where LEAVE messages are delivered") + public DestinationObject leave = DestinationObject.of(MessageDestination.EVENT, false, "default"); @Path("advancements") @SpecComment("Control where ADVANCEMENT messages are delivered") diff --git a/src/main/java/com/hypherionmc/sdlink/core/discord/commands/slash/setup/SetChannelCommand.java b/src/main/java/com/hypherionmc/sdlink/core/discord/commands/slash/setup/SetChannelCommand.java index 6a50cd9..47ba7fb 100644 --- a/src/main/java/com/hypherionmc/sdlink/core/discord/commands/slash/setup/SetChannelCommand.java +++ b/src/main/java/com/hypherionmc/sdlink/core/discord/commands/slash/setup/SetChannelCommand.java @@ -1,3 +1,7 @@ +/* + * This file is part of sdlink-core, licensed under the MIT License (MIT). + * Copyright HypherionSA and Contributors + */ package com.hypherionmc.sdlink.core.discord.commands.slash.setup; import com.hypherionmc.sdlink.core.config.SDLinkConfig; diff --git a/src/main/java/com/hypherionmc/sdlink/core/messaging/MessageType.java b/src/main/java/com/hypherionmc/sdlink/core/messaging/MessageType.java index 60a17b8..2b9b292 100644 --- a/src/main/java/com/hypherionmc/sdlink/core/messaging/MessageType.java +++ b/src/main/java/com/hypherionmc/sdlink/core/messaging/MessageType.java @@ -10,8 +10,10 @@ package com.hypherionmc.sdlink.core.messaging; */ public enum MessageType { CHAT, - START_STOP, - JOIN_LEAVE, + START, + STOP, + JOIN, + LEAVE, ADVANCEMENT, DEATH, COMMAND, diff --git a/src/main/java/com/hypherionmc/sdlink/core/messaging/discord/DiscordMessage.java b/src/main/java/com/hypherionmc/sdlink/core/messaging/discord/DiscordMessage.java index 92591b5..e62f6e4 100644 --- a/src/main/java/com/hypherionmc/sdlink/core/messaging/discord/DiscordMessage.java +++ b/src/main/java/com/hypherionmc/sdlink/core/messaging/discord/DiscordMessage.java @@ -191,16 +191,32 @@ public final class DiscordMessage { chat ); } - case START_STOP -> { - MessageChannelConfig.DestinationObject startStop = SDLinkConfig.INSTANCE.messageDestinations.startStop; + case START -> { + MessageChannelConfig.DestinationObject startStop = SDLinkConfig.INSTANCE.messageDestinations.start; return Triple.of( ChannelManager.getDestinationChannel(startStop.channel), WebhookManager.getWebhookClient(startStop.channel), startStop ); } - case JOIN_LEAVE -> { - MessageChannelConfig.DestinationObject joinLeave = SDLinkConfig.INSTANCE.messageDestinations.joinLeave; + case STOP -> { + MessageChannelConfig.DestinationObject startStop = SDLinkConfig.INSTANCE.messageDestinations.stop; + return Triple.of( + ChannelManager.getDestinationChannel(startStop.channel), + WebhookManager.getWebhookClient(startStop.channel), + startStop + ); + } + case JOIN -> { + MessageChannelConfig.DestinationObject joinLeave = SDLinkConfig.INSTANCE.messageDestinations.join; + return Triple.of( + ChannelManager.getDestinationChannel(joinLeave.channel), + WebhookManager.getWebhookClient(joinLeave.channel), + joinLeave + ); + } + case LEAVE -> { + MessageChannelConfig.DestinationObject joinLeave = SDLinkConfig.INSTANCE.messageDestinations.leave; return Triple.of( ChannelManager.getDestinationChannel(joinLeave.channel), WebhookManager.getWebhookClient(joinLeave.channel),