41b update
This commit is contained in:
parent
062dd38b2b
commit
18db20fe42
@ -7,7 +7,7 @@ import net.md_5.bungee.protocol.packet.Login;
|
|||||||
import net.md_5.bungee.protocol.packet.Chat;
|
import net.md_5.bungee.protocol.packet.Chat;
|
||||||
import net.md_5.bungee.protocol.packet.EncryptionRequest;
|
import net.md_5.bungee.protocol.packet.EncryptionRequest;
|
||||||
import net.md_5.bungee.protocol.packet.PlayerListItem;
|
import net.md_5.bungee.protocol.packet.PlayerListItem;
|
||||||
import net.md_5.bungee.protocol.packet.TabComplete;
|
import net.md_5.bungee.protocol.packet.TabCompleteRequest;
|
||||||
import net.md_5.bungee.protocol.packet.ScoreboardObjective;
|
import net.md_5.bungee.protocol.packet.ScoreboardObjective;
|
||||||
import net.md_5.bungee.protocol.packet.ScoreboardScore;
|
import net.md_5.bungee.protocol.packet.ScoreboardScore;
|
||||||
import net.md_5.bungee.protocol.packet.ScoreboardDisplay;
|
import net.md_5.bungee.protocol.packet.ScoreboardDisplay;
|
||||||
@ -22,10 +22,15 @@ import net.md_5.bungee.protocol.packet.LoginSuccess;
|
|||||||
import net.md_5.bungee.protocol.packet.PingPacket;
|
import net.md_5.bungee.protocol.packet.PingPacket;
|
||||||
import net.md_5.bungee.protocol.packet.StatusRequest;
|
import net.md_5.bungee.protocol.packet.StatusRequest;
|
||||||
import net.md_5.bungee.protocol.packet.StatusResponse;
|
import net.md_5.bungee.protocol.packet.StatusResponse;
|
||||||
|
import net.md_5.bungee.protocol.packet.TabCompleteResponse;
|
||||||
|
|
||||||
public abstract class AbstractPacketHandler
|
public abstract class AbstractPacketHandler
|
||||||
{
|
{
|
||||||
|
|
||||||
|
public void handle(TabCompleteResponse tabResponse) throws Exception
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
public void handle(PingPacket ping) throws Exception
|
public void handle(PingPacket ping) throws Exception
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -74,7 +79,7 @@ public abstract class AbstractPacketHandler
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handle(TabComplete tabComplete) throws Exception
|
public void handle(TabCompleteRequest tabComplete) throws Exception
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,6 +41,26 @@ public abstract class DefinedPacket
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void writeStringArray(String[] s, ByteBuf buf)
|
||||||
|
{
|
||||||
|
writeVarInt( s.length, buf );
|
||||||
|
for ( String str : s )
|
||||||
|
{
|
||||||
|
writeString( str, buf );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String[] readStringArray(ByteBuf buf)
|
||||||
|
{
|
||||||
|
int len = readVarInt( buf );
|
||||||
|
String[] ret = new String[ len ];
|
||||||
|
for ( int i = 0; i < ret.length; i++ )
|
||||||
|
{
|
||||||
|
ret[i] = readString( buf );
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
public static int readVarInt(ByteBuf input)
|
public static int readVarInt(ByteBuf input)
|
||||||
{
|
{
|
||||||
int out = 0;
|
int out = 0;
|
||||||
|
@ -24,7 +24,8 @@ import net.md_5.bungee.protocol.packet.ScoreboardObjective;
|
|||||||
import net.md_5.bungee.protocol.packet.ScoreboardScore;
|
import net.md_5.bungee.protocol.packet.ScoreboardScore;
|
||||||
import net.md_5.bungee.protocol.packet.StatusRequest;
|
import net.md_5.bungee.protocol.packet.StatusRequest;
|
||||||
import net.md_5.bungee.protocol.packet.StatusResponse;
|
import net.md_5.bungee.protocol.packet.StatusResponse;
|
||||||
import net.md_5.bungee.protocol.packet.TabComplete;
|
import net.md_5.bungee.protocol.packet.TabCompleteRequest;
|
||||||
|
import net.md_5.bungee.protocol.packet.TabCompleteResponse;
|
||||||
import net.md_5.bungee.protocol.packet.Team;
|
import net.md_5.bungee.protocol.packet.Team;
|
||||||
|
|
||||||
public enum Protocol
|
public enum Protocol
|
||||||
@ -48,7 +49,7 @@ public enum Protocol
|
|||||||
TO_CLIENT.registerPacket( 0x02, Chat.class );
|
TO_CLIENT.registerPacket( 0x02, Chat.class );
|
||||||
TO_CLIENT.registerPacket( 0x07, Respawn.class );
|
TO_CLIENT.registerPacket( 0x07, Respawn.class );
|
||||||
TO_CLIENT.registerPacket( 0x3B, PlayerListItem.class );
|
TO_CLIENT.registerPacket( 0x3B, PlayerListItem.class );
|
||||||
TO_CLIENT.registerPacket( 0x3D, TabComplete.class );
|
TO_CLIENT.registerPacket( 0x3D, TabCompleteResponse.class );
|
||||||
TO_CLIENT.registerPacket( 0x3E, ScoreboardObjective.class );
|
TO_CLIENT.registerPacket( 0x3E, ScoreboardObjective.class );
|
||||||
TO_CLIENT.registerPacket( 0x3F, ScoreboardScore.class );
|
TO_CLIENT.registerPacket( 0x3F, ScoreboardScore.class );
|
||||||
TO_CLIENT.registerPacket( 0x40, ScoreboardDisplay.class );
|
TO_CLIENT.registerPacket( 0x40, ScoreboardDisplay.class );
|
||||||
@ -59,7 +60,7 @@ public enum Protocol
|
|||||||
|
|
||||||
TO_SERVER.registerPacket( 0x00, KeepAlive.class );
|
TO_SERVER.registerPacket( 0x00, KeepAlive.class );
|
||||||
TO_SERVER.registerPacket( 0x01, Chat.class );
|
TO_SERVER.registerPacket( 0x01, Chat.class );
|
||||||
TO_SERVER.registerPacket( 0x14, TabComplete.class );
|
TO_SERVER.registerPacket( 0x14, TabCompleteRequest.class );
|
||||||
TO_SERVER.registerPacket( 0x15, ClientSettings.class );
|
TO_SERVER.registerPacket( 0x15, ClientSettings.class );
|
||||||
TO_SERVER.registerPacket( 0x17, PluginMessage.class );
|
TO_SERVER.registerPacket( 0x17, PluginMessage.class );
|
||||||
}
|
}
|
||||||
@ -92,7 +93,7 @@ public enum Protocol
|
|||||||
/*========================================================================*/
|
/*========================================================================*/
|
||||||
public static final int MAX_PACKET_ID = 0xFF;
|
public static final int MAX_PACKET_ID = 0xFF;
|
||||||
public static final int PROTOCOL_VERSION = 0x00;
|
public static final int PROTOCOL_VERSION = 0x00;
|
||||||
public static final String MINECRAFT_VERSION = "13w41a";
|
public static final String MINECRAFT_VERSION = "13w41b";
|
||||||
/*========================================================================*/
|
/*========================================================================*/
|
||||||
public final ProtocolDirection TO_SERVER = new ProtocolDirection( "TO_SERVER" );
|
public final ProtocolDirection TO_SERVER = new ProtocolDirection( "TO_SERVER" );
|
||||||
public final ProtocolDirection TO_CLIENT = new ProtocolDirection( "TO_CLIENT" );
|
public final ProtocolDirection TO_CLIENT = new ProtocolDirection( "TO_CLIENT" );
|
||||||
|
@ -25,7 +25,7 @@ public class Handshake extends DefinedPacket
|
|||||||
{
|
{
|
||||||
protocolVersion = readVarInt( buf );
|
protocolVersion = readVarInt( buf );
|
||||||
host = readString( buf );
|
host = readString( buf );
|
||||||
port = readVarInt( buf );
|
port = buf.readUnsignedShort();
|
||||||
requestedProtocol = readVarInt( buf );
|
requestedProtocol = readVarInt( buf );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -34,7 +34,7 @@ public class Handshake extends DefinedPacket
|
|||||||
{
|
{
|
||||||
writeVarInt( protocolVersion, buf );
|
writeVarInt( protocolVersion, buf );
|
||||||
writeString( host, buf );
|
writeString( host, buf );
|
||||||
writeVarInt( port, buf );
|
buf.writeShort( port );
|
||||||
writeVarInt( requestedProtocol, buf );
|
writeVarInt( requestedProtocol, buf );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,34 +16,28 @@ public class Login extends DefinedPacket
|
|||||||
{
|
{
|
||||||
|
|
||||||
private int entityId;
|
private int entityId;
|
||||||
private String levelType;
|
private short gameMode;
|
||||||
private byte gameMode;
|
|
||||||
private int dimension;
|
private int dimension;
|
||||||
private byte difficulty;
|
private short difficulty;
|
||||||
private byte unused;
|
private short maxPlayers;
|
||||||
private byte maxPlayers;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void read(ByteBuf buf)
|
public void read(ByteBuf buf)
|
||||||
{
|
{
|
||||||
entityId = buf.readInt();
|
entityId = buf.readInt();
|
||||||
levelType = readString( buf );
|
gameMode = buf.readUnsignedByte();
|
||||||
gameMode = buf.readByte();
|
|
||||||
dimension = buf.readByte();
|
dimension = buf.readByte();
|
||||||
difficulty = buf.readByte();
|
difficulty = buf.readUnsignedByte();
|
||||||
unused = buf.readByte();
|
maxPlayers = buf.readUnsignedByte();
|
||||||
maxPlayers = buf.readByte();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void write(ByteBuf buf)
|
public void write(ByteBuf buf)
|
||||||
{
|
{
|
||||||
buf.writeInt( entityId );
|
buf.writeInt( entityId );
|
||||||
writeString( levelType, buf );
|
|
||||||
buf.writeByte( gameMode );
|
buf.writeByte( gameMode );
|
||||||
buf.writeByte( dimension );
|
buf.writeByte( dimension );
|
||||||
buf.writeByte( difficulty );
|
buf.writeByte( difficulty );
|
||||||
buf.writeByte( unused );
|
|
||||||
buf.writeByte( maxPlayers );
|
buf.writeByte( maxPlayers );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,7 +6,6 @@ import lombok.AllArgsConstructor;
|
|||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
import lombok.ToString;
|
|
||||||
import net.md_5.bungee.protocol.AbstractPacketHandler;
|
import net.md_5.bungee.protocol.AbstractPacketHandler;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@ -17,19 +16,15 @@ public class Respawn extends DefinedPacket
|
|||||||
{
|
{
|
||||||
|
|
||||||
private int dimension;
|
private int dimension;
|
||||||
private byte difficulty;
|
private short difficulty;
|
||||||
private byte gameMode;
|
private short gameMode;
|
||||||
private short worldHeight;
|
|
||||||
private String levelType;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void read(ByteBuf buf)
|
public void read(ByteBuf buf)
|
||||||
{
|
{
|
||||||
dimension = buf.readInt();
|
dimension = buf.readInt();
|
||||||
difficulty = buf.readByte();
|
difficulty = buf.readUnsignedByte();
|
||||||
gameMode = buf.readByte();
|
gameMode = buf.readUnsignedByte();
|
||||||
worldHeight = buf.readShort();
|
|
||||||
levelType = readString( buf );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -38,8 +33,6 @@ public class Respawn extends DefinedPacket
|
|||||||
buf.writeInt( dimension );
|
buf.writeInt( dimension );
|
||||||
buf.writeByte( difficulty );
|
buf.writeByte( difficulty );
|
||||||
buf.writeByte( gameMode );
|
buf.writeByte( gameMode );
|
||||||
buf.writeShort( worldHeight );
|
|
||||||
writeString( levelType, buf );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -12,16 +12,10 @@ import net.md_5.bungee.protocol.AbstractPacketHandler;
|
|||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@EqualsAndHashCode(callSuper = false)
|
@EqualsAndHashCode(callSuper = false)
|
||||||
public class TabComplete extends DefinedPacket
|
public class TabCompleteRequest extends DefinedPacket
|
||||||
{
|
{
|
||||||
|
|
||||||
private String cursor;
|
private String cursor;
|
||||||
private String[] commands;
|
|
||||||
|
|
||||||
public TabComplete(String[] alternatives)
|
|
||||||
{
|
|
||||||
commands = alternatives;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void read(ByteBuf buf)
|
public void read(ByteBuf buf)
|
||||||
@ -32,13 +26,7 @@ public class TabComplete extends DefinedPacket
|
|||||||
@Override
|
@Override
|
||||||
public void write(ByteBuf buf)
|
public void write(ByteBuf buf)
|
||||||
{
|
{
|
||||||
StringBuilder tab = new StringBuilder();
|
writeString( cursor, buf );
|
||||||
for ( String alternative : commands )
|
|
||||||
{
|
|
||||||
tab.append( alternative );
|
|
||||||
tab.append( "\00" );
|
|
||||||
}
|
|
||||||
writeString( tab.substring( 0, tab.length() - 1 ), buf );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
@ -0,0 +1,37 @@
|
|||||||
|
package net.md_5.bungee.protocol.packet;
|
||||||
|
|
||||||
|
import net.md_5.bungee.protocol.DefinedPacket;
|
||||||
|
import io.netty.buffer.ByteBuf;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import net.md_5.bungee.protocol.AbstractPacketHandler;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@EqualsAndHashCode(callSuper = false)
|
||||||
|
public class TabCompleteResponse extends DefinedPacket
|
||||||
|
{
|
||||||
|
|
||||||
|
private String[] commands;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void read(ByteBuf buf)
|
||||||
|
{
|
||||||
|
commands = readStringArray( buf );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void write(ByteBuf buf)
|
||||||
|
{
|
||||||
|
writeStringArray( commands, buf );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handle(AbstractPacketHandler handler) throws Exception
|
||||||
|
{
|
||||||
|
handler.handle( this );
|
||||||
|
}
|
||||||
|
}
|
@ -7,8 +7,8 @@ import net.md_5.bungee.protocol.packet.PluginMessage;
|
|||||||
public class PacketConstants
|
public class PacketConstants
|
||||||
{
|
{
|
||||||
|
|
||||||
public static final Respawn DIM1_SWITCH = new Respawn( (byte) 1, (byte) 0, (byte) 0, (short) 256, "DEFAULT" );
|
public static final Respawn DIM1_SWITCH = new Respawn( (byte) 1, (byte) 0, (byte) 0 );
|
||||||
public static final Respawn DIM2_SWITCH = new Respawn( (byte) -1, (byte) 0, (byte) 0, (short) 256, "DEFAULT" );
|
public static final Respawn DIM2_SWITCH = new Respawn( (byte) -1, (byte) 0, (byte) 0 );
|
||||||
public static final ClientStatus CLIENT_LOGIN = new ClientStatus( (byte) 0 );
|
public static final ClientStatus CLIENT_LOGIN = new ClientStatus( (byte) 0 );
|
||||||
public static final PluginMessage FORGE_MOD_REQUEST = new PluginMessage( "FML", new byte[]
|
public static final PluginMessage FORGE_MOD_REQUEST = new PluginMessage( "FML", new byte[]
|
||||||
{
|
{
|
||||||
|
@ -22,7 +22,6 @@ import net.md_5.bungee.netty.ChannelWrapper;
|
|||||||
import net.md_5.bungee.netty.PacketHandler;
|
import net.md_5.bungee.netty.PacketHandler;
|
||||||
import net.md_5.bungee.protocol.MinecraftOutput;
|
import net.md_5.bungee.protocol.MinecraftOutput;
|
||||||
import net.md_5.bungee.protocol.DefinedPacket;
|
import net.md_5.bungee.protocol.DefinedPacket;
|
||||||
import net.md_5.bungee.protocol.PacketWrapper;
|
|
||||||
import net.md_5.bungee.protocol.Protocol;
|
import net.md_5.bungee.protocol.Protocol;
|
||||||
import net.md_5.bungee.protocol.packet.Login;
|
import net.md_5.bungee.protocol.packet.Login;
|
||||||
import net.md_5.bungee.protocol.packet.Respawn;
|
import net.md_5.bungee.protocol.packet.Respawn;
|
||||||
@ -131,7 +130,7 @@ public class ServerConnector extends PacketHandler
|
|||||||
user.setServerEntityId( login.getEntityId() );
|
user.setServerEntityId( login.getEntityId() );
|
||||||
|
|
||||||
// Set tab list size, this sucks balls, TODO: what shall we do about packet mutability
|
// Set tab list size, this sucks balls, TODO: what shall we do about packet mutability
|
||||||
Login modLogin = new Login( login.getEntityId(), login.getLevelType(), login.getGameMode(), (byte) login.getDimension(), login.getDifficulty(), login.getUnused(),
|
Login modLogin = new Login( login.getEntityId(), login.getGameMode(), (byte) login.getDimension(), login.getDifficulty(),
|
||||||
(byte) user.getPendingConnection().getListener().getTabListSize() );
|
(byte) user.getPendingConnection().getListener().getTabListSize() );
|
||||||
|
|
||||||
user.unsafe().sendPacket( modLogin );
|
user.unsafe().sendPacket( modLogin );
|
||||||
@ -157,7 +156,7 @@ public class ServerConnector extends PacketHandler
|
|||||||
user.sendDimensionSwitch();
|
user.sendDimensionSwitch();
|
||||||
|
|
||||||
user.setServerEntityId( login.getEntityId() );
|
user.setServerEntityId( login.getEntityId() );
|
||||||
user.unsafe().sendPacket( new Respawn( login.getDimension(), login.getDifficulty(), login.getGameMode(), (short) 256, login.getLevelType() ) );
|
user.unsafe().sendPacket( new Respawn( login.getDimension(), login.getDifficulty(), login.getGameMode() ) );
|
||||||
|
|
||||||
// Remove from old servers
|
// Remove from old servers
|
||||||
user.getServer().setObsolete( true );
|
user.getServer().setObsolete( true );
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package net.md_5.bungee.connection;
|
package net.md_5.bungee.connection;
|
||||||
|
|
||||||
import net.md_5.bungee.BungeeCord;
|
import net.md_5.bungee.BungeeCord;
|
||||||
import net.md_5.bungee.EntityMap;
|
|
||||||
import net.md_5.bungee.UserConnection;
|
import net.md_5.bungee.UserConnection;
|
||||||
import net.md_5.bungee.Util;
|
import net.md_5.bungee.Util;
|
||||||
import net.md_5.bungee.api.ProxyServer;
|
import net.md_5.bungee.api.ProxyServer;
|
||||||
@ -13,11 +12,12 @@ import net.md_5.bungee.netty.PacketHandler;
|
|||||||
import net.md_5.bungee.protocol.PacketWrapper;
|
import net.md_5.bungee.protocol.PacketWrapper;
|
||||||
import net.md_5.bungee.protocol.packet.KeepAlive;
|
import net.md_5.bungee.protocol.packet.KeepAlive;
|
||||||
import net.md_5.bungee.protocol.packet.Chat;
|
import net.md_5.bungee.protocol.packet.Chat;
|
||||||
import net.md_5.bungee.protocol.packet.TabComplete;
|
import net.md_5.bungee.protocol.packet.TabCompleteRequest;
|
||||||
import net.md_5.bungee.protocol.packet.ClientSettings;
|
import net.md_5.bungee.protocol.packet.ClientSettings;
|
||||||
import net.md_5.bungee.protocol.packet.PluginMessage;
|
import net.md_5.bungee.protocol.packet.PluginMessage;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import net.md_5.bungee.protocol.packet.TabCompleteResponse;
|
||||||
|
|
||||||
public class UpstreamBridge extends PacketHandler
|
public class UpstreamBridge extends PacketHandler
|
||||||
{
|
{
|
||||||
@ -93,7 +93,7 @@ public class UpstreamBridge extends PacketHandler
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handle(TabComplete tabComplete) throws Exception
|
public void handle(TabCompleteRequest tabComplete) throws Exception
|
||||||
{
|
{
|
||||||
if ( tabComplete.getCursor().startsWith( "/" ) )
|
if ( tabComplete.getCursor().startsWith( "/" ) )
|
||||||
{
|
{
|
||||||
@ -102,7 +102,7 @@ public class UpstreamBridge extends PacketHandler
|
|||||||
|
|
||||||
if ( !results.isEmpty() )
|
if ( !results.isEmpty() )
|
||||||
{
|
{
|
||||||
con.unsafe().sendPacket( new TabComplete( results.toArray( new String[ results.size() ] ) ) );
|
con.unsafe().sendPacket( new TabCompleteResponse( results.toArray( new String[ results.size() ] ) ) );
|
||||||
throw new CancelSendSignal();
|
throw new CancelSendSignal();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user