forked from ChomeNS/chomens-bot-java
Add fallback on translate (ComponentUtilities)
This commit is contained in:
parent
0d73ddd791
commit
b1dc8dfc7c
1 changed files with 5 additions and 3 deletions
|
@ -81,13 +81,15 @@ public class ComponentUtilities {
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String getOrReturnKey (String key) {
|
private static String getOrReturnFallback (TranslatableComponent component) {
|
||||||
|
final String key = component.key();
|
||||||
|
|
||||||
final String minecraftKey = language.get(key);
|
final String minecraftKey = language.get(key);
|
||||||
final String voiceChatKey = voiceChatLanguage.get(key);
|
final String voiceChatKey = voiceChatLanguage.get(key);
|
||||||
|
|
||||||
if (minecraftKey != null) return minecraftKey;
|
if (minecraftKey != null) return minecraftKey;
|
||||||
else if (voiceChatKey != null) return voiceChatKey;
|
else if (voiceChatKey != null) return voiceChatKey;
|
||||||
else return key;
|
else return component.fallback() != null ? component.fallback() : key;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String stringify (Component message) { return stringify(message, null); }
|
public static String stringify (Component message) { return stringify(message, null); }
|
||||||
|
@ -264,7 +266,7 @@ public class ComponentUtilities {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static PartiallyStringified stringifyPartially (TranslatableComponent message, boolean motd, boolean ansi, String lastColor, boolean noHex) {
|
public static PartiallyStringified stringifyPartially (TranslatableComponent message, boolean motd, boolean ansi, String lastColor, boolean noHex) {
|
||||||
String format = getOrReturnKey(message.key());
|
String format = getOrReturnFallback(message);
|
||||||
|
|
||||||
// totallynotskidded™️ from HBot (and changed a bit)
|
// totallynotskidded™️ from HBot (and changed a bit)
|
||||||
Matcher matcher = ARG_PATTERN.matcher(format);
|
Matcher matcher = ARG_PATTERN.matcher(format);
|
||||||
|
|
Loading…
Reference in a new issue