From 46cc0b729fa0b0790ea4e44a632c03d64b1e90af Mon Sep 17 00:00:00 2001 From: creeper123123321 <7974274+creeper123123321@users.noreply.github.com> Date: Tue, 25 Aug 2020 10:22:18 -0300 Subject: [PATCH] 0.2.9, fix ProtocolViaFabricHostname, update README --- README.md | 4 ++++ build.gradle.kts | 2 +- .../com/github/creeper123123321/viafabric/ViaFabric.java | 5 +++++ .../mixin/client/MixinClientConnectionChInit.java | 4 ++-- .../ViaFabricHostnameProtocol.java} | 7 ++++--- 5 files changed, 16 insertions(+), 6 deletions(-) rename src/main/java/com/github/creeper123123321/viafabric/{ProtocolViaFabricHostname.java => protocol/ViaFabricHostnameProtocol.java} (88%) diff --git a/README.md b/README.md index 820f3c3..ff6041d 100644 --- a/README.md +++ b/README.md @@ -89,6 +89,10 @@ Adding [ViaBackwards](https://viaversion.com/backwards) (and optionally [ViaRewi - You can disable it by resetting the anti-cheat warning in config file or by setting protocol version to -1 +**How can I set the version for specific servers?:** +- Append ._v(VERSION).viafabric. Example: ``minigame.example.com._v1_8.viafabric``, ``native.example.com._v-1.viafabric`` + + **Does it work with multiconnect at same time on client?:** - Yes, ViaFabric can be used with multiconnect. ViaFabric will send to their version auto detector their closest supported version. (multiconnect beta-supported versions (currently 1.10) aren't used) - Example of setups: diff --git a/build.gradle.kts b/build.gradle.kts index eeef699..0a02dfd 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -19,7 +19,7 @@ val branch = if (!travisBranch.isNullOrBlank()) travisBranch else try { "unknown" } -version = "0.2.8-SNAPSHOT+" + try { +version = "0.2.9-SNAPSHOT+" + try { gitVersion() + "-" + branch } catch (e: Exception) { "unknown" diff --git a/src/main/java/com/github/creeper123123321/viafabric/ViaFabric.java b/src/main/java/com/github/creeper123123321/viafabric/ViaFabric.java index 97b258d..da84254 100644 --- a/src/main/java/com/github/creeper123123321/viafabric/ViaFabric.java +++ b/src/main/java/com/github/creeper123123321/viafabric/ViaFabric.java @@ -30,7 +30,9 @@ import com.github.creeper123123321.viafabric.config.VRConfig; import com.github.creeper123123321.viafabric.platform.VRInjector; import com.github.creeper123123321.viafabric.platform.VRLoader; import com.github.creeper123123321.viafabric.platform.VRPlatform; +import com.github.creeper123123321.viafabric.protocol.ViaFabricHostnameProtocol; import com.github.creeper123123321.viafabric.util.JLoggerToLog4j; +import com.google.common.collect.Range; import com.google.common.util.concurrent.ThreadFactoryBuilder; import com.mojang.brigadier.arguments.StringArgumentType; import com.mojang.brigadier.builder.LiteralArgumentBuilder; @@ -46,6 +48,7 @@ import org.apache.logging.log4j.LogManager; import us.myles.ViaVersion.ViaManager; import us.myles.ViaVersion.api.Via; import us.myles.ViaVersion.api.data.MappingDataLoader; +import us.myles.ViaVersion.api.protocol.ProtocolRegistry; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; @@ -92,6 +95,8 @@ public class ViaFabric implements ModInitializer { Via.getManager().init(); + ProtocolRegistry.registerBaseProtocol(ViaFabricHostnameProtocol.INSTANCE, Range.lessThan(Integer.MIN_VALUE)); + FabricLoader.getInstance().getEntrypoints("viafabric:via_api_initialized", Runnable.class).forEach(Runnable::run); try { diff --git a/src/main/java/com/github/creeper123123321/viafabric/mixin/client/MixinClientConnectionChInit.java b/src/main/java/com/github/creeper123123321/viafabric/mixin/client/MixinClientConnectionChInit.java index 613c563..5b7b438 100644 --- a/src/main/java/com/github/creeper123123321/viafabric/mixin/client/MixinClientConnectionChInit.java +++ b/src/main/java/com/github/creeper123123321/viafabric/mixin/client/MixinClientConnectionChInit.java @@ -25,7 +25,7 @@ package com.github.creeper123123321.viafabric.mixin.client; -import com.github.creeper123123321.viafabric.ProtocolViaFabricHostname; +import com.github.creeper123123321.viafabric.protocol.ViaFabricHostnameProtocol; import com.github.creeper123123321.viafabric.handler.CommonTransformer; import com.github.creeper123123321.viafabric.handler.clientside.VRDecodeHandler; import com.github.creeper123123321.viafabric.handler.clientside.VREncodeHandler; @@ -45,7 +45,7 @@ public class MixinClientConnectionChInit { private void onInitChannel(Channel channel, CallbackInfo ci) { if (channel instanceof SocketChannel) { UserConnection user = new VRClientSideUserConnection(channel); - new ProtocolPipeline(user).add(ProtocolViaFabricHostname.INSTANCE); + new ProtocolPipeline(user).add(ViaFabricHostnameProtocol.INSTANCE); channel.pipeline().addBefore("encoder", CommonTransformer.HANDLER_ENCODER_NAME, new VREncodeHandler(user)); channel.pipeline().addBefore("decoder", CommonTransformer.HANDLER_DECODER_NAME, new VRDecodeHandler(user)); diff --git a/src/main/java/com/github/creeper123123321/viafabric/ProtocolViaFabricHostname.java b/src/main/java/com/github/creeper123123321/viafabric/protocol/ViaFabricHostnameProtocol.java similarity index 88% rename from src/main/java/com/github/creeper123123321/viafabric/ProtocolViaFabricHostname.java rename to src/main/java/com/github/creeper123123321/viafabric/protocol/ViaFabricHostnameProtocol.java index 38a533d..8d1497c 100644 --- a/src/main/java/com/github/creeper123123321/viafabric/ProtocolViaFabricHostname.java +++ b/src/main/java/com/github/creeper123123321/viafabric/protocol/ViaFabricHostnameProtocol.java @@ -23,8 +23,9 @@ * SOFTWARE. */ -package com.github.creeper123123321.viafabric; +package com.github.creeper123123321.viafabric.protocol; +import com.github.creeper123123321.viafabric.ViaFabricAddress; import us.myles.ViaVersion.api.PacketWrapper; import us.myles.ViaVersion.api.protocol.SimpleProtocol; import us.myles.ViaVersion.api.remapper.PacketRemapper; @@ -32,8 +33,8 @@ import us.myles.ViaVersion.api.remapper.ValueTransformer; import us.myles.ViaVersion.api.type.Type; import us.myles.ViaVersion.packets.State; -public class ProtocolViaFabricHostname extends SimpleProtocol { - public static final ProtocolViaFabricHostname INSTANCE = new ProtocolViaFabricHostname(); +public class ViaFabricHostnameProtocol extends SimpleProtocol { + public static final ViaFabricHostnameProtocol INSTANCE = new ViaFabricHostnameProtocol(); @Override protected void registerPackets() {