コード例 #1
0
 public static boolean hasPermission(
     Resident res, FlagType<Boolean> flagType, int dim, int x, int y, int z) {
   if (MyTownUniverse.instance.blocks.contains(dim, x >> 4, z >> 4)) {
     Town town = MyTownUniverse.instance.blocks.get(dim, x >> 4, z >> 4).getTown();
     return town.hasPermission(res, flagType, dim, x, y, z);
   } else {
     return !flagType.isWildPerm || Wild.instance.hasPermission(res, flagType);
   }
 }
コード例 #2
0
  public static boolean hasPermission(
      Resident res, FlagType<Boolean> flagType, int dim, Volume volume) {
    boolean inWild = false;

    for (int townBlockX = volume.getMinX() >> 4;
        townBlockX <= volume.getMaxX() >> 4;
        townBlockX++) {
      for (int townBlockZ = volume.getMinZ() >> 4;
          townBlockZ <= volume.getMaxZ() >> 4;
          townBlockZ++) {
        TownBlock townBlock = MyTownUniverse.instance.blocks.get(dim, townBlockX, townBlockZ);

        if (townBlock == null) {
          inWild = true;
          continue;
        }

        Town town = townBlock.getTown();
        Volume rangeBox = volume.intersect(townBlock.toVolume());

        // If the range volume intersects the TownBlock, check Town/Plot permissions
        if (rangeBox != null) {
          int totalIntersectArea = 0;

          // Check every plot in the current TownBlock and sum all plot areas
          for (Plot plot : townBlock.plotsContainer) {
            Volume plotIntersection = volume.intersect(plot.toVolume());
            if (plotIntersection != null) {
              if (!plot.hasPermission(res, flagType)) {
                return false;
              }
              totalIntersectArea += plotIntersection.getVolumeAmount();
            }
          }

          // If plot area sum is not equal to range area, check town permission
          if (totalIntersectArea != rangeBox.getVolumeAmount()) {
            if (!town.hasPermission(res, flagType)) {
              return false;
            }
          }
        }
      }
    }

    if (inWild) {
      return Wild.instance.hasPermission(res, flagType);
    }

    return true;
  }