Fix NPE in donor perk packet

This commit is contained in:
Electroblob77
2020-10-23 15:38:29 +01:00
parent 97061f7a32
commit 2a21eb4392
@@ -47,12 +47,13 @@ public class PacketRequestDonationPerks implements IMessageHandler<PacketRequest
@Override @Override
public void fromBytes(ByteBuf buf){ public void fromBytes(ByteBuf buf){
// The order is important // The order is important
element = Element.values()[buf.readShort()]; int i = buf.readShort();
element = i == -1 ? null : Element.values()[i];
} }
@Override @Override
public void toBytes(ByteBuf buf){ public void toBytes(ByteBuf buf){
buf.writeShort(element.ordinal()); buf.writeShort(element == null ? -1 : element.ordinal());
} }
} }
} }