2022-03-06 15:57:48 +01:00
|
|
|
From 608e7343216c313476d8c0d09a8b94c9f85a8519 Mon Sep 17 00:00:00 2001
|
2021-10-08 02:52:39 +02:00
|
|
|
From: LinsaFTW <25271111+linsaftw@users.noreply.github.com>
|
|
|
|
Date: Thu, 7 Oct 2021 21:37:24 -0300
|
|
|
|
Subject: [PATCH] Custom motd system
|
|
|
|
|
|
|
|
|
|
|
|
diff --git a/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/FlameCordConfiguration.java b/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/FlameCordConfiguration.java
|
2022-03-06 15:57:48 +01:00
|
|
|
index 701db67c..48deace6 100644
|
2021-10-08 02:52:39 +02:00
|
|
|
--- a/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/FlameCordConfiguration.java
|
|
|
|
+++ b/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/FlameCordConfiguration.java
|
|
|
|
@@ -6,12 +6,33 @@ import java.util.ArrayList;
|
|
|
|
import java.util.Arrays;
|
|
|
|
import java.util.Collection;
|
|
|
|
import java.util.HashSet;
|
|
|
|
+import java.util.List;
|
|
|
|
+import java.util.Random;
|
|
|
|
|
|
|
|
import lombok.Getter;
|
|
|
|
+import net.md_5.bungee.api.ChatColor;
|
|
|
|
import net.md_5.bungee.config.Configuration;
|
|
|
|
import net.md_5.bungee.config.ConfigurationProvider;
|
|
|
|
|
2022-03-06 15:57:48 +01:00
|
|
|
public class FlameCordConfiguration extends FlameConfig {
|
2021-10-08 02:52:39 +02:00
|
|
|
+ private List<String> colors(final List<String> strings) {
|
|
|
|
+ for (int i = 0; i < strings.size(); i++) {
|
|
|
|
+ strings.set(i, ChatColor.translateAlternateColorCodes('&', strings.get(i)));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return strings;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Getter
|
|
|
|
+ private boolean customMotdEnabled = false;
|
|
|
|
+ private List<String> customMotdMotds = Arrays.asList(new String[] { "&eDefault &cFlameCord&e custom motd!\n&eChange me in &cflamecord.yml&e file!" });
|
|
|
|
+
|
|
|
|
+ public String getRandomMotd() {
|
|
|
|
+ final Random random = new Random();
|
|
|
|
+
|
|
|
|
+ return customMotdMotds.get(random.nextInt(customMotdMotds.size()));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
@Getter
|
|
|
|
private boolean loggerInitialhandler = false;
|
|
|
|
@Getter
|
2022-03-06 15:57:48 +01:00
|
|
|
@@ -34,6 +55,9 @@ public class FlameCordConfiguration extends FlameConfig {
|
2021-10-08 02:52:39 +02:00
|
|
|
configuration = configurationProvider.load(configurationFile);
|
|
|
|
}
|
|
|
|
|
|
|
|
+ this.customMotdEnabled = setIfUnexistant("custom-motd.enabled", this.customMotdEnabled, configuration);
|
|
|
|
+ this.customMotdMotds = colors(new ArrayList<>(setIfUnexistant("custom-motd.motds", this.customMotdMotds, configuration)));
|
|
|
|
+
|
|
|
|
this.loggerInitialhandler = setIfUnexistant("logger.initialhandler", this.loggerInitialhandler, configuration);
|
|
|
|
this.loggerExceptions = setIfUnexistant("logger.exceptions", this.loggerExceptions, configuration);
|
|
|
|
this.loggerDump = setIfUnexistant("logger.dump", this.loggerDump, configuration);
|
|
|
|
diff --git a/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java b/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java
|
2022-03-04 17:38:12 +01:00
|
|
|
index cfd6249e..0c608e0f 100644
|
2021-10-08 02:52:39 +02:00
|
|
|
--- a/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java
|
|
|
|
+++ b/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java
|
2022-02-14 23:57:35 +01:00
|
|
|
@@ -250,7 +250,9 @@ public class InitialHandler extends PacketHandler implements PendingConnection
|
2021-10-08 02:52:39 +02:00
|
|
|
Preconditions.checkState( thisState == State.STATUS, "Not expecting STATUS" );
|
|
|
|
|
|
|
|
ServerInfo forced = AbstractReconnectHandler.getForcedHost( this );
|
|
|
|
- final String motd = ( forced != null ) ? forced.getMotd() : listener.getMotd();
|
|
|
|
+ // FlameCord - Custom motd
|
|
|
|
+ final String listenerMotd = FlameCord.getInstance().getFlameCordConfiguration().isCustomMotdEnabled() ? FlameCord.getInstance().getFlameCordConfiguration().getRandomMotd() : listener.getMotd();
|
|
|
|
+ final String motd = ( forced != null ) ? forced.getMotd() : listenerMotd;
|
|
|
|
final int protocol = ( ProtocolConstants.SUPPORTED_VERSION_IDS.contains( handshake.getProtocolVersion() ) ) ? handshake.getProtocolVersion() : bungee.getProtocolVersion();
|
|
|
|
|
|
|
|
Callback<ServerPing> pingBack = new Callback<ServerPing>()
|
|
|
|
--
|
2021-12-30 03:02:28 +01:00
|
|
|
2.32.0
|
2021-10-08 02:52:39 +02:00
|
|
|
|