Remove Villager entity with Customnames???

Discussion in 'Plugin Development' started by Nico4898, Aug 20, 2014.

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

    Nico4898

    Hi , there
    I'm coding a Plugin , which removes villagers , that have special Customname....
    But it dosen't work with my code...

    Code:java
    1. for (LivingEntity entities : world.getLivingEntities()) {
    2. if(entities.getCustomName().equals(Villagername)){
    3. entities.remove(); //<---How to get entity by Name ???
    4.  
    5. }
     
  2. Offline

    mine-care

    What u mean how to get entity by name?
    Also try entity.kill(); and can we see full code? Any errors? What hAppends?
     
  3. Offline

    Nico4898

    I want only get all Villager entitys and remove the Villagers , with a special customname.
     
  4. Offline

    Yekllurt

    Try this
    Code:java
    1.  
    2. for(Entity entity : Bukkit.getWorld("world").getEntities()){
    3. if(entity instanceof Villager){
    4. Villager villager = (Villager) entity;
    5. if(villager.getCustomName() == "customName"){
    6. villager.remove();
    7. villager.eject();
    8. }
    9. }
    10. }
    11.  
     
Thread Status:
Not open for further replies.

Share This Page