mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-08-14 23:57:35 +00:00
Fix some nested language strings (#482)
This commit is contained in:
parent
5b3e7c965f
commit
eeb4cafbc8
1 changed files with 19 additions and 9 deletions
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue