mirror of
https://github.com/EssentialsX/Essentials.git
synced 2024-12-26 02:58:03 +01:00
Set display name for given spawners
This commit is contained in:
parent
e7337d06b5
commit
37d4dc70e5
@ -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<EntityType, String> entityToDisplayName = ImmutableMap.<EntityType, String>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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user