9
0
mirror of https://github.com/HibiscusMC/HMCCosmetics.git synced 2025-12-30 04:19:28 +00:00

clean: change TranslationPair to a record

This commit is contained in:
LoJoSho
2023-08-01 13:06:27 -05:00
parent 8c2c6db81b
commit 14b27abe92
2 changed files with 3 additions and 18 deletions

View File

@@ -1,20 +1,5 @@
package com.hibiscusmc.hmccosmetics.util;
public class TranslationPair {
public record TranslationPair(String key, String value) {
private String key;
private String value;
public TranslationPair(String key, String value) {
this.key = key;
this.value = value;
}
public String getKey() {
return key;
}
public String getValue() {
return value;
}
}

View File

@@ -22,7 +22,7 @@ public class TranslationUtil {
pairs.add(pair);
MessagesUtil.sendDebugMessages("setupTranslation key:" + node.key().toString() + " | " + node);
MessagesUtil.sendDebugMessages("Overall Key " + node.key().toString());
MessagesUtil.sendDebugMessages("Key '" + pair.getKey() + "' Value '" + pair.getValue() + "'");
MessagesUtil.sendDebugMessages("Key '" + pair.key() + "' Value '" + pair.value() + "'");
}
keys.put(node.key().toString().toLowerCase(), pairs);
}
@@ -31,7 +31,7 @@ public class TranslationUtil {
public static String getTranslation(String key, String message) {
List<TranslationPair> pairs = keys.get(key);
for (TranslationPair pair : pairs) {
if (pair.getKey() == message) return StringUtils.parseStringToString(pair.getValue());
if (pair.key() == message) return StringUtils.parseStringToString(pair.value());
}
return message;