diff --git a/src/main/java/com/songoda/ultimatestacker/entity/EntityStack.java b/src/main/java/com/songoda/ultimatestacker/entity/EntityStack.java index 3e8f681..e505f26 100644 --- a/src/main/java/com/songoda/ultimatestacker/entity/EntityStack.java +++ b/src/main/java/com/songoda/ultimatestacker/entity/EntityStack.java @@ -14,6 +14,7 @@ import org.bukkit.entity.ExperienceOrb; import org.bukkit.entity.LivingEntity; import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.inventory.ItemStack; +import org.bukkit.metadata.FixedMetadataValue; import java.util.ArrayDeque; import java.util.Deque; @@ -138,9 +139,21 @@ public class EntityStack { if (killed.getType() == EntityType.PIG_ZOMBIE) newEntity.getEquipment().setItemInHand(new ItemStack(instance.isServerVersionAtLeast(ServerVersion.V1_13) ? Material.GOLDEN_SWORD : Material.valueOf("GOLD_SWORD"))); - if (Bukkit.getPluginManager().isPluginEnabled("EpicSpawners")) + if (Setting.CARRY_OVER_METADATA_ON_DEATH.getBoolean()) { + if (Bukkit.getPluginManager().isPluginEnabled("EpicSpawners")) + if (killed.hasMetadata("ES")) + newEntity.setMetadata("ES", killed.getMetadata("ES").get(0)); + + if (Bukkit.getPluginManager().isPluginEnabled("mcMMO")) { + String entityMetadataKey = "mcMMO: Spawned Entity"; + if (killed.hasMetadata(entityMetadataKey)) + newEntity.setMetadata(entityMetadataKey, new FixedMetadataValue(UltimateStacker.getInstance(), true)); + + } + if (killed.hasMetadata("ES")) newEntity.setMetadata("ES", killed.getMetadata("ES").get(0)); + } EntityStack entityStack = stackManager.updateStack(killed, newEntity); diff --git a/src/main/java/com/songoda/ultimatestacker/utils/settings/Setting.java b/src/main/java/com/songoda/ultimatestacker/utils/settings/Setting.java index 5d9514b..a65b3ed 100644 --- a/src/main/java/com/songoda/ultimatestacker/utils/settings/Setting.java +++ b/src/main/java/com/songoda/ultimatestacker/utils/settings/Setting.java @@ -99,6 +99,10 @@ public enum Setting { "if the entity originated from a spawner or not is wiped on", "server restart."), + CARRY_OVER_METADATA_ON_DEATH("Entities.Carry Over Metadata On Death", true, + "With this enabled any metadata assigned from supported plugins such", + "as EpicSpawners and mcMMO will be preserved when the entity is killed."), + ONLY_STACK_ON_SURFACE("Entities.Only Stack On Surface", true, "Should entities only be stacked if they are touching the ground", "or swimming? This does not effect flying entities."), @@ -251,4 +255,5 @@ public enum Setting { public double getDouble() { return UltimateStacker.getInstance().getConfig().getDouble(setting); } + } \ No newline at end of file