save and persist the raw minimessage string for the display name

This commit is contained in:
2025-11-24 23:30:49 +01:00
parent 0261b0ceae
commit ed7653aa66
3 changed files with 8 additions and 5 deletions
@@ -28,6 +28,7 @@ public class ArmorStandToMannequinConverter implements EntityConverter<ArmorStan
try { try {
return from.getWorld().spawn(from.getLocation(), Mannequin.class, (mannequin -> { return from.getWorld().spawn(from.getLocation(), Mannequin.class, (mannequin -> {
mannequin.customName(from.customName()); mannequin.customName(from.customName());
EntityConverter.saveRawEntityName(mannequin, EntityConverter.getRawEntityName(from));
mannequin.setImmovable(!from.canMove()); mannequin.setImmovable(!from.canMove());
mannequin.setGravity(from.hasGravity()); mannequin.setGravity(from.hasGravity());
for (EquipmentSlot slot : EquipmentSlot.values()) { for (EquipmentSlot slot : EquipmentSlot.values()) {
@@ -27,6 +27,7 @@ public class MannequinToArmorStandConverter implements EntityConverter<Mannequin
try { try {
return from.getWorld().spawn(from.getLocation(), ArmorStand.class, (armorStand -> { return from.getWorld().spawn(from.getLocation(), ArmorStand.class, (armorStand -> {
armorStand.customName(from.customName()); armorStand.customName(from.customName());
EntityConverter.saveRawEntityName(armorStand, EntityConverter.getRawEntityName(from));
armorStand.setGravity(from.hasGravity()); armorStand.setGravity(from.hasGravity());
armorStand.setCanMove(!from.isImmovable()); armorStand.setCanMove(!from.isImmovable());
for (EquipmentSlot slot : EquipmentSlot.values()) { for (EquipmentSlot slot : EquipmentSlot.values()) {
@@ -7,11 +7,11 @@ import io.papermc.paper.registry.data.dialog.DialogBase;
import io.papermc.paper.registry.data.dialog.action.DialogAction; import io.papermc.paper.registry.data.dialog.action.DialogAction;
import io.papermc.paper.registry.data.dialog.input.DialogInput; import io.papermc.paper.registry.data.dialog.input.DialogInput;
import io.papermc.paper.registry.data.dialog.type.DialogType; import io.papermc.paper.registry.data.dialog.type.DialogType;
import me.youhavetrouble.standin.converter.EntityConverter;
import me.youhavetrouble.standin.converter.MannequinToArmorStandConverter; import me.youhavetrouble.standin.converter.MannequinToArmorStandConverter;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.event.ClickCallback; import net.kyori.adventure.text.event.ClickCallback;
import net.kyori.adventure.text.minimessage.MiniMessage; import net.kyori.adventure.text.minimessage.MiniMessage;
import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.Mannequin; import org.bukkit.entity.Mannequin;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@@ -39,14 +39,14 @@ public class MannequinHandler extends EntityHandler<Mannequin> {
List<DialogInput> inputs = new ArrayList<>(); List<DialogInput> inputs = new ArrayList<>();
String name = ""; String name = EntityConverter.getRawEntityName(mannequin);
Component customName = mannequin.customName(); if (name == null) {
if (customName != null) { name = "";
name = PlainTextComponentSerializer.plainText().serialize(customName);
} }
inputs.add( inputs.add(
DialogInput.text("name", Component.text("Name")) DialogInput.text("name", Component.text("Name"))
.initial(name) .initial(name)
.maxLength(1024)
.build() .build()
); );
String profileName = ""; String profileName = "";
@@ -91,6 +91,7 @@ public class MannequinHandler extends EntityHandler<Mannequin> {
} else { } else {
mann.customName(null); mann.customName(null);
} }
EntityConverter.saveRawEntityName(mann, newName);
mann.setImmovable(Boolean.TRUE.equals(view.getBoolean("immovable"))); mann.setImmovable(Boolean.TRUE.equals(view.getBoolean("immovable")));
mann.setVelocity(mann.getVelocity().zero()); mann.setVelocity(mann.getVelocity().zero());
mann.setGravity(Boolean.TRUE.equals(view.getBoolean("gravity"))); mann.setGravity(Boolean.TRUE.equals(view.getBoolean("gravity")));