41b update
This commit is contained in:
@@ -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.EncryptionRequest;
|
||||
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.ScoreboardScore;
|
||||
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.StatusRequest;
|
||||
import net.md_5.bungee.protocol.packet.StatusResponse;
|
||||
import net.md_5.bungee.protocol.packet.TabCompleteResponse;
|
||||
|
||||
public abstract class AbstractPacketHandler
|
||||
{
|
||||
|
||||
public void handle(TabCompleteResponse tabResponse) 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;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
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.StatusRequest;
|
||||
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;
|
||||
|
||||
public enum Protocol
|
||||
@@ -48,7 +49,7 @@ public enum Protocol
|
||||
TO_CLIENT.registerPacket( 0x02, Chat.class );
|
||||
TO_CLIENT.registerPacket( 0x07, Respawn.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( 0x3F, ScoreboardScore.class );
|
||||
TO_CLIENT.registerPacket( 0x40, ScoreboardDisplay.class );
|
||||
@@ -59,7 +60,7 @@ public enum Protocol
|
||||
|
||||
TO_SERVER.registerPacket( 0x00, KeepAlive.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( 0x17, PluginMessage.class );
|
||||
}
|
||||
@@ -92,7 +93,7 @@ public enum Protocol
|
||||
/*========================================================================*/
|
||||
public static final int MAX_PACKET_ID = 0xFF;
|
||||
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_CLIENT = new ProtocolDirection( "TO_CLIENT" );
|
||||
|
@@ -25,7 +25,7 @@ public class Handshake extends DefinedPacket
|
||||
{
|
||||
protocolVersion = readVarInt( buf );
|
||||
host = readString( buf );
|
||||
port = readVarInt( buf );
|
||||
port = buf.readUnsignedShort();
|
||||
requestedProtocol = readVarInt( buf );
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ public class Handshake extends DefinedPacket
|
||||
{
|
||||
writeVarInt( protocolVersion, buf );
|
||||
writeString( host, buf );
|
||||
writeVarInt( port, buf );
|
||||
buf.writeShort( port );
|
||||
writeVarInt( requestedProtocol, buf );
|
||||
}
|
||||
|
||||
|
@@ -16,34 +16,28 @@ public class Login extends DefinedPacket
|
||||
{
|
||||
|
||||
private int entityId;
|
||||
private String levelType;
|
||||
private byte gameMode;
|
||||
private short gameMode;
|
||||
private int dimension;
|
||||
private byte difficulty;
|
||||
private byte unused;
|
||||
private byte maxPlayers;
|
||||
private short difficulty;
|
||||
private short maxPlayers;
|
||||
|
||||
@Override
|
||||
public void read(ByteBuf buf)
|
||||
{
|
||||
entityId = buf.readInt();
|
||||
levelType = readString( buf );
|
||||
gameMode = buf.readByte();
|
||||
gameMode = buf.readUnsignedByte();
|
||||
dimension = buf.readByte();
|
||||
difficulty = buf.readByte();
|
||||
unused = buf.readByte();
|
||||
maxPlayers = buf.readByte();
|
||||
difficulty = buf.readUnsignedByte();
|
||||
maxPlayers = buf.readUnsignedByte();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(ByteBuf buf)
|
||||
{
|
||||
buf.writeInt( entityId );
|
||||
writeString( levelType, buf );
|
||||
buf.writeByte( gameMode );
|
||||
buf.writeByte( dimension );
|
||||
buf.writeByte( difficulty );
|
||||
buf.writeByte( unused );
|
||||
buf.writeByte( maxPlayers );
|
||||
}
|
||||
|
||||
|
@@ -6,7 +6,6 @@ import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.ToString;
|
||||
import net.md_5.bungee.protocol.AbstractPacketHandler;
|
||||
|
||||
@Data
|
||||
@@ -17,19 +16,15 @@ public class Respawn extends DefinedPacket
|
||||
{
|
||||
|
||||
private int dimension;
|
||||
private byte difficulty;
|
||||
private byte gameMode;
|
||||
private short worldHeight;
|
||||
private String levelType;
|
||||
private short difficulty;
|
||||
private short gameMode;
|
||||
|
||||
@Override
|
||||
public void read(ByteBuf buf)
|
||||
{
|
||||
dimension = buf.readInt();
|
||||
difficulty = buf.readByte();
|
||||
gameMode = buf.readByte();
|
||||
worldHeight = buf.readShort();
|
||||
levelType = readString( buf );
|
||||
difficulty = buf.readUnsignedByte();
|
||||
gameMode = buf.readUnsignedByte();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -38,8 +33,6 @@ public class Respawn extends DefinedPacket
|
||||
buf.writeInt( dimension );
|
||||
buf.writeByte( difficulty );
|
||||
buf.writeByte( gameMode );
|
||||
buf.writeShort( worldHeight );
|
||||
writeString( levelType, buf );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -12,16 +12,10 @@ import net.md_5.bungee.protocol.AbstractPacketHandler;
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class TabComplete extends DefinedPacket
|
||||
public class TabCompleteRequest extends DefinedPacket
|
||||
{
|
||||
|
||||
private String cursor;
|
||||
private String[] commands;
|
||||
|
||||
public TabComplete(String[] alternatives)
|
||||
{
|
||||
commands = alternatives;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(ByteBuf buf)
|
||||
@@ -32,13 +26,7 @@ public class TabComplete extends DefinedPacket
|
||||
@Override
|
||||
public void write(ByteBuf buf)
|
||||
{
|
||||
StringBuilder tab = new StringBuilder();
|
||||
for ( String alternative : commands )
|
||||
{
|
||||
tab.append( alternative );
|
||||
tab.append( "\00" );
|
||||
}
|
||||
writeString( tab.substring( 0, tab.length() - 1 ), buf );
|
||||
writeString( cursor, buf );
|
||||
}
|
||||
|
||||
@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 );
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user