From cdf47d84d8176c85a8d5b83ccdd8e0111627b55a Mon Sep 17 00:00:00 2001 From: md_5 Date: Sat, 19 Oct 2013 20:01:22 +1100 Subject: [PATCH] Fix offline mode. Latest snapshot appears to be pretty much functional, although the client itself seems to have some reliability issues. --- .../src/main/java/net/md_5/bungee/EncryptionUtil.java | 4 ++-- .../net/md_5/bungee/connection/InitialHandler.java | 10 +++++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/proxy/src/main/java/net/md_5/bungee/EncryptionUtil.java b/proxy/src/main/java/net/md_5/bungee/EncryptionUtil.java index 9cc2140d..eb7fe4f1 100644 --- a/proxy/src/main/java/net/md_5/bungee/EncryptionUtil.java +++ b/proxy/src/main/java/net/md_5/bungee/EncryptionUtil.java @@ -40,9 +40,9 @@ public class EncryptionUtil } } - public static EncryptionRequest encryptRequest(boolean onlinemode) + public static EncryptionRequest encryptRequest() { - String hash = ( onlinemode ) ? Long.toString( random.nextLong(), 16 ) : "-"; + String hash = Long.toString( random.nextLong(), 16 ); byte[] pubKey = keys.getPublic().getEncoded(); byte[] verify = new byte[ 4 ]; random.nextBytes( verify ); diff --git a/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java b/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java index 67234e8d..89f9d299 100644 --- a/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java +++ b/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java @@ -1,8 +1,6 @@ package net.md_5.bungee.connection; import com.google.common.base.Preconditions; -import io.netty.buffer.ByteBuf; -import io.netty.buffer.Unpooled; import java.math.BigInteger; import java.net.InetSocketAddress; import java.net.URLEncoder; @@ -249,7 +247,13 @@ public class InitialHandler extends PacketHandler implements PendingConnection // TODO: Nuuuu Mojang why u do this // unsafe().sendPacket( PacketConstants.I_AM_BUNGEE ); // unsafe().sendPacket( PacketConstants.FORGE_MOD_REQUEST ); - unsafe().sendPacket( request = EncryptionUtil.encryptRequest( this.onlineMode ) ); + if ( this.onlineMode ) + { + unsafe().sendPacket( request = EncryptionUtil.encryptRequest() ); + } else + { + finish(); + } thisState = State.ENCRYPT; }