3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-12-27 00:22:51 +01:00

Add enforce-secure-chat setting to determine what is sent to the client by default

Dieser Commit ist enthalten in:
Nassim Jahnke 2024-04-25 20:21:36 +02:00
Ursprung b13fbbe175
Commit fdf735420f
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: EF6771C01F6EF02F
7 geänderte Dateien mit 26 neuen und 11 gelöschten Zeilen

Datei anzeigen

@ -55,10 +55,10 @@ public class ProtocolVersion {
public static final ProtocolVersion v1_9 = register(107, "1.9");
public static final ProtocolVersion v1_9_1 = register(108, "1.9.1");
public static final ProtocolVersion v1_9_2 = register(109, "1.9.2");
public static final ProtocolVersion v1_9_3 = register(110, "1.9.3/4", new SubVersionRange("1.9", 3, 4));
public static final ProtocolVersion v1_9_3 = register(110, "1.9.3/1.9.4", new SubVersionRange("1.9", 3, 4));
public static final ProtocolVersion v1_10 = register(210, "1.10.x");
public static final ProtocolVersion v1_11 = register(315, "1.11");
public static final ProtocolVersion v1_11_1 = register(316, "1.11.1/2", new SubVersionRange("1.11", 1, 2));
public static final ProtocolVersion v1_11_1 = register(316, "1.11.1/1.11.2", new SubVersionRange("1.11", 1, 2));
public static final ProtocolVersion v1_12 = register(335, "1.12");
public static final ProtocolVersion v1_12_1 = register(338, "1.12.1");
public static final ProtocolVersion v1_12_2 = register(340, "1.12.2");
@ -77,13 +77,13 @@ public class ProtocolVersion {
public static final ProtocolVersion v1_16_1 = register(736, "1.16.1");
public static final ProtocolVersion v1_16_2 = register(751, "1.16.2");
public static final ProtocolVersion v1_16_3 = register(753, "1.16.3");
public static final ProtocolVersion v1_16_4 = register(754, "1.16.4/5", new SubVersionRange("1.16", 4, 5));
public static final ProtocolVersion v1_16_4 = register(754, "1.16.4/1.16.5", new SubVersionRange("1.16", 4, 5));
public static final ProtocolVersion v1_17 = register(755, "1.17");
public static final ProtocolVersion v1_17_1 = register(756, "1.17.1");
public static final ProtocolVersion v1_18 = register(757, "1.18/1.18.1", new SubVersionRange("1.18", 0, 1));
public static final ProtocolVersion v1_18_2 = register(758, "1.18.2");
public static final ProtocolVersion v1_19 = register(759, "1.19");
public static final ProtocolVersion v1_19_1 = register(760, "1.19.1/2", new SubVersionRange("1.19", 1, 2));
public static final ProtocolVersion v1_19_1 = register(760, "1.19.1/1.19.2", new SubVersionRange("1.19", 1, 2));
public static final ProtocolVersion v1_19_3 = register(761, "1.19.3");
public static final ProtocolVersion v1_19_4 = register(762, "1.19.4");
public static final ProtocolVersion v1_20 = register(763, "1.20/1.20.1", new SubVersionRange("1.20", 0, 1));

Datei anzeigen

@ -450,4 +450,11 @@ public interface ViaVersionConfig extends Config {
* @return true if enabled
*/
boolean translateOcelotToCat();
/**
* Returns the value of the "enforce secure chat" setting sent to 1.19+ clients on join.
*
* @return the value sent to 1.19+ clients on join
*/
boolean enforceSecureChat();
}

Datei anzeigen

@ -22,14 +22,12 @@ import com.viaversion.viaversion.api.configuration.ViaVersionConfig;
import com.viaversion.viaversion.api.minecraft.WorldIdentifiers;
import com.viaversion.viaversion.api.protocol.version.BlockedProtocolVersions;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import com.viaversion.viaversion.api.protocol.version.VersionType;
import com.viaversion.viaversion.protocol.BlockedProtocolVersionsImpl;
import com.viaversion.viaversion.util.Config;
import java.io.File;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.function.Predicate;
import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet;
import it.unimi.dsi.fastutil.objects.ObjectSet;
import org.checkerframework.checker.nullness.qual.Nullable;
@ -89,6 +87,7 @@ public abstract class AbstractViaConfig extends Config implements ViaVersionConf
private WorldIdentifiers map1_16WorldNames;
private boolean cache1_17Light;
private boolean translateOcelotToCat;
private boolean enforceSecureChat;
protected AbstractViaConfig(final File configFile) {
super(configFile);
@ -157,6 +156,7 @@ public abstract class AbstractViaConfig extends Config implements ViaVersionConf
worlds.getOrDefault("end", WorldIdentifiers.END_DEFAULT));
cache1_17Light = getBoolean("cache-1_17-light", true);
translateOcelotToCat = getBoolean("translate-ocelot-to-cat", true);
enforceSecureChat = getBoolean("enforce-secure-chat", false);
}
private BlockedProtocolVersions loadBlockedProtocolVersions() {
@ -528,4 +528,9 @@ public abstract class AbstractViaConfig extends Config implements ViaVersionConf
public boolean translateOcelotToCat() {
return translateOcelotToCat;
}
@Override
public boolean enforceSecureChat() {
return enforceSecureChat;
}
}

Datei anzeigen

@ -208,7 +208,7 @@ public final class Protocol1_19_1To1_19 extends AbstractProtocol<ClientboundPack
map(Type.OPTIONAL_COMPONENT); // Motd
map(Type.OPTIONAL_STRING); // Encoded icon
map(Type.BOOLEAN); // Previews chat
create(Type.BOOLEAN, false); // Enforces secure chat
create(Type.BOOLEAN, Via.getConfig().enforceSecureChat()); // Enforces secure chat
}
});

Datei anzeigen

@ -664,10 +664,10 @@ public class ComponentRewriter1_20_5 extends ComponentRewriter<ClientboundPacket
patternTag.put("asset_id", convertIdentifier(armorTrimPattern.assetName()));
patternTag.putString("template_item", templateItem);
patternTag.put("description", armorTrimPattern.description());
tag.put("pattern", patternTag);
if (armorTrimPattern.decal()) {
patternTag.putBoolean("decal", true);
}
tag.put("pattern", patternTag);
}
if (!value.showInTooltip()) {

Datei anzeigen

@ -21,6 +21,7 @@ import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import com.github.steveice10.opennbt.tag.builtin.ListTag;
import com.github.steveice10.opennbt.tag.builtin.StringTag;
import com.github.steveice10.opennbt.tag.builtin.Tag;
import com.viaversion.viaversion.api.Via;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.data.entity.DimensionData;
import com.viaversion.viaversion.api.minecraft.Particle;
@ -215,9 +216,7 @@ public final class EntityPacketRewriter1_20_5 extends EntityRewriter<Clientbound
// Just put in what we know if this is sent multiple times
wrapper.write(Type.BOOLEAN, storage.isSecureChatEnforced());
} else {
// Assume that it isn't, otherwise the client will disregard chat messages from players
// without chat sessions if it assumes secure chat is enforced
wrapper.write(Type.BOOLEAN, false);
wrapper.write(Type.BOOLEAN, Via.getConfig().enforceSecureChat());
}
storage.clear();

Datei anzeigen

@ -178,6 +178,10 @@ map-1_16-world-names:
# If disabled, tamed cats will be displayed as ocelots to 1.14+ clients on 1.13 servers. Otherwise, ocelots (tamed and untamed) will be displayed as cats.
translate-ocelot-to-cat: false
#
# Determines the value sent to 1.19+ clients on join if currently not accessible by ViaVersion.
# It is not recommended to fake this value if your server is running 1.19 or later, as 1.20.5 have stricter chat handling and may get kicked otherwise.
enforce-secure-chat: false
#
#----------------------------------------------------------#
# 1.9+ CLIENTS ON 1.8 SERVERS OPTIONS #
#----------------------------------------------------------#