Hide NpcManager blank custom names

This commit is contained in:
CoderTim 2014-10-16 22:24:24 -04:00
parent edb2c4f26a
commit 930cdf6c07
1 changed files with 14 additions and 7 deletions

View File

@ -300,14 +300,21 @@ public class NpcManager extends MiniPlugin
{
LivingEntity entity = (LivingEntity) _creature.SpawnEntity(npc.getLocation(), EntityType.valueOf(npc.getDatabaseRecord().getEntityType()));
entity.setCustomNameVisible(true);
String name = npc.getDatabaseRecord().getName() == null ? "" : npc.getDatabaseRecord().getName();
for (ChatColor color : ChatColor.values())
name = name.replace("(" + color.name().toLowerCase() + ")", color.toString());
if (npc.getDatabaseRecord().getName() == null)
{
entity.setCustomNameVisible(false);
entity.setCustomName(ChatColor.RESET.toString());
}
else
{
String name = npc.getDatabaseRecord().getName();
for (ChatColor color : ChatColor.values())
name = name.replace("(" + color.name().toLowerCase() + ")", color.toString());
name = ChatColor.translateAlternateColorCodes('&', name);
name = ChatColor.translateAlternateColorCodes('&', name);
entity.setCustomName(ChatColor.RESET + name);
entity.setCustomNameVisible(true);
entity.setCustomName(ChatColor.RESET + name);
}
entity.setCanPickupItems(false);
entity.setRemoveWhenFarAway(false);