diff --git a/Plugins/Mineplex.Core/src/mineplex/core/npc/NpcManager.java b/Plugins/Mineplex.Core/src/mineplex/core/npc/NpcManager.java index 818c4841e..457aba91e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/npc/NpcManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/npc/NpcManager.java @@ -13,6 +13,7 @@ import java.util.UUID; import org.bukkit.Bukkit; import org.bukkit.ChatColor; +import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.World; import org.bukkit.configuration.InvalidConfigurationException; @@ -300,14 +301,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); @@ -338,6 +346,7 @@ public class NpcManager extends MiniPlugin { UtilEnt.Vegetate(entity); UtilEnt.silence(entity, true); + UtilEnt.ghost(entity, true, false); } if (npc.getDatabaseRecord().getHelmet() != null) @@ -414,7 +423,10 @@ public class NpcManager extends MiniPlugin if (npc.getFailedAttempts() >= 10 || npc.getDatabaseRecord().getRadius() == 0) { - entity.teleport(npc.getLocation()); + Location location = npc.getLocation(); + location.setPitch(entity.getLocation().getPitch()); + location.setYaw(entity.getLocation().getYaw()); + entity.teleport(location); entity.setVelocity(new Vector(0, 0, 0)); npc.setFailedAttempts(0); } @@ -450,7 +462,10 @@ public class NpcManager extends MiniPlugin if (!entity.isDead() && entity.isValid()) { - entity.teleport(npc.getLocation()); + Location location = npc.getLocation(); + location.setPitch(entity.getLocation().getPitch()); + location.setYaw(entity.getLocation().getYaw()); + entity.teleport(location); entity.setVelocity(new Vector(0, 0, 0)); npc.setFailedAttempts(0); @@ -550,7 +565,10 @@ public class NpcManager extends MiniPlugin UtilEnt.ghost(entity, true, false); if (npc.getDatabaseRecord().getRadius() == 0) + { UtilEnt.Vegetate(entity); + UtilEnt.ghost(entity, true, false); + } } if (isDetachedNpc((LivingEntity) entity))