Beispiel #1
0
  public void checkRegion(Player sender, String[] args) {
    if (!sender.hasPermission("iceprotect.buy")) {
      sender.sendMessage(ChatColor.RED + "You don't have permission!");
      return;
    }

    if (args.length != 1) {
      sender.sendMessage(ChatColor.RED + "Wrong usage. /pr help");
      return;
    }

    String id = "icp__tempregion";

    Location loc = sender.getLocation();

    BlockVector min = new BlockVector(loc.getX() - 1, loc.getY() - 1, loc.getZ() - 1);
    BlockVector max = new BlockVector(loc.getX() + 1, loc.getY() + 1, loc.getZ() + 1);
    ProtectedRegion region = new ProtectedCuboidRegion(id, min, max);

    RegionManager mgr = plugin.getGlobalRegionManager().get(sender.getWorld());

    ApplicableRegionSet regions = mgr.getApplicableRegions(region);
    ProtectedRegion appReg = null;

    for (ProtectedRegion r : regions) {
      if (econ.isRegionForSale(r.getId())) {
        appReg = r;
        break;
      }
    }

    if (appReg == null) {
      sender.sendMessage(ChatColor.RED + "No nearby regions for sale!");
      return;
    } else {
      double cost = regionsForSale.getDouble("regions." + appReg.getId() + ".price", 0D);
      if (cost == 0) {
        sender.sendMessage(
            ChatColor.RED + "(this shouldn't happen) You can't buy this region. Notify an admin!");
        return;
      }

      sender.sendMessage(
          ChatColor.YELLOW
              + "This region "
              + appReg.getId()
              + " is for sale by "
              + regionsForSale.getString("regions." + appReg.getId() + ".seller"));
      sender.sendMessage(ChatColor.YELLOW + "And costs $" + cost + ".");
    }
  }