diff --git a/gradle.properties b/gradle.properties index 63632ba..90f2f3c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,7 +2,7 @@ org.gradle.jvmargs=-Xms32M -Xmx4G -XX:+UseG1GC -XX:+UseStringDeduplication loader_version=0.15.6 -viaver_version=4.10.0-24w06a-SNAPSHOT +viaver_version=4.10.0-24w07a-SNAPSHOT yaml_version=2.2 publish_mc_versions=1.20.4, 1.19.4, 1.18.2, 1.17.1, 1.16.5, 1.15.2, 1.14.4, 1.12.2, 1.8.9 diff --git a/src/main/java/com/viaversion/fabric/common/config/AbstractViaConfigScreen.java b/src/main/java/com/viaversion/fabric/common/config/AbstractViaConfigScreen.java index 44a58ba..f3604fd 100644 --- a/src/main/java/com/viaversion/fabric/common/config/AbstractViaConfigScreen.java +++ b/src/main/java/com/viaversion/fabric/common/config/AbstractViaConfigScreen.java @@ -18,14 +18,15 @@ package com.viaversion.fabric.common.config; import com.viaversion.fabric.common.util.ProtocolUtils; +import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; public interface AbstractViaConfigScreen { String TITLE_TRANSLATE_ID = "gui.viafabric_config.title"; String VERSION_TRANSLATE_ID = "gui.protocol_version_field.name"; - default int getProtocolTextColor(int version, boolean parsedValid) { + default int getProtocolTextColor(ProtocolVersion version, boolean parsedValid) { if (!parsedValid) return 0xff0000; // Red - if (version == -1 || version == -2) return 0x5555FF; // Blue + if (!ProtocolUtils.isValid(version)) return 0x5555FF; // Blue if (!ProtocolUtils.isSupportedClientSide(version)) return 0xFFA500; // Orange return 0xE0E0E0; // Default } diff --git a/src/main/java/com/viaversion/fabric/common/platform/FabricInjector.java b/src/main/java/com/viaversion/fabric/common/platform/FabricInjector.java index 17abbfb..94ee8a6 100644 --- a/src/main/java/com/viaversion/fabric/common/platform/FabricInjector.java +++ b/src/main/java/com/viaversion/fabric/common/platform/FabricInjector.java @@ -21,13 +21,15 @@ import com.viaversion.fabric.common.handler.CommonTransformer; import com.viaversion.viaversion.api.Via; import com.viaversion.viaversion.api.platform.ViaInjector; import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; -import com.viaversion.viaversion.libs.fastutil.ints.IntLinkedOpenHashSet; -import com.viaversion.viaversion.libs.fastutil.ints.IntSortedSet; -import com.viaversion.viaversion.libs.fastutil.ints.IntSortedSets; import com.viaversion.viaversion.libs.gson.JsonObject; +import it.unimi.dsi.fastutil.objects.ObjectLinkedOpenHashSet; +import it.unimi.dsi.fastutil.objects.ObjectSortedSet; +import it.unimi.dsi.fastutil.objects.ObjectSortedSets; import net.fabricmc.api.EnvType; import net.fabricmc.loader.api.FabricLoader; +import java.util.OptionalInt; + public class FabricInjector implements ViaInjector { @Override public void inject() { @@ -55,23 +57,21 @@ public class FabricInjector implements ViaInjector { } @Override - public IntSortedSet getServerProtocolVersions() { + public ObjectSortedSet getServerProtocolVersions() { if (FabricLoader.getInstance().getEnvironmentType() == EnvType.SERVER) { - int version = Via.getManager().getProviders().get(NativeVersionProvider.class).getNativeServerVersion(); - return IntSortedSets.singleton(version); + final ProtocolVersion version = Via.getManager().getProviders().get(NativeVersionProvider.class).getNativeServerProtocolVersion(); + return ObjectSortedSets.singleton(version); } // On client-side we can connect to any server version - IntSortedSet versions = new IntLinkedOpenHashSet(); - versions.add(ProtocolVersion.v1_8.getOriginalVersion()); - versions.add(ProtocolVersion.getProtocols() - .stream() - .mapToInt(ProtocolVersion::getOriginalVersion) - .max().getAsInt()); + ObjectSortedSet versions = new ObjectLinkedOpenHashSet<>(); + versions.add(ProtocolVersion.v1_8); + final OptionalInt highestSupportedVersion = ProtocolVersion.getProtocols().stream().mapToInt(ProtocolVersion::getOriginalVersion).max(); + versions.add(ProtocolVersion.getProtocol(highestSupportedVersion.getAsInt())); return versions; } @Override - public int getServerProtocolVersion() { - return getServerProtocolVersions().firstInt(); + public ProtocolVersion getServerProtocolVersion() { + return getServerProtocolVersions().first(); } } diff --git a/src/main/java/com/viaversion/fabric/common/platform/FabricViaAPI.java b/src/main/java/com/viaversion/fabric/common/platform/FabricViaAPI.java index 49c39d6..f3ff02e 100644 --- a/src/main/java/com/viaversion/fabric/common/platform/FabricViaAPI.java +++ b/src/main/java/com/viaversion/fabric/common/platform/FabricViaAPI.java @@ -18,8 +18,20 @@ package com.viaversion.fabric.common.platform; import com.viaversion.viaversion.ViaAPIBase; +import com.viaversion.viaversion.api.connection.UserConnection; +import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; +import io.netty.buffer.ByteBuf; import java.util.UUID; -public class FabricViaAPI extends ViaAPIBase { +public class FabricViaAPI extends ViaAPIBase { + @Override + public ProtocolVersion getPlayerProtocolVersion(UserConnection player) { + return player.getProtocolInfo().protocolVersion(); + } + + @Override + public void sendRawPacket(UserConnection player, ByteBuf packet) { + player.scheduleSendRawPacket(packet); + } } diff --git a/src/main/java/com/viaversion/fabric/common/platform/NativeVersionProvider.java b/src/main/java/com/viaversion/fabric/common/platform/NativeVersionProvider.java index e196757..8d70268 100644 --- a/src/main/java/com/viaversion/fabric/common/platform/NativeVersionProvider.java +++ b/src/main/java/com/viaversion/fabric/common/platform/NativeVersionProvider.java @@ -18,7 +18,13 @@ package com.viaversion.fabric.common.platform; import com.viaversion.viaversion.api.platform.providers.Provider; +import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; public interface NativeVersionProvider extends Provider { + int getNativeServerVersion(); + + default ProtocolVersion getNativeServerProtocolVersion() { + return ProtocolVersion.getProtocol(getNativeServerVersion()); + } } diff --git a/src/main/java/com/viaversion/fabric/common/provider/AbstractFabricPlatform.java b/src/main/java/com/viaversion/fabric/common/provider/AbstractFabricPlatform.java index 9517ed4..b5c4421 100644 --- a/src/main/java/com/viaversion/fabric/common/provider/AbstractFabricPlatform.java +++ b/src/main/java/com/viaversion/fabric/common/provider/AbstractFabricPlatform.java @@ -26,6 +26,7 @@ import com.viaversion.viaversion.api.Via; import com.viaversion.viaversion.api.ViaAPI; import com.viaversion.viaversion.api.configuration.ConfigurationProvider; import com.viaversion.viaversion.api.configuration.ViaVersionConfig; +import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.api.platform.UnsupportedSoftware; import com.viaversion.viaversion.api.platform.ViaPlatform; import com.viaversion.viaversion.libs.gson.JsonArray; @@ -54,11 +55,11 @@ import java.util.concurrent.ExecutorService; import java.util.concurrent.TimeUnit; import java.util.logging.Logger; -public abstract class AbstractFabricPlatform implements ViaPlatform { +public abstract class AbstractFabricPlatform implements ViaPlatform { private final Logger logger = new JLoggerToLog4j(LogManager.getLogger("ViaVersion")); private FabricViaConfig config; private File dataFolder; - private final ViaAPI api; + private final ViaAPI api; { api = new FabricViaAPI(); @@ -148,7 +149,7 @@ public abstract class AbstractFabricPlatform implements ViaPlatform { } @Override - public ViaAPI getApi() { + public ViaAPI getApi() { return api; } @@ -214,7 +215,7 @@ public abstract class AbstractFabricPlatform implements ViaPlatform { platformSpecific.add("mods", mods); NativeVersionProvider ver = Via.getManager().getProviders().get(NativeVersionProvider.class); if (ver != null) { - platformSpecific.addProperty("native version", ver.getNativeServerVersion()); + platformSpecific.addProperty("native version", ver.getNativeServerProtocolVersion().getVersion()); } return platformSpecific; } diff --git a/src/main/java/com/viaversion/fabric/common/provider/AbstractFabricVersionProvider.java b/src/main/java/com/viaversion/fabric/common/provider/AbstractFabricVersionProvider.java index 30d5e8b..d0ac232 100644 --- a/src/main/java/com/viaversion/fabric/common/provider/AbstractFabricVersionProvider.java +++ b/src/main/java/com/viaversion/fabric/common/provider/AbstractFabricVersionProvider.java @@ -82,11 +82,11 @@ public abstract class AbstractFabricVersionProvider extends BaseVersionProvider } @Override - public int getClosestServerProtocol(UserConnection connection) throws Exception { + public ProtocolVersion getClosestServerProtocol(UserConnection connection) throws Exception { if (connection.isClientSide()) { ProtocolInfo info = Objects.requireNonNull(connection.getProtocolInfo()); - if (!getConfig().isClientSideEnabled()) return info.getProtocolVersion(); + if (!getConfig().isClientSideEnabled()) return info.protocolVersion(); int serverVer = getConfig().getClientSideVersion(); SocketAddress addr = connection.getChannel().remoteAddress(); @@ -112,18 +112,20 @@ public abstract class AbstractFabricVersionProvider extends BaseVersionProvider } } - boolean blocked = checkAddressBlocked(addr); - boolean supported = ProtocolUtils.isSupported(serverVer, info.getProtocolVersion()); + ProtocolVersion serverVersion = ProtocolVersion.getProtocol(serverVer); - handleMulticonnectPing(connection, info, blocked, serverVer); + boolean blocked = checkAddressBlocked(addr); + boolean supported = ProtocolUtils.isSupported(serverVersion, info.protocolVersion()); + + handleMulticonnectPing(connection, info, blocked, serverVersion); if (blocked || !supported) serverVer = info.getProtocolVersion(); - return serverVer; + return ProtocolVersion.getProtocol(serverVer); } NativeVersionProvider natProvider = Via.getManager().getProviders().get(NativeVersionProvider.class); if (natProvider != null) { - return ProtocolVersion.getProtocol(natProvider.getNativeServerVersion()).getVersion(); + return natProvider.getNativeServerProtocolVersion(); } return super.getClosestServerProtocol(connection); } @@ -135,15 +137,15 @@ public abstract class AbstractFabricVersionProvider extends BaseVersionProvider || isDisabled(((InetSocketAddress) addr).getAddress().getHostName())))); } - private void handleMulticonnectPing(UserConnection connection, ProtocolInfo info, boolean blocked, int serverVer) throws Exception { + private void handleMulticonnectPing(UserConnection connection, ProtocolInfo info, boolean blocked, ProtocolVersion serverVer) throws Exception { if (info.getState() == State.STATUS && info.getProtocolVersion() == -1 && isMulticonnectHandler(connection.getChannel().pipeline()) && (blocked || ProtocolUtils.isSupported(serverVer, getVersionForMulticonnect(serverVer)))) { // Intercept the connection - int multiconnectSuggestion = blocked ? -1 : getVersionForMulticonnect(serverVer); - getLogger().info("Sending " + ProtocolVersion.getProtocol(multiconnectSuggestion) + " for multiconnect version detector"); + ProtocolVersion multiconnectSuggestion = blocked ? ProtocolVersion.unknown : getVersionForMulticonnect(serverVer); + getLogger().info("Sending " + multiconnectSuggestion + " for multiconnect version detector"); PacketWrapper newAnswer = PacketWrapper.create(ClientboundStatusPackets.STATUS_RESPONSE, null, connection); - newAnswer.write(Type.STRING, "{\"version\":{\"name\":\"viafabric integration\",\"protocol\":" + multiconnectSuggestion + "}}"); + newAnswer.write(Type.STRING, "{\"version\":{\"name\":\"viafabric integration\",\"protocol\":" + multiconnectSuggestion.getVersion() + "}}"); newAnswer.send(info.getPipeline().contains(BaseProtocol1_16.class) ? BaseProtocol1_16.class : BaseProtocol1_7.class); throw CancelException.generate(); } @@ -153,23 +155,23 @@ public abstract class AbstractFabricVersionProvider extends BaseVersionProvider return false; } - private int getVersionForMulticonnect(int clientSideVersion) { + private ProtocolVersion getVersionForMulticonnect(ProtocolVersion clientSideVersion) { // https://github.com/ViaVersion/ViaVersion/blob/master/velocity/src/main/java/us/myles/ViaVersion/velocity/providers/VelocityVersionProvider.java int[] compatibleProtocols = multiconnectSupportedVersions; - if (Arrays.binarySearch(compatibleProtocols, clientSideVersion) >= 0) { + if (Arrays.binarySearch(compatibleProtocols, clientSideVersion.getVersion()) >= 0) { return clientSideVersion; } - if (clientSideVersion < compatibleProtocols[0]) { - return compatibleProtocols[0]; + if (clientSideVersion.getVersion() < compatibleProtocols[0]) { + return ProtocolVersion.getProtocol(compatibleProtocols[0]); } // TODO: This needs a better fix, i.e checking ProtocolRegistry to see if it would work. for (int i = compatibleProtocols.length - 1; i >= 0; i--) { int protocol = compatibleProtocols[i]; - if (clientSideVersion > protocol && ProtocolVersion.isRegistered(protocol)) { - return protocol; + if (clientSideVersion.getVersion() > protocol && ProtocolVersion.isRegistered(protocol)) { + return ProtocolVersion.getProtocol(protocol); } } diff --git a/src/main/java/com/viaversion/fabric/common/util/ProtocolUtils.java b/src/main/java/com/viaversion/fabric/common/util/ProtocolUtils.java index 4a6823d..8c7aa2e 100644 --- a/src/main/java/com/viaversion/fabric/common/util/ProtocolUtils.java +++ b/src/main/java/com/viaversion/fabric/common/util/ProtocolUtils.java @@ -25,14 +25,14 @@ import java.util.Arrays; import java.util.stream.Stream; public class ProtocolUtils { - public static boolean isSupportedClientSide(int server) { + public static boolean isSupportedClientSide(ProtocolVersion server) { return isSupported(server, Via.getManager().getProviders() .get(NativeVersionProvider.class) - .getNativeServerVersion()); + .getNativeServerProtocolVersion()); } - public static boolean isSupported(int server, int client) { - return server == client || Via.getManager().getProtocolManager().getProtocolPath(client, server) != null; + public static boolean isSupported(ProtocolVersion server, ProtocolVersion client) { + return server.equals(client) || Via.getManager().getProtocolManager().getProtocolPath(client, server) != null; } public static String getProtocolName(int id) { @@ -40,6 +40,10 @@ public class ProtocolUtils { return ProtocolVersion.getProtocol(id).getName(); } + public static boolean isValid(final ProtocolVersion version) { + return version.isKnown() && version.getVersion() != -2; + } + public static boolean isStartOfProtocolText(String s) { try { Integer.parseInt(s); diff --git a/viafabric-mc112/src/main/java/com/viaversion/fabric/mc112/ViaFabric.java b/viafabric-mc112/src/main/java/com/viaversion/fabric/mc112/ViaFabric.java index 0d81a75..0ac3159 100644 --- a/viafabric-mc112/src/main/java/com/viaversion/fabric/mc112/ViaFabric.java +++ b/viafabric-mc112/src/main/java/com/viaversion/fabric/mc112/ViaFabric.java @@ -72,7 +72,8 @@ public class ViaFabric implements ModInitializer { ViaManagerImpl manager = (ViaManagerImpl) Via.getManager(); manager.init(); - Via.getManager().getProtocolManager().registerBaseProtocol(HostnameParserProtocol.INSTANCE, Range.lessThan(Integer.MIN_VALUE)); + HostnameParserProtocol.INSTANCE.initialize(); + HostnameParserProtocol.INSTANCE.register(Via.getManager().getProviders()); ProtocolVersion.register(-2, "AUTO"); FabricLoader.getInstance().getEntrypoints("viafabric:via_api_initialized", Runnable.class).forEach(Runnable::run); diff --git a/viafabric-mc112/src/main/java/com/viaversion/fabric/mc112/gui/ViaConfigScreen.java b/viafabric-mc112/src/main/java/com/viaversion/fabric/mc112/gui/ViaConfigScreen.java index f31e78e..7b959e0 100644 --- a/viafabric-mc112/src/main/java/com/viaversion/fabric/mc112/gui/ViaConfigScreen.java +++ b/viafabric-mc112/src/main/java/com/viaversion/fabric/mc112/gui/ViaConfigScreen.java @@ -20,6 +20,7 @@ package com.viaversion.fabric.mc112.gui; import com.viaversion.fabric.common.config.AbstractViaConfigScreen; import com.viaversion.fabric.mc112.ViaFabric; import com.viaversion.fabric.common.util.ProtocolUtils; +import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.client.MinecraftClient; @@ -95,7 +96,7 @@ public class ViaConfigScreen extends Screen implements AbstractViaConfigScreen { validProtocol = false; } - protocolVersion.setEditableColor(getProtocolTextColor(newVersion, validProtocol)); + protocolVersion.setEditableColor(getProtocolTextColor(ProtocolVersion.getProtocol(newVersion), validProtocol)); int finalNewVersion = newVersion; if (latestProtocolSave == null) latestProtocolSave = CompletableFuture.completedFuture(null); diff --git a/viafabric-mc112/src/main/java/com/viaversion/fabric/mc112/platform/FabricNativeVersionProvider.java b/viafabric-mc112/src/main/java/com/viaversion/fabric/mc112/platform/FabricNativeVersionProvider.java index 9259f5c..ff4e83c 100644 --- a/viafabric-mc112/src/main/java/com/viaversion/fabric/mc112/platform/FabricNativeVersionProvider.java +++ b/viafabric-mc112/src/main/java/com/viaversion/fabric/mc112/platform/FabricNativeVersionProvider.java @@ -35,7 +35,7 @@ public class FabricNativeVersionProvider implements NativeVersionProvider { } ServerMetadata.Version version = MinecraftClient.getInstance().getServer().getServerMetadata().getVersion(); - if (version == null) return ProtocolVersion.v1_8.getVersion(); + if (version == null) return ProtocolVersion.v1_12_2.getVersion(); return version.getProtocolVersion(); } @@ -46,6 +46,6 @@ public class FabricNativeVersionProvider implements NativeVersionProvider { } catch (IllegalAccessException | NoSuchFieldException e) { e.printStackTrace(); } - return ProtocolVersion.v1_8.getVersion(); // fallback + return ProtocolVersion.v1_12_2.getVersion(); // fallback } } diff --git a/viafabric-mc114/src/main/java/com/viaversion/fabric/mc114/ViaFabric.java b/viafabric-mc114/src/main/java/com/viaversion/fabric/mc114/ViaFabric.java index 59158b8..ef0210b 100644 --- a/viafabric-mc114/src/main/java/com/viaversion/fabric/mc114/ViaFabric.java +++ b/viafabric-mc114/src/main/java/com/viaversion/fabric/mc114/ViaFabric.java @@ -86,7 +86,8 @@ public class ViaFabric implements ModInitializer { ViaManagerImpl manager = (ViaManagerImpl) Via.getManager(); manager.init(); - Via.getManager().getProtocolManager().registerBaseProtocol(HostnameParserProtocol.INSTANCE, Range.lessThan(Integer.MIN_VALUE)); + HostnameParserProtocol.INSTANCE.initialize(); + HostnameParserProtocol.INSTANCE.register(Via.getManager().getProviders()); ProtocolVersion.register(-2, "AUTO"); FabricLoader.getInstance().getEntrypoints("viafabric:via_api_initialized", Runnable.class).forEach(Runnable::run); diff --git a/viafabric-mc114/src/main/java/com/viaversion/fabric/mc114/gui/ViaConfigScreen.java b/viafabric-mc114/src/main/java/com/viaversion/fabric/mc114/gui/ViaConfigScreen.java index 3a7b21c..e322a7d 100644 --- a/viafabric-mc114/src/main/java/com/viaversion/fabric/mc114/gui/ViaConfigScreen.java +++ b/viafabric-mc114/src/main/java/com/viaversion/fabric/mc114/gui/ViaConfigScreen.java @@ -20,6 +20,7 @@ package com.viaversion.fabric.mc114.gui; import com.viaversion.fabric.common.config.AbstractViaConfigScreen; import com.viaversion.fabric.mc114.ViaFabric; import com.viaversion.fabric.common.util.ProtocolUtils; +import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.client.MinecraftClient; @@ -93,7 +94,7 @@ public class ViaConfigScreen extends Screen implements AbstractViaConfigScreen { } } - protocolVersion.setEditableColor(getProtocolTextColor(newVersion, validProtocol)); + protocolVersion.setEditableColor(getProtocolTextColor(ProtocolVersion.getProtocol(newVersion), validProtocol)); int finalNewVersion = newVersion; if (latestProtocolSave == null) latestProtocolSave = CompletableFuture.completedFuture(null); diff --git a/viafabric-mc115/src/main/java/com/viaversion/fabric/mc115/ViaFabric.java b/viafabric-mc115/src/main/java/com/viaversion/fabric/mc115/ViaFabric.java index 9464bee..158e815 100644 --- a/viafabric-mc115/src/main/java/com/viaversion/fabric/mc115/ViaFabric.java +++ b/viafabric-mc115/src/main/java/com/viaversion/fabric/mc115/ViaFabric.java @@ -86,7 +86,8 @@ public class ViaFabric implements ModInitializer { ViaManagerImpl manager = (ViaManagerImpl) Via.getManager(); manager.init(); - Via.getManager().getProtocolManager().registerBaseProtocol(HostnameParserProtocol.INSTANCE, Range.lessThan(Integer.MIN_VALUE)); + HostnameParserProtocol.INSTANCE.initialize(); + HostnameParserProtocol.INSTANCE.register(Via.getManager().getProviders()); ProtocolVersion.register(-2, "AUTO"); FabricLoader.getInstance().getEntrypoints("viafabric:via_api_initialized", Runnable.class).forEach(Runnable::run); diff --git a/viafabric-mc115/src/main/java/com/viaversion/fabric/mc115/gui/ViaConfigScreen.java b/viafabric-mc115/src/main/java/com/viaversion/fabric/mc115/gui/ViaConfigScreen.java index a1d96ca..6a4c865 100644 --- a/viafabric-mc115/src/main/java/com/viaversion/fabric/mc115/gui/ViaConfigScreen.java +++ b/viafabric-mc115/src/main/java/com/viaversion/fabric/mc115/gui/ViaConfigScreen.java @@ -20,6 +20,7 @@ package com.viaversion.fabric.mc115.gui; import com.viaversion.fabric.common.config.AbstractViaConfigScreen; import com.viaversion.fabric.mc115.ViaFabric; import com.viaversion.fabric.common.util.ProtocolUtils; +import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.client.MinecraftClient; @@ -93,7 +94,7 @@ public class ViaConfigScreen extends Screen implements AbstractViaConfigScreen { } } - protocolVersion.setEditableColor(getProtocolTextColor(newVersion, validProtocol)); + protocolVersion.setEditableColor(getProtocolTextColor(ProtocolVersion.getProtocol(newVersion), validProtocol)); int finalNewVersion = newVersion; if (latestProtocolSave == null) latestProtocolSave = CompletableFuture.completedFuture(null); diff --git a/viafabric-mc116/src/main/java/com/viaversion/fabric/mc116/ViaFabric.java b/viafabric-mc116/src/main/java/com/viaversion/fabric/mc116/ViaFabric.java index 1f2fefd..207f70d 100644 --- a/viafabric-mc116/src/main/java/com/viaversion/fabric/mc116/ViaFabric.java +++ b/viafabric-mc116/src/main/java/com/viaversion/fabric/mc116/ViaFabric.java @@ -88,7 +88,8 @@ public class ViaFabric implements ModInitializer { ViaManagerImpl manager = (ViaManagerImpl) Via.getManager(); manager.init(); - Via.getManager().getProtocolManager().registerBaseProtocol(HostnameParserProtocol.INSTANCE, Range.lessThan(Integer.MIN_VALUE)); + HostnameParserProtocol.INSTANCE.initialize(); + HostnameParserProtocol.INSTANCE.register(Via.getManager().getProviders()); ProtocolVersion.register(-2, "AUTO"); FabricLoader.getInstance().getEntrypoints("viafabric:via_api_initialized", Runnable.class).forEach(Runnable::run); diff --git a/viafabric-mc116/src/main/java/com/viaversion/fabric/mc116/gui/ViaConfigScreen.java b/viafabric-mc116/src/main/java/com/viaversion/fabric/mc116/gui/ViaConfigScreen.java index 2fe8b38..77ce35a 100644 --- a/viafabric-mc116/src/main/java/com/viaversion/fabric/mc116/gui/ViaConfigScreen.java +++ b/viafabric-mc116/src/main/java/com/viaversion/fabric/mc116/gui/ViaConfigScreen.java @@ -20,6 +20,7 @@ package com.viaversion.fabric.mc116.gui; import com.viaversion.fabric.common.config.AbstractViaConfigScreen; import com.viaversion.fabric.mc116.ViaFabric; import com.viaversion.fabric.common.util.ProtocolUtils; +import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.client.MinecraftClient; @@ -95,7 +96,7 @@ public class ViaConfigScreen extends Screen implements AbstractViaConfigScreen { } } - protocolVersion.setEditableColor(getProtocolTextColor(newVersion, validProtocol)); + protocolVersion.setEditableColor(getProtocolTextColor(ProtocolVersion.getProtocol(newVersion), validProtocol)); int finalNewVersion = newVersion; if (latestProtocolSave == null) latestProtocolSave = CompletableFuture.completedFuture(null); diff --git a/viafabric-mc117/src/main/java/com/viaversion/fabric/mc117/ViaFabric.java b/viafabric-mc117/src/main/java/com/viaversion/fabric/mc117/ViaFabric.java index f3f7a7f..e4b9573 100644 --- a/viafabric-mc117/src/main/java/com/viaversion/fabric/mc117/ViaFabric.java +++ b/viafabric-mc117/src/main/java/com/viaversion/fabric/mc117/ViaFabric.java @@ -88,7 +88,8 @@ public class ViaFabric implements ModInitializer { ViaManagerImpl manager = (ViaManagerImpl) Via.getManager(); manager.init(); - Via.getManager().getProtocolManager().registerBaseProtocol(HostnameParserProtocol.INSTANCE, Range.lessThan(Integer.MIN_VALUE)); + HostnameParserProtocol.INSTANCE.initialize(); + HostnameParserProtocol.INSTANCE.register(Via.getManager().getProviders()); ProtocolVersion.register(-2, "AUTO"); FabricLoader.getInstance().getEntrypoints("viafabric:via_api_initialized", Runnable.class).forEach(Runnable::run); diff --git a/viafabric-mc117/src/main/java/com/viaversion/fabric/mc117/gui/ViaConfigScreen.java b/viafabric-mc117/src/main/java/com/viaversion/fabric/mc117/gui/ViaConfigScreen.java index 8fe148b..4daeb77 100644 --- a/viafabric-mc117/src/main/java/com/viaversion/fabric/mc117/gui/ViaConfigScreen.java +++ b/viafabric-mc117/src/main/java/com/viaversion/fabric/mc117/gui/ViaConfigScreen.java @@ -20,6 +20,7 @@ package com.viaversion.fabric.mc117.gui; import com.viaversion.fabric.common.config.AbstractViaConfigScreen; import com.viaversion.fabric.mc117.ViaFabric; import com.viaversion.fabric.common.util.ProtocolUtils; +import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.client.MinecraftClient; @@ -95,7 +96,7 @@ public class ViaConfigScreen extends Screen implements AbstractViaConfigScreen { } } - protocolVersion.setEditableColor(getProtocolTextColor(newVersion, validProtocol)); + protocolVersion.setEditableColor(getProtocolTextColor(ProtocolVersion.getProtocol(newVersion), validProtocol)); int finalNewVersion = newVersion; if (latestProtocolSave == null) latestProtocolSave = CompletableFuture.completedFuture(null); diff --git a/viafabric-mc118/src/main/java/com/viaversion/fabric/mc118/ViaFabric.java b/viafabric-mc118/src/main/java/com/viaversion/fabric/mc118/ViaFabric.java index 187735b..cad3d6d 100644 --- a/viafabric-mc118/src/main/java/com/viaversion/fabric/mc118/ViaFabric.java +++ b/viafabric-mc118/src/main/java/com/viaversion/fabric/mc118/ViaFabric.java @@ -88,7 +88,8 @@ public class ViaFabric implements ModInitializer { ViaManagerImpl manager = (ViaManagerImpl) Via.getManager(); manager.init(); - Via.getManager().getProtocolManager().registerBaseProtocol(HostnameParserProtocol.INSTANCE, Range.lessThan(Integer.MIN_VALUE)); + HostnameParserProtocol.INSTANCE.initialize(); + HostnameParserProtocol.INSTANCE.register(Via.getManager().getProviders()); ProtocolVersion.register(-2, "AUTO"); FabricLoader.getInstance().getEntrypoints("viafabric:via_api_initialized", Runnable.class).forEach(Runnable::run); diff --git a/viafabric-mc118/src/main/java/com/viaversion/fabric/mc118/gui/ViaConfigScreen.java b/viafabric-mc118/src/main/java/com/viaversion/fabric/mc118/gui/ViaConfigScreen.java index 95fc8c1..db89e35 100644 --- a/viafabric-mc118/src/main/java/com/viaversion/fabric/mc118/gui/ViaConfigScreen.java +++ b/viafabric-mc118/src/main/java/com/viaversion/fabric/mc118/gui/ViaConfigScreen.java @@ -20,6 +20,7 @@ package com.viaversion.fabric.mc118.gui; import com.viaversion.fabric.common.config.AbstractViaConfigScreen; import com.viaversion.fabric.mc118.ViaFabric; import com.viaversion.fabric.common.util.ProtocolUtils; +import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.client.MinecraftClient; @@ -95,7 +96,7 @@ public class ViaConfigScreen extends Screen implements AbstractViaConfigScreen { } } - protocolVersion.setEditableColor(getProtocolTextColor(newVersion, validProtocol)); + protocolVersion.setEditableColor(getProtocolTextColor(ProtocolVersion.getProtocol(newVersion), validProtocol)); int finalNewVersion = newVersion; if (latestProtocolSave == null) latestProtocolSave = CompletableFuture.completedFuture(null); diff --git a/viafabric-mc119/src/main/java/com/viaversion/fabric/mc119/ViaFabric.java b/viafabric-mc119/src/main/java/com/viaversion/fabric/mc119/ViaFabric.java index 27178b1..17b7880 100644 --- a/viafabric-mc119/src/main/java/com/viaversion/fabric/mc119/ViaFabric.java +++ b/viafabric-mc119/src/main/java/com/viaversion/fabric/mc119/ViaFabric.java @@ -88,7 +88,8 @@ public class ViaFabric implements ModInitializer { ViaManagerImpl manager = (ViaManagerImpl) Via.getManager(); manager.init(); - Via.getManager().getProtocolManager().registerBaseProtocol(HostnameParserProtocol.INSTANCE, Range.lessThan(Integer.MIN_VALUE)); + HostnameParserProtocol.INSTANCE.initialize(); + HostnameParserProtocol.INSTANCE.register(Via.getManager().getProviders()); ProtocolVersion.register(-2, "AUTO"); FabricLoader.getInstance().getEntrypoints("viafabric:via_api_initialized", Runnable.class).forEach(Runnable::run); diff --git a/viafabric-mc119/src/main/java/com/viaversion/fabric/mc119/gui/ViaConfigScreen.java b/viafabric-mc119/src/main/java/com/viaversion/fabric/mc119/gui/ViaConfigScreen.java index b5f3645..2e553c2 100644 --- a/viafabric-mc119/src/main/java/com/viaversion/fabric/mc119/gui/ViaConfigScreen.java +++ b/viafabric-mc119/src/main/java/com/viaversion/fabric/mc119/gui/ViaConfigScreen.java @@ -20,6 +20,7 @@ package com.viaversion.fabric.mc119.gui; import com.viaversion.fabric.common.config.AbstractViaConfigScreen; import com.viaversion.fabric.mc119.ViaFabric; import com.viaversion.fabric.common.util.ProtocolUtils; +import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.client.MinecraftClient; @@ -99,7 +100,7 @@ public class ViaConfigScreen extends Screen implements AbstractViaConfigScreen { } } - protocolVersion.setEditableColor(getProtocolTextColor(newVersion, validProtocol)); + protocolVersion.setEditableColor(getProtocolTextColor(ProtocolVersion.getProtocol(newVersion), validProtocol)); int finalNewVersion = newVersion; if (latestProtocolSave == null) latestProtocolSave = CompletableFuture.completedFuture(null); diff --git a/viafabric-mc120/src/main/java/com/viaversion/fabric/mc120/ViaFabric.java b/viafabric-mc120/src/main/java/com/viaversion/fabric/mc120/ViaFabric.java index 64cefc7..dbdcb1c 100644 --- a/viafabric-mc120/src/main/java/com/viaversion/fabric/mc120/ViaFabric.java +++ b/viafabric-mc120/src/main/java/com/viaversion/fabric/mc120/ViaFabric.java @@ -88,7 +88,8 @@ public class ViaFabric implements ModInitializer { ViaManagerImpl manager = (ViaManagerImpl) Via.getManager(); manager.init(); - Via.getManager().getProtocolManager().registerBaseProtocol(HostnameParserProtocol.INSTANCE, Range.lessThan(Integer.MIN_VALUE)); + HostnameParserProtocol.INSTANCE.initialize(); + HostnameParserProtocol.INSTANCE.register(Via.getManager().getProviders()); ProtocolVersion.register(-2, "AUTO"); FabricLoader.getInstance().getEntrypoints("viafabric:via_api_initialized", Runnable.class).forEach(Runnable::run); diff --git a/viafabric-mc120/src/main/java/com/viaversion/fabric/mc120/gui/ViaConfigScreen.java b/viafabric-mc120/src/main/java/com/viaversion/fabric/mc120/gui/ViaConfigScreen.java index 8a66127..3f6fc6b 100644 --- a/viafabric-mc120/src/main/java/com/viaversion/fabric/mc120/gui/ViaConfigScreen.java +++ b/viafabric-mc120/src/main/java/com/viaversion/fabric/mc120/gui/ViaConfigScreen.java @@ -20,6 +20,7 @@ package com.viaversion.fabric.mc120.gui; import com.viaversion.fabric.common.config.AbstractViaConfigScreen; import com.viaversion.fabric.mc120.ViaFabric; import com.viaversion.fabric.common.util.ProtocolUtils; +import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.client.MinecraftClient; @@ -99,7 +100,7 @@ public class ViaConfigScreen extends Screen implements AbstractViaConfigScreen { } } - protocolVersion.setEditableColor(getProtocolTextColor(newVersion, validProtocol)); + protocolVersion.setEditableColor(getProtocolTextColor(ProtocolVersion.getProtocol(newVersion), validProtocol)); int finalNewVersion = newVersion; if (latestProtocolSave == null) latestProtocolSave = CompletableFuture.completedFuture(null); diff --git a/viafabric-mc18/src/main/java/com/viaversion/fabric/mc18/ViaFabric.java b/viafabric-mc18/src/main/java/com/viaversion/fabric/mc18/ViaFabric.java index 9503b34..d7e8879 100644 --- a/viafabric-mc18/src/main/java/com/viaversion/fabric/mc18/ViaFabric.java +++ b/viafabric-mc18/src/main/java/com/viaversion/fabric/mc18/ViaFabric.java @@ -72,7 +72,8 @@ public class ViaFabric implements ModInitializer { ViaManagerImpl manager = (ViaManagerImpl) Via.getManager(); manager.init(); - Via.getManager().getProtocolManager().registerBaseProtocol(HostnameParserProtocol.INSTANCE, Range.lessThan(Integer.MIN_VALUE)); + HostnameParserProtocol.INSTANCE.initialize(); + HostnameParserProtocol.INSTANCE.register(Via.getManager().getProviders()); ProtocolVersion.register(-2, "AUTO"); FabricLoader.getInstance().getEntrypoints("viafabric:via_api_initialized", Runnable.class).forEach(Runnable::run); diff --git a/viafabric-mc18/src/main/java/com/viaversion/fabric/mc18/gui/ViaConfigScreen.java b/viafabric-mc18/src/main/java/com/viaversion/fabric/mc18/gui/ViaConfigScreen.java index 020f69a..ea10b18 100644 --- a/viafabric-mc18/src/main/java/com/viaversion/fabric/mc18/gui/ViaConfigScreen.java +++ b/viafabric-mc18/src/main/java/com/viaversion/fabric/mc18/gui/ViaConfigScreen.java @@ -20,6 +20,7 @@ package com.viaversion.fabric.mc18.gui; import com.viaversion.fabric.common.config.AbstractViaConfigScreen; import com.viaversion.fabric.mc18.ViaFabric; import com.viaversion.fabric.common.util.ProtocolUtils; +import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.client.MinecraftClient; @@ -95,7 +96,7 @@ public class ViaConfigScreen extends Screen implements AbstractViaConfigScreen { validProtocol = false; } - protocolVersion.setEditableColor(getProtocolTextColor(newVersion, validProtocol)); + protocolVersion.setEditableColor(getProtocolTextColor(ProtocolVersion.getProtocol(newVersion), validProtocol)); int finalNewVersion = newVersion; if (latestProtocolSave == null) latestProtocolSave = CompletableFuture.completedFuture(null);