Exemplo n.º 1
0
  public Map<String, ProtectedRegion> getRegions() {
    HashMap<String, ProtectedRegion> ret = new HashMap<String, ProtectedRegion>();
    ret.putAll(this.cRegions);
    ret.putAll(this.pRegions);

    for (Map.Entry<String, ProtectedRegion> entry : ret.entrySet()) {
      ProtectedRegion region = entry.getValue();

      String parentId = region.getParentId();
      if (parentId != null) {
        try {
          region.setParent(ret.get(parentId));
        } catch (CircularInheritanceException ex) {
        }
      } else {
        try {
          region.setParent(null);
        } catch (CircularInheritanceException ex) {
        }
      }

      if (region.getOwners() == null) {
        region.setOwners(new DefaultDomain());
      } else if (region.getMembers() == null) {
        region.setMembers(new DefaultDomain());
      }
    }

    return ret;
  }
 /**
  * Copy attributes from another region.
  *
  * @param other the other region
  */
 public void copyFrom(ProtectedRegion other) {
   checkNotNull(other);
   setMembers(other.getMembers());
   setOwners(other.getOwners());
   setFlags(other.getFlags());
   setPriority(other.getPriority());
   try {
     setParent(other.getParent());
   } catch (CircularInheritanceException ignore) {
     // This should not be thrown
   }
 }
Exemplo n.º 3
0
  void setUpEntryRegion() {
    DefaultDomain domain = new DefaultDomain();
    domain.addGroup(VIP_GROUP);

    ProtectedRegion region =
        new ProtectedCuboidRegion(ENTRY_ID, new BlockVector(1, 0, 1), new BlockVector(10, 255, 10));

    region.setMembers(domain);
    manager.addRegion(region);

    entryRegion = region;
    // this is the way it's supposed to work
    // whatever the group flag is set to is the group that the flag APPLIES to
    // in this case, non members (esskay) should be DENIED entry
    entryRegion.setFlag(DefaultFlag.ENTRY, StateFlag.State.DENY);
    entryRegion.setFlag(DefaultFlag.ENTRY.getRegionGroupFlag(), RegionGroup.NON_MEMBERS);
  }
  @Override
  public void untakeRegion(String world, String region) {
    final ProtectedRegion protectedRegion =
        SimpleRegionMarket.wgManager.getProtectedRegion(Bukkit.getWorld(world), region);

    // Clear Members
    protectedRegion.setMembers(new DefaultDomain());

    checkUntakeActions(protectedRegion, world);

    Utils.setEntry(this, world, region, "taken", false);
    Utils.removeEntry(this, world, region, "owner");
    Utils.removeEntry(this, world, region, "expiredate");
    Utils.setEntry(this, world, region, "hidden", false);

    tokenManager.updateSigns(this, world, region);
  }
  @Override
  public void takeRegion(Player newOwner, String world, String region) {
    final ProtectedRegion protectedRegion =
        SimpleRegionMarket.wgManager.getProtectedRegion(Bukkit.getWorld(world), region);

    if (Utils.getEntryBoolean(this, world, region, "taken")) {
      final Player oldOwner = Bukkit.getPlayer(Utils.getEntryString(this, world, region, "owner"));
      final ArrayList<String> list = new ArrayList<String>();
      list.add(region);
      list.add(newOwner.getName());
      LangHandler.NormalOut(oldOwner, "PLAYER.REGION.JUST_TAKEN_BY", list);
      untakeRegion(world, region);
    } else {
      // Clear Members
      protectedRegion.setMembers(new DefaultDomain());
    }

    protectedRegion.getMembers().addPlayer(SimpleRegionMarket.wgManager.wrapPlayer(newOwner));

    checkTakeActions(protectedRegion, world);

    Utils.setEntry(this, world, region, "taken", true);
    Utils.setEntry(this, world, region, "owner", newOwner.getName());
    Utils.setEntry(
        this,
        world,
        region,
        "expiredate",
        System.currentTimeMillis() + Utils.getEntryLong(this, world, region, "renttime"));
    Utils.setEntry(this, world, region, "hidden", true);

    final ArrayList<String> list = new ArrayList<String>();
    list.add(region);
    LangHandler.NormalOut(newOwner, "PLAYER.REGION.RENT", list);

    tokenManager.updateSigns(this, world, region);
  }