Skip to content

Commit b0970e5

Browse files
committed
Added MiniMessage support to the motd
1 parent 60853e7 commit b0970e5

File tree

3 files changed

+24
-0
lines changed

3 files changed

+24
-0
lines changed

deepslateMC-server/minecraft-patches/sources/net/minecraft/server/MinecraftServer.java.patch

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,23 @@
3535
}
3636

3737
public SystemReport fillSystemReport(SystemReport systemReport) {
38+
@@ -2038,7 +_,18 @@
39+
40+
public void setMotd(String motd) {
41+
// Paper start - Adventure
42+
- this.motd = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserializeOr(motd, net.kyori.adventure.text.Component.empty());
43+
+ // Deepslate start - MiniMessage MOTD
44+
+ if(de.pascalpex.deepslatemc.files.Config.getMinimessageMotd()) {
45+
+ try {
46+
+ this.motd = net.kyori.adventure.text.minimessage.MiniMessage.miniMessage().deserializeOr(motd, net.kyori.adventure.text.Component.empty());
47+
+ } catch (net.kyori.adventure.text.minimessage.internal.parser.ParsingExceptionImpl e) {
48+
+ org.bukkit.Bukkit.getLogger().warning("You have enabled DeepslateMC's miniMessageMotdSupport but your motd contains legacy color codes. Will fallback to legacy colors.");
49+
+ this.motd = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserializeOr(motd, net.kyori.adventure.text.Component.empty());
50+
+ }
51+
+ } else {
52+
+ this.motd = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserializeOr(motd, net.kyori.adventure.text.Component.empty());
53+
+ }
54+
+ // Deepslate end - MiniMessage MOTD
55+
}
56+
57+
public net.kyori.adventure.text.Component motd() {

deepslateMC-server/src/main/java/de/pascalpex/deepslatemc/files/Config.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,5 +148,8 @@ public static boolean getActionbarEnabled() {
148148
public static String getActionbarText() {
149149
return config.getString(ACTIONBAR_TEXT.key);
150150
}
151+
public static boolean getMinimessageMotd() {
152+
return config.getBoolean(MINIMESSAGE_MOTD.key);
153+
}
151154

152155
}

deepslateMC-server/src/main/java/de/pascalpex/deepslatemc/files/ConfigEntry.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ enum ConfigEntry {
3131
BOSSBAR_STYLE("bossbar" + ".style", BossBar.Overlay.PROGRESS.name()),
3232
BOSSBAR_TEXT("bossbar" + ".text", "&6Custom Bossbar"),
3333
ACTIONBAR_ENABLED("actionbar" + ".enabled", false),
34+
MINIMESSAGE_MOTD("miniMessageMotdSupport", false),
3435
ACTIONBAR_TEXT("actionbar" + ".text", "&6Custom Actionbar");
3536

3637
final String key;

0 commit comments

Comments
 (0)