From ad0842c1075b7fc8804cfc2e35b058a7055adf3d Mon Sep 17 00:00:00 2001 From: KennyTV Date: Fri, 23 Apr 2021 22:48:08 +0200 Subject: [PATCH] Bump version to 4.0.0, remove ProtocolRegistry The bump was overdue given the breakages that have happened --- .../api/protocol/ProtocolRegistry.java | 136 ------------------ build.gradle.kts | 2 +- .../bukkit/classgenerator/ClassGenerator.java | 3 +- .../api/protocol/ProtocolManagerImpl.java | 1 - 4 files changed, 2 insertions(+), 140 deletions(-) delete mode 100644 api/src/main/java/us/myles/ViaVersion/api/protocol/ProtocolRegistry.java diff --git a/api/src/main/java/us/myles/ViaVersion/api/protocol/ProtocolRegistry.java b/api/src/main/java/us/myles/ViaVersion/api/protocol/ProtocolRegistry.java deleted file mode 100644 index 3e73ed185..000000000 --- a/api/src/main/java/us/myles/ViaVersion/api/protocol/ProtocolRegistry.java +++ /dev/null @@ -1,136 +0,0 @@ -/* - * This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion - * Copyright (C) 2016-2021 ViaVersion and contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -package us.myles.ViaVersion.api.protocol; - -import com.google.common.collect.Range; -import org.checkerframework.checker.nullness.qual.Nullable; -import us.myles.ViaVersion.ViaManager; -import us.myles.ViaVersion.api.Pair; -import us.myles.ViaVersion.api.Via; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.SortedSet; - -/** - * @see ViaManager#getProtocolManager() - * @deprecated use {@link ProtocolManager} - */ -@Deprecated -public class ProtocolRegistry { - @Deprecated - public static int SERVER_PROTOCOL = -1; - @Deprecated - public static int maxProtocolPathSize = 50; - - /** - * Register a protocol - * - * @param protocol The protocol to register. - * @param supported Supported client versions. - * @param output The output server version it converts to. - */ - public static void registerProtocol(Protocol protocol, ProtocolVersion supported, ProtocolVersion output) { - registerProtocol(protocol, Collections.singletonList(supported.getVersion()), output.getVersion()); - } - - /** - * Register a protocol - * - * @param protocol The protocol to register. - * @param supported Supported client versions. - * @param output The output server version it converts to. - */ - public static void registerProtocol(Protocol protocol, List supported, int output) { - Via.getManager().getProtocolManager().registerProtocol(protocol, supported, output); - } - - /** - * Registers a base protocol. - * Base Protocols registered later have higher priority - * Only one base protocol will be added to pipeline - * - * @param baseProtocol Base Protocol to register - * @param supportedProtocols Versions that baseProtocol supports - */ - public static void registerBaseProtocol(Protocol baseProtocol, Range supportedProtocols) { - Via.getManager().getProtocolManager().registerBaseProtocol(baseProtocol, supportedProtocols); - } - - /** - * Get the versions compatible with the server. - * - * @return Read-only set of the versions. - */ - public static SortedSet getSupportedVersions() { - return Via.getManager().getProtocolManager().getSupportedVersions(); - } - - /** - * Check if this plugin is useful to the server. - * - * @return True if there is a useful pipe - */ - public static boolean isWorkingPipe() { - return Via.getManager().getProtocolManager().isWorkingPipe(); - } - - /** - * Calculate a path from a client version to server version. - * - * @param clientVersion The input client version - * @param serverVersion The desired output server version - * @return The path it generated, null if it failed. - */ - public static @Nullable List> getProtocolPath(int clientVersion, int serverVersion) { - List pathList = Via.getManager().getProtocolManager().getProtocolPath(clientVersion, serverVersion); - if (pathList == null) { - return null; - } - - List> list = new ArrayList<>(); - for (ProtocolPathEntry entry : pathList) { - list.add(new Pair<>(entry.getOutputProtocolVersion(), entry.getProtocol())); - } - return list; - } - - /** - * Returns a protocol instance by its class. - * - * @param protocolClass class of the protocol - * @return protocol if present - */ - public static @Nullable Protocol getProtocol(Class protocolClass) { - return Via.getManager().getProtocolManager().getProtocol(protocolClass); - } - - public static Protocol getBaseProtocol(int serverVersion) { - return Via.getManager().getProtocolManager().getBaseProtocol(serverVersion); - } - - public static boolean isBaseProtocol(Protocol protocol) { - return Via.getManager().getProtocolManager().isBaseProtocol(protocol); - } -} diff --git a/build.gradle.kts b/build.gradle.kts index 074251433..8fafec1fb 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -8,7 +8,7 @@ plugins { allprojects { group = "us.myles" - version = "3.3.0-21w16a" + version = "4.0.0-21w16a" description = "Allow newer clients to join older server versions." } diff --git a/bukkit/src/main/java/us/myles/ViaVersion/bukkit/classgenerator/ClassGenerator.java b/bukkit/src/main/java/us/myles/ViaVersion/bukkit/classgenerator/ClassGenerator.java index b368d00bd..6a5b29745 100644 --- a/bukkit/src/main/java/us/myles/ViaVersion/bukkit/classgenerator/ClassGenerator.java +++ b/bukkit/src/main/java/us/myles/ViaVersion/bukkit/classgenerator/ClassGenerator.java @@ -202,7 +202,6 @@ public class ClassGenerator { connectListenerClazz.setSuperclass(toExtend); // Import packages pool.importPackage("java.util.Arrays"); - pool.importPackage("us.myles.ViaVersion.api.protocol.ProtocolRegistry"); pool.importPackage("protocolsupport.api.ProtocolVersion"); pool.importPackage("protocolsupport.api.ProtocolType"); pool.importPackage("protocolsupport.api.Connection"); @@ -232,7 +231,7 @@ public class ClassGenerator { )) // ViaVersion has at this point already spoofed the connectionversion. (Since it is higher up the pipeline) // If via has put the protoVersion to the server we can spoof ProtocolSupport's version. - + " if (connection.getVersion() == ProtocolVersion.MINECRAFT_FUTURE && protoVersion == us.myles.ViaVersion.api.protocol.ProtocolRegistry.SERVER_PROTOCOL) {\n" + + " if (connection.getVersion() == ProtocolVersion.MINECRAFT_FUTURE && protoVersion == us.myles.ViaVersion.api.Via.getAPI().getServerVersion().lowestSupportedVersion()) {\n" + " connection.setVersion(ProtocolVersion.getLatest(ProtocolType.PC));\n" + " }\n" + " }\n" diff --git a/common/src/main/java/us/myles/ViaVersion/api/protocol/ProtocolManagerImpl.java b/common/src/main/java/us/myles/ViaVersion/api/protocol/ProtocolManagerImpl.java index 5d73a28f3..0cc2edf10 100644 --- a/common/src/main/java/us/myles/ViaVersion/api/protocol/ProtocolManagerImpl.java +++ b/common/src/main/java/us/myles/ViaVersion/api/protocol/ProtocolManagerImpl.java @@ -308,7 +308,6 @@ public class ProtocolManagerImpl implements ProtocolManager { public void setServerProtocol(ServerProtocolVersion serverProtocolVersion) { this.serverProtocolVersion = serverProtocolVersion; - ProtocolRegistry.SERVER_PROTOCOL = serverProtocolVersion.lowestSupportedVersion(); } @Override