3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-11-03 14:50:30 +01:00

Merge remote-tracking branch 'origin/master' into dev

Dieser Commit ist enthalten in:
Nassim Jahnke 2022-06-30 10:42:27 +02:00
Commit 6baae5e4f7
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 6BE3B555EBC5982B
5 geänderte Dateien mit 43 neuen und 20 gelöschten Zeilen

Datei anzeigen

@ -1,5 +1,6 @@
name: Feature Request name: Feature Request
description: Suggest a feature to be added description: Suggest a feature to be added
labels: [Feature Request]
body: body:
- type: textarea - type: textarea
@ -34,4 +35,4 @@ body:
description: | description: |
Does the feature apply to any specific version or environment? Does the feature apply to any specific version or environment?
validations: validations:
required: false required: false

Datei anzeigen

@ -36,7 +36,7 @@ public final class BukkitAckSequenceProvider extends AckSequenceProvider {
final SequenceStorage sequenceStorage = connection.get(SequenceStorage.class); final SequenceStorage sequenceStorage = connection.get(SequenceStorage.class);
final int previousSequence = sequenceStorage.setSequenceId(sequence); final int previousSequence = sequenceStorage.setSequenceId(sequence);
if (previousSequence == -1) { if (previousSequence == -1) {
plugin.getServer().getScheduler().runTask(plugin, new AckSequenceTask(connection, sequenceStorage)); plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new AckSequenceTask(connection, sequenceStorage), 1);
} }
} }
} }

Datei anzeigen

@ -31,6 +31,7 @@ import org.checkerframework.checker.nullness.qual.Nullable;
import java.io.File; import java.io.File;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.function.IntPredicate; import java.util.function.IntPredicate;
@ -160,10 +161,12 @@ public abstract class AbstractViaConfig extends Config implements ViaVersionConf
} }
private BlockedProtocolVersions loadBlockedProtocolVersions() { private BlockedProtocolVersions loadBlockedProtocolVersions() {
IntSet blockedProtocols = new IntOpenHashSet(getIntegerList("block-protocols")); List<Integer> blockProtocols = getListSafe("block-protocols", Integer.class, "Invalid blocked version protocol found in config: '%s'");
List<String> blockVersions = getListSafe("block-versions", String.class, "Invalid blocked version found in config: '%s'");
IntSet blockedProtocols = new IntOpenHashSet(blockProtocols);
int lowerBound = -1; int lowerBound = -1;
int upperBound = -1; int upperBound = -1;
for (String s : getStringList("block-versions")) { for (String s : blockVersions) {
if (s.isEmpty()) { if (s.isEmpty()) {
continue; continue;
} }

Datei anzeigen

@ -21,6 +21,7 @@ import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import com.github.steveice10.opennbt.tag.builtin.IntTag; import com.github.steveice10.opennbt.tag.builtin.IntTag;
import com.github.steveice10.opennbt.tag.builtin.ListTag; import com.github.steveice10.opennbt.tag.builtin.ListTag;
import com.github.steveice10.opennbt.tag.builtin.Tag; import com.github.steveice10.opennbt.tag.builtin.Tag;
import com.google.common.collect.Maps;
import com.viaversion.viaversion.api.Via; import com.viaversion.viaversion.api.Via;
import com.viaversion.viaversion.api.data.entity.DimensionData; import com.viaversion.viaversion.api.data.entity.DimensionData;
import com.viaversion.viaversion.api.minecraft.Position; import com.viaversion.viaversion.api.minecraft.Position;
@ -39,12 +40,10 @@ import com.viaversion.viaversion.protocols.protocol1_19to1_18_2.ClientboundPacke
import com.viaversion.viaversion.protocols.protocol1_19to1_18_2.Protocol1_19To1_18_2; import com.viaversion.viaversion.protocols.protocol1_19to1_18_2.Protocol1_19To1_18_2;
import com.viaversion.viaversion.protocols.protocol1_19to1_18_2.storage.DimensionRegistryStorage; import com.viaversion.viaversion.protocols.protocol1_19to1_18_2.storage.DimensionRegistryStorage;
import com.viaversion.viaversion.rewriter.EntityRewriter; import com.viaversion.viaversion.rewriter.EntityRewriter;
import com.viaversion.viaversion.util.Pair;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public final class EntityPackets extends EntityRewriter<Protocol1_19To1_18_2> { public final class EntityPackets extends EntityRewriter<Protocol1_19To1_18_2> {
@ -308,15 +307,21 @@ public final class EntityPackets extends EntityRewriter<Protocol1_19To1_18_2> {
private static void writeDimensionKey(final PacketWrapper wrapper, final DimensionRegistryStorage registryStorage) throws Exception { private static void writeDimensionKey(final PacketWrapper wrapper, final DimensionRegistryStorage registryStorage) throws Exception {
// Find dimension key by data // Find dimension key by data
final CompoundTag currentDimension = wrapper.read(Type.NBT); final CompoundTag currentDimension = wrapper.read(Type.NBT);
final String dimensionKey = registryStorage.dimensionKey(currentDimension); String dimensionKey = registryStorage.dimensionKey(currentDimension);
if (dimensionKey == null) { if (dimensionKey == null) {
Via.getPlatform().getLogger().severe("The server tried to send dimension data from a dimension the client wasn't told about on join. " + if (!Via.getConfig().isSuppressConversionWarnings()) {
"Plugins and mods have to make sure they are not creating new dimension types while players are online, and proxies need to make sure they don't scramble dimension data." + Via.getPlatform().getLogger().warning("The server tried to send dimension data from a dimension the client wasn't told about on join. " +
" Known dimensions:"); "Plugins and mods have to make sure they are not creating new dimension types while players are online, and proxies need to make sure they don't scramble dimension data." +
for (final Map.Entry<CompoundTag, String> entry : registryStorage.dimensions().entrySet()) { " Received dimension: " + currentDimension + ". Known dimensions: " + registryStorage.dimensions());
Via.getPlatform().getLogger().severe(entry.getValue() + ": " + entry.getKey());
} }
throw new IllegalArgumentException("Dimension not found in registry data from join packet: " + currentDimension);
// Try to find the most similar dimension
dimensionKey = registryStorage.dimensions().entrySet().stream()
.map(it -> new Pair<>(it, Maps.difference(currentDimension.getValue(), it.getKey().getValue()).entriesInCommon()))
.filter(it -> it.value().containsKey("min_y") && it.value().containsKey("height"))
.max(Comparator.comparingInt(it -> it.value().size()))
.orElseThrow(() -> new IllegalArgumentException("Dimension not found in registry data from join packet: " + currentDimension))
.key().getValue();
} }
wrapper.write(Type.STRING, dimensionKey); wrapper.write(Type.STRING, dimensionKey);

Datei anzeigen

@ -18,6 +18,7 @@
package com.viaversion.viaversion.util; package com.viaversion.viaversion.util;
import com.google.gson.JsonElement; import com.google.gson.JsonElement;
import com.viaversion.viaversion.api.Via;
import com.viaversion.viaversion.api.configuration.ConfigurationProvider; import com.viaversion.viaversion.api.configuration.ConfigurationProvider;
import com.viaversion.viaversion.libs.kyori.adventure.text.serializer.gson.GsonComponentSerializer; import com.viaversion.viaversion.libs.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
import com.viaversion.viaversion.libs.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer; import com.viaversion.viaversion.libs.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
@ -26,11 +27,7 @@ import org.yaml.snakeyaml.DumperOptions;
import org.yaml.snakeyaml.Yaml; import org.yaml.snakeyaml.Yaml;
import org.yaml.snakeyaml.representer.Representer; import org.yaml.snakeyaml.representer.Representer;
import java.io.File; import java.io.*;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL; import java.net.URL;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
@ -214,6 +211,23 @@ public abstract class Config implements ConfigurationProvider {
return o != null ? (List<String>) o : new ArrayList<>(); return o != null ? (List<String>) o : new ArrayList<>();
} }
public <T> List<T> getListSafe(String key, Class<T> type, String invalidValueMessage) {
Object o = this.config.get(key);
if (o instanceof List) {
List<?> list = (List<?>) o;
List<T> filteredValues = new ArrayList<>();
for (Object o1 : list) {
if (type.isInstance(o1)) {
filteredValues.add(type.cast(o1));
} else if (invalidValueMessage != null) {
Via.getPlatform().getLogger().warning(String.format(invalidValueMessage, o1));
}
}
return filteredValues;
}
return new ArrayList<>();
}
public @Nullable JsonElement getSerializedComponent(String key) { public @Nullable JsonElement getSerializedComponent(String key) {
final Object o = this.config.get(key); final Object o = this.config.get(key);
if (o != null && !((String) o).isEmpty()) { if (o != null && !((String) o).isEmpty()) {