mirror of
https://github.com/ViaVersion/ViaFabric.git
synced 2024-12-20 16:07:36 +01:00
Port to upstream changes (maybe)
This commit is contained in:
parent
2971cdedeb
commit
fbd46800c0
@ -2,7 +2,7 @@
|
|||||||
org.gradle.jvmargs=-Xms32M -Xmx4G -XX:+UseG1GC -XX:+UseStringDeduplication
|
org.gradle.jvmargs=-Xms32M -Xmx4G -XX:+UseG1GC -XX:+UseStringDeduplication
|
||||||
|
|
||||||
loader_version=0.15.6
|
loader_version=0.15.6
|
||||||
viaver_version=4.10.0-24w06a-SNAPSHOT
|
viaver_version=4.10.0-24w07a-SNAPSHOT
|
||||||
yaml_version=2.2
|
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
|
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
|
||||||
|
@ -18,14 +18,15 @@
|
|||||||
package com.viaversion.fabric.common.config;
|
package com.viaversion.fabric.common.config;
|
||||||
|
|
||||||
import com.viaversion.fabric.common.util.ProtocolUtils;
|
import com.viaversion.fabric.common.util.ProtocolUtils;
|
||||||
|
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||||
|
|
||||||
public interface AbstractViaConfigScreen {
|
public interface AbstractViaConfigScreen {
|
||||||
String TITLE_TRANSLATE_ID = "gui.viafabric_config.title";
|
String TITLE_TRANSLATE_ID = "gui.viafabric_config.title";
|
||||||
String VERSION_TRANSLATE_ID = "gui.protocol_version_field.name";
|
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 (!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
|
if (!ProtocolUtils.isSupportedClientSide(version)) return 0xFFA500; // Orange
|
||||||
return 0xE0E0E0; // Default
|
return 0xE0E0E0; // Default
|
||||||
}
|
}
|
||||||
|
@ -21,13 +21,15 @@ import com.viaversion.fabric.common.handler.CommonTransformer;
|
|||||||
import com.viaversion.viaversion.api.Via;
|
import com.viaversion.viaversion.api.Via;
|
||||||
import com.viaversion.viaversion.api.platform.ViaInjector;
|
import com.viaversion.viaversion.api.platform.ViaInjector;
|
||||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
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 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.api.EnvType;
|
||||||
import net.fabricmc.loader.api.FabricLoader;
|
import net.fabricmc.loader.api.FabricLoader;
|
||||||
|
|
||||||
|
import java.util.OptionalInt;
|
||||||
|
|
||||||
public class FabricInjector implements ViaInjector {
|
public class FabricInjector implements ViaInjector {
|
||||||
@Override
|
@Override
|
||||||
public void inject() {
|
public void inject() {
|
||||||
@ -55,23 +57,21 @@ public class FabricInjector implements ViaInjector {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IntSortedSet getServerProtocolVersions() {
|
public ObjectSortedSet<ProtocolVersion> getServerProtocolVersions() {
|
||||||
if (FabricLoader.getInstance().getEnvironmentType() == EnvType.SERVER) {
|
if (FabricLoader.getInstance().getEnvironmentType() == EnvType.SERVER) {
|
||||||
int version = Via.getManager().getProviders().get(NativeVersionProvider.class).getNativeServerVersion();
|
final ProtocolVersion version = Via.getManager().getProviders().get(NativeVersionProvider.class).getNativeServerProtocolVersion();
|
||||||
return IntSortedSets.singleton(version);
|
return ObjectSortedSets.singleton(version);
|
||||||
}
|
}
|
||||||
// On client-side we can connect to any server version
|
// On client-side we can connect to any server version
|
||||||
IntSortedSet versions = new IntLinkedOpenHashSet();
|
ObjectSortedSet<ProtocolVersion> versions = new ObjectLinkedOpenHashSet<>();
|
||||||
versions.add(ProtocolVersion.v1_8.getOriginalVersion());
|
versions.add(ProtocolVersion.v1_8);
|
||||||
versions.add(ProtocolVersion.getProtocols()
|
final OptionalInt highestSupportedVersion = ProtocolVersion.getProtocols().stream().mapToInt(ProtocolVersion::getOriginalVersion).max();
|
||||||
.stream()
|
versions.add(ProtocolVersion.getProtocol(highestSupportedVersion.getAsInt()));
|
||||||
.mapToInt(ProtocolVersion::getOriginalVersion)
|
|
||||||
.max().getAsInt());
|
|
||||||
return versions;
|
return versions;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getServerProtocolVersion() {
|
public ProtocolVersion getServerProtocolVersion() {
|
||||||
return getServerProtocolVersions().firstInt();
|
return getServerProtocolVersions().first();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,8 +18,20 @@
|
|||||||
package com.viaversion.fabric.common.platform;
|
package com.viaversion.fabric.common.platform;
|
||||||
|
|
||||||
import com.viaversion.viaversion.ViaAPIBase;
|
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;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class FabricViaAPI extends ViaAPIBase<UUID> {
|
public class FabricViaAPI extends ViaAPIBase<UserConnection> {
|
||||||
|
@Override
|
||||||
|
public ProtocolVersion getPlayerProtocolVersion(UserConnection player) {
|
||||||
|
return player.getProtocolInfo().protocolVersion();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void sendRawPacket(UserConnection player, ByteBuf packet) {
|
||||||
|
player.scheduleSendRawPacket(packet);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,13 @@
|
|||||||
package com.viaversion.fabric.common.platform;
|
package com.viaversion.fabric.common.platform;
|
||||||
|
|
||||||
import com.viaversion.viaversion.api.platform.providers.Provider;
|
import com.viaversion.viaversion.api.platform.providers.Provider;
|
||||||
|
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||||
|
|
||||||
public interface NativeVersionProvider extends Provider {
|
public interface NativeVersionProvider extends Provider {
|
||||||
|
|
||||||
int getNativeServerVersion();
|
int getNativeServerVersion();
|
||||||
|
|
||||||
|
default ProtocolVersion getNativeServerProtocolVersion() {
|
||||||
|
return ProtocolVersion.getProtocol(getNativeServerVersion());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,7 @@ import com.viaversion.viaversion.api.Via;
|
|||||||
import com.viaversion.viaversion.api.ViaAPI;
|
import com.viaversion.viaversion.api.ViaAPI;
|
||||||
import com.viaversion.viaversion.api.configuration.ConfigurationProvider;
|
import com.viaversion.viaversion.api.configuration.ConfigurationProvider;
|
||||||
import com.viaversion.viaversion.api.configuration.ViaVersionConfig;
|
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.UnsupportedSoftware;
|
||||||
import com.viaversion.viaversion.api.platform.ViaPlatform;
|
import com.viaversion.viaversion.api.platform.ViaPlatform;
|
||||||
import com.viaversion.viaversion.libs.gson.JsonArray;
|
import com.viaversion.viaversion.libs.gson.JsonArray;
|
||||||
@ -54,11 +55,11 @@ import java.util.concurrent.ExecutorService;
|
|||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
public abstract class AbstractFabricPlatform implements ViaPlatform<UUID> {
|
public abstract class AbstractFabricPlatform implements ViaPlatform<UserConnection> {
|
||||||
private final Logger logger = new JLoggerToLog4j(LogManager.getLogger("ViaVersion"));
|
private final Logger logger = new JLoggerToLog4j(LogManager.getLogger("ViaVersion"));
|
||||||
private FabricViaConfig config;
|
private FabricViaConfig config;
|
||||||
private File dataFolder;
|
private File dataFolder;
|
||||||
private final ViaAPI<UUID> api;
|
private final ViaAPI<UserConnection> api;
|
||||||
|
|
||||||
{
|
{
|
||||||
api = new FabricViaAPI();
|
api = new FabricViaAPI();
|
||||||
@ -148,7 +149,7 @@ public abstract class AbstractFabricPlatform implements ViaPlatform<UUID> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ViaAPI<UUID> getApi() {
|
public ViaAPI<UserConnection> getApi() {
|
||||||
return api;
|
return api;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -214,7 +215,7 @@ public abstract class AbstractFabricPlatform implements ViaPlatform<UUID> {
|
|||||||
platformSpecific.add("mods", mods);
|
platformSpecific.add("mods", mods);
|
||||||
NativeVersionProvider ver = Via.getManager().getProviders().get(NativeVersionProvider.class);
|
NativeVersionProvider ver = Via.getManager().getProviders().get(NativeVersionProvider.class);
|
||||||
if (ver != null) {
|
if (ver != null) {
|
||||||
platformSpecific.addProperty("native version", ver.getNativeServerVersion());
|
platformSpecific.addProperty("native version", ver.getNativeServerProtocolVersion().getVersion());
|
||||||
}
|
}
|
||||||
return platformSpecific;
|
return platformSpecific;
|
||||||
}
|
}
|
||||||
|
@ -82,11 +82,11 @@ public abstract class AbstractFabricVersionProvider extends BaseVersionProvider
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getClosestServerProtocol(UserConnection connection) throws Exception {
|
public ProtocolVersion getClosestServerProtocol(UserConnection connection) throws Exception {
|
||||||
if (connection.isClientSide()) {
|
if (connection.isClientSide()) {
|
||||||
ProtocolInfo info = Objects.requireNonNull(connection.getProtocolInfo());
|
ProtocolInfo info = Objects.requireNonNull(connection.getProtocolInfo());
|
||||||
|
|
||||||
if (!getConfig().isClientSideEnabled()) return info.getProtocolVersion();
|
if (!getConfig().isClientSideEnabled()) return info.protocolVersion();
|
||||||
|
|
||||||
int serverVer = getConfig().getClientSideVersion();
|
int serverVer = getConfig().getClientSideVersion();
|
||||||
SocketAddress addr = connection.getChannel().remoteAddress();
|
SocketAddress addr = connection.getChannel().remoteAddress();
|
||||||
@ -112,18 +112,20 @@ public abstract class AbstractFabricVersionProvider extends BaseVersionProvider
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean blocked = checkAddressBlocked(addr);
|
ProtocolVersion serverVersion = ProtocolVersion.getProtocol(serverVer);
|
||||||
boolean supported = ProtocolUtils.isSupported(serverVer, info.getProtocolVersion());
|
|
||||||
|
|
||||||
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();
|
if (blocked || !supported) serverVer = info.getProtocolVersion();
|
||||||
|
|
||||||
return serverVer;
|
return ProtocolVersion.getProtocol(serverVer);
|
||||||
}
|
}
|
||||||
NativeVersionProvider natProvider = Via.getManager().getProviders().get(NativeVersionProvider.class);
|
NativeVersionProvider natProvider = Via.getManager().getProviders().get(NativeVersionProvider.class);
|
||||||
if (natProvider != null) {
|
if (natProvider != null) {
|
||||||
return ProtocolVersion.getProtocol(natProvider.getNativeServerVersion()).getVersion();
|
return natProvider.getNativeServerProtocolVersion();
|
||||||
}
|
}
|
||||||
return super.getClosestServerProtocol(connection);
|
return super.getClosestServerProtocol(connection);
|
||||||
}
|
}
|
||||||
@ -135,15 +137,15 @@ public abstract class AbstractFabricVersionProvider extends BaseVersionProvider
|
|||||||
|| isDisabled(((InetSocketAddress) addr).getAddress().getHostName()))));
|
|| 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
|
if (info.getState() == State.STATUS
|
||||||
&& info.getProtocolVersion() == -1
|
&& info.getProtocolVersion() == -1
|
||||||
&& isMulticonnectHandler(connection.getChannel().pipeline())
|
&& isMulticonnectHandler(connection.getChannel().pipeline())
|
||||||
&& (blocked || ProtocolUtils.isSupported(serverVer, getVersionForMulticonnect(serverVer)))) { // Intercept the connection
|
&& (blocked || ProtocolUtils.isSupported(serverVer, getVersionForMulticonnect(serverVer)))) { // Intercept the connection
|
||||||
int multiconnectSuggestion = blocked ? -1 : getVersionForMulticonnect(serverVer);
|
ProtocolVersion multiconnectSuggestion = blocked ? ProtocolVersion.unknown : getVersionForMulticonnect(serverVer);
|
||||||
getLogger().info("Sending " + ProtocolVersion.getProtocol(multiconnectSuggestion) + " for multiconnect version detector");
|
getLogger().info("Sending " + multiconnectSuggestion + " for multiconnect version detector");
|
||||||
PacketWrapper newAnswer = PacketWrapper.create(ClientboundStatusPackets.STATUS_RESPONSE, null, connection);
|
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);
|
newAnswer.send(info.getPipeline().contains(BaseProtocol1_16.class) ? BaseProtocol1_16.class : BaseProtocol1_7.class);
|
||||||
throw CancelException.generate();
|
throw CancelException.generate();
|
||||||
}
|
}
|
||||||
@ -153,23 +155,23 @@ public abstract class AbstractFabricVersionProvider extends BaseVersionProvider
|
|||||||
return false;
|
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
|
// https://github.com/ViaVersion/ViaVersion/blob/master/velocity/src/main/java/us/myles/ViaVersion/velocity/providers/VelocityVersionProvider.java
|
||||||
int[] compatibleProtocols = multiconnectSupportedVersions;
|
int[] compatibleProtocols = multiconnectSupportedVersions;
|
||||||
|
|
||||||
if (Arrays.binarySearch(compatibleProtocols, clientSideVersion) >= 0) {
|
if (Arrays.binarySearch(compatibleProtocols, clientSideVersion.getVersion()) >= 0) {
|
||||||
return clientSideVersion;
|
return clientSideVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (clientSideVersion < compatibleProtocols[0]) {
|
if (clientSideVersion.getVersion() < compatibleProtocols[0]) {
|
||||||
return compatibleProtocols[0];
|
return ProtocolVersion.getProtocol(compatibleProtocols[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: This needs a better fix, i.e checking ProtocolRegistry to see if it would work.
|
// 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--) {
|
for (int i = compatibleProtocols.length - 1; i >= 0; i--) {
|
||||||
int protocol = compatibleProtocols[i];
|
int protocol = compatibleProtocols[i];
|
||||||
if (clientSideVersion > protocol && ProtocolVersion.isRegistered(protocol)) {
|
if (clientSideVersion.getVersion() > protocol && ProtocolVersion.isRegistered(protocol)) {
|
||||||
return protocol;
|
return ProtocolVersion.getProtocol(protocol);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,14 +25,14 @@ import java.util.Arrays;
|
|||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
public class ProtocolUtils {
|
public class ProtocolUtils {
|
||||||
public static boolean isSupportedClientSide(int server) {
|
public static boolean isSupportedClientSide(ProtocolVersion server) {
|
||||||
return isSupported(server, Via.getManager().getProviders()
|
return isSupported(server, Via.getManager().getProviders()
|
||||||
.get(NativeVersionProvider.class)
|
.get(NativeVersionProvider.class)
|
||||||
.getNativeServerVersion());
|
.getNativeServerProtocolVersion());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isSupported(int server, int client) {
|
public static boolean isSupported(ProtocolVersion server, ProtocolVersion client) {
|
||||||
return server == client || Via.getManager().getProtocolManager().getProtocolPath(client, server) != null;
|
return server.equals(client) || Via.getManager().getProtocolManager().getProtocolPath(client, server) != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getProtocolName(int id) {
|
public static String getProtocolName(int id) {
|
||||||
@ -40,6 +40,10 @@ public class ProtocolUtils {
|
|||||||
return ProtocolVersion.getProtocol(id).getName();
|
return ProtocolVersion.getProtocol(id).getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isValid(final ProtocolVersion version) {
|
||||||
|
return version.isKnown() && version.getVersion() != -2;
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean isStartOfProtocolText(String s) {
|
public static boolean isStartOfProtocolText(String s) {
|
||||||
try {
|
try {
|
||||||
Integer.parseInt(s);
|
Integer.parseInt(s);
|
||||||
|
@ -72,7 +72,8 @@ public class ViaFabric implements ModInitializer {
|
|||||||
ViaManagerImpl manager = (ViaManagerImpl) Via.getManager();
|
ViaManagerImpl manager = (ViaManagerImpl) Via.getManager();
|
||||||
manager.init();
|
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");
|
ProtocolVersion.register(-2, "AUTO");
|
||||||
|
|
||||||
FabricLoader.getInstance().getEntrypoints("viafabric:via_api_initialized", Runnable.class).forEach(Runnable::run);
|
FabricLoader.getInstance().getEntrypoints("viafabric:via_api_initialized", Runnable.class).forEach(Runnable::run);
|
||||||
|
@ -20,6 +20,7 @@ package com.viaversion.fabric.mc112.gui;
|
|||||||
import com.viaversion.fabric.common.config.AbstractViaConfigScreen;
|
import com.viaversion.fabric.common.config.AbstractViaConfigScreen;
|
||||||
import com.viaversion.fabric.mc112.ViaFabric;
|
import com.viaversion.fabric.mc112.ViaFabric;
|
||||||
import com.viaversion.fabric.common.util.ProtocolUtils;
|
import com.viaversion.fabric.common.util.ProtocolUtils;
|
||||||
|
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||||
import net.fabricmc.api.EnvType;
|
import net.fabricmc.api.EnvType;
|
||||||
import net.fabricmc.api.Environment;
|
import net.fabricmc.api.Environment;
|
||||||
import net.minecraft.client.MinecraftClient;
|
import net.minecraft.client.MinecraftClient;
|
||||||
@ -95,7 +96,7 @@ public class ViaConfigScreen extends Screen implements AbstractViaConfigScreen {
|
|||||||
validProtocol = false;
|
validProtocol = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protocolVersion.setEditableColor(getProtocolTextColor(newVersion, validProtocol));
|
protocolVersion.setEditableColor(getProtocolTextColor(ProtocolVersion.getProtocol(newVersion), validProtocol));
|
||||||
|
|
||||||
int finalNewVersion = newVersion;
|
int finalNewVersion = newVersion;
|
||||||
if (latestProtocolSave == null) latestProtocolSave = CompletableFuture.completedFuture(null);
|
if (latestProtocolSave == null) latestProtocolSave = CompletableFuture.completedFuture(null);
|
||||||
|
@ -35,7 +35,7 @@ public class FabricNativeVersionProvider implements NativeVersionProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ServerMetadata.Version version = MinecraftClient.getInstance().getServer().getServerMetadata().getVersion();
|
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();
|
return version.getProtocolVersion();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -46,6 +46,6 @@ public class FabricNativeVersionProvider implements NativeVersionProvider {
|
|||||||
} catch (IllegalAccessException | NoSuchFieldException e) {
|
} catch (IllegalAccessException | NoSuchFieldException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
return ProtocolVersion.v1_8.getVersion(); // fallback
|
return ProtocolVersion.v1_12_2.getVersion(); // fallback
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -86,7 +86,8 @@ public class ViaFabric implements ModInitializer {
|
|||||||
ViaManagerImpl manager = (ViaManagerImpl) Via.getManager();
|
ViaManagerImpl manager = (ViaManagerImpl) Via.getManager();
|
||||||
manager.init();
|
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");
|
ProtocolVersion.register(-2, "AUTO");
|
||||||
|
|
||||||
FabricLoader.getInstance().getEntrypoints("viafabric:via_api_initialized", Runnable.class).forEach(Runnable::run);
|
FabricLoader.getInstance().getEntrypoints("viafabric:via_api_initialized", Runnable.class).forEach(Runnable::run);
|
||||||
|
@ -20,6 +20,7 @@ package com.viaversion.fabric.mc114.gui;
|
|||||||
import com.viaversion.fabric.common.config.AbstractViaConfigScreen;
|
import com.viaversion.fabric.common.config.AbstractViaConfigScreen;
|
||||||
import com.viaversion.fabric.mc114.ViaFabric;
|
import com.viaversion.fabric.mc114.ViaFabric;
|
||||||
import com.viaversion.fabric.common.util.ProtocolUtils;
|
import com.viaversion.fabric.common.util.ProtocolUtils;
|
||||||
|
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||||
import net.fabricmc.api.EnvType;
|
import net.fabricmc.api.EnvType;
|
||||||
import net.fabricmc.api.Environment;
|
import net.fabricmc.api.Environment;
|
||||||
import net.minecraft.client.MinecraftClient;
|
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;
|
int finalNewVersion = newVersion;
|
||||||
if (latestProtocolSave == null) latestProtocolSave = CompletableFuture.completedFuture(null);
|
if (latestProtocolSave == null) latestProtocolSave = CompletableFuture.completedFuture(null);
|
||||||
|
@ -86,7 +86,8 @@ public class ViaFabric implements ModInitializer {
|
|||||||
ViaManagerImpl manager = (ViaManagerImpl) Via.getManager();
|
ViaManagerImpl manager = (ViaManagerImpl) Via.getManager();
|
||||||
manager.init();
|
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");
|
ProtocolVersion.register(-2, "AUTO");
|
||||||
|
|
||||||
FabricLoader.getInstance().getEntrypoints("viafabric:via_api_initialized", Runnable.class).forEach(Runnable::run);
|
FabricLoader.getInstance().getEntrypoints("viafabric:via_api_initialized", Runnable.class).forEach(Runnable::run);
|
||||||
|
@ -20,6 +20,7 @@ package com.viaversion.fabric.mc115.gui;
|
|||||||
import com.viaversion.fabric.common.config.AbstractViaConfigScreen;
|
import com.viaversion.fabric.common.config.AbstractViaConfigScreen;
|
||||||
import com.viaversion.fabric.mc115.ViaFabric;
|
import com.viaversion.fabric.mc115.ViaFabric;
|
||||||
import com.viaversion.fabric.common.util.ProtocolUtils;
|
import com.viaversion.fabric.common.util.ProtocolUtils;
|
||||||
|
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||||
import net.fabricmc.api.EnvType;
|
import net.fabricmc.api.EnvType;
|
||||||
import net.fabricmc.api.Environment;
|
import net.fabricmc.api.Environment;
|
||||||
import net.minecraft.client.MinecraftClient;
|
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;
|
int finalNewVersion = newVersion;
|
||||||
if (latestProtocolSave == null) latestProtocolSave = CompletableFuture.completedFuture(null);
|
if (latestProtocolSave == null) latestProtocolSave = CompletableFuture.completedFuture(null);
|
||||||
|
@ -88,7 +88,8 @@ public class ViaFabric implements ModInitializer {
|
|||||||
ViaManagerImpl manager = (ViaManagerImpl) Via.getManager();
|
ViaManagerImpl manager = (ViaManagerImpl) Via.getManager();
|
||||||
manager.init();
|
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");
|
ProtocolVersion.register(-2, "AUTO");
|
||||||
|
|
||||||
FabricLoader.getInstance().getEntrypoints("viafabric:via_api_initialized", Runnable.class).forEach(Runnable::run);
|
FabricLoader.getInstance().getEntrypoints("viafabric:via_api_initialized", Runnable.class).forEach(Runnable::run);
|
||||||
|
@ -20,6 +20,7 @@ package com.viaversion.fabric.mc116.gui;
|
|||||||
import com.viaversion.fabric.common.config.AbstractViaConfigScreen;
|
import com.viaversion.fabric.common.config.AbstractViaConfigScreen;
|
||||||
import com.viaversion.fabric.mc116.ViaFabric;
|
import com.viaversion.fabric.mc116.ViaFabric;
|
||||||
import com.viaversion.fabric.common.util.ProtocolUtils;
|
import com.viaversion.fabric.common.util.ProtocolUtils;
|
||||||
|
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||||
import net.fabricmc.api.EnvType;
|
import net.fabricmc.api.EnvType;
|
||||||
import net.fabricmc.api.Environment;
|
import net.fabricmc.api.Environment;
|
||||||
import net.minecraft.client.MinecraftClient;
|
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;
|
int finalNewVersion = newVersion;
|
||||||
if (latestProtocolSave == null) latestProtocolSave = CompletableFuture.completedFuture(null);
|
if (latestProtocolSave == null) latestProtocolSave = CompletableFuture.completedFuture(null);
|
||||||
|
@ -88,7 +88,8 @@ public class ViaFabric implements ModInitializer {
|
|||||||
ViaManagerImpl manager = (ViaManagerImpl) Via.getManager();
|
ViaManagerImpl manager = (ViaManagerImpl) Via.getManager();
|
||||||
manager.init();
|
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");
|
ProtocolVersion.register(-2, "AUTO");
|
||||||
|
|
||||||
FabricLoader.getInstance().getEntrypoints("viafabric:via_api_initialized", Runnable.class).forEach(Runnable::run);
|
FabricLoader.getInstance().getEntrypoints("viafabric:via_api_initialized", Runnable.class).forEach(Runnable::run);
|
||||||
|
@ -20,6 +20,7 @@ package com.viaversion.fabric.mc117.gui;
|
|||||||
import com.viaversion.fabric.common.config.AbstractViaConfigScreen;
|
import com.viaversion.fabric.common.config.AbstractViaConfigScreen;
|
||||||
import com.viaversion.fabric.mc117.ViaFabric;
|
import com.viaversion.fabric.mc117.ViaFabric;
|
||||||
import com.viaversion.fabric.common.util.ProtocolUtils;
|
import com.viaversion.fabric.common.util.ProtocolUtils;
|
||||||
|
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||||
import net.fabricmc.api.EnvType;
|
import net.fabricmc.api.EnvType;
|
||||||
import net.fabricmc.api.Environment;
|
import net.fabricmc.api.Environment;
|
||||||
import net.minecraft.client.MinecraftClient;
|
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;
|
int finalNewVersion = newVersion;
|
||||||
if (latestProtocolSave == null) latestProtocolSave = CompletableFuture.completedFuture(null);
|
if (latestProtocolSave == null) latestProtocolSave = CompletableFuture.completedFuture(null);
|
||||||
|
@ -88,7 +88,8 @@ public class ViaFabric implements ModInitializer {
|
|||||||
ViaManagerImpl manager = (ViaManagerImpl) Via.getManager();
|
ViaManagerImpl manager = (ViaManagerImpl) Via.getManager();
|
||||||
manager.init();
|
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");
|
ProtocolVersion.register(-2, "AUTO");
|
||||||
|
|
||||||
FabricLoader.getInstance().getEntrypoints("viafabric:via_api_initialized", Runnable.class).forEach(Runnable::run);
|
FabricLoader.getInstance().getEntrypoints("viafabric:via_api_initialized", Runnable.class).forEach(Runnable::run);
|
||||||
|
@ -20,6 +20,7 @@ package com.viaversion.fabric.mc118.gui;
|
|||||||
import com.viaversion.fabric.common.config.AbstractViaConfigScreen;
|
import com.viaversion.fabric.common.config.AbstractViaConfigScreen;
|
||||||
import com.viaversion.fabric.mc118.ViaFabric;
|
import com.viaversion.fabric.mc118.ViaFabric;
|
||||||
import com.viaversion.fabric.common.util.ProtocolUtils;
|
import com.viaversion.fabric.common.util.ProtocolUtils;
|
||||||
|
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||||
import net.fabricmc.api.EnvType;
|
import net.fabricmc.api.EnvType;
|
||||||
import net.fabricmc.api.Environment;
|
import net.fabricmc.api.Environment;
|
||||||
import net.minecraft.client.MinecraftClient;
|
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;
|
int finalNewVersion = newVersion;
|
||||||
if (latestProtocolSave == null) latestProtocolSave = CompletableFuture.completedFuture(null);
|
if (latestProtocolSave == null) latestProtocolSave = CompletableFuture.completedFuture(null);
|
||||||
|
@ -88,7 +88,8 @@ public class ViaFabric implements ModInitializer {
|
|||||||
ViaManagerImpl manager = (ViaManagerImpl) Via.getManager();
|
ViaManagerImpl manager = (ViaManagerImpl) Via.getManager();
|
||||||
manager.init();
|
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");
|
ProtocolVersion.register(-2, "AUTO");
|
||||||
|
|
||||||
FabricLoader.getInstance().getEntrypoints("viafabric:via_api_initialized", Runnable.class).forEach(Runnable::run);
|
FabricLoader.getInstance().getEntrypoints("viafabric:via_api_initialized", Runnable.class).forEach(Runnable::run);
|
||||||
|
@ -20,6 +20,7 @@ package com.viaversion.fabric.mc119.gui;
|
|||||||
import com.viaversion.fabric.common.config.AbstractViaConfigScreen;
|
import com.viaversion.fabric.common.config.AbstractViaConfigScreen;
|
||||||
import com.viaversion.fabric.mc119.ViaFabric;
|
import com.viaversion.fabric.mc119.ViaFabric;
|
||||||
import com.viaversion.fabric.common.util.ProtocolUtils;
|
import com.viaversion.fabric.common.util.ProtocolUtils;
|
||||||
|
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||||
import net.fabricmc.api.EnvType;
|
import net.fabricmc.api.EnvType;
|
||||||
import net.fabricmc.api.Environment;
|
import net.fabricmc.api.Environment;
|
||||||
import net.minecraft.client.MinecraftClient;
|
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;
|
int finalNewVersion = newVersion;
|
||||||
if (latestProtocolSave == null) latestProtocolSave = CompletableFuture.completedFuture(null);
|
if (latestProtocolSave == null) latestProtocolSave = CompletableFuture.completedFuture(null);
|
||||||
|
@ -88,7 +88,8 @@ public class ViaFabric implements ModInitializer {
|
|||||||
ViaManagerImpl manager = (ViaManagerImpl) Via.getManager();
|
ViaManagerImpl manager = (ViaManagerImpl) Via.getManager();
|
||||||
manager.init();
|
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");
|
ProtocolVersion.register(-2, "AUTO");
|
||||||
|
|
||||||
FabricLoader.getInstance().getEntrypoints("viafabric:via_api_initialized", Runnable.class).forEach(Runnable::run);
|
FabricLoader.getInstance().getEntrypoints("viafabric:via_api_initialized", Runnable.class).forEach(Runnable::run);
|
||||||
|
@ -20,6 +20,7 @@ package com.viaversion.fabric.mc120.gui;
|
|||||||
import com.viaversion.fabric.common.config.AbstractViaConfigScreen;
|
import com.viaversion.fabric.common.config.AbstractViaConfigScreen;
|
||||||
import com.viaversion.fabric.mc120.ViaFabric;
|
import com.viaversion.fabric.mc120.ViaFabric;
|
||||||
import com.viaversion.fabric.common.util.ProtocolUtils;
|
import com.viaversion.fabric.common.util.ProtocolUtils;
|
||||||
|
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||||
import net.fabricmc.api.EnvType;
|
import net.fabricmc.api.EnvType;
|
||||||
import net.fabricmc.api.Environment;
|
import net.fabricmc.api.Environment;
|
||||||
import net.minecraft.client.MinecraftClient;
|
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;
|
int finalNewVersion = newVersion;
|
||||||
if (latestProtocolSave == null) latestProtocolSave = CompletableFuture.completedFuture(null);
|
if (latestProtocolSave == null) latestProtocolSave = CompletableFuture.completedFuture(null);
|
||||||
|
@ -72,7 +72,8 @@ public class ViaFabric implements ModInitializer {
|
|||||||
ViaManagerImpl manager = (ViaManagerImpl) Via.getManager();
|
ViaManagerImpl manager = (ViaManagerImpl) Via.getManager();
|
||||||
manager.init();
|
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");
|
ProtocolVersion.register(-2, "AUTO");
|
||||||
|
|
||||||
FabricLoader.getInstance().getEntrypoints("viafabric:via_api_initialized", Runnable.class).forEach(Runnable::run);
|
FabricLoader.getInstance().getEntrypoints("viafabric:via_api_initialized", Runnable.class).forEach(Runnable::run);
|
||||||
|
@ -20,6 +20,7 @@ package com.viaversion.fabric.mc18.gui;
|
|||||||
import com.viaversion.fabric.common.config.AbstractViaConfigScreen;
|
import com.viaversion.fabric.common.config.AbstractViaConfigScreen;
|
||||||
import com.viaversion.fabric.mc18.ViaFabric;
|
import com.viaversion.fabric.mc18.ViaFabric;
|
||||||
import com.viaversion.fabric.common.util.ProtocolUtils;
|
import com.viaversion.fabric.common.util.ProtocolUtils;
|
||||||
|
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||||
import net.fabricmc.api.EnvType;
|
import net.fabricmc.api.EnvType;
|
||||||
import net.fabricmc.api.Environment;
|
import net.fabricmc.api.Environment;
|
||||||
import net.minecraft.client.MinecraftClient;
|
import net.minecraft.client.MinecraftClient;
|
||||||
@ -95,7 +96,7 @@ public class ViaConfigScreen extends Screen implements AbstractViaConfigScreen {
|
|||||||
validProtocol = false;
|
validProtocol = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protocolVersion.setEditableColor(getProtocolTextColor(newVersion, validProtocol));
|
protocolVersion.setEditableColor(getProtocolTextColor(ProtocolVersion.getProtocol(newVersion), validProtocol));
|
||||||
|
|
||||||
int finalNewVersion = newVersion;
|
int finalNewVersion = newVersion;
|
||||||
if (latestProtocolSave == null) latestProtocolSave = CompletableFuture.completedFuture(null);
|
if (latestProtocolSave == null) latestProtocolSave = CompletableFuture.completedFuture(null);
|
||||||
|
Loading…
Reference in New Issue
Block a user