コード例 #1
0
  /**
   * Load region information for a world.
   *
   * @param world
   */
  public void load(World world) {
    String name = world.getName();
    File file = getPath(name);

    try {
      // Create a manager
      RegionManager manager = new FlatRegionManager(new CSVDatabase(file));
      managers.put(name, manager);
      manager.load();

      logger.warning(
          "WorldGuard: "
              + manager.getRegions().size()
              + " "
              + " regions loaded for '"
              + name
              + "'");

      // Store the last modification date so we can track changes
      lastModified.put(name, file.lastModified());
    } catch (FileNotFoundException e) {
    } catch (IOException e) {
      logger.warning(
          "WorldGuard: Failed to load regions from file "
              + file.getAbsolutePath()
              + " : "
              + e.getMessage());
    }
  }
コード例 #2
0
ファイル: Utilities.java プロジェクト: roastnewt/FactionsPlus
  /**
   * Returns true or false. Based on the previous Factions source.
   *
   * @param loc
   * @return
   */
  public static boolean checkForRegionsInChunk(Location currentLocation) {

    // This is pretty much the exact same as Factions 1.6.x source's method
    // except it's inside FactionsPlus!

    World world = currentLocation.getWorld();
    Chunk chunk = world.getChunkAt(currentLocation);

    int minChunkX = chunk.getX() << 4;
    int minChunkZ = chunk.getZ() << 4;
    int maxChunkX = minChunkX + 15;
    int maxChunkZ = minChunkZ + 15;

    int worldHeight = world.getMaxHeight();

    BlockVector minChunk = new BlockVector(minChunkX, 0, minChunkZ);
    BlockVector maxChunk = new BlockVector(maxChunkX, worldHeight, maxChunkZ);

    RegionManager regionManager = FP.worldGuardPlugin.getRegionManager(world);

    ProtectedCuboidRegion region =
        new ProtectedCuboidRegion("factionsplus_tempoverlapcheck", minChunk, maxChunk);

    Map<String, ProtectedRegion> allregions = regionManager.getRegions();

    List<ProtectedRegion> allregionslist = new ArrayList<ProtectedRegion>(allregions.values());

    List<ProtectedRegion> overlaps;

    boolean foundregions = false;

    try {
      overlaps = region.getIntersectingRegions(allregionslist);
      if (overlaps == null || overlaps.isEmpty()) {
        foundregions = false;
      } else {
        foundregions = true;
      }
    } catch (Exception e) {

      e.printStackTrace();
    }

    region = null;
    allregionslist = null;
    overlaps = null;

    return (foundregions);
  }
コード例 #3
0
ファイル: Commands.java プロジェクト: alexstanoev/IceProtect
  public void listRegions(Player player, String[] args) {
    World world = player.getWorld();

    RegionManager mgr = plugin.getGlobalRegionManager().get(world);
    StringBuilder regions = new StringBuilder();
    Set<String> keySet = mgr.getRegions().keySet();

    for (String regionName : keySet) {
      if (regionName.startsWith("icp_" + player.getName().toLowerCase() + "_")) {
        regions.append(
            regionName.replaceFirst("icp_" + player.getName().toLowerCase() + "_", "") + ", ");
      }
    }

    if (regions.length() == 0) {
      player.sendMessage(ChatColor.RED + "You don't have regions in this world.");
    } else {
      player.sendMessage(ChatColor.AQUA + "Your regions:");
      regions.deleteCharAt(regions.length() - 2);
      player.sendMessage(ChatColor.AQUA + regions.toString());
    }
  }