refactor: use switch-case in stringPartially in ComponentUtilities (now the bot requires java >= 21)

This commit is contained in:
ChomeNS
2024-12-17 18:44:53 +07:00
parent 36fa5b3f9b
commit c1efc1c3d5
3 changed files with 9 additions and 8 deletions

View File

@@ -1 +1 @@
1267
1270

View File

@@ -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()

View File

@@ -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) {