@Override public void handle(ScoreboardScore score) throws Exception { Scoreboard serverScoreboard = con.getServerSentScoreboard(); switch ( score.getAction() ) { case 0: Score s = new Score( score.getItemName(), score.getScoreName(), score.getValue() ); serverScoreboard.removeScore( score.getItemName() ); serverScoreboard.addScore( s ); break; case 1: serverScoreboard.removeScore( score.getItemName() ); break; default: throw new IllegalArgumentException( "Unknown scoreboard action: " + score.getAction() ); } }
@Override public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion) { itemName = readString( buf ); action = buf.readByte(); scoreName = readString( buf ); if ( action != 1 ) { value = readVarInt( buf ); } }
@Override public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion) { writeString( itemName, buf ); buf.writeByte( action ); writeString( scoreName, buf ); if ( action != 1 ) { writeVarInt( value, buf ); } }
user.unsafe().sendPacket( new ScoreboardScore( score.getItemName(), (byte) 1, score.getScoreName(), score.getValue() ) );
@Override public void handle(ScoreboardScore score) throws Exception { Scoreboard serverScoreboard = con.getServerSentScoreboard(); switch ( score.getAction() ) { case 0: Score s = new Score( score.getItemName(), score.getScoreName(), score.getValue() ); serverScoreboard.removeScore( score.getItemName() ); serverScoreboard.addScore( s ); break; case 1: serverScoreboard.removeScore( score.getItemName() ); break; default: throw new IllegalArgumentException( "Unknown scoreboard action: " + score.getAction() ); } }
@Override public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion) { itemName = readString( buf ); action = buf.readByte(); if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_8 ) { scoreName = readString( buf ); if ( action != 1 ) { value = readVarInt( buf ); } } else { if ( action != 1 ) { scoreName = readString( buf ); value = buf.readInt(); } } }
@Override public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion) { writeString( itemName, buf ); buf.writeByte( action ); if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_8 ) { writeString( scoreName, buf ); if ( action != 1 ) { writeVarInt( value, buf ); } } else { if ( action != 1 ) { writeString( scoreName, buf ); buf.writeInt( value ); } } }