refactor: use switch-case in stringPartially in ComponentUtilities (now the bot requires java >= 21)
This commit is contained in:
@@ -1 +1 @@
|
||||
1267
|
||||
1270
|
||||
@@ -9,7 +9,7 @@ plugins {
|
||||
group = 'me.chayapak1'
|
||||
version = 'rolling'
|
||||
description = 'ChomeNS Bot'
|
||||
java.sourceCompatibility = JavaVersion.VERSION_17
|
||||
java.sourceCompatibility = JavaVersion.VERSION_21
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
|
||||
@@ -149,12 +149,13 @@ public class ComponentUtilities {
|
||||
}
|
||||
|
||||
public static PartiallyStringified stringifyPartially (Component message, boolean motd, boolean ansi, String lastColor, boolean noHex, int depth) {
|
||||
if (message instanceof TextComponent) return stringifyPartially((TextComponent) message, motd, ansi, lastColor, noHex);
|
||||
else if (message instanceof TranslatableComponent) return stringifyPartially((TranslatableComponent) message, motd, ansi, lastColor, noHex, depth);
|
||||
else if (message instanceof SelectorComponent) return stringifyPartially((SelectorComponent) message, motd, ansi, lastColor, noHex);
|
||||
else if (message instanceof KeybindComponent) return stringifyPartially((KeybindComponent) message, motd, ansi, lastColor, noHex);
|
||||
|
||||
return new PartiallyStringified("", null);
|
||||
return switch (message) {
|
||||
case TextComponent t_component -> stringifyPartially(t_component, motd, ansi, lastColor, noHex);
|
||||
case TranslatableComponent t_component -> stringifyPartially(t_component, motd, ansi, lastColor, noHex, depth);
|
||||
case SelectorComponent t_component -> stringifyPartially(t_component, motd, ansi, lastColor, noHex);
|
||||
case KeybindComponent t_component -> stringifyPartially(t_component, motd, ansi, lastColor, noHex);
|
||||
default -> new PartiallyStringified("", null);
|
||||
};
|
||||
}
|
||||
|
||||
public static String getStyle (Style textStyle, boolean motd) {
|
||||
|
||||
Reference in New Issue
Block a user