Counting Animals in a Specific Worldguard Region

Discussion in 'Spigot Plugin Development' started by Atterbhog, Sep 16, 2018.

  1. Hello,

    is there any way how I can count the number of specific Animals in a specific WorldGuard-Region inside one of my Plugins I am coding right now?

    With the best regards,
  2. First have a look at

    It explains how to implement to WorldGuard Region API into your plugin.
    After that is done, you can loop over all regions and then check if you got the region you want.
    Then you can get all current entities in the world and loop over them: World#getEntities
    Then you check if the Entity's x is smaller than the region max X and greater than the region minX.
    Do the same with the Y coordinate and the Z coordinate. If your entity meets these requirements you can be sure that it is located inside your region. Simple increment an integer if you want to count them then.
    • Like Like x 1
  3. Thank you very much!
    • Funny Funny x 1

Share This Page