Update packets for MINECRAFT_14_11_a

This commit is contained in:
md_5 2014-04-16 10:48:40 +10:00
parent 1a1a51b38d
commit 3715756be7
9 changed files with 84 additions and 29 deletions

View File

@ -16,7 +16,7 @@ public class Team
private String displayName; private String displayName;
private String prefix; private String prefix;
private String suffix; private String suffix;
private boolean friendlyFire; private byte friendlyFire;
private Set<String> players = new HashSet<>(); private Set<String> players = new HashSet<>();
public Collection<String> getPlayers() public Collection<String> getPlayers()

View File

@ -7,7 +7,6 @@ import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import net.md_5.bungee.protocol.AbstractPacketHandler; import net.md_5.bungee.protocol.AbstractPacketHandler;
import net.md_5.bungee.protocol.Protocol;
import net.md_5.bungee.protocol.ProtocolConstants; import net.md_5.bungee.protocol.ProtocolConstants;
@Data @Data

View File

@ -19,9 +19,9 @@ public class ClientSettings extends DefinedPacket
private String locale; private String locale;
private byte viewDistance; private byte viewDistance;
private byte chatFlags; private byte chatFlags;
private boolean unknown; private boolean chatColours;
private byte difficulty; private byte difficulty;
private byte showCape; private byte skinParts;
@Override @Override
public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion) public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
@ -29,12 +29,12 @@ public class ClientSettings extends DefinedPacket
locale = readString( buf ); locale = readString( buf );
viewDistance = buf.readByte(); viewDistance = buf.readByte();
chatFlags = buf.readByte(); chatFlags = buf.readByte();
unknown = buf.readBoolean(); chatColours = buf.readBoolean();
if ( protocolVersion <= ProtocolConstants.MINECRAFT_1_7_6 ) if ( protocolVersion <= ProtocolConstants.MINECRAFT_1_7_6 )
{ {
difficulty = buf.readByte(); difficulty = buf.readByte();
} }
showCape = buf.readByte(); skinParts = buf.readByte();
} }
@Override @Override
@ -43,12 +43,12 @@ public class ClientSettings extends DefinedPacket
writeString( locale, buf ); writeString( locale, buf );
buf.writeByte( viewDistance ); buf.writeByte( viewDistance );
buf.writeByte( chatFlags ); buf.writeByte( chatFlags );
buf.writeBoolean( unknown ); buf.writeBoolean( chatColours );
if ( protocolVersion <= ProtocolConstants.MINECRAFT_1_7_6 ) if ( protocolVersion <= ProtocolConstants.MINECRAFT_1_7_6 )
{ {
buf.writeByte( difficulty ); buf.writeByte( difficulty );
} }
buf.writeByte( showCape ); buf.writeByte( skinParts );
} }
@Override @Override

View File

@ -7,6 +7,7 @@ import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import net.md_5.bungee.protocol.AbstractPacketHandler; import net.md_5.bungee.protocol.AbstractPacketHandler;
import net.md_5.bungee.protocol.ProtocolConstants;
@Data @Data
@NoArgsConstructor @NoArgsConstructor
@ -18,15 +19,27 @@ public class KeepAlive extends DefinedPacket
private int randomId; private int randomId;
@Override @Override
public void read(ByteBuf buf) public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
{ {
randomId = buf.readInt(); if ( direction == ProtocolConstants.Direction.TO_SERVER && protocolVersion >= ProtocolConstants.MINECRAFT_14_11_a )
{
randomId = readVarInt( buf );
} else
{
randomId = buf.readInt();
}
} }
@Override @Override
public void write(ByteBuf buf) public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
{ {
buf.writeInt( randomId ); if ( direction == ProtocolConstants.Direction.TO_SERVER && protocolVersion >= ProtocolConstants.MINECRAFT_14_11_a )
{
writeVarInt( randomId, buf );
} else
{
buf.writeInt( randomId );
}
} }
@Override @Override

View File

@ -7,6 +7,7 @@ import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import net.md_5.bungee.protocol.AbstractPacketHandler; import net.md_5.bungee.protocol.AbstractPacketHandler;
import net.md_5.bungee.protocol.ProtocolConstants;
@Data @Data
@NoArgsConstructor @NoArgsConstructor
@ -17,22 +18,34 @@ public class PlayerListItem extends DefinedPacket
private String username; private String username;
private boolean online; private boolean online;
private short ping; private int ping;
@Override @Override
public void read(ByteBuf buf) public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
{ {
username = readString( buf ); username = readString( buf );
online = buf.readBoolean(); online = buf.readBoolean();
ping = buf.readShort(); if ( protocolVersion >= ProtocolConstants.MINECRAFT_14_11_a )
{
ping = readVarInt( buf );
} else
{
ping = buf.readShort();
}
} }
@Override @Override
public void write(ByteBuf buf) public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
{ {
writeString( username, buf ); writeString( username, buf );
buf.writeBoolean( online ); buf.writeBoolean( online );
buf.writeShort( ping ); if ( protocolVersion >= ProtocolConstants.MINECRAFT_14_11_a )
{
writeVarInt( ping, buf );
} else
{
buf.writeShort( ping );
}
} }
@Override @Override

View File

@ -7,6 +7,7 @@ import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import net.md_5.bungee.protocol.AbstractPacketHandler; import net.md_5.bungee.protocol.AbstractPacketHandler;
import net.md_5.bungee.protocol.ProtocolConstants;
@Data @Data
@NoArgsConstructor @NoArgsConstructor
@ -16,26 +17,43 @@ public class ScoreboardObjective extends DefinedPacket
{ {
private String name; private String name;
private String text; private String value;
private String type;
/** /**
* 0 to create, 1 to remove. * 0 to create, 1 to remove, 2 to update display text.
*/ */
private byte action; private byte action;
@Override @Override
public void read(ByteBuf buf) public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
{ {
name = readString( buf ); name = readString( buf );
text = readString( buf ); if ( protocolVersion <= ProtocolConstants.MINECRAFT_1_7_6 )
{
value = readString( buf );
}
action = buf.readByte(); action = buf.readByte();
if ( protocolVersion >= ProtocolConstants.MINECRAFT_14_11_a && ( action == 0 || action == 2 ) )
{
value = readString( buf );
type = readString( buf );
}
} }
@Override @Override
public void write(ByteBuf buf) public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
{ {
writeString( name, buf ); writeString( name, buf );
writeString( text, buf ); if ( protocolVersion <= ProtocolConstants.MINECRAFT_1_7_6 )
{
writeString( value, buf );
}
buf.writeByte( action ); buf.writeByte( action );
if ( protocolVersion >= ProtocolConstants.MINECRAFT_14_11_a && ( action == 0 || action == 2 ) )
{
writeString( value, buf );
writeString( type, buf );
}
} }
@Override @Override

View File

@ -24,7 +24,9 @@ public class Team extends DefinedPacket
private String displayName; private String displayName;
private String prefix; private String prefix;
private String suffix; private String suffix;
private boolean friendlyFire; private String unknown;
private byte unknown2;
private byte friendlyFire;
private String[] players; private String[] players;
/** /**
@ -49,7 +51,12 @@ public class Team extends DefinedPacket
displayName = readString( buf ); displayName = readString( buf );
prefix = readString( buf ); prefix = readString( buf );
suffix = readString( buf ); suffix = readString( buf );
friendlyFire = buf.readBoolean(); friendlyFire = buf.readByte();
if ( protocolVersion >= ProtocolConstants.MINECRAFT_14_11_a )
{
unknown = readString( buf );
unknown2 = buf.readByte();
}
} }
if ( mode == 0 || mode == 3 || mode == 4 ) if ( mode == 0 || mode == 3 || mode == 4 )
{ {
@ -72,7 +79,12 @@ public class Team extends DefinedPacket
writeString( displayName, buf ); writeString( displayName, buf );
writeString( prefix, buf ); writeString( prefix, buf );
writeString( suffix, buf ); writeString( suffix, buf );
buf.writeBoolean( friendlyFire ); buf.writeByte( friendlyFire );
if ( protocolVersion >= ProtocolConstants.MINECRAFT_14_11_a )
{
writeString( unknown, buf );
buf.writeByte( unknown2 );
}
} }
if ( mode == 0 || mode == 3 || mode == 4 ) if ( mode == 0 || mode == 3 || mode == 4 )
{ {

View File

@ -153,7 +153,7 @@ public class ServerConnector extends PacketHandler
Scoreboard serverScoreboard = user.getServerSentScoreboard(); Scoreboard serverScoreboard = user.getServerSentScoreboard();
for ( Objective objective : serverScoreboard.getObjectives() ) for ( Objective objective : serverScoreboard.getObjectives() )
{ {
user.unsafe().sendPacket( new ScoreboardObjective( objective.getName(), objective.getValue(), (byte) 1 ) ); user.unsafe().sendPacket( new ScoreboardObjective( objective.getName(), objective.getValue(), "integer", (byte) 1 ) ); // TODO:
} }
for ( Team team : serverScoreboard.getTeams() ) for ( Team team : serverScoreboard.getTeams() )
{ {

View File

@ -114,7 +114,7 @@ public class DownstreamBridge extends PacketHandler
switch ( objective.getAction() ) switch ( objective.getAction() )
{ {
case 0: case 0:
serverScoreboard.addObjective( new Objective( objective.getName(), objective.getText() ) ); serverScoreboard.addObjective( new Objective( objective.getName(), objective.getValue() ) );
break; break;
case 1: case 1:
serverScoreboard.removeObjective( objective.getName() ); serverScoreboard.removeObjective( objective.getName() );
@ -176,7 +176,7 @@ public class DownstreamBridge extends PacketHandler
t.setDisplayName( team.getDisplayName() ); t.setDisplayName( team.getDisplayName() );
t.setPrefix( team.getPrefix() ); t.setPrefix( team.getPrefix() );
t.setSuffix( team.getSuffix() ); t.setSuffix( team.getSuffix() );
t.setFriendlyFire( team.isFriendlyFire() ); t.setFriendlyFire( team.getFriendlyFire() );
} }
if ( team.getPlayers() != null ) if ( team.getPlayers() != null )
{ {