3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-11-16 04:50:08 +01:00

Also cache missing protocol paths, don't reverse base protocols

Dieser Commit ist enthalten in:
Nassim Jahnke 2024-08-30 11:19:32 +02:00
Ursprung 0b2dac9056
Commit f92dbb655d
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: EF6771C01F6EF02F

Datei anzeigen

@ -279,12 +279,14 @@ public class ProtocolManagerImpl implements ProtocolManager {
ProtocolPathKey protocolKey = new ProtocolPathKeyImpl(clientVersion, serverVersion); ProtocolPathKey protocolKey = new ProtocolPathKeyImpl(clientVersion, serverVersion);
List<ProtocolPathEntry> protocolList = pathCache.get(protocolKey); List<ProtocolPathEntry> protocolList = pathCache.get(protocolKey);
if (protocolList != null) { if (protocolList != null) {
return protocolList; return protocolList.isEmpty() ? null : protocolList;
} }
// Calculate path // Calculate path
Object2ObjectSortedMap<ProtocolVersion, Protocol> outputPath = getProtocolPath(new Object2ObjectLinkedOpenHashMap<>(), clientVersion, serverVersion); Object2ObjectSortedMap<ProtocolVersion, Protocol> outputPath = getProtocolPath(new Object2ObjectLinkedOpenHashMap<>(), clientVersion, serverVersion);
if (outputPath == null) { if (outputPath == null) {
// Also cache that there is no path
pathCache.put(protocolKey, List.of());
return null; return null;
} }
@ -374,14 +376,14 @@ public class ProtocolManagerImpl implements ProtocolManager {
public List<Protocol> getBaseProtocols(@Nullable ProtocolVersion clientVersion, @Nullable ProtocolVersion serverVersion) { public List<Protocol> getBaseProtocols(@Nullable ProtocolVersion clientVersion, @Nullable ProtocolVersion serverVersion) {
final List<Protocol> list = new ArrayList<>(); final List<Protocol> list = new ArrayList<>();
if (clientVersion != null) { if (clientVersion != null) {
for (Pair<Range<ProtocolVersion>, Protocol> rangeProtocol : Lists.reverse(serverboundBaseProtocols)) { for (Pair<Range<ProtocolVersion>, Protocol> rangeProtocol : serverboundBaseProtocols) {
if (rangeProtocol.key().contains(clientVersion)) { if (rangeProtocol.key().contains(clientVersion)) {
list.add(rangeProtocol.value()); list.add(rangeProtocol.value());
} }
} }
} }
if (serverVersion != null) { if (serverVersion != null) {
for (Pair<Range<ProtocolVersion>, Protocol> rangeProtocol : Lists.reverse(clientboundBaseProtocols)) { for (Pair<Range<ProtocolVersion>, Protocol> rangeProtocol : clientboundBaseProtocols) {
if (rangeProtocol.key().contains(serverVersion)) { if (rangeProtocol.key().contains(serverVersion)) {
list.add(rangeProtocol.value()); list.add(rangeProtocol.value());
} }
@ -534,7 +536,7 @@ public class ProtocolManagerImpl implements ProtocolManager {
Preconditions.checkArgument(!mappingsLoaded); Preconditions.checkArgument(!mappingsLoaded);
// If this log message is missing, something is wrong // If this log message is missing, something is wrong
Via.getPlatform().getLogger().info("Finished mapping loading, shutting down loader executor!"); Via.getPlatform().getLogger().info("Finished mapping loading, shutting down loader executor.");
mappingsLoaded = true; mappingsLoaded = true;
mappingLoaderExecutor.shutdown(); mappingLoaderExecutor.shutdown();
mappingLoaderExecutor = null; mappingLoaderExecutor = null;