3
0
Mirror von https://github.com/GeyserMC/Geyser.git synchronisiert 2024-11-03 14:50:19 +01:00

Fix some nested language strings (#482)

Dieser Commit ist enthalten in:
rtm516 2020-05-05 03:32:57 +01:00 committet von GitHub
Ursprung 5b3e7c965f
Commit eeb4cafbc8
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 4AEE18F83AFDEB23

Datei anzeigen

@ -27,18 +27,15 @@ package org.geysermc.connector.utils;
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.*; import com.github.steveice10.mc.protocol.data.message.*;
import com.github.steveice10.opennbt.tag.builtin.StringTag; import com.google.gson.*;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.google.gson.JsonPrimitive;
import net.kyori.text.Component; import net.kyori.text.Component;
import net.kyori.text.serializer.gson.GsonComponentSerializer; import net.kyori.text.serializer.gson.GsonComponentSerializer;
import net.kyori.text.serializer.legacy.LegacyComponentSerializer; import net.kyori.text.serializer.legacy.LegacyComponentSerializer;
import org.geysermc.connector.network.session.GeyserSession; import org.geysermc.connector.network.session.GeyserSession;
import java.util.*; import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
@ -111,9 +108,20 @@ public class MessageUtils {
builder.append(getColorOrParent(msg.getStyle())); builder.append(getColorOrParent(msg.getStyle()));
if (!(msg.getText() == null)) { if (!(msg.getText() == null)) {
boolean isTranslationMessage = (msg instanceof TranslationMessage); boolean isTranslationMessage = (msg instanceof TranslationMessage);
builder.append(getTranslatedBedrockMessage(msg, locale, isTranslationMessage)); String extraText = "";
if (isTranslationMessage) {
List<String> paramsTranslated = getTranslationParams(((TranslationMessage) msg).getTranslationParams(), locale);
extraText = insertParams(getTranslatedBedrockMessage(msg, locale, isTranslationMessage), paramsTranslated);
} else {
extraText = getTranslatedBedrockMessage(msg, locale, isTranslationMessage);
}
builder.append(extraText);
builder.append("\u00a7r");
} }
} }
return builder.toString(); return builder.toString();
} }
@ -164,9 +172,11 @@ public class MessageUtils {
} }
for (String text : params) { for (String text : params) {
newMessage = newMessage.replaceFirst("%s", text); newMessage = newMessage.replaceFirst("%s", text.replaceAll("%s", "%r"));
} }
newMessage = newMessage.replaceAll("%r", "MISSING!");
return newMessage; return newMessage;
} }