Getting the region a player is STANDING in

Discussion in 'Spigot Plugin Development' started by plisov, Apr 13, 2017.

  1. I've been working on a SkyBlock plugin and I'm trying to figure out how to get the region name a player is standing in. For example, if there are people on my island and I set my island to private, I want it automatically go through the WorldGuard members for that region and if the players are not a member of the region, they get kicked. How would I do this? I already have the private system working and the kicking system working. All I need to figure out is how to get the region the players are standing in.
  2. You could remove the tpa thing or just get the location of the player island, get the corners and add them in a skyblock yml file and check if player is inside to kick him
  3. Play around with worldguard API. You can get a list of owners from their region class
  4. I would keep a Map with the regions for each player, so you don't have to run all the methods to get the player's region each time you want to something, so you just get the regions from the map and check em, then you just have to update the regions on the map when it is needed. Well it kinda depends of how frecuent you will check which region is the player in.
    • Agree Agree x 1
  5. The worldguard API as far as checking regions is quite fast. I've used it in onPlayerMoveEvent which fires A LOT.

    Hook wg plugin
    for(ProtectedRegion rg:wg.getRegionManager().getApplicableRegions(p.getLocation))
    // do stuff

    //teleport player out

    Sent from my iPhone using Tapatalk
  6. The problem with that is I need to get every person on the person's island and not just one person. So think of the region a stove top. It isn't turned on. When the owner of the region sets their island to private, the stove top instantly becomes hot. Whoever isn't a region member gets kicked out as the stove is too hot. So when the region owner turns their realm to private I need it to run on the owner's side, get all the players on their realm, get those player's names and check if their names are on the region member list. If not, kick them.
  7. Anyone know any other way?
  8. How they set their island to private?
  9. Well you can set multiple owners on a wg region, and you can add or remove them via the API.

    When your stove top goes hot loop all online players and teleport them out if they're not found in the owners list. And they're in that region.

    Or schedule a task to run every few mins that loops all players, checks the regions and teleports them out.

    Or do all online players when the command is invoked just to get the online ones and then run the code to check if the region is private / not the owner on player login. That way if players are offline when the island is made private it will boot them when they log in

    Sent from my iPhone using Tapatalk
  10. Wouldn't this way kick everyone on the server?
  11. It would if the worldguard region encompasses the entire world I guess... I assumed by your original post you had a wg region around each island with an owner.

    The code I posted previously should let you check if a player is in a region they are an owner of then you could kick them if not. By kick them I assume you want to teleport them to spawn or some other location.

    Sent from my iPhone using Tapatalk