Search in sources :

Example 1 with V1_5Team

use of com.github.dirtpowered.dirtmv.data.protocol.objects.V1_5Team in project DirtMultiversion by DirtPowered.

the class V1_5RTeamDataType method write.

@Override
public void write(TypeHolder typeHolder, PacketOutput packetOutput) throws IOException {
    V1_5Team teamObject = (V1_5Team) typeHolder.getObject();
    BaseProtocol.STRING.write(new TypeHolder(Type.STRING, teamObject.getName()), packetOutput);
    packetOutput.writeByte(teamObject.getAction());
    switch(teamObject.getAction()) {
        case 0:
            BaseProtocol.STRING.write(new TypeHolder(Type.STRING, teamObject.getDisplayName()), packetOutput);
            BaseProtocol.STRING.write(new TypeHolder(Type.STRING, teamObject.getPrefix()), packetOutput);
            BaseProtocol.STRING.write(new TypeHolder(Type.STRING, teamObject.getSuffix()), packetOutput);
            packetOutput.writeByte(teamObject.getFriendlyFire());
            packetOutput.writeShort(teamObject.getPlayers().length);
            for (int i = 0; i < teamObject.getPlayers().length; i++) BaseProtocol.STRING.write(new TypeHolder(Type.STRING, teamObject.getPlayers()[i]), packetOutput);
            break;
        case 2:
            BaseProtocol.STRING.write(new TypeHolder(Type.STRING, teamObject.getDisplayName()), packetOutput);
            BaseProtocol.STRING.write(new TypeHolder(Type.STRING, teamObject.getPrefix()), packetOutput);
            BaseProtocol.STRING.write(new TypeHolder(Type.STRING, teamObject.getSuffix()), packetOutput);
            packetOutput.writeByte(teamObject.getFriendlyFire());
            break;
        case 3:
        case 4:
            packetOutput.writeShort(teamObject.getPlayers().length);
            for (int i = 0; i < teamObject.getPlayers().length; i++) BaseProtocol.STRING.write(new TypeHolder(Type.STRING, teamObject.getPlayers()[i]), packetOutput);
            break;
    }
}
Also used : TypeHolder(com.github.dirtpowered.dirtmv.data.protocol.TypeHolder) V1_5Team(com.github.dirtpowered.dirtmv.data.protocol.objects.V1_5Team)

Aggregations

TypeHolder (com.github.dirtpowered.dirtmv.data.protocol.TypeHolder)1 V1_5Team (com.github.dirtpowered.dirtmv.data.protocol.objects.V1_5Team)1