diff --git a/plugin/src/main/java/lol/pyr/znpcsplus/entity/properties/DinnerboneProperty.java b/plugin/src/main/java/lol/pyr/znpcsplus/entity/properties/DinnerboneProperty.java index e8b81a6..b04fc87 100644 --- a/plugin/src/main/java/lol/pyr/znpcsplus/entity/properties/DinnerboneProperty.java +++ b/plugin/src/main/java/lol/pyr/znpcsplus/entity/properties/DinnerboneProperty.java @@ -7,6 +7,7 @@ import com.github.retrooper.packetevents.util.adventure.AdventureSerializer; import lol.pyr.znpcsplus.entity.EntityPropertyImpl; import lol.pyr.znpcsplus.entity.PacketEntity; import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer; import org.bukkit.entity.Player; import java.util.Map; @@ -19,7 +20,8 @@ public class DinnerboneProperty extends EntityPropertyImpl { public DinnerboneProperty(boolean legacy, boolean optional) { super("dinnerbone", false, Boolean.class); Component name = Component.text("Dinnerbone"); - Object serialized = legacy ? AdventureSerializer.getLegacyGsonSerializer().serialize(name) : name; + Object serialized = legacy ? AdventureSerializer.getLegacyGsonSerializer().serialize(name) : + optional ? name : LegacyComponentSerializer.legacySection().serialize(name); this.serialized = optional ? Optional.of(serialized) : serialized; this.type = optional ? EntityDataTypes.OPTIONAL_ADV_COMPONENT : EntityDataTypes.STRING; } diff --git a/plugin/src/main/java/lol/pyr/znpcsplus/entity/properties/NameProperty.java b/plugin/src/main/java/lol/pyr/znpcsplus/entity/properties/NameProperty.java index 426101f..779c4ff 100644 --- a/plugin/src/main/java/lol/pyr/znpcsplus/entity/properties/NameProperty.java +++ b/plugin/src/main/java/lol/pyr/znpcsplus/entity/properties/NameProperty.java @@ -15,14 +15,14 @@ import java.util.Optional; public class NameProperty extends EntityPropertyImpl { private final LegacyComponentSerializer legacySerializer; - private final boolean legacy; + private final boolean legacySerialization; private final boolean optional; - public NameProperty(LegacyComponentSerializer legacySerializer, boolean legacy, boolean optional) { + public NameProperty(LegacyComponentSerializer legacySerializer, boolean legacySerialization, boolean optional) { super("name", null, Component.class); this.legacySerializer = legacySerializer; - this.legacy = legacy; + this.legacySerialization = legacySerialization; this.optional = optional; } @@ -31,12 +31,13 @@ public class NameProperty extends EntityPropertyImpl { Component value = entity.getProperty(this); if (value != null) { value = PapiUtil.set(legacySerializer, player, value); - Object serialized = legacy ? AdventureSerializer.getLegacyGsonSerializer().serialize(value) : value; + Object serialized = legacySerialization ? AdventureSerializer.getLegacyGsonSerializer().serialize(value) : + optional ? value : LegacyComponentSerializer.legacySection().serialize(value); if (optional) properties.put(2, new EntityData(2, EntityDataTypes.OPTIONAL_ADV_COMPONENT, Optional.of(serialized))); else properties.put(2, new EntityData(2, EntityDataTypes.STRING, serialized)); } - if (legacy) properties.put(3, newEntityData(3, EntityDataTypes.BYTE, (byte) (value != null ? 1 : 0))); + if (legacySerialization) properties.put(3, newEntityData(3, EntityDataTypes.BYTE, (byte) (value != null ? 1 : 0))); else properties.put(3, newEntityData(3, EntityDataTypes.BOOLEAN, value != null)); } } diff --git a/plugin/src/main/java/lol/pyr/znpcsplus/entity/properties/RabbitTypeProperty.java b/plugin/src/main/java/lol/pyr/znpcsplus/entity/properties/RabbitTypeProperty.java index c67bd36..992bd8d 100644 --- a/plugin/src/main/java/lol/pyr/znpcsplus/entity/properties/RabbitTypeProperty.java +++ b/plugin/src/main/java/lol/pyr/znpcsplus/entity/properties/RabbitTypeProperty.java @@ -8,6 +8,7 @@ import lol.pyr.znpcsplus.entity.EntityPropertyImpl; import lol.pyr.znpcsplus.entity.PacketEntity; import lol.pyr.znpcsplus.util.RabbitType; import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer; import org.bukkit.entity.Player; import java.util.Map; @@ -24,7 +25,8 @@ public class RabbitTypeProperty extends EntityPropertyImpl { this.index = index; this.legacyBooleans = legacyBooleans; Component name = Component.text("Toast"); - Object serialized = legacyNames ? AdventureSerializer.getLegacyGsonSerializer().serialize(name) : name; + Object serialized = legacyNames ? AdventureSerializer.getLegacyGsonSerializer().serialize(name) : + optional ? name : LegacyComponentSerializer.legacySection().serialize(name); this.serialized = optional ? Optional.of(serialized) : serialized; this.type = optional ? EntityDataTypes.OPTIONAL_ADV_COMPONENT : EntityDataTypes.STRING; }