use of com.viaversion.viaversion.api.protocol.ProtocolPathKey in project ViaVersion by ViaVersion.
the class ProtocolManagerImpl method getProtocolPath.
@Override
@Nullable
public List<ProtocolPathEntry> getProtocolPath(int clientVersion, int serverVersion) {
// Nothing to do!
if (clientVersion == serverVersion)
return null;
// Check cache
ProtocolPathKey protocolKey = new ProtocolPathKeyImpl(clientVersion, serverVersion);
List<ProtocolPathEntry> protocolList = pathCache.get(protocolKey);
if (protocolList != null) {
return protocolList;
}
// Calculate path
Int2ObjectSortedMap<Protocol> outputPath = getProtocolPath(new Int2ObjectLinkedOpenHashMap<>(), clientVersion, serverVersion);
if (outputPath == null) {
return null;
}
List<ProtocolPathEntry> path = new ArrayList<>(outputPath.size());
for (Int2ObjectMap.Entry<Protocol> entry : outputPath.int2ObjectEntrySet()) {
path.add(new ProtocolPathEntryImpl(entry.getIntKey(), entry.getValue()));
}
pathCache.put(protocolKey, path);
return path;
}
Aggregations