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

Get a list of entities in the server

Comments in 'Plugin Development' started by BlubberBoy333, May 5, 2016.

  1. BlubberBoy333
    Offline

    BlubberBoy333 Active Member

    Joined:
    Aug 31, 2014
    Posts:
    177
    Minecraft User:
    Blubberboy333
    So you know how you can do
    PHP:
    foreach($this->getServer()->getPlayers() as $i){

    }
    And it'll do something to every player in the server? Is there a way to do that but with the entities?
  2. HotFireyDeath
    Offline

    HotFireyDeath Notable Member Plugin Developer

    Joined:
    Mar 19, 2015
    Posts:
    328
    Plugins:
    1
    Minecraft User:
    HotFireyDeath
    While I have not found a server-wide solution, there is a method to do per level...
    PHP:
    foreach($level->getEntities() as $a){
    }
    where $level is a Level object.
    applqpak likes this.
  3. applqpak
    Offline

    applqpak Active Member Plugin Developer

    Joined:
    Dec 16, 2015
    Posts:
    284
    Plugins:
    1
    Minecraft User:
    applqpak
    And, to make it server-wide, you could just do a foreach level, then run your piece of code. :)
    HotFireyDeath likes this.
  4. BlubberBoy333
    Offline

    BlubberBoy333 Active Member

    Joined:
    Aug 31, 2014
    Posts:
    177
    Minecraft User:
    Blubberboy333
    Oh ok, thanks guys :D
    applqpak likes this.
  5. HotFireyDeath
    Offline

    HotFireyDeath Notable Member Plugin Developer

    Joined:
    Mar 19, 2015
    Posts:
    328
    Plugins:
    1
    Minecraft User:
    HotFireyDeath
    Ahaaaaaaaaa. Good catch ;)

    ...why did I not think of that...
    applqpak likes this.
  6. applqpak
    Offline

    applqpak Active Member Plugin Developer

    Joined:
    Dec 16, 2015
    Posts:
    284
    Plugins:
    1
    Minecraft User:
    applqpak
    Lol. No worries :)
  7. CrazedMiner
    Offline

    CrazedMiner Notable Member Plugin Developer

    Joined:
    Jan 31, 2015
    Posts:
    348
    Plugins:
    2
    Minecraft User:
    CrazedMinerYT
    If you just want players you can use
    PHP:
    foreach(Server::getOnlinePlayers() as $p) {
        
    // your code here
    }
    applqpak likes this.

Share This Page

Advertisement