Hide NpcManager blank custom names
This commit is contained in:
parent
edb2c4f26a
commit
930cdf6c07
@ -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();
|
||||
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);
|
||||
|
||||
entity.setCustomNameVisible(true);
|
||||
entity.setCustomName(ChatColor.RESET + name);
|
||||
}
|
||||
|
||||
entity.setCanPickupItems(false);
|
||||
entity.setRemoveWhenFarAway(false);
|
||||
|
Loading…
Reference in New Issue
Block a user