Refactor forge support - closes #318
This commit is contained in:
parent
904a1bfaa3
commit
332bdaaec0
@ -19,8 +19,6 @@ public class ServerConnection implements Server
|
|||||||
@Getter
|
@Getter
|
||||||
private final BungeeServerInfo info;
|
private final BungeeServerInfo info;
|
||||||
@Getter
|
@Getter
|
||||||
private final boolean isForgeWrapper;
|
|
||||||
@Getter
|
|
||||||
@Setter
|
@Setter
|
||||||
private boolean isObsolete;
|
private boolean isObsolete;
|
||||||
|
|
||||||
|
@ -48,6 +48,7 @@ public class ServerConnector extends PacketHandler
|
|||||||
private final BungeeServerInfo target;
|
private final BungeeServerInfo target;
|
||||||
private State thisState = State.ENCRYPT_REQUEST;
|
private State thisState = State.ENCRYPT_REQUEST;
|
||||||
private SecretKey secretkey;
|
private SecretKey secretkey;
|
||||||
|
private boolean sentMessages;
|
||||||
|
|
||||||
private enum State
|
private enum State
|
||||||
{
|
{
|
||||||
@ -59,7 +60,7 @@ public class ServerConnector extends PacketHandler
|
|||||||
public void exception(Throwable t) throws Exception
|
public void exception(Throwable t) throws Exception
|
||||||
{
|
{
|
||||||
String message = "Exception Connectiong:" + Util.exception( t );
|
String message = "Exception Connectiong:" + Util.exception( t );
|
||||||
if ( user.getServer() == null || user.getServer().isForgeWrapper() )
|
if ( user.getServer() == null )
|
||||||
{
|
{
|
||||||
user.disconnect( message );
|
user.disconnect( message );
|
||||||
} else
|
} else
|
||||||
@ -99,7 +100,7 @@ public class ServerConnector extends PacketHandler
|
|||||||
{
|
{
|
||||||
Preconditions.checkState( thisState == State.LOGIN, "Not exepcting LOGIN" );
|
Preconditions.checkState( thisState == State.LOGIN, "Not exepcting LOGIN" );
|
||||||
|
|
||||||
ServerConnection server = new ServerConnection( ch, target, false );
|
ServerConnection server = new ServerConnection( ch, target );
|
||||||
ServerConnectedEvent event = new ServerConnectedEvent( user, server );
|
ServerConnectedEvent event = new ServerConnectedEvent( user, server );
|
||||||
bungee.getPluginManager().callEvent( event );
|
bungee.getPluginManager().callEvent( event );
|
||||||
|
|
||||||
@ -113,9 +114,12 @@ public class ServerConnector extends PacketHandler
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for ( PacketFAPluginMessage message : user.getPendingConnection().getLoginMessages() )
|
if ( !sentMessages )
|
||||||
{
|
{
|
||||||
ch.write( message );
|
for ( PacketFAPluginMessage message : user.getPendingConnection().getLoginMessages() )
|
||||||
|
{
|
||||||
|
ch.write( message );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( user.getSettings() != null )
|
if ( user.getSettings() != null )
|
||||||
@ -125,8 +129,7 @@ public class ServerConnector extends PacketHandler
|
|||||||
|
|
||||||
synchronized ( user.getSwitchMutex() )
|
synchronized ( user.getSwitchMutex() )
|
||||||
{
|
{
|
||||||
// TODO: This whole wrapper business is a hack
|
if ( user.getServer() == null )
|
||||||
if ( user.getServer() == null || user.getServer().isForgeWrapper() )
|
|
||||||
{
|
{
|
||||||
// Once again, first connection
|
// Once again, first connection
|
||||||
user.setClientEntityId( login.entityId );
|
user.setClientEntityId( login.entityId );
|
||||||
@ -226,7 +229,6 @@ public class ServerConnector extends PacketHandler
|
|||||||
ch.getHandle().pipeline().addBefore( "decoder", "decrypt", new CipherDecoder( decrypt ) );
|
ch.getHandle().pipeline().addBefore( "decoder", "decrypt", new CipherDecoder( decrypt ) );
|
||||||
|
|
||||||
ch.write( user.getPendingConnection().getForgeLogin() );
|
ch.write( user.getPendingConnection().getForgeLogin() );
|
||||||
user.setServer( new ServerConnection( ch, target, true ) );
|
|
||||||
|
|
||||||
ch.write( PacketCDClientStatus.CLIENT_LOGIN );
|
ch.write( PacketCDClientStatus.CLIENT_LOGIN );
|
||||||
thisState = State.LOGIN;
|
thisState = State.LOGIN;
|
||||||
@ -270,11 +272,20 @@ public class ServerConnector extends PacketHandler
|
|||||||
}
|
}
|
||||||
if ( in.readByte() != 0 )
|
if ( in.readByte() != 0 )
|
||||||
{
|
{
|
||||||
|
// TODO: Using forge flag
|
||||||
ch.getHandle().pipeline().get( PacketDecoder.class ).setProtocol( PacketDefinitions.FORGE_PROTOCOL );
|
ch.getHandle().pipeline().get( PacketDecoder.class ).setProtocol( PacketDefinitions.FORGE_PROTOCOL );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
user.sendPacket( pluginMessage ); // We have to forward these to the user, especially with Forge as stuff might break
|
user.sendPacket( pluginMessage ); // We have to forward these to the user, especially with Forge as stuff might break
|
||||||
|
if ( !sentMessages && user.getPendingConnection().getForgeLogin() != null )
|
||||||
|
{
|
||||||
|
for ( PacketFAPluginMessage message : user.getPendingConnection().getLoginMessages() )
|
||||||
|
{
|
||||||
|
ch.write( message );
|
||||||
|
}
|
||||||
|
sentMessages = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -63,6 +63,10 @@ public class InitialHandler extends PacketHandler implements PendingConnection
|
|||||||
private State thisState = State.HANDSHAKE;
|
private State thisState = State.HANDSHAKE;
|
||||||
private SecretKey sharedKey;
|
private SecretKey sharedKey;
|
||||||
private boolean disconnected;
|
private boolean disconnected;
|
||||||
|
private static final PacketFAPluginMessage forgeMods = new PacketFAPluginMessage( "FML", new byte[]
|
||||||
|
{
|
||||||
|
0, 0, 0, 0, 0, 2
|
||||||
|
} );
|
||||||
|
|
||||||
private enum State
|
private enum State
|
||||||
{
|
{
|
||||||
@ -133,6 +137,7 @@ public class InitialHandler extends PacketHandler implements PendingConnection
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.handshake = handshake;
|
this.handshake = handshake;
|
||||||
|
ch.write( forgeMods );
|
||||||
ch.write( request = EncryptionUtil.encryptRequest() );
|
ch.write( request = EncryptionUtil.encryptRequest() );
|
||||||
thisState = State.ENCRYPT;
|
thisState = State.ENCRYPT;
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package net.md_5.bungee.connection;
|
package net.md_5.bungee.connection;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
import net.md_5.bungee.BungeeCord;
|
import net.md_5.bungee.BungeeCord;
|
||||||
import net.md_5.bungee.EntityMap;
|
import net.md_5.bungee.EntityMap;
|
||||||
import net.md_5.bungee.UserConnection;
|
import net.md_5.bungee.UserConnection;
|
||||||
|
Loading…
Reference in New Issue
Block a user