mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-08-14 23:57:35 +00:00
Renamed translation method and cleaned up variable declaration
This commit is contained in:
parent
845c914492
commit
c809ddb618
6 changed files with 17 additions and 13 deletions
|
@ -102,7 +102,9 @@ public class GeyserBukkitConfiguration implements IGeyserConfiguration {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getDefaultLocale() { return config.getString("default-locale", "en_us"); }
|
||||
public String getDefaultLocale() {
|
||||
return config.getString("default-locale", "en_us");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Path getFloodgateKeyFile() {
|
||||
|
|
|
@ -103,7 +103,9 @@ public class GeyserBungeeConfiguration implements IGeyserConfiguration {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getDefaultLocale() { return config.getString("default-locale", "en_us"); }
|
||||
public String getDefaultLocale() {
|
||||
return config.getString("default-locale", "en_us");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Path getFloodgateKeyFile() {
|
||||
|
|
|
@ -106,7 +106,9 @@ public class GeyserSpongeConfiguration implements IGeyserConfiguration {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getDefaultLocale() { return node.getNode("default-locale").getString("en_us"); }
|
||||
public String getDefaultLocale() {
|
||||
return node.getNode("default-locale").getString("en_us");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Path getFloodgateKeyFile() {
|
||||
|
|
|
@ -62,7 +62,7 @@ public class JavaChatTranslator extends PacketTranslator<ServerChatPacket> {
|
|||
textPacket.setType(TextPacket.Type.TRANSLATION);
|
||||
textPacket.setNeedsTranslation(true);
|
||||
textPacket.setParameters(MessageUtils.getTranslationParams(((TranslationMessage) packet.getMessage()).getTranslationParams()));
|
||||
textPacket.setMessage(MessageUtils.getBedrockMessageWithTranslate(packet.getMessage(), session.getClientData().getLanguageCode()));
|
||||
textPacket.setMessage(MessageUtils.getTranslatedBedrockMessage(packet.getMessage(), session.getClientData().getLanguageCode()));
|
||||
} else {
|
||||
textPacket.setNeedsTranslation(false);
|
||||
textPacket.setMessage(MessageUtils.getBedrockMessage(packet.getMessage()));
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
|
||||
package org.geysermc.connector.utils;
|
||||
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.github.steveice10.mc.protocol.data.game.scoreboard.TeamColor;
|
||||
import com.github.steveice10.mc.protocol.data.message.ChatColor;
|
||||
import com.github.steveice10.mc.protocol.data.message.ChatFormat;
|
||||
|
@ -38,7 +37,6 @@ import com.google.gson.JsonParser;
|
|||
import com.google.gson.JsonPrimitive;
|
||||
import org.geysermc.connector.GeyserConnector;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.*;
|
||||
|
||||
public class MessageUtils {
|
||||
|
@ -77,7 +75,7 @@ public class MessageUtils {
|
|||
+ "%" + message.getTranslationKey();
|
||||
}
|
||||
|
||||
public static String getBedrockMessageWithTranslate(Message message, String locale) {
|
||||
public static String getTranslatedBedrockMessage(Message message, String locale) {
|
||||
JsonParser parser = new JsonParser();
|
||||
if (isMessage(message.getText())) {
|
||||
JsonObject object = parser.parse(message.getText()).getAsJsonObject();
|
||||
|
@ -100,12 +98,12 @@ public class MessageUtils {
|
|||
return builder.toString();
|
||||
}
|
||||
|
||||
public static String getBedrockMessageWithTranslate(Message message) {
|
||||
return getBedrockMessageWithTranslate(message, null);
|
||||
public static String getTranslatedBedrockMessage(Message message) {
|
||||
return getTranslatedBedrockMessage(message, null);
|
||||
}
|
||||
|
||||
private static String getLocaleString(String messageText, String locale) {
|
||||
HashMap<String, String> localeStrings = Toolbox.LOCALE_MAPPINGS.get(locale.toLowerCase());
|
||||
Map<String, String> localeStrings = Toolbox.LOCALE_MAPPINGS.get(locale.toLowerCase());
|
||||
if (localeStrings == null)
|
||||
localeStrings = Toolbox.LOCALE_MAPPINGS.get(GeyserConnector.getInstance().getConfig().getDefaultLocale());
|
||||
|
||||
|
@ -116,7 +114,7 @@ public class MessageUtils {
|
|||
}
|
||||
|
||||
public static String getBedrockMessage(Message message) {
|
||||
return getBedrockMessageWithTranslate(message);
|
||||
return getTranslatedBedrockMessage(message);
|
||||
}
|
||||
|
||||
private static String getColor(ChatColor color) {
|
||||
|
|
|
@ -52,7 +52,7 @@ public class Toolbox {
|
|||
|
||||
public static final Int2ObjectMap<ItemEntry> ITEM_ENTRIES = new Int2ObjectOpenHashMap<>();
|
||||
|
||||
public static final HashMap<String, HashMap<String, String>> LOCALE_MAPPINGS = new HashMap<>();
|
||||
public static final Map<String, Map<String, String>> LOCALE_MAPPINGS = new HashMap<>();
|
||||
|
||||
static {
|
||||
/* Load biomes */
|
||||
|
@ -127,7 +127,7 @@ public class Toolbox {
|
|||
}
|
||||
|
||||
Iterator<Map.Entry<String, JsonNode>> localeIterator = locale.fields();
|
||||
HashMap<String, String> langMap = new HashMap<>();
|
||||
Map<String, String> langMap = new HashMap<>();
|
||||
while (localeIterator.hasNext()) {
|
||||
Map.Entry<String, JsonNode> entry = localeIterator.next();
|
||||
langMap.put(entry.getKey(), entry.getValue().asText());
|
||||
|
|
Loading…
Reference in a new issue