Skip to content

Commit 96b78a5

Browse files
Allow using Text for splash text (#16)
1 parent 9e165e1 commit 96b78a5

3 files changed

Lines changed: 11 additions & 4 deletions

File tree

src/main/java/com/mosadie/servermainmenu/api/MenuTheme.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@
88
public interface MenuTheme {
99
String getId();
1010
Identifier getPanorama();
11-
String getSplashText();
11+
@Deprecated
12+
default String getSplashText() {
13+
return null;
14+
}
15+
Text getSplashAsText();
1216

1317
boolean rollOdds();
1418

src/main/java/com/mosadie/servermainmenu/api/NormalTheme.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ public Identifier getPanorama() {
2020
}
2121

2222
@Override
23-
public String getSplashText() {
24-
return "Just a normal menu...";
23+
public Text getSplashAsText() {
24+
return Text.literal("Just a normal menu...");
2525
}
2626

2727
@Override

src/main/java/com/mosadie/servermainmenu/client/ServerMainMenuLibClient.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,15 @@ public static MenuTheme getTheme() {
7878

7979
private static ServerMainMenuLibConfig config;
8080

81+
@SuppressWarnings("deprecation")
8182
public static Text getSplashText() {
8283
if (config != null && config.splashOptions.overrideSplash) {
8384
return Text.of(config.splashOptions.overrideSplashText);
8485
}
8586

86-
return Text.of(getTheme().getSplashText());
87+
// Should still work with old mods that don't implement the asText method I hope...
88+
if (getTheme().getSplashText() != null) return Text.of(getTheme().getSplashText());
89+
return getTheme().getSplashAsText();
8790
}
8891

8992
public static Text getButtonText() {

0 commit comments

Comments
 (0)