3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-12-28 00:50:13 +01:00
Dieser Commit ist enthalten in:
Nassim Jahnke 2022-07-28 18:48:33 +02:00
Ursprung 1c511a82b2
Commit 4f2a5bb7e2
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 6BE3B555EBC5982B
2 geänderte Dateien mit 27 neuen und 24 gelöschten Zeilen

Datei anzeigen

@ -47,6 +47,7 @@ import com.viaversion.viaversion.protocols.protocol1_19_1to1_19.storage.NonceSto
import com.viaversion.viaversion.protocols.protocol1_19to1_18_2.ClientboundPackets1_19; import com.viaversion.viaversion.protocols.protocol1_19to1_18_2.ClientboundPackets1_19;
import com.viaversion.viaversion.protocols.protocol1_19to1_18_2.ServerboundPackets1_19; import com.viaversion.viaversion.protocols.protocol1_19to1_18_2.ServerboundPackets1_19;
import com.viaversion.viaversion.util.CipherUtil; import com.viaversion.viaversion.util.CipherUtil;
import org.checkerframework.checker.nullness.qual.Nullable;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
@ -255,7 +256,7 @@ public final class Protocol1_19_1To1_19 extends AbstractProtocol<ClientboundPack
connection.put(new ChatTypeStorage()); connection.put(new ChatTypeStorage());
} }
private boolean decorateChatMessage(final PacketWrapper wrapper, final int chatTypeId, final JsonElement senderName, final JsonElement teamName, final JsonElement message) { private boolean decorateChatMessage(final PacketWrapper wrapper, final int chatTypeId, final JsonElement senderName, @Nullable final JsonElement teamName, final JsonElement message) {
final CompoundTag chatType = wrapper.user().get(ChatTypeStorage.class).chatType(chatTypeId); final CompoundTag chatType = wrapper.user().get(ChatTypeStorage.class).chatType(chatTypeId);
if (chatType == null) { if (chatType == null) {
Via.getPlatform().getLogger().warning("Chat message has unknown chat type id " + chatTypeId + ". Message: " + message); Via.getPlatform().getLogger().warning("Chat message has unknown chat type id " + chatTypeId + ". Message: " + message);
@ -285,9 +286,9 @@ public final class Protocol1_19_1To1_19 extends AbstractProtocol<ClientboundPack
final TranslatableComponent.Builder componentBuilder = Component.translatable().key(translationKey); final TranslatableComponent.Builder componentBuilder = Component.translatable().key(translationKey);
// Add the style // Add the style
final Style.Builder styleBuilder = Style.style();
final CompoundTag style = decoaration.get("style"); final CompoundTag style = decoaration.get("style");
if (style != null) { if (style != null) {
final Style.Builder styleBuilder = Style.style();
final StringTag color = style.get("color"); final StringTag color = style.get("color");
if (color != null) { if (color != null) {
final NamedTextColor textColor = NamedTextColor.NAMES.value(color.getValue()); final NamedTextColor textColor = NamedTextColor.NAMES.value(color.getValue());
@ -301,33 +302,35 @@ public final class Protocol1_19_1To1_19 extends AbstractProtocol<ClientboundPack
styleBuilder.decoration(TextDecoration.NAMES.value(key), style.<ByteTag>get(key).asByte() == 1); styleBuilder.decoration(TextDecoration.NAMES.value(key), style.<ByteTag>get(key).asByte() == 1);
} }
} }
componentBuilder.style(styleBuilder.build());
} }
componentBuilder.style(styleBuilder.build());
// Add the replacements // Add the replacements
final List<Component> arguments = new ArrayList<>();
final ListTag parameters = decoaration.get("parameters"); final ListTag parameters = decoaration.get("parameters");
if (parameters != null) for (final Tag element : parameters) { if (parameters != null) {
JsonElement argument = null; final List<Component> arguments = new ArrayList<>();
switch ((String) element.getValue()) { for (final Tag element : parameters) {
case "sender": JsonElement argument = null;
argument = senderName; switch ((String) element.getValue()) {
break; case "sender":
case "content": argument = senderName;
argument = message; break;
break; case "content":
case "team_name": argument = message;
Preconditions.checkNotNull(teamName, "Team name is null"); break;
argument = teamName; case "team_name":
break; Preconditions.checkNotNull(teamName, "Team name is null");
default: argument = teamName;
Via.getPlatform().getLogger().warning("Unknown parameter for chat decoration: " + element.getValue()); break;
} default:
if (argument != null) { Via.getPlatform().getLogger().warning("Unknown parameter for chat decoration: " + element.getValue());
arguments.add(GsonComponentSerializer.gson().deserializeFromTree(argument)); }
if (argument != null) {
arguments.add(GsonComponentSerializer.gson().deserializeFromTree(argument));
}
} }
componentBuilder.args(arguments);
} }
componentBuilder.args(arguments);
wrapper.write(Type.COMPONENT, GsonComponentSerializer.gson().serializeToTree(componentBuilder.build())); wrapper.write(Type.COMPONENT, GsonComponentSerializer.gson().serializeToTree(componentBuilder.build()));
wrapper.write(Type.BOOLEAN, overlay); wrapper.write(Type.BOOLEAN, overlay);

Datei anzeigen

@ -1,5 +1,5 @@
# Project properties - we put these here so they can be modified without causing a recompile of the build scripts # Project properties - we put these here so they can be modified without causing a recompile of the build scripts
projectVersion=4.4.1-SNAPSHOT projectVersion=4.4.1
# Gradle properties # Gradle properties
org.gradle.daemon=true org.gradle.daemon=true