WorldGuard & WorldEdit API: Check if Selection is in a Region owned by the "Selector"?

Discussion in 'Plugin Development' started by ServerfromMinecraft, Nov 28, 2013.

Thread Status:
Not open for further replies.
  1. Hi!

    I tried many things now, but it seems that I can't get it to work. I want to check, on command, if the selection of the command-executor is in a region owned by this player. Anyone has an Idea on how to achieve this?
    THe thing is, you can't just check one location; For example, the method should return false in this case:

    W= Selection
    O = Placeholder
    X = Region owned by the player
    OOOWWWWWWOOO
    OOOWOOOOXWXXO
    OOOWWWWWWOXO
    OOOOOOOOXOOXO
    OOOOOOOOXXXXO
    OOOOOOOOOOOOO
     
  2. Offline

    CubieX

    With the WE API first define a global or local RegionManager.
    Then create a cuboidSelection where the player selected one with the wand tool.
    Then call " getApplicableRegions()" on this selection, and check for each delivered region, if the issuing player of the command is an owner of this region.
    If he is the owner of all of these regions intersecting with his selection, you can be sure, no foreign region is there.
    However, if there is kind of a "public" region like a defined freebuild area with buil flag = true, you have to modify this check a bit to take this into account. Because then he may not be the owner of all intersecting regions in this selection, but have building rights there.
    But this depends on how your world is structured region-wise.
    The method " overlapsUnownedRegion()" may also be helpful.
     
  3. Hi!

    Thanks for the answer. But theres one problem: CuboidSelection hasn't a getApplicableRegions method, and the method from WGBukkit.getRegionManager(world).getApplicableRegions() can't take a cuboidselection as argument...
     
  4. Offline

    CubieX

    Sorry. I described it off the top of my head.
    You have to define a region out of your cuboidSelection. Then you can call .getApplicableRegions(myRegion).

    See the WG API if you did not do it yet. It's not that complicated to find the needed methods.
     
Thread Status:
Not open for further replies.

Share This Page