mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-08-14 23:57:35 +00:00
Fixed NONE colour formatting and cleaned up imports
This commit is contained in:
parent
1e1d2f00ae
commit
9f1da99b71
3 changed files with 15 additions and 17 deletions
|
@ -28,16 +28,12 @@ package org.geysermc.connector.utils;
|
|||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import lombok.Getter;
|
||||
import org.geysermc.connector.GeyserConnector;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.URL;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.nio.file.StandardCopyOption;
|
||||
import java.time.OffsetDateTime;
|
||||
import java.util.*;
|
||||
import java.util.zip.ZipFile;
|
||||
|
||||
|
|
|
@ -26,16 +26,12 @@
|
|||
package org.geysermc.connector.utils;
|
||||
|
||||
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;
|
||||
import com.github.steveice10.mc.protocol.data.message.Message;
|
||||
import com.github.steveice10.mc.protocol.data.message.TranslationMessage;
|
||||
import com.github.steveice10.mc.protocol.data.message.*;
|
||||
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 org.geysermc.connector.GeyserConnector;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.regex.Matcher;
|
||||
|
@ -70,7 +66,7 @@ public class MessageUtils {
|
|||
}
|
||||
} else {
|
||||
String builder = getFormat(message.getStyle().getFormats()) +
|
||||
getColor(message.getStyle().getColor());
|
||||
getColorOrParent(message.getStyle());
|
||||
builder += getTranslatedBedrockMessage(message, locale, false);
|
||||
strings.add(builder);
|
||||
}
|
||||
|
@ -84,7 +80,7 @@ public class MessageUtils {
|
|||
}
|
||||
|
||||
public static String getTranslationText(TranslationMessage message) {
|
||||
return getFormat(message.getStyle().getFormats()) + getColor(message.getStyle().getColor())
|
||||
return getFormat(message.getStyle().getFormats()) + getColorOrParent(message.getStyle())
|
||||
+ "%" + message.getTranslationKey();
|
||||
}
|
||||
|
||||
|
@ -103,7 +99,7 @@ public class MessageUtils {
|
|||
StringBuilder builder = new StringBuilder(messageText);
|
||||
for (Message msg : message.getExtra()) {
|
||||
builder.append(getFormat(msg.getStyle().getFormats()));
|
||||
builder.append(getColor(msg.getStyle().getColor()));
|
||||
builder.append(getColorOrParent(msg.getStyle()));
|
||||
if (!(msg.getText() == null)) {
|
||||
boolean isTranslationMessage = (msg instanceof TranslationMessage);
|
||||
builder.append(getTranslatedBedrockMessage(msg, locale, isTranslationMessage));
|
||||
|
@ -136,6 +132,16 @@ public class MessageUtils {
|
|||
return newMessage;
|
||||
}
|
||||
|
||||
private static String getColorOrParent(MessageStyle style) {
|
||||
ChatColor chatColor = style.getColor();
|
||||
|
||||
if (chatColor == ChatColor.NONE) {
|
||||
return getColor(style.getParent().getColor());
|
||||
}
|
||||
|
||||
return getColor(chatColor);
|
||||
}
|
||||
|
||||
private static String getColor(ChatColor color) {
|
||||
String base = "\u00a7";
|
||||
switch (color) {
|
||||
|
@ -188,6 +194,7 @@ public class MessageUtils {
|
|||
base += "f";
|
||||
break;
|
||||
case RESET:
|
||||
case NONE:
|
||||
base += "r";
|
||||
break;
|
||||
default:
|
||||
|
|
|
@ -25,16 +25,11 @@
|
|||
|
||||
package org.geysermc.connector.utils;
|
||||
|
||||
import org.geysermc.connector.GeyserConnector;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.nio.file.StandardCopyOption;
|
||||
|
|
Loading…
Reference in a new issue