From 00b71cafc935ac7aea9b914b3573c2855d5c8f3c Mon Sep 17 00:00:00 2001 From: Josh Roy <10731363+JRoy@users.noreply.github.com> Date: Sat, 6 Mar 2021 14:06:31 -0500 Subject: [PATCH] Add netherite related items to spawnmob (#4031) Allows spawning skeletons and zombies with netherite armor and swords. Fixes #4029. --- .../src/main/java/com/earth2me/essentials/MobData.java | 6 ++++++ .../src/main/java/com/earth2me/essentials/SpawnMob.java | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/Essentials/src/main/java/com/earth2me/essentials/MobData.java b/Essentials/src/main/java/com/earth2me/essentials/MobData.java index 5d9c6b137..20397d352 100644 --- a/Essentials/src/main/java/com/earth2me/essentials/MobData.java +++ b/Essentials/src/main/java/com/earth2me/essentials/MobData.java @@ -95,11 +95,13 @@ public enum MobData { ALL_BLACK_CAT("allblack", MobCompat.CAT, MobCompat.CatType.BLACK, true), BABY_ZOMBIE("baby", EntityType.ZOMBIE.getEntityClass(), Data.BABYZOMBIE, true), ADULT_ZOMBIE("adult", EntityType.ZOMBIE.getEntityClass(), Data.ADULTZOMBIE, true), + NETHERITE_SWORD_ZOMBIE("netheritesword", EntityType.ZOMBIE.getEntityClass(), EnumUtil.getMaterial("NETHERITE_SWORD"), true), DIAMOND_SWORD_ZOMBIE("diamondsword", EntityType.ZOMBIE.getEntityClass(), Material.DIAMOND_SWORD, true), GOLD_SWORD_ZOMBIE("goldsword", EntityType.ZOMBIE.getEntityClass(), EnumUtil.getMaterial("GOLDEN_SWORD", "GOLD_SWORD"), true), IRON_SWORD_ZOMBIE("ironsword", EntityType.ZOMBIE.getEntityClass(), Material.IRON_SWORD, true), STONE_SWORD_ZOMBIE("stonesword", EntityType.ZOMBIE.getEntityClass(), Material.STONE_SWORD, false), SWORD_ZOMBIE("sword", EntityType.ZOMBIE.getEntityClass(), Material.STONE_SWORD, true), + NETHERITE_SWORD_SKELETON("netheritesword", EntityType.SKELETON, EnumUtil.getMaterial("NETHERITE_SWORD"), true), DIAMOND_SWORD_SKELETON("diamondsword", EntityType.SKELETON, Material.DIAMOND_SWORD, true), GOLD_SWORD_SKELETON("goldsword", EntityType.SKELETON, EnumUtil.getMaterial("GOLDEN_SWORD", "GOLD_SWORD"), true), IRON_SWORD_SKELETON("ironsword", EntityType.SKELETON, Material.IRON_SWORD, true), @@ -258,6 +260,10 @@ public enum MobData { } public void setData(final Entity spawned, final Player target, final String rawData) throws Exception { + if (value == null) { + return; + } + if (this.value.equals(Data.ANGRY)) { ((Wolf) spawned).setAngry(true); } else if (this.value.equals(Data.ADULT)) { diff --git a/Essentials/src/main/java/com/earth2me/essentials/SpawnMob.java b/Essentials/src/main/java/com/earth2me/essentials/SpawnMob.java index b706545ee..7fa39ab57 100644 --- a/Essentials/src/main/java/com/earth2me/essentials/SpawnMob.java +++ b/Essentials/src/main/java/com/earth2me/essentials/SpawnMob.java @@ -5,6 +5,7 @@ import com.earth2me.essentials.craftbukkit.InventoryWorkaround; import com.earth2me.essentials.utils.EnumUtil; import com.earth2me.essentials.utils.LocationUtil; import com.earth2me.essentials.utils.StringUtil; +import com.earth2me.essentials.utils.VersionUtil; import net.ess3.api.IEssentials; import org.bukkit.Location; import org.bukkit.Material; @@ -205,6 +206,11 @@ public final class SpawnMob { final EntityEquipment invent = ((LivingEntity) spawned).getEquipment(); if (inputData.contains("noarmor") || inputData.contains("noarmour")) { invent.clear(); + } else if (inputData.contains("netherite") && VersionUtil.getServerBukkitVersion().isHigherThanOrEqualTo(VersionUtil.v1_16_1_R01)) { + invent.setBoots(new ItemStack(Material.NETHERITE_BOOTS, 1)); + invent.setLeggings(new ItemStack(Material.NETHERITE_LEGGINGS, 1)); + invent.setChestplate(new ItemStack(Material.NETHERITE_CHESTPLATE, 1)); + invent.setHelmet(new ItemStack(Material.NETHERITE_HELMET, 1)); } else if (inputData.contains("diamond")) { invent.setBoots(new ItemStack(Material.DIAMOND_BOOTS, 1)); invent.setLeggings(new ItemStack(Material.DIAMOND_LEGGINGS, 1));