Solved Worldguard regions overlapping

Discussion in 'Plugin Development' started by Befitipo, Sep 12, 2018.

  1. Offline

    Befitipo

    I'm developing a plugin that makes the Console create worldguard regions for players.
    The Console create the region, set some flags, at the end set the owner as the player who requested it.
    Now the problem is: if a player creates regions overlapping their own regions it's ok, but if a player is trying to create a region overlapping an other player region the Console does not have to create it.
    How can i check if a player is trying to overlap an another player region?

    I solved it by myself!!! Here my solution:
    Code:
    for(ProtectedRegion rg : region.getIntersectingRegions(regions.getRegions().values())) {
                if(!rg.getOwners().contains(e.getPlayer().getUniqueId())) {
                    e.getPlayer().sendMessage("You can't override other player area");
                    e.setCancelled(true);
                    return;
                }
            }
    Foreach region intersecting the new region i check if the owner is the same of the new region, if it find a region with a different owner, it alert the player and cancel the event!

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Sep 12, 2018

Share This Page