mirror of
https://github.com/YouHaveTrouble/Stand-in.git
synced 2026-05-11 22:16:55 +00:00
mark all entities spawn by the plugin and allow other plugins to check for that
This commit is contained in:
+2
-1
@@ -27,8 +27,9 @@ public class ArmorStandToMannequinConverter implements EntityConverter<ArmorStan
|
||||
public Mannequin spawn(@NotNull ArmorStand from) {
|
||||
try {
|
||||
return from.getWorld().spawn(from.getLocation(), Mannequin.class, (mannequin -> {
|
||||
mannequin.customName(from.customName());
|
||||
markAsTransformed(mannequin);
|
||||
EntityConverter.saveRawEntityName(mannequin, EntityConverter.getRawEntityName(from));
|
||||
mannequin.customName(from.customName());
|
||||
mannequin.setImmovable(!from.canMove());
|
||||
mannequin.setGravity(from.hasGravity());
|
||||
for (EquipmentSlot slot : EquipmentSlot.values()) {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package me.youhavetrouble.standin.converter;
|
||||
|
||||
import me.youhavetrouble.standin.StandIn;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
|
||||
import org.bukkit.NamespacedKey;
|
||||
@@ -26,6 +27,11 @@ public interface EntityConverter<F extends Entity, T extends Entity> {
|
||||
*/
|
||||
T spawn(@NotNull F from);
|
||||
|
||||
default void markAsTransformed(@NotNull T entity) {
|
||||
PersistentDataContainer pdc = entity.getPersistentDataContainer();
|
||||
pdc.set(StandIn.KEY, PersistentDataType.BYTE, (byte) 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* MiniMessage serialized entity name
|
||||
* @param entity Entity to get name for
|
||||
|
||||
@@ -26,6 +26,7 @@ public class MannequinToArmorStandConverter implements EntityConverter<Mannequin
|
||||
public ArmorStand spawn(@NotNull Mannequin from) {
|
||||
try {
|
||||
return from.getWorld().spawn(from.getLocation(), ArmorStand.class, (armorStand -> {
|
||||
markAsTransformed(armorStand);
|
||||
armorStand.customName(from.customName());
|
||||
EntityConverter.saveRawEntityName(armorStand, EntityConverter.getRawEntityName(from));
|
||||
armorStand.setGravity(from.hasGravity());
|
||||
|
||||
@@ -8,6 +8,7 @@ import io.papermc.paper.registry.data.dialog.body.DialogBody;
|
||||
import io.papermc.paper.registry.data.dialog.input.DialogInput;
|
||||
import io.papermc.paper.registry.data.dialog.input.SingleOptionDialogInput;
|
||||
import io.papermc.paper.registry.data.dialog.type.DialogType;
|
||||
import me.youhavetrouble.standin.StandIn;
|
||||
import me.youhavetrouble.standin.converter.EntityConverter;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.event.ClickCallback;
|
||||
@@ -172,4 +173,13 @@ public abstract class EntityHandler<E extends Entity> {
|
||||
CHANGE_TYPE,
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if entity is entity transformed by stand-in plugin
|
||||
* @param entity entity to check
|
||||
* @return boolean representing whether entity is a stand-in entity
|
||||
*/
|
||||
public static boolean isStandinEntity(@NotNull Entity entity) {
|
||||
return entity.getPersistentDataContainer().has(StandIn.KEY);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user