@Override
	public void updatePlayerState(Player player, ByteVector update, boolean forced, boolean chat) {
		synchronized(player) {
			int mask = 0x0;
			if (player.getUpdateFlags().contains("chat") && !chat) {
				mask |= 0x80;
			}
			if (player.getUpdateFlags().contains("appearance") || forced) {
				mask |= 0x10;
			}
			if (mask >= 0x100) {
				mask |= 0x40;
				update.writeByte((byte) (mask & 0xFF));
				update.writeByte((byte) (mask >> 8));
			} else {
				update.writeByte((byte) mask);
			}
			if (player.getUpdateFlags().contains("chat") && !chat) {
				update.writeLittleEndianShort(((player.getChatTextColor() & 0xFF) << 8) + (player.getChatTextEffects() & 0xFF));
				update.writeByte(0);
				update.writeByte((byte) -player.getChatText().length);
				update.getBuffer().put(player.getChatText());
			}
			if (player.getUpdateFlags().contains("appearance") || forced) {
				ByteVector properties = new ByteVector(ByteBuffer.allocate(128));
				properties.writeByte(0);
				properties.writeByte(0);
				properties.writeByte(0);
				properties.writeByte(0);
				properties.writeByte(0);
				properties.writeByte(0);
				properties.writeShort((short) (0x100 + player.getAppearanceValues()[0]));
				properties.writeByte(0);
				properties.writeShort((short) (0x100 + player.getAppearanceValues()[1]));
				properties.writeShort((short) (0x100 + player.getAppearanceValues()[2]));
				properties.writeShort((short) (0x100 + player.getAppearanceValues()[3]));
				properties.writeShort((short) (0x100 + player.getAppearanceValues()[4]));
				properties.writeShort((short) (0x100 + player.getAppearanceValues()[5]));
				properties.writeShort((short) (0x100 + player.getAppearanceValues()[6]));
				properties.writeByte((byte) player.getColorValues()[0]);
				properties.writeByte((byte) player.getColorValues()[1]);
				properties.writeByte((byte) player.getColorValues()[2]);
				properties.writeByte((byte) player.getColorValues()[3]);
				properties.writeByte((byte) player.getColorValues()[4]);
				properties.writeShort((short) 0x328); 
				properties.writeShort((short) 0x337); 
				properties.writeShort((short) 0x333); 
				properties.writeShort((short) 0x334); 
				properties.writeShort((short) 0x335); 
				properties.writeShort((short) 0x336); 
				properties.writeShort((short) 0x338);
				properties.writeLong(Utilities.convertStringToLong(player.getAccountName()));
				properties.writeByte(3);
				properties.writeShort((short) 0);
				update.writeByte((byte) -properties.getBuffer().position());
				update.writeBytes(properties.getBuffer());
			}
		}
	}