Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Remove entity via Id in an array?

Comments in 'Plugin Development' started by JonsMC, Aug 29, 2016.

  1. JonsMC
    Offline

    JonsMC Active Member

    Joined:
    Jul 26, 2016
    Posts:
    107
    Minecraft User:
    JonsMC
    hello, i was working on a minigame plugin and i need to clear Mobs entity(beside Slappers entities) in a world, i stored their's edit in an array. So how would i kill/clear those mobs?
  2. MyNameIsTriXz
    Offline

    MyNameIsTriXz Notable Member

    Joined:
    Aug 17, 2015
    Posts:
    538
    Minecraft User:
    MyNameIsTriXz
    PHP:
    foreach($yourEntityArray as $ent){
    if(!
    in_array($ent$this->getServer()->getPluginManager()->getPlugin("Slapper")->exemptedEntities)) $ent->close();
    }

    // I use close, because it removes the entity instead of kill(), which kills the entity
    And about exemptedEntities, its an array by Slapper which includes the entities from Slapper. When the the in_array function doesnt work, then try to check for Slapper NBT tags like Slapper_Version or other Slapper exclusive NBT tags. For more help, ask @jojoe77777
  3. jojoe77777
    Offline

    jojoe77777 Notable Member Plugin Developer

    Joined:
    May 28, 2015
    Posts:
    653
    Plugins:
    1
    Minecraft User:
    jojoe77777
    ... Slapper doesn't have an array for that.

    !$entity instanceof SlapperEntity && !$entity instanceof SlapperHuman


    Read the code again:

    PHP:
                $clearLagg $this->getServer()->getPluginManager()->getPlugin("ClearLagg");
                if (
    $clearLagg !== null) {
                    
    $clearLagg->exemptEntity($entity);
                }
    Survingo likes this.

Share This Page

Advertisement