From 4a78b4becb5e0f146c48e82e4d346530d09e0734 Mon Sep 17 00:00:00 2001 From: RaphiMC <50594595+RaphiMC@users.noreply.github.com> Date: Tue, 10 Jan 2023 21:59:45 +0100 Subject: [PATCH] Updated Via* --- build.gradle | 4 ++-- gradle.properties | 2 +- .../java/net/raphimc/viaproxy/ViaProxy.java | 2 -- .../raphimc/viaproxy/cli/options/Options.java | 6 +++-- .../cli/options/VersionEnumConverter.java | 2 +- .../ClassicWorldHeightInjection.java | 11 +++++++--- .../MixinAbstractFenceConnectionHandler.java | 6 +++-- .../mixins/MixinGlassConnectionHandler.java | 2 +- .../plugins/events/PreConnectEvent.java | 2 +- .../ViaProxyClassicWorldHeightProvider.java | 2 +- .../viaproxy/proxy/ProxyConnection.java | 14 ++++++++---- .../client2proxy/Client2ProxyHandler.java | 22 ++++++++++++++----- .../Proxy2ServerChannelInitializer.java | 2 +- .../proxy2server/Proxy2ServerHandler.java | 6 +++-- .../raphimc/viaproxy/ui/impl/GeneralTab.java | 4 ++-- 15 files changed, 56 insertions(+), 31 deletions(-) diff --git a/build.gradle b/build.gradle index af83abf..3578537 100644 --- a/build.gradle +++ b/build.gradle @@ -42,8 +42,8 @@ dependencies { exclude group: "com.google.guava", module: "guava" } include "com.viaversion:viarewind-core:2.0.3-SNAPSHOT" - include "net.raphimc:ViaLegacy:2.0.4" - include("net.raphimc:ViaProtocolHack:2.0.1") { + include "net.raphimc:ViaLegacy:2.1.0" + include("net.raphimc:ViaProtocolHack:2.1.0") { exclude group: "org.slf4j", module: "slf4j-api" } diff --git a/gradle.properties b/gradle.properties index c1f5fc7..d755640 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,4 +6,4 @@ org.gradle.configureondemand=true # Project properties maven_name=ViaProxy maven_group=net.raphimc -maven_version=3.0.5 +maven_version=3.0.6 diff --git a/src/main/java/net/raphimc/viaproxy/ViaProxy.java b/src/main/java/net/raphimc/viaproxy/ViaProxy.java index d5ef6aa..6b000a8 100644 --- a/src/main/java/net/raphimc/viaproxy/ViaProxy.java +++ b/src/main/java/net/raphimc/viaproxy/ViaProxy.java @@ -15,7 +15,6 @@ import net.lenni0451.classtransform.utils.loader.InjectionClassLoader; import net.lenni0451.reflect.ClassLoaders; import net.raphimc.netminecraft.constants.MCPipeline; import net.raphimc.netminecraft.netty.connection.NetServer; -import net.raphimc.vialegacy.util.VersionEnum; import net.raphimc.viaproxy.cli.ConsoleHandler; import net.raphimc.viaproxy.cli.options.Options; import net.raphimc.viaproxy.plugins.PluginManager; @@ -58,7 +57,6 @@ public class ViaProxy { ConsoleHandler.hookConsole(); Logger.LOGGER.info("Initializing ViaProxy v" + VERSION + "..."); saveManager = new SaveManager(); - VersionEnum.init(); setNettyParameters(); MCPipeline.useOptimizedPipeline(); c2pChannels = new DefaultChannelGroup(GlobalEventExecutor.INSTANCE); diff --git a/src/main/java/net/raphimc/viaproxy/cli/options/Options.java b/src/main/java/net/raphimc/viaproxy/cli/options/Options.java index e98f5ed..be0b795 100644 --- a/src/main/java/net/raphimc/viaproxy/cli/options/Options.java +++ b/src/main/java/net/raphimc/viaproxy/cli/options/Options.java @@ -1,8 +1,10 @@ package net.raphimc.viaproxy.cli.options; -import joptsimple.*; +import joptsimple.OptionParser; +import joptsimple.OptionSet; +import joptsimple.OptionSpec; import net.raphimc.mcauth.step.java.StepMCProfile; -import net.raphimc.vialegacy.util.VersionEnum; +import net.raphimc.viaprotocolhack.util.VersionEnum; import net.raphimc.viaproxy.util.logging.Logger; import java.io.IOException; diff --git a/src/main/java/net/raphimc/viaproxy/cli/options/VersionEnumConverter.java b/src/main/java/net/raphimc/viaproxy/cli/options/VersionEnumConverter.java index dff7d08..64eeba4 100644 --- a/src/main/java/net/raphimc/viaproxy/cli/options/VersionEnumConverter.java +++ b/src/main/java/net/raphimc/viaproxy/cli/options/VersionEnumConverter.java @@ -2,7 +2,7 @@ package net.raphimc.viaproxy.cli.options; import joptsimple.ValueConversionException; import joptsimple.ValueConverter; -import net.raphimc.vialegacy.util.VersionEnum; +import net.raphimc.viaprotocolhack.util.VersionEnum; public class VersionEnumConverter implements ValueConverter { diff --git a/src/main/java/net/raphimc/viaproxy/injection/ClassicWorldHeightInjection.java b/src/main/java/net/raphimc/viaproxy/injection/ClassicWorldHeightInjection.java index 4b1e237..ec6fd22 100644 --- a/src/main/java/net/raphimc/viaproxy/injection/ClassicWorldHeightInjection.java +++ b/src/main/java/net/raphimc/viaproxy/injection/ClassicWorldHeightInjection.java @@ -6,15 +6,20 @@ import com.viaversion.viaversion.api.minecraft.chunks.Chunk; import com.viaversion.viaversion.api.minecraft.chunks.ChunkSection; import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper; import com.viaversion.viaversion.api.type.Type; -import com.viaversion.viaversion.libs.opennbt.tag.builtin.*; +import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag; +import com.viaversion.viaversion.libs.opennbt.tag.builtin.IntTag; +import com.viaversion.viaversion.libs.opennbt.tag.builtin.ListTag; +import com.viaversion.viaversion.libs.opennbt.tag.builtin.Tag; import com.viaversion.viaversion.protocols.protocol1_17to1_16_4.Protocol1_17To1_16_4; import com.viaversion.viaversion.protocols.protocol1_17to1_16_4.types.Chunk1_17Type; import net.raphimc.vialegacy.protocols.classic.protocola1_0_15toc0_28_30.model.ClassicLevel; import net.raphimc.vialegacy.protocols.classic.protocola1_0_15toc0_28_30.providers.ClassicWorldHeightProvider; import net.raphimc.vialegacy.protocols.classic.protocola1_0_15toc0_28_30.storage.ClassicLevelStorage; -import net.raphimc.vialegacy.util.VersionEnum; +import net.raphimc.viaprotocolhack.util.VersionEnum; -import java.util.*; +import java.util.ArrayList; +import java.util.BitSet; +import java.util.List; public class ClassicWorldHeightInjection { diff --git a/src/main/java/net/raphimc/viaproxy/injection/mixins/MixinAbstractFenceConnectionHandler.java b/src/main/java/net/raphimc/viaproxy/injection/mixins/MixinAbstractFenceConnectionHandler.java index bfbfb27..f8ab6e5 100644 --- a/src/main/java/net/raphimc/viaproxy/injection/mixins/MixinAbstractFenceConnectionHandler.java +++ b/src/main/java/net/raphimc/viaproxy/injection/mixins/MixinAbstractFenceConnectionHandler.java @@ -4,8 +4,10 @@ import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.api.minecraft.BlockFace; import com.viaversion.viaversion.api.minecraft.Position; import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.blockconnections.AbstractFenceConnectionHandler; -import net.raphimc.vialegacy.util.VersionEnum; -import org.spongepowered.asm.mixin.*; +import net.raphimc.viaprotocolhack.util.VersionEnum; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Overwrite; +import org.spongepowered.asm.mixin.Shadow; @Mixin(value = AbstractFenceConnectionHandler.class, remap = false) public abstract class MixinAbstractFenceConnectionHandler { diff --git a/src/main/java/net/raphimc/viaproxy/injection/mixins/MixinGlassConnectionHandler.java b/src/main/java/net/raphimc/viaproxy/injection/mixins/MixinGlassConnectionHandler.java index 7a9ec19..a887999 100644 --- a/src/main/java/net/raphimc/viaproxy/injection/mixins/MixinGlassConnectionHandler.java +++ b/src/main/java/net/raphimc/viaproxy/injection/mixins/MixinGlassConnectionHandler.java @@ -5,7 +5,7 @@ import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.api.minecraft.Position; import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.blockconnections.AbstractFenceConnectionHandler; import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.blockconnections.GlassConnectionHandler; -import net.raphimc.vialegacy.util.VersionEnum; +import net.raphimc.viaprotocolhack.util.VersionEnum; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Overwrite; diff --git a/src/main/java/net/raphimc/viaproxy/plugins/events/PreConnectEvent.java b/src/main/java/net/raphimc/viaproxy/plugins/events/PreConnectEvent.java index 776850f..6586aba 100644 --- a/src/main/java/net/raphimc/viaproxy/plugins/events/PreConnectEvent.java +++ b/src/main/java/net/raphimc/viaproxy/plugins/events/PreConnectEvent.java @@ -2,7 +2,7 @@ package net.raphimc.viaproxy.plugins.events; import io.netty.channel.Channel; import net.raphimc.netminecraft.util.ServerAddress; -import net.raphimc.vialegacy.util.VersionEnum; +import net.raphimc.viaprotocolhack.util.VersionEnum; import net.raphimc.viaproxy.plugins.events.types.ICancellable; public class PreConnectEvent implements ICancellable { diff --git a/src/main/java/net/raphimc/viaproxy/protocolhack/providers/ViaProxyClassicWorldHeightProvider.java b/src/main/java/net/raphimc/viaproxy/protocolhack/providers/ViaProxyClassicWorldHeightProvider.java index 98976bd..2643432 100644 --- a/src/main/java/net/raphimc/viaproxy/protocolhack/providers/ViaProxyClassicWorldHeightProvider.java +++ b/src/main/java/net/raphimc/viaproxy/protocolhack/providers/ViaProxyClassicWorldHeightProvider.java @@ -2,7 +2,7 @@ package net.raphimc.viaproxy.protocolhack.providers; import com.viaversion.viaversion.api.connection.UserConnection; import net.raphimc.vialegacy.protocols.classic.protocola1_0_15toc0_28_30.providers.ClassicWorldHeightProvider; -import net.raphimc.vialegacy.util.VersionEnum; +import net.raphimc.viaprotocolhack.util.VersionEnum; import net.raphimc.viaproxy.proxy.ProxyConnection; public class ViaProxyClassicWorldHeightProvider extends ClassicWorldHeightProvider { diff --git a/src/main/java/net/raphimc/viaproxy/proxy/ProxyConnection.java b/src/main/java/net/raphimc/viaproxy/proxy/ProxyConnection.java index 07fceba..96da01f 100644 --- a/src/main/java/net/raphimc/viaproxy/proxy/ProxyConnection.java +++ b/src/main/java/net/raphimc/viaproxy/proxy/ProxyConnection.java @@ -5,19 +5,25 @@ import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.libs.gson.JsonObject; import com.viaversion.viaversion.libs.gson.JsonPrimitive; import io.netty.bootstrap.Bootstrap; -import io.netty.buffer.*; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.ByteBufUtil; +import io.netty.buffer.Unpooled; import io.netty.channel.*; import io.netty.channel.socket.SocketChannel; import io.netty.util.AttributeKey; -import net.raphimc.netminecraft.constants.*; +import net.raphimc.netminecraft.constants.ConnectionState; +import net.raphimc.netminecraft.constants.MCPackets; +import net.raphimc.netminecraft.constants.MCPipeline; import net.raphimc.netminecraft.netty.connection.NetClient; import net.raphimc.netminecraft.netty.crypto.AESEncryption; import net.raphimc.netminecraft.packet.PacketTypes; -import net.raphimc.netminecraft.packet.impl.login.*; +import net.raphimc.netminecraft.packet.impl.login.C2SLoginHelloPacket1_7; +import net.raphimc.netminecraft.packet.impl.login.S2CLoginCustomPayloadPacket; +import net.raphimc.netminecraft.packet.impl.login.S2CLoginDisconnectPacket; import net.raphimc.netminecraft.packet.impl.status.S2CStatusResponsePacket; import net.raphimc.netminecraft.packet.registry.PacketRegistryUtil; import net.raphimc.netminecraft.util.ServerAddress; -import net.raphimc.vialegacy.util.VersionEnum; +import net.raphimc.viaprotocolhack.util.VersionEnum; import net.raphimc.viaproxy.proxy.util.CloseAndReturn; import net.raphimc.viaproxy.util.logging.Logger; diff --git a/src/main/java/net/raphimc/viaproxy/proxy/client2proxy/Client2ProxyHandler.java b/src/main/java/net/raphimc/viaproxy/proxy/client2proxy/Client2ProxyHandler.java index d5725fb..2e67ab2 100644 --- a/src/main/java/net/raphimc/viaproxy/proxy/client2proxy/Client2ProxyHandler.java +++ b/src/main/java/net/raphimc/viaproxy/proxy/client2proxy/Client2ProxyHandler.java @@ -3,22 +3,30 @@ package net.raphimc.viaproxy.proxy.client2proxy; import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; import io.netty.buffer.ByteBuf; import io.netty.buffer.Unpooled; -import io.netty.channel.*; +import io.netty.channel.ChannelFutureListener; +import io.netty.channel.ChannelHandlerContext; +import io.netty.channel.SimpleChannelInboundHandler; import io.netty.channel.socket.SocketChannel; -import net.raphimc.netminecraft.constants.*; +import net.raphimc.netminecraft.constants.ConnectionState; +import net.raphimc.netminecraft.constants.MCPackets; +import net.raphimc.netminecraft.constants.MCPipeline; import net.raphimc.netminecraft.netty.crypto.AESEncryption; import net.raphimc.netminecraft.netty.crypto.CryptUtil; -import net.raphimc.netminecraft.packet.*; +import net.raphimc.netminecraft.packet.IPacket; +import net.raphimc.netminecraft.packet.PacketTypes; +import net.raphimc.netminecraft.packet.UnknownPacket; import net.raphimc.netminecraft.packet.impl.handshake.C2SHandshakePacket; import net.raphimc.netminecraft.packet.impl.login.*; import net.raphimc.netminecraft.util.ServerAddress; -import net.raphimc.vialegacy.util.VersionEnum; +import net.raphimc.viaprotocolhack.util.VersionEnum; import net.raphimc.viaproxy.ViaProxy; import net.raphimc.viaproxy.cli.options.Options; import net.raphimc.viaproxy.plugins.PluginManager; import net.raphimc.viaproxy.plugins.events.PreConnectEvent; import net.raphimc.viaproxy.protocolhack.providers.ViaProxyGameProfileFetcher; -import net.raphimc.viaproxy.proxy.*; +import net.raphimc.viaproxy.proxy.ExternalInterface; +import net.raphimc.viaproxy.proxy.LoginState; +import net.raphimc.viaproxy.proxy.ProxyConnection; import net.raphimc.viaproxy.proxy.proxy2server.Proxy2ServerChannelInitializer; import net.raphimc.viaproxy.proxy.proxy2server.Proxy2ServerHandler; import net.raphimc.viaproxy.proxy.util.CloseAndReturn; @@ -29,7 +37,9 @@ import net.raphimc.viaproxy.util.logging.Logger; import javax.crypto.SecretKey; import java.math.BigInteger; import java.nio.charset.StandardCharsets; -import java.security.*; +import java.security.GeneralSecurityException; +import java.security.KeyPair; +import java.security.NoSuchAlgorithmException; import java.security.spec.InvalidKeySpecException; import java.time.Instant; import java.util.Arrays; diff --git a/src/main/java/net/raphimc/viaproxy/proxy/proxy2server/Proxy2ServerChannelInitializer.java b/src/main/java/net/raphimc/viaproxy/proxy/proxy2server/Proxy2ServerChannelInitializer.java index e8425a6..dc91130 100644 --- a/src/main/java/net/raphimc/viaproxy/proxy/proxy2server/Proxy2ServerChannelInitializer.java +++ b/src/main/java/net/raphimc/viaproxy/proxy/proxy2server/Proxy2ServerChannelInitializer.java @@ -11,9 +11,9 @@ import net.raphimc.netminecraft.packet.registry.PacketRegistryUtil; import net.raphimc.vialegacy.netty.PreNettyDecoder; import net.raphimc.vialegacy.netty.PreNettyEncoder; import net.raphimc.vialegacy.protocols.release.protocol1_7_2_5to1_6_4.baseprotocols.PreNettyBaseProtocol; -import net.raphimc.vialegacy.util.VersionEnum; import net.raphimc.viaprotocolhack.netty.ViaEncodeHandler; import net.raphimc.viaprotocolhack.netty.ViaPipeline; +import net.raphimc.viaprotocolhack.util.VersionEnum; import net.raphimc.viaproxy.plugins.PluginManager; import net.raphimc.viaproxy.plugins.events.Proxy2ServerChannelInitializeEvent; import net.raphimc.viaproxy.plugins.events.types.ITyped; diff --git a/src/main/java/net/raphimc/viaproxy/proxy/proxy2server/Proxy2ServerHandler.java b/src/main/java/net/raphimc/viaproxy/proxy/proxy2server/Proxy2ServerHandler.java index ae4c021..f9555aa 100644 --- a/src/main/java/net/raphimc/viaproxy/proxy/proxy2server/Proxy2ServerHandler.java +++ b/src/main/java/net/raphimc/viaproxy/proxy/proxy2server/Proxy2ServerHandler.java @@ -1,7 +1,9 @@ package net.raphimc.viaproxy.proxy.proxy2server; import com.github.steveice10.mc.auth.data.GameProfile; -import io.netty.channel.*; +import io.netty.channel.ChannelFutureListener; +import io.netty.channel.ChannelHandlerContext; +import io.netty.channel.SimpleChannelInboundHandler; import net.raphimc.netminecraft.constants.ConnectionState; import net.raphimc.netminecraft.constants.MCPipeline; import net.raphimc.netminecraft.netty.crypto.AESEncryption; @@ -9,7 +11,7 @@ import net.raphimc.netminecraft.netty.crypto.CryptUtil; import net.raphimc.netminecraft.packet.IPacket; import net.raphimc.netminecraft.packet.impl.login.*; import net.raphimc.vialegacy.protocols.release.protocol1_7_2_5to1_6_4.storage.ProtocolMetadataStorage; -import net.raphimc.vialegacy.util.VersionEnum; +import net.raphimc.viaprotocolhack.util.VersionEnum; import net.raphimc.viaproxy.cli.options.Options; import net.raphimc.viaproxy.proxy.ExternalInterface; import net.raphimc.viaproxy.proxy.ProxyConnection; diff --git a/src/main/java/net/raphimc/viaproxy/ui/impl/GeneralTab.java b/src/main/java/net/raphimc/viaproxy/ui/impl/GeneralTab.java index 8f5aa9e..e111970 100644 --- a/src/main/java/net/raphimc/viaproxy/ui/impl/GeneralTab.java +++ b/src/main/java/net/raphimc/viaproxy/ui/impl/GeneralTab.java @@ -1,7 +1,7 @@ package net.raphimc.viaproxy.ui.impl; import com.google.common.net.HostAndPort; -import net.raphimc.vialegacy.util.VersionEnum; +import net.raphimc.viaprotocolhack.util.VersionEnum; import net.raphimc.viaproxy.ViaProxy; import net.raphimc.viaproxy.cli.options.Options; import net.raphimc.viaproxy.ui.AUITab; @@ -67,7 +67,7 @@ public class GeneralTab extends AUITab { serverVersionLabel.setBounds(10, 100, 100, 20); contentPane.add(serverVersionLabel); - this.serverVersion = new JComboBox<>(VersionEnum.RENDER_VERSIONS.toArray(new VersionEnum[0])); + this.serverVersion = new JComboBox<>(VersionEnum.SORTED_VERSIONS.toArray(new VersionEnum[0])); this.serverVersion.setBounds(10, 120, 465, 20); this.serverVersion.setRenderer(new DefaultListCellRenderer() { @Override