mirror of
https://github.com/GeyserMC/MCProtocolLib.git
synced 2024-12-04 21:01:02 -05:00
Add new OPTIONAL_CHAT MetadataType
This commit is contained in:
parent
669aa7b93f
commit
26f3711c7f
3 changed files with 23 additions and 9 deletions
|
@ -136,15 +136,16 @@ public class MagicValues {
|
|||
register(MetadataType.FLOAT, 2);
|
||||
register(MetadataType.STRING, 3);
|
||||
register(MetadataType.CHAT, 4);
|
||||
register(MetadataType.ITEM, 5);
|
||||
register(MetadataType.BOOLEAN, 6);
|
||||
register(MetadataType.ROTATION, 7);
|
||||
register(MetadataType.POSITION, 8);
|
||||
register(MetadataType.OPTIONAL_POSITION, 9);
|
||||
register(MetadataType.BLOCK_FACE, 10);
|
||||
register(MetadataType.OPTIONAL_UUID, 11);
|
||||
register(MetadataType.BLOCK_STATE, 12);
|
||||
register(MetadataType.NBT_TAG, 13);
|
||||
register(MetadataType.OPTIONAL_CHAT, 5);
|
||||
register(MetadataType.ITEM, 6);
|
||||
register(MetadataType.BOOLEAN, 7);
|
||||
register(MetadataType.ROTATION, 8);
|
||||
register(MetadataType.POSITION, 9);
|
||||
register(MetadataType.OPTIONAL_POSITION, 10);
|
||||
register(MetadataType.BLOCK_FACE, 11);
|
||||
register(MetadataType.OPTIONAL_UUID, 12);
|
||||
register(MetadataType.BLOCK_STATE, 13);
|
||||
register(MetadataType.NBT_TAG, 14);
|
||||
|
||||
register(HandshakeIntent.STATUS, 1);
|
||||
register(HandshakeIntent.LOGIN, 2);
|
||||
|
|
|
@ -6,6 +6,7 @@ public enum MetadataType {
|
|||
FLOAT,
|
||||
STRING,
|
||||
CHAT,
|
||||
OPTIONAL_CHAT,
|
||||
ITEM,
|
||||
BOOLEAN,
|
||||
ROTATION,
|
||||
|
|
|
@ -130,6 +130,12 @@ public class NetUtil {
|
|||
case STRING:
|
||||
value = in.readString();
|
||||
break;
|
||||
case OPTIONAL_CHAT:
|
||||
boolean chatPresent = in.readBoolean();
|
||||
if (!chatPresent) {
|
||||
break;
|
||||
}
|
||||
// Intentional fall-through
|
||||
case CHAT:
|
||||
value = Message.fromString(in.readString());
|
||||
break;
|
||||
|
@ -195,6 +201,12 @@ public class NetUtil {
|
|||
case STRING:
|
||||
out.writeString((String) meta.getValue());
|
||||
break;
|
||||
case OPTIONAL_CHAT:
|
||||
out.writeBoolean(meta.getValue() != null);
|
||||
if (meta.getValue() == null) {
|
||||
break;
|
||||
}
|
||||
// Intentional fall-through
|
||||
case CHAT:
|
||||
out.writeString(((Message) meta.getValue()).toJsonString());
|
||||
break;
|
||||
|
|
Loading…
Reference in a new issue