From 121b262d1b1621261b58893b423416206e1b5a4d Mon Sep 17 00:00:00 2001 From: vemacs Date: Wed, 17 Jun 2015 10:54:23 -0400 Subject: [PATCH] Use returned value for setEntityType, attempt fixing name setting --- Essentials/src/com/earth2me/essentials/ItemDb.java | 6 +++--- .../ess3/nms/v1_8_R1/v1_8_R1SpawnerProvider.java | 14 +++++++++++++- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/Essentials/src/com/earth2me/essentials/ItemDb.java b/Essentials/src/com/earth2me/essentials/ItemDb.java index 06cfcb928..2b8f9d07e 100644 --- a/Essentials/src/com/earth2me/essentials/ItemDb.java +++ b/Essentials/src/com/earth2me/essentials/ItemDb.java @@ -135,17 +135,17 @@ public class ItemDb implements IConf, net.ess3.api.IItemDb { if (mat == null) { throw new Exception(tl("unknownItemId", itemid)); } - final ItemStack retval = new ItemStack(mat); - retval.setAmount(mat.getMaxStackSize()); + ItemStack retval = new ItemStack(mat); if (mat == Material.MOB_SPAWNER) { try { - ess.getSpawnerProvider().setEntityType(retval, EntityType.fromId(metaData)); + retval = ess.getSpawnerProvider().setEntityType(retval, EntityType.fromId(metaData)); } catch (IllegalArgumentException e) { throw new Exception("Can't spawn entity ID " + metaData + " from mob spawners."); } } else { retval.setDurability(metaData); } + retval.setAmount(mat.getMaxStackSize()); return retval; } diff --git a/nms/1_8_R1Provider/src/net/ess3/nms/v1_8_R1/v1_8_R1SpawnerProvider.java b/nms/1_8_R1Provider/src/net/ess3/nms/v1_8_R1/v1_8_R1SpawnerProvider.java index 9945ed552..3dece79c7 100644 --- a/nms/1_8_R1Provider/src/net/ess3/nms/v1_8_R1/v1_8_R1SpawnerProvider.java +++ b/nms/1_8_R1Provider/src/net/ess3/nms/v1_8_R1/v1_8_R1SpawnerProvider.java @@ -2,9 +2,11 @@ package net.ess3.nms.v1_8_R1; import net.ess3.nms.SpawnerProvider; import net.minecraft.server.v1_8_R1.NBTTagCompound; +import org.bukkit.ChatColor; import org.bukkit.craftbukkit.v1_8_R1.inventory.CraftItemStack; import org.bukkit.entity.EntityType; import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; public class v1_8_R1SpawnerProvider extends SpawnerProvider { @Override @@ -22,7 +24,17 @@ public class v1_8_R1SpawnerProvider extends SpawnerProvider { } tag = itemStack.getTag().getCompound("BlockEntityTag"); tag.setString("EntityId", type.getName()); - return CraftItemStack.asCraftMirror(itemStack); + ItemStack bukkitItemStack = CraftItemStack.asCraftMirror(itemStack).clone(); + ItemMeta meta = bukkitItemStack.getItemMeta(); + String displayName; + if (entityToDisplayName.containsKey(type)) { + displayName = entityToDisplayName.get(type); + } else { + displayName = type.getName(); + } + meta.setDisplayName(ChatColor.RESET + displayName + " Spawner"); + bukkitItemStack.setItemMeta(meta); + return bukkitItemStack; } @Override