3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-12-28 00:50:13 +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
description: Suggest a feature to be added
labels: [Feature Request]
body:
- type: textarea

Datei anzeigen

@ -36,7 +36,7 @@ public final class BukkitAckSequenceProvider extends AckSequenceProvider {
final SequenceStorage sequenceStorage = connection.get(SequenceStorage.class);
final int previousSequence = sequenceStorage.setSequenceId(sequence);
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.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.function.IntPredicate;
@ -160,10 +161,12 @@ public abstract class AbstractViaConfig extends Config implements ViaVersionConf
}
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 upperBound = -1;
for (String s : getStringList("block-versions")) {
for (String s : blockVersions) {
if (s.isEmpty()) {
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.ListTag;
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.data.entity.DimensionData;
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.storage.DimensionRegistryStorage;
import com.viaversion.viaversion.rewriter.EntityRewriter;
import com.viaversion.viaversion.util.Pair;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
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 {
// Find dimension key by data
final CompoundTag currentDimension = wrapper.read(Type.NBT);
final String dimensionKey = registryStorage.dimensionKey(currentDimension);
String dimensionKey = registryStorage.dimensionKey(currentDimension);
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()) {
Via.getPlatform().getLogger().warning("The server tried to send dimension data from a dimension the client wasn't told about on join. " +
"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." +
" Known dimensions:");
for (final Map.Entry<CompoundTag, String> entry : registryStorage.dimensions().entrySet()) {
Via.getPlatform().getLogger().severe(entry.getValue() + ": " + entry.getKey());
" Received dimension: " + currentDimension + ". Known dimensions: " + registryStorage.dimensions());
}
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);

Datei anzeigen

@ -18,6 +18,7 @@
package com.viaversion.viaversion.util;
import com.google.gson.JsonElement;
import com.viaversion.viaversion.api.Via;
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.legacy.LegacyComponentSerializer;
@ -26,11 +27,7 @@ import org.yaml.snakeyaml.DumperOptions;
import org.yaml.snakeyaml.Yaml;
import org.yaml.snakeyaml.representer.Representer;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.*;
import java.net.URL;
import java.util.ArrayList;
import java.util.HashMap;
@ -214,6 +211,23 @@ public abstract class Config implements ConfigurationProvider {
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) {
final Object o = this.config.get(key);
if (o != null && !((String) o).isEmpty()) {