mirror of
https://github.com/darksaid98/Carbon.git
synced 2026-12-01 14:38:48 +00:00
Use ordinal instead of name for enums over network
This commit is contained in:
1 file changed
+2
-2
@@ -88,11 +88,11 @@ public abstract class CarbonPacket extends AbstractPacket {
|
||||
}
|
||||
|
||||
protected final <E extends Enum<E>> void writeEnum(final E value, final ByteBuf buf) {
|
||||
this.writeString(value.name(), buf);
|
||||
this.writeVarInt(value.ordinal(), buf);
|
||||
}
|
||||
|
||||
protected final <E extends Enum<E>> E readEnum(final ByteBuf buf, final Class<E> cls) {
|
||||
return Enum.valueOf(cls, this.readString(buf));
|
||||
return cls.getEnumConstants()[this.readVarInt(buf)];
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user