Fix some nested language strings (#482)

This commit is contained in:
rtm516 2020-05-05 03:32:57 +01:00 committed by GitHub
parent 5b3e7c965f
commit eeb4cafbc8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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.message.*;
import com.github.steveice10.opennbt.tag.builtin.StringTag;
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 com.google.gson.*;
import net.kyori.text.Component;
import net.kyori.text.serializer.gson.GsonComponentSerializer;
import net.kyori.text.serializer.legacy.LegacyComponentSerializer;
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.Pattern;
@ -111,9 +108,20 @@ public class MessageUtils {
builder.append(getColorOrParent(msg.getStyle()));
if (!(msg.getText() == null)) {
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();
}
@ -164,9 +172,11 @@ public class MessageUtils {
}
for (String text : params) {
newMessage = newMessage.replaceFirst("%s", text);
newMessage = newMessage.replaceFirst("%s", text.replaceAll("%s", "%r"));
}
newMessage = newMessage.replaceAll("%r", "MISSING!");
return newMessage;
}