Custom mob names

Discussion in 'Plugin Development' started by Ghilliedrone, Jul 28, 2013.

Thread Status:
Not open for further replies.
  1. Offline

    Ghilliedrone

    I need to check if when a mob spawns, a different mob with a custom name exists. Is there any way to check this?

    bump

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 3, 2016
  2. Offline

    adam753

    You could easily do this by listening to CreatureSpawnEvent.
     
  3. Offline

    Jozeth

    To check if any living entities (that aren't players) have a custom name when a mob spawns.

    Code:java
    1.  
    2. @EventHandler
    3. public void onCreatureSpawn(CreatureSpawnEvent event) {
    4. if(!(event.getEntity() instanceof Player)) {
    5. for(LivingEntity all : Bukkit.getServer().getWorld("WORLD NAME").getLivingEntities()) {
    6. if(all.getCustomName() != null) {
    7. // Code
    8. }
    9. }
    10. }
    11. }
    12.  
     
Thread Status:
Not open for further replies.

Share This Page