Whats this? It compiles. Doesn't mean it near works though.
This commit is contained in:
parent
c3d702a5b3
commit
e18fe49cf9
@ -52,8 +52,10 @@ public final class UserConnection implements ProxiedPlayer
|
||||
@Getter
|
||||
private final Object switchMutex = new Object();
|
||||
|
||||
public UserConnection(Channel channel, PendingConnection pendingConnection, Packet2Handshake handshake, Packet1Login forgeLogin, List<PacketFAPluginMessage> loginMessages)
|
||||
public UserConnection(BungeeCord bungee, Channel channel, PendingConnection pendingConnection, Packet2Handshake handshake, Packet1Login forgeLogin, List<PacketFAPluginMessage> loginMessages)
|
||||
{
|
||||
this.bungee = bungee;
|
||||
this.ch = channel;
|
||||
this.handshake = handshake;
|
||||
this.pendingConnection = pendingConnection;
|
||||
this.forgeLogin = forgeLogin;
|
||||
|
@ -142,7 +142,7 @@ public class InitialHandler extends PacketHandler implements PendingConnection
|
||||
{
|
||||
Preconditions.checkState( thisState == State.LOGIN, "Not expecting LOGIN" );
|
||||
|
||||
UserConnection userCon = new UserConnection( socket, this, stream, handshake, forgeLogin, loginMessages );
|
||||
UserConnection userCon = new UserConnection( (BungeeCord) bungee, ch, this, handshake, forgeLogin, loginMessages );
|
||||
ServerInfo server = bungee.getReconnectHandler().getServer( userCon );
|
||||
userCon.connect( server );
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
package net.md_5.bungee.packet;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.ReferenceCounted;
|
||||
import io.netty.buffer.Unpooled;
|
||||
@ -21,26 +20,20 @@ public abstract class DefinedPacket implements ByteBuf
|
||||
{
|
||||
ByteBuf.class, ReferenceCounted.class
|
||||
})
|
||||
private ByteBuf out;
|
||||
/**
|
||||
* Packet id.
|
||||
*/
|
||||
public final int id;
|
||||
private ByteBuf buf;
|
||||
|
||||
public DefinedPacket(int id, byte[] buf)
|
||||
public DefinedPacket(int id, ByteBuf buf)
|
||||
{
|
||||
out = Unpooled.wrappedBuffer( buf );
|
||||
this.buf = buf;
|
||||
if ( readUnsignedByte() != id )
|
||||
{
|
||||
throw new IllegalArgumentException( "Wasn't expecting packet id " + Util.hex( id ) );
|
||||
}
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public DefinedPacket(int id)
|
||||
{
|
||||
out = Unpooled.buffer();
|
||||
this.id = id;
|
||||
buf = Unpooled.buffer();
|
||||
writeByte( id );
|
||||
}
|
||||
|
||||
@ -90,6 +83,8 @@ public abstract class DefinedPacket implements ByteBuf
|
||||
public abstract void handle(PacketHandler handler) throws Exception;
|
||||
@SuppressWarnings("unchecked")
|
||||
private static Class<? extends DefinedPacket>[] classes = new Class[ 256 ];
|
||||
@SuppressWarnings("unchecked")
|
||||
private static Constructor<? extends DefinedPacket>[] consructors = new Constructor[ 256 ];
|
||||
|
||||
public static DefinedPacket packet(ByteBuf buf)
|
||||
{
|
||||
@ -100,7 +95,13 @@ public abstract class DefinedPacket implements ByteBuf
|
||||
{
|
||||
try
|
||||
{
|
||||
Constructor<? extends DefinedPacket> constructor = clazz.getDeclaredConstructor( byte[].class );
|
||||
Constructor<? extends DefinedPacket> constructor = consructors[id];
|
||||
if ( constructor == null )
|
||||
{
|
||||
constructor = clazz.getDeclaredConstructor( ByteBuf.class );
|
||||
consructors[id] = constructor;
|
||||
}
|
||||
|
||||
if ( constructor != null )
|
||||
{
|
||||
ret = constructor.newInstance( buf );
|
||||
@ -108,12 +109,8 @@ public abstract class DefinedPacket implements ByteBuf
|
||||
} catch ( IllegalAccessException | InstantiationException | InvocationTargetException | NoSuchMethodException ex )
|
||||
{
|
||||
}
|
||||
} else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
Preconditions.checkState( ret != null, "Don't know how to deal with packet ID %s", Util.hex( id ) );
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
package net.md_5.bungee.packet;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
@ -10,9 +11,9 @@ public class Packet0KeepAlive extends DefinedPacket
|
||||
|
||||
public int id;
|
||||
|
||||
public Packet0KeepAlive(byte[] buffer)
|
||||
public Packet0KeepAlive(ByteBuf buf)
|
||||
{
|
||||
super( 0x00, buffer );
|
||||
super( 0x00, buf );
|
||||
id = readInt();
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
package net.md_5.bungee.packet;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
@ -28,7 +29,7 @@ public class Packet1Login extends DefinedPacket
|
||||
writeByte( maxPlayers );
|
||||
}
|
||||
|
||||
public Packet1Login(byte[] buf)
|
||||
public Packet1Login(ByteBuf buf)
|
||||
{
|
||||
super( 0x01, buf );
|
||||
this.entityId = readInt();
|
||||
|
@ -1,5 +1,6 @@
|
||||
package net.md_5.bungee.packet;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
@ -22,7 +23,7 @@ public class Packet2Handshake extends DefinedPacket
|
||||
writeInt( port );
|
||||
}
|
||||
|
||||
public Packet2Handshake(byte[] buf)
|
||||
public Packet2Handshake(ByteBuf buf)
|
||||
{
|
||||
super( 0x02, buf );
|
||||
this.procolVersion = readByte();
|
||||
|
@ -1,5 +1,6 @@
|
||||
package net.md_5.bungee.packet;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
@ -16,7 +17,7 @@ public class Packet3Chat extends DefinedPacket
|
||||
writeString( message );
|
||||
}
|
||||
|
||||
public Packet3Chat(byte[] buf)
|
||||
public Packet3Chat(ByteBuf buf)
|
||||
{
|
||||
super( 0x03, buf );
|
||||
this.message = readString();
|
||||
|
@ -1,5 +1,6 @@
|
||||
package net.md_5.bungee.packet;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
@ -26,7 +27,7 @@ public class Packet9Respawn extends DefinedPacket
|
||||
writeString( levelType );
|
||||
}
|
||||
|
||||
public Packet9Respawn(byte[] buf)
|
||||
public Packet9Respawn(ByteBuf buf)
|
||||
{
|
||||
super( 0x09, buf );
|
||||
this.dimension = readInt();
|
||||
|
@ -1,5 +1,6 @@
|
||||
package net.md_5.bungee.packet;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
@ -12,9 +13,9 @@ public class PacketC9PlayerListItem extends DefinedPacket
|
||||
public boolean online;
|
||||
public int ping;
|
||||
|
||||
public PacketC9PlayerListItem(byte[] packet)
|
||||
public PacketC9PlayerListItem(ByteBuf buf)
|
||||
{
|
||||
super( 0xC9, packet );
|
||||
super( 0xC9, buf );
|
||||
username = readString();
|
||||
online = readBoolean();
|
||||
ping = readShort();
|
||||
|
@ -1,5 +1,6 @@
|
||||
package net.md_5.bungee.packet;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
@ -21,7 +22,7 @@ public class PacketCDClientStatus extends DefinedPacket
|
||||
writeByte( payload );
|
||||
}
|
||||
|
||||
public PacketCDClientStatus(byte[] buf)
|
||||
public PacketCDClientStatus(ByteBuf buf)
|
||||
{
|
||||
super( 0xCD, buf );
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package net.md_5.bungee.packet;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
@ -20,7 +21,7 @@ public class PacketFAPluginMessage extends DefinedPacket
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public PacketFAPluginMessage(byte[] buf)
|
||||
public PacketFAPluginMessage(ByteBuf buf)
|
||||
{
|
||||
super( 0xFA, buf );
|
||||
this.tag = readString();
|
||||
|
@ -1,5 +1,6 @@
|
||||
package net.md_5.bungee.packet;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
@ -25,7 +26,7 @@ public class PacketFCEncryptionResponse extends DefinedPacket
|
||||
writeArray( verifyToken );
|
||||
}
|
||||
|
||||
public PacketFCEncryptionResponse(byte[] buf)
|
||||
public PacketFCEncryptionResponse(ByteBuf buf)
|
||||
{
|
||||
super( 0xFC, buf );
|
||||
this.sharedSecret = readArray();
|
||||
|
@ -1,5 +1,6 @@
|
||||
package net.md_5.bungee.packet;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
@ -23,7 +24,7 @@ public class PacketFDEncryptionRequest extends DefinedPacket
|
||||
this.verifyToken = verifyToken;
|
||||
}
|
||||
|
||||
public PacketFDEncryptionRequest(byte[] buf)
|
||||
public PacketFDEncryptionRequest(ByteBuf buf)
|
||||
{
|
||||
super( 0xFD, buf );
|
||||
serverId = readString();
|
||||
|
@ -1,5 +1,6 @@
|
||||
package net.md_5.bungee.packet;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
@ -8,9 +9,12 @@ import lombok.ToString;
|
||||
public class PacketFEPing extends DefinedPacket
|
||||
{
|
||||
|
||||
public PacketFEPing(byte[] buffer)
|
||||
public byte version;
|
||||
|
||||
public PacketFEPing(ByteBuf buffer)
|
||||
{
|
||||
super( 0xFE, buffer );
|
||||
version = readByte();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,5 +1,6 @@
|
||||
package net.md_5.bungee.packet;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
@ -16,7 +17,7 @@ public class PacketFFKick extends DefinedPacket
|
||||
writeString( message );
|
||||
}
|
||||
|
||||
public PacketFFKick(byte[] buf)
|
||||
public PacketFFKick(ByteBuf buf)
|
||||
{
|
||||
super( 0xFF, buf );
|
||||
this.message = readString();
|
||||
|
Loading…
Reference in New Issue
Block a user