From 37d4dc70e5dadde7f21d73f540259671d9a1a468 Mon Sep 17 00:00:00 2001 From: vemacs Date: Tue, 2 Jun 2015 13:56:54 -0600 Subject: [PATCH] Set display name for given spawners --- .../essentials/utils/SpawnerUtil.java | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/Essentials/src/com/earth2me/essentials/utils/SpawnerUtil.java b/Essentials/src/com/earth2me/essentials/utils/SpawnerUtil.java index a0310db6e..7a8bd9d31 100644 --- a/Essentials/src/com/earth2me/essentials/utils/SpawnerUtil.java +++ b/Essentials/src/com/earth2me/essentials/utils/SpawnerUtil.java @@ -1,5 +1,6 @@ package com.earth2me.essentials.utils; +import com.google.common.collect.ImmutableMap; import net.ess3.api.IEssentials; import org.bukkit.Material; import org.bukkit.block.BlockState; @@ -9,8 +10,22 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.BlockStateMeta; import org.bukkit.inventory.meta.ItemMeta; +import java.util.Map; + public class SpawnerUtil { private boolean useMeta; + private Map entityToDisplayName = ImmutableMap.builder() + .put(EntityType.CAVE_SPIDER, "Cave Spider") + .put(EntityType.PIG_ZOMBIE, "Zombie Pigman") + .put(EntityType.MAGMA_CUBE, "Magma Cube") + .put(EntityType.ENDER_DRAGON, "Ender Dragon") + .put(EntityType.MUSHROOM_COW, "Mooshroom") + .put(EntityType.SNOWMAN, "Snow Golem") + .put(EntityType.OCELOT, "Ocelot") + .put(EntityType.IRON_GOLEM, "Iron Golem") + .put(EntityType.WITHER, "Wither") + .put(EntityType.HORSE, "Horse") + .build(); public SpawnerUtil(IEssentials ess) { try { @@ -39,6 +54,15 @@ public class SpawnerUtil { // Legacy behavior is.setDurability(type.getTypeId()); } + ItemMeta meta = is.getItemMeta(); + String displayName; + if (entityToDisplayName.containsKey(type)) { + displayName = entityToDisplayName.get(type); + } else { + displayName = type.getName(); + } + meta.setDisplayName(displayName + " Spawner"); + is.setItemMeta(meta); return is; }