WorldGuard API can't add owners to region

Discussion in 'Plugin Development' started by Weasel_Squeezer, Apr 21, 2014.

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

    Weasel_Squeezer

    When I try to add a player as an owner to a region the correct way, they are never added to the region. I have extended the ProtectedCuboidRegion class, and am setting the region values from within that class. All region properties other that setting or adding owners works fine, but once I try to add an owner, the region is never updated. I must be missing something here but I cannot tell what. Here is basically what I have:
    Code:java
    1. public class Region extends ProtectedCuboidRegion {
    2.  
    3. private List<String> owners = new ArrayList<String>();
    4.  
    5. public Region(String id, BlockVector max, BlockVector min) {
    6. super(id, max, min);
    7. saveRegion();
    8. }
    9.  
    10. public void addOwner(String owner) {
    11. owners.add(owner);
    12. updateOwners();
    13. }
    14.  
    15. private void updateOwners() {
    16. super.getOwners().removeAll();
    17. for (String owner : owners) {
    18. super.getOwners().addPlayer(owner);
    19. }
    20. saveRegion();
    21. }
    22.  
    23. public void saveRegion() {
    24. try {
    25. if (!this.equals(regionManager.getRegion(getId().toLowerCase()))) {
    26. regionManager.addRegion(this);
    27. }
    28. regionManager.save();
    29. } catch (ProtectionDatabaseException e) {
    30. e.printStackTrace();
    31. }
    32. }
    33.  
    34. }


    Does anyone have any idea why this would work. If I do anything like:
    Code:java
    1. super.setParent(parent);
    and then calling saveRegion(); it works fine, but not with owners.
     
  2. Offline

    CubieX

    I think you need to use the region manager for this.

    This is how I add members or owners to a region:
    Code:
    wgRM.getRegion(args[1]).getOwners().addPlayer(args[2]);
    wgRM.save();
    Where "wgRM" is a RegionManager for the current world.
     
Thread Status:
Not open for further replies.

Share This Page