Remove entity when Reload/stop server

Discussion in 'Plugin Development' started by bronzzze, Apr 24, 2015.

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

    bronzzze

    I just want to make when I reset Server it remove Pet/LivingEntity. Any Ideas. What event is for it

    Edit:
    I just put code there?

    public void onDisable() {
    ....
    }
     
  2. Offline

    Koobaczech

    Loop through the world entities, and if the entity is your pet remove it! Use a for loop. If you don't know how a loop works check it out
    http://www.tutorialspoint.com/java/java_loop_control.htm
    Code:
    for (World w : Bukkit.getWorlds()) //Since you don't pass the pet world to your disable function, we need to loop through all worlds
           for(Entity e : w.getEntities()) {
                 if (something)//Check if an attribute of entity e matches an attribute of your pet
                       e.remove(); //only if e is the pet entity
            }
    
    Please read the BukkitAPI to learn more http://docs.codelanx.com/Bukkit/1.8/overview-summary.html
     
    Last edited: Apr 24, 2015
Thread Status:
Not open for further replies.

Share This Page