Solved Hooking WG/WE (Vectors, Regions, Owners)

Discussion in 'Plugin Development' started by martian3333, Apr 16, 2013.

Thread Status:
Not open for further replies.
  1. Offline

    martian3333

    I'm working on a project that hooks into WorldGuard and WorldEdit. I've got a for/next loop that runs through all the points in a WE selection and turns them into vectors. I want to pass these vectors to WG to see if :
    A. The vector in this selection is unclaimed
    B. The vector in this selection is part of a region
    C. The owner of said region.

    I've got it mostly working but am having trouble getting it to distinguish between an unclaimed region and one owned by the player who is the sender. I know there are a lot of help topics on this subject here, but I just haven't been able to find this exact answer. I will appreciate any help and apologize if I simply overlooked the answer to my query.
     
  2. Offline

    seemethere

    martian3333

    This should do what you're looking for.

    Code:
    // Check if region is unclaimed
    if (region.getOwners().size() == 0 && region.getMembers.size() == 0) {
        //do whatever
    }
     
    // Check if player is the owner
    if (region.getOwners().contains(sender.getName()) {
        //Do whatever
    }
    
    As far as checking if a vector is part of a region you would iterate through all locations within a selection and then do a check to is if there are any applicable regions within that.
     
    martian3333 likes this.
  3. Offline

    martian3333

    Looks pretty good, I'll give that a shot when I get back to my computer. Thank you :)

    seemethere
    Thanks for the advice! Using .size() was the key to solving my problem. My logic works great now.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 1, 2016
Thread Status:
Not open for further replies.

Share This Page