Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
817593ee43 | ||
|
|
044980c1a8 | ||
|
|
245bd53850 | ||
|
|
b632e4772f | ||
|
|
b336b8a1fc |
No files matched your search
+1
-1
@@ -5,7 +5,7 @@ plugins {
|
||||
|
||||
allprojects {
|
||||
group = "com.viaversion"
|
||||
version = "4.4.0"
|
||||
version = "4.4.1"
|
||||
description = "Allow older clients to join newer server versions."
|
||||
}
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ public class ViaBackwardsConfig extends Config implements com.viaversion.viaback
|
||||
fix1_13FormattedInventoryTitles = getBoolean("fix-formatted-inventory-titles", true);
|
||||
alwaysShowOriginalMobName = getBoolean("always-show-original-mob-name", true);
|
||||
handlePingsAsInvAcknowledgements = getBoolean("handle-pings-as-inv-acknowledgements", false);
|
||||
chatTypeFormats = get("chat-types", Map.class, new HashMap<String, String>());
|
||||
chatTypeFormats = get("chat-types-1_19_1", Map.class, new HashMap<String, String>());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -58,7 +58,7 @@ import java.util.logging.Logger;
|
||||
|
||||
public interface ViaBackwardsPlatform {
|
||||
|
||||
String MINIMUM_VV_VERSION = "4.4.0";
|
||||
String MINIMUM_VV_VERSION = "4.4.1";
|
||||
String IMPL_VERSION = "$IMPL_VERSION";
|
||||
|
||||
/**
|
||||
@@ -80,7 +80,8 @@ public interface ViaBackwardsPlatform {
|
||||
getLogger().info("Loading translations...");
|
||||
TranslatableRewriter.loadTranslatables();
|
||||
|
||||
ProtocolManager protocolManager = Via.getManager().getProtocolManager();
|
||||
final ProtocolManager protocolManager = Via.getManager().getProtocolManager();
|
||||
protocolManager.setMaxPathDeltaIncrease(1); // Since we skip 1.19
|
||||
protocolManager.registerProtocol(new Protocol1_9_4To1_10(), ProtocolVersion.v1_9_3, ProtocolVersion.v1_10);
|
||||
|
||||
protocolManager.registerProtocol(new Protocol1_10To1_11(), ProtocolVersion.v1_10, ProtocolVersion.v1_11);
|
||||
|
||||
+50
-40
@@ -41,8 +41,9 @@ import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.data.entity.EntityTrackerBase;
|
||||
import com.viaversion.viaversion.libs.gson.JsonElement;
|
||||
import com.viaversion.viaversion.libs.kyori.adventure.text.Component;
|
||||
import com.viaversion.viaversion.libs.kyori.adventure.text.TextReplacementConfig;
|
||||
import com.viaversion.viaversion.libs.kyori.adventure.text.TranslatableComponent;
|
||||
import com.viaversion.viaversion.libs.kyori.adventure.text.format.NamedTextColor;
|
||||
import com.viaversion.viaversion.libs.kyori.adventure.text.format.Style;
|
||||
import com.viaversion.viaversion.libs.kyori.adventure.text.format.TextDecoration;
|
||||
import com.viaversion.viaversion.libs.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.ByteTag;
|
||||
@@ -60,8 +61,11 @@ import com.viaversion.viaversion.protocols.protocol1_19to1_18_2.Protocol1_19To1_
|
||||
import com.viaversion.viaversion.rewriter.CommandRewriter;
|
||||
import com.viaversion.viaversion.rewriter.StatisticsRewriter;
|
||||
import com.viaversion.viaversion.rewriter.TagRewriter;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public final class Protocol1_18_2To1_19_1 extends BackwardsProtocol<ClientboundPackets1_19_1, ClientboundPackets1_18, ServerboundPackets1_19_1, ServerboundPackets1_17> {
|
||||
@@ -223,7 +227,7 @@ public final class Protocol1_18_2To1_19_1 extends BackwardsProtocol<ClientboundP
|
||||
}
|
||||
|
||||
// Send the unsigned message if present, otherwise the signed message
|
||||
String plainMessage = wrapper.read(Type.STRING); // Plain message
|
||||
final String plainMessage = wrapper.read(Type.STRING); // Plain message
|
||||
JsonElement message = null;
|
||||
JsonElement decoratedMessage = wrapper.read(Type.OPTIONAL_COMPONENT);
|
||||
if (decoratedMessage != null) {
|
||||
@@ -373,11 +377,7 @@ public final class Protocol1_18_2To1_19_1 extends BackwardsProtocol<ClientboundP
|
||||
return blockItemPackets;
|
||||
}
|
||||
|
||||
private TextReplacementConfig replace(final JsonElement replacement) {
|
||||
return TextReplacementConfig.builder().matchLiteral("%s").replacement(GsonComponentSerializer.gson().deserializeFromTree(replacement)).once().build();
|
||||
}
|
||||
|
||||
private JsonElement decorateChatMessage(final PacketWrapper wrapper, final int chatTypeId, final JsonElement senderName, final JsonElement targetName, final JsonElement message) {
|
||||
private @Nullable JsonElement decorateChatMessage(final PacketWrapper wrapper, final int chatTypeId, final JsonElement senderName, @Nullable final JsonElement targetName, final JsonElement message) {
|
||||
translatableRewriter.processText(message);
|
||||
|
||||
CompoundTag chatType = wrapper.user().get(DimensionRegistryStorage.class).chatType(chatTypeId);
|
||||
@@ -391,46 +391,56 @@ public final class Protocol1_18_2To1_19_1 extends BackwardsProtocol<ClientboundP
|
||||
return null;
|
||||
}
|
||||
|
||||
String translationKey = (String) chatType.get("translation_key").getValue();
|
||||
String rawTranslation = translationKey.contains("%s") ? translationKey : ViaBackwards.getConfig().chatTypeFormat(translationKey);
|
||||
if (rawTranslation == null) {
|
||||
ViaBackwards.getPlatform().getLogger().warning("Missing chat type translation for key " + translationKey);
|
||||
return null;
|
||||
}
|
||||
final String translationKey = (String) chatType.get("translation_key").getValue();
|
||||
final TranslatableComponent.Builder componentBuilder = Component.translatable().key(translationKey);
|
||||
|
||||
Component component = Component.text(rawTranslation);
|
||||
|
||||
CompoundTag style = chatType.get("style");
|
||||
// Add the style
|
||||
final CompoundTag style = chatType.get("style");
|
||||
if (style != null) {
|
||||
StringTag color = style.get("color");
|
||||
if (color != null && NamedTextColor.NAMES.value(color.getValue()) != null) {
|
||||
component = component.color(NamedTextColor.NAMES.value(color.getValue()));
|
||||
}
|
||||
for (String key : TextDecoration.NAMES.keys()) {
|
||||
if (style.contains(key) && style.<ByteTag>get(key).asByte() == 1) {
|
||||
component = component.decorate(TextDecoration.NAMES.value(key));
|
||||
final Style.Builder styleBuilder = Style.style();
|
||||
final StringTag color = style.get("color");
|
||||
if (color != null) {
|
||||
final NamedTextColor textColor = NamedTextColor.NAMES.value(color.getValue());
|
||||
if (textColor != null) {
|
||||
styleBuilder.color(NamedTextColor.NAMES.value(color.getValue()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ListTag parameters = chatType.get("parameters");
|
||||
if (parameters != null) for (Tag element : parameters) {
|
||||
switch ((String) element.getValue()) {
|
||||
case "sender":
|
||||
component = component.replaceText(replace(senderName));
|
||||
break;
|
||||
case "content":
|
||||
component = component.replaceText(replace(message));
|
||||
break;
|
||||
case "target":
|
||||
Preconditions.checkNotNull(targetName, "Target name is null");
|
||||
component = component.replaceText(replace(targetName));
|
||||
break;
|
||||
default:
|
||||
ViaBackwards.getPlatform().getLogger().warning("Unknown parameter for chat decoration: " + element.getValue());
|
||||
for (final String key : TextDecoration.NAMES.keys()) {
|
||||
if (style.contains(key)) {
|
||||
styleBuilder.decoration(TextDecoration.NAMES.value(key), style.<ByteTag>get(key).asByte() == 1);
|
||||
}
|
||||
}
|
||||
componentBuilder.style(styleBuilder.build());
|
||||
}
|
||||
|
||||
return GsonComponentSerializer.gson().serializeToTree(component);
|
||||
// Add the replacements
|
||||
final ListTag parameters = chatType.get("parameters");
|
||||
if (parameters != null) {
|
||||
final List<Component> arguments = new ArrayList<>();
|
||||
for (final Tag element : parameters) {
|
||||
JsonElement argument = null;
|
||||
switch ((String) element.getValue()) {
|
||||
case "sender":
|
||||
argument = senderName;
|
||||
break;
|
||||
case "content":
|
||||
argument = message;
|
||||
break;
|
||||
case "target":
|
||||
Preconditions.checkNotNull(targetName, "Target name is null");
|
||||
argument = targetName;
|
||||
break;
|
||||
default:
|
||||
ViaBackwards.getPlatform().getLogger().warning("Unknown parameter for chat decoration: " + element.getValue());
|
||||
}
|
||||
if (argument != null) {
|
||||
arguments.add(GsonComponentSerializer.gson().deserializeFromTree(argument));
|
||||
}
|
||||
}
|
||||
componentBuilder.args(arguments);
|
||||
}
|
||||
|
||||
return GsonComponentSerializer.gson().serializeToTree(componentBuilder.build());
|
||||
}
|
||||
}
|
||||
@@ -21,10 +21,12 @@ fix-formatted-inventory-titles: true
|
||||
# This only takes effect for ids in the short range. Useful for anticheat compatibility.
|
||||
handle-pings-as-inv-acknowledgements: false
|
||||
#
|
||||
# Chat type formats used for sub 1.19 clients.
|
||||
chat-types:
|
||||
# 1.19.1 chat type formats.
|
||||
chat-types-1_19_1:
|
||||
"chat.type.text": "<%s> %s"
|
||||
"chat.type.announcement": "[%s] %s"
|
||||
"commands.message.display.incoming": "%s whispers to you: %s"
|
||||
"commands.message.display.outgoing": "You whisper to %s: %s"
|
||||
"chat.type.team.text": "%s <%s> %s"
|
||||
"chat.type.team.sent": "-> %s <%s> %s"
|
||||
"chat.type.emote": "* %s %s"
|
||||
@@ -442,7 +442,7 @@
|
||||
"entity.frog.lay_spawn": "",
|
||||
"entity.frog.long_jump": "",
|
||||
"entity.frog.step": "",
|
||||
"entity.frog.tounge": "",
|
||||
"entity.frog.tongue": "",
|
||||
"block.mangrove_roots.break": "",
|
||||
"block.mangrove_roots.fall": "",
|
||||
"block.mangrove_roots.hit": "",
|
||||
|
||||
@@ -3,7 +3,7 @@ metadata.format.version = "1.1"
|
||||
[versions]
|
||||
|
||||
# ViaVersion
|
||||
viaver = "4.4.0-1.19.1-rc3-SNAPSHOT"
|
||||
viaver = "4.4.1"
|
||||
|
||||
# Common provided
|
||||
netty = "4.0.20.Final"
|
||||
|
||||
Reference in new issue
Block a user