Mirror von
https://github.com/GeyserMC/Geyser.git
synchronisiert 2024-11-03 14:50:19 +01:00
Moved to json file lang mapping
Dieser Commit ist enthalten in:
Ursprung
7298e2ff3f
Commit
c1e00e3614
@ -25,6 +25,7 @@
|
|||||||
|
|
||||||
package org.geysermc.connector.utils;
|
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.game.scoreboard.TeamColor;
|
||||||
import com.github.steveice10.mc.protocol.data.message.ChatColor;
|
import com.github.steveice10.mc.protocol.data.message.ChatColor;
|
||||||
import com.github.steveice10.mc.protocol.data.message.ChatFormat;
|
import com.github.steveice10.mc.protocol.data.message.ChatFormat;
|
||||||
@ -36,11 +37,28 @@ import com.google.gson.JsonObject;
|
|||||||
import com.google.gson.JsonParser;
|
import com.google.gson.JsonParser;
|
||||||
import com.google.gson.JsonPrimitive;
|
import com.google.gson.JsonPrimitive;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.io.InputStream;
|
||||||
import java.util.Collections;
|
import java.util.*;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class MessageUtils {
|
public class MessageUtils {
|
||||||
|
private static final HashMap<String, String> LANG_MAPPINGS = new HashMap<>();
|
||||||
|
|
||||||
|
static {
|
||||||
|
/* Load the language mappings */
|
||||||
|
InputStream stream = Toolbox.getResource("mappings/lang.json");
|
||||||
|
JsonNode lang;
|
||||||
|
try {
|
||||||
|
lang = Toolbox.JSON_MAPPER.readTree(stream);
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new AssertionError("Unable to load Java lang mappings", e);
|
||||||
|
}
|
||||||
|
|
||||||
|
Iterator<Map.Entry<String, JsonNode>> langIterator = lang.fields();
|
||||||
|
while (langIterator.hasNext()) {
|
||||||
|
Map.Entry<String, JsonNode> entry = langIterator.next();
|
||||||
|
LANG_MAPPINGS.put(entry.getKey(), entry.getValue().asText());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static List<String> getTranslationParams(Message[] messages) {
|
public static List<String> getTranslationParams(Message[] messages) {
|
||||||
List<String> strings = new ArrayList<>();
|
List<String> strings = new ArrayList<>();
|
||||||
@ -100,33 +118,7 @@ public class MessageUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static String getLangConversion(String messageText) {
|
private static String getLangConversion(String messageText) {
|
||||||
switch (messageText) {
|
return LANG_MAPPINGS.getOrDefault(messageText, messageText);
|
||||||
case "block.minecraft.bed.occupied":
|
|
||||||
return "tile.bed.occupied";
|
|
||||||
case "block.minecraft.bed.too_far_away":
|
|
||||||
return "tile.bed.tooFar";
|
|
||||||
case "block.minecraft.bed.not_safe":
|
|
||||||
return "tile.bed.notSafe";
|
|
||||||
case "block.minecraft.bed.no_sleep":
|
|
||||||
return "tile.bed.noSleep";
|
|
||||||
case "block.minecraft.bed.not_valid":
|
|
||||||
return "tile.bed.notValid";
|
|
||||||
case "block.minecraft.bed.set_spawn":
|
|
||||||
return "tile.bed.respawnSet";
|
|
||||||
|
|
||||||
case "chat.type.advancement.task":
|
|
||||||
case "chat.type.advancement.challenge":
|
|
||||||
case "chat.type.advancement.goal":
|
|
||||||
return "chat.type.achievement";
|
|
||||||
|
|
||||||
case "commands.teleport.success.entity.single":
|
|
||||||
return "commands.tp.success";
|
|
||||||
case "commands.teleport.success.location.single":
|
|
||||||
return "commands.tp.success.coordinates";
|
|
||||||
|
|
||||||
default:
|
|
||||||
return messageText;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getBedrockMessage(Message message) {
|
public static String getBedrockMessage(Message message) {
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren