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()));
|
LivingEntity entity = (LivingEntity) _creature.SpawnEntity(npc.getLocation(), EntityType.valueOf(npc.getDatabaseRecord().getEntityType()));
|
||||||
|
|
||||||
entity.setCustomNameVisible(true);
|
if (npc.getDatabaseRecord().getName() == null)
|
||||||
String name = npc.getDatabaseRecord().getName() == null ? "" : npc.getDatabaseRecord().getName();
|
{
|
||||||
for (ChatColor color : ChatColor.values())
|
entity.setCustomNameVisible(false);
|
||||||
name = name.replace("(" + color.name().toLowerCase() + ")", color.toString());
|
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.setCustomNameVisible(true);
|
||||||
|
entity.setCustomName(ChatColor.RESET + name);
|
||||||
entity.setCustomName(ChatColor.RESET + name);
|
}
|
||||||
|
|
||||||
entity.setCanPickupItems(false);
|
entity.setCanPickupItems(false);
|
||||||
entity.setRemoveWhenFarAway(false);
|
entity.setRemoveWhenFarAway(false);
|
||||||
|
Loading…
Reference in New Issue
Block a user