public void setLobbySignsFromSelection(Player pl, int a) {
   FileConfiguration c = SettingsManager.getInstance().getSystemConfig();
   SettingsManager s = SettingsManager.getInstance();
   if (!c.getBoolean("walls-system.lobby.sign.set", false)) {
     c.set("walls-system.lobby.sign.set", true);
     s.saveSystemConfig();
   }
   WorldEditPlugin we = GameManager.getInstance().getWorldEdit();
   Selection sel = we.getSelection(pl);
   if (sel == null) {
     pl.sendMessage(ChatColor.RED + "You must make a WorldEdit Selection first");
     return;
   }
   if ((sel.getNativeMaximumPoint().getBlockX() - sel.getNativeMinimumPoint().getBlockX()) != 0
       && (sel.getNativeMinimumPoint().getBlockZ() - sel.getNativeMaximumPoint().getBlockZ()
           != 0)) {
     pl.sendMessage(ChatColor.RED + " Must be in a straight line!");
     return;
   }
   Vector max = sel.getNativeMaximumPoint();
   Vector min = sel.getNativeMinimumPoint();
   int i = c.getInt("walls-system.lobby.signno", 0) + 1;
   c.set("walls-system.lobby.signno", i);
   c.set("walls-system.lobby.signs." + i + ".id", a);
   c.set("walls-system.lobby.signs." + i + ".world", pl.getWorld().getName());
   c.set("walls-system.lobby.signs." + i + ".x1", max.getBlockX());
   c.set("walls-system.lobby.signs." + i + ".y1", max.getBlockY());
   c.set("walls-system.lobby.signs." + i + ".z1", max.getBlockZ());
   c.set("walls-system.lobby.signs." + i + ".x2", min.getBlockX());
   c.set("walls-system.lobby.signs." + i + ".y2", min.getBlockY());
   c.set("walls-system.lobby.signs." + i + ".z2", min.getBlockZ());
   pl.sendMessage(ChatColor.GREEN + "Added Lobby Wall"); // TODO
   s.saveSystemConfig();
   loadSign(i);
 }
Пример #2
0
 public void createMap(String id, Player p) throws EmptyClipboardException {
   Selection sel = WorldEditUtilities.getWorldEdit().getSelection(p);
   if (sel != null) {
     MapConfiguration.getMaps().reloadMap(id);
     Location b1 =
         new Location(
             p.getWorld(),
             sel.getNativeMinimumPoint().getBlockX(),
             sel.getNativeMinimumPoint().getBlockY(),
             sel.getNativeMinimumPoint().getBlockZ());
     Location b2 =
         new Location(
             p.getWorld(),
             sel.getNativeMaximumPoint().getBlockX(),
             sel.getNativeMaximumPoint().getBlockY(),
             sel.getNativeMaximumPoint().getBlockZ());
     MapConfiguration.getMaps().getMap(id).set("region.p1.w", b1.getWorld().getName());
     MapConfiguration.getMaps().getMap(id).set("region.p1.x", b1.getBlockX());
     MapConfiguration.getMaps().getMap(id).set("region.p1.y", b1.getBlockY());
     MapConfiguration.getMaps().getMap(id).set("region.p1.z", b1.getBlockZ());
     MapConfiguration.getMaps().getMap(id).set("region.p2.w", b2.getWorld().getName());
     MapConfiguration.getMaps().getMap(id).set("region.p2.x", b2.getBlockX());
     MapConfiguration.getMaps().getMap(id).set("region.p2.y", b2.getBlockY());
     MapConfiguration.getMaps().getMap(id).set("region.p2.z", b2.getBlockZ());
     MapConfiguration.getMaps().saveMap(id);
     List<String> enabled =
         DataConfiguration.getData().getDataFile().getStringList("enabled-maps");
     enabled.add(id);
     DataConfiguration.getData().getDataFile().set("enabled-maps", enabled);
     DataConfiguration.getData().saveData();
   } else {
     throw new EmptyClipboardException();
   }
 }
Пример #3
0
  public void regionPrice(Player player, String[] args) {
    Selection sel = worldEdit.getSelection(player);

    if (sel == null) {
      player.sendMessage(ChatColor.RED + "Select a region with a wooden axe first.");
      return;
    }

    ProtectedRegion region = null;
    String id = "icp__tempregion";

    if (sel instanceof Polygonal2DSelection) {
      Polygonal2DSelection polySel = (Polygonal2DSelection) sel;
      int minY = polySel.getNativeMinimumPoint().getBlockY();
      int maxY = polySel.getNativeMaximumPoint().getBlockY();
      region = new ProtectedPolygonalRegion(id, polySel.getNativePoints(), minY, maxY);
    } else if (sel instanceof CuboidSelection) {
      BlockVector min = sel.getNativeMinimumPoint().toBlockVector();
      BlockVector max = sel.getNativeMaximumPoint().toBlockVector();
      region = new ProtectedCuboidRegion(id, min, max);
    } else {
      player.sendMessage(
          ChatColor.RED
              + "(shouldn't happen) Something went wrong. The type of region selected is unsupported!");
      return;
    }

    double cost = (int) Math.ceil(econ.getCost(region.volume()));

    player.sendMessage(ChatColor.AQUA + "That region will cost you $" + cost + ".");
  }
Пример #4
0
 private static ProtectedRegion checkRegionFromSelection(Player player, String id)
     throws CommandException {
   Selection selection = checkSelection(player);
   if (selection instanceof Polygonal2DSelection) {
     Polygonal2DSelection polySel = (Polygonal2DSelection) selection;
     int minY = polySel.getNativeMinimumPoint().getBlockY();
     int maxY = polySel.getNativeMaximumPoint().getBlockY();
     return new ProtectedPolygonalRegion(id, polySel.getNativePoints(), minY, maxY);
   } else if (selection instanceof CuboidSelection) {
     BlockVector min = selection.getNativeMinimumPoint().toBlockVector();
     BlockVector max = selection.getNativeMaximumPoint().toBlockVector();
     return new ProtectedCuboidRegion(id, min, max);
   } else {
     throw new CommandException(
         "Sorry, you can only use cuboids and polygons for WorldGuard regions.");
   }
 }
Пример #5
0
  public void setRegion(Player sender, String[] args) {
    if (args.length != 2) {
      sender.sendMessage(ChatColor.RED + "Wrong usage. /pr help");
      return;
    }

    LocalPlayer wgPlayer = plugin.wrapPlayer(sender);

    String id = "icp_" + sender.getName() + "_" + args[1];

    if (!ProtectedRegion.isValidId(id)) {
      sender.sendMessage(ChatColor.RED + "Invalid region name specified!");
      return;
    }

    Selection sel = worldEdit.getSelection(sender);

    if (sel == null) {
      sender.sendMessage(ChatColor.RED + "Select a region with a wooden axe first.");
      return;
    }

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

    if (mgr.hasRegion(id)) {
      sender.sendMessage(
          ChatColor.RED + "That region name is already taken. Please choose a new name.");
      return;
    }

    int regionCount = mgr.getRegionCountOfPlayer(wgPlayer);

    if (regionCount > Economy.maxDonatorAllowedRegions
        && !sender.isOp()
        && sender.hasPermission("iceprotect.freeprotect")) {
      sender.sendMessage(
          ChatColor.RED
              + "You have reached the maximum allowed regions per user ("
              + Economy.maxDonatorAllowedRegions
              + ").");
      sender.sendMessage(ChatColor.RED + "Please contact an admin.");
      return;
    }

    ProtectedRegion region = null;

    if (sel instanceof Polygonal2DSelection) {
      Polygonal2DSelection polySel = (Polygonal2DSelection) sel;
      int minY = polySel.getNativeMinimumPoint().getBlockY();
      int maxY = polySel.getNativeMaximumPoint().getBlockY();
      region = new ProtectedPolygonalRegion(id, polySel.getNativePoints(), minY, maxY);
    } else if (sel instanceof CuboidSelection) {
      BlockVector min = sel.getNativeMinimumPoint().toBlockVector();
      BlockVector max = sel.getNativeMaximumPoint().toBlockVector();
      region = new ProtectedCuboidRegion(id, min, max);
    } else {
      sender.sendMessage(
          ChatColor.RED
              + "(shouldn't happen) Something went wrong. The type of region selected is unsupported!");
      return;
    }

    String[] names = new String[1];
    names[0] = sender.getName();
    region.setOwners(RegionUtil.parseDomainString(names, 0));

    ApplicableRegionSet regions = mgr.getApplicableRegions(region);

    if (!regions.isOwnerOfAll(wgPlayer)) {
      sender.sendMessage(ChatColor.RED + "That region overlaps with another one not owned by you!");
      return;
    }

    double cost = (int) Math.ceil(econ.getCost(region.volume()));

    if (cost > Economy.maxDonatorAllowedCost && sender.hasPermission("iceprotect.freeprotect")) {
      sender.sendMessage(
          ChatColor.RED + "You have exceeded the maximum allowed price for this region!");
      sender.sendMessage(
          ChatColor.RED
              + "Cost: "
              + ChatColor.GRAY
              + "$"
              + cost
              + ChatColor.RED
              + ", "
              + ChatColor.GRAY
              + "$"
              + Economy.maxDonatorAllowedCost
              + " allowed.");
      return;
    }

    if (!sender.hasPermission("iceprotect.freeprotect") && !econ.chargePlayer(sender, cost)) {
      sender.sendMessage(ChatColor.RED + "You don't have enough money! $" + cost + " needed.");
      return;
    }

    mgr.addRegion(region);

    try {
      mgr.save();
      sender.sendMessage(
          ChatColor.YELLOW
              + "Region saved as "
              + args[1]
              + ". "
              + (sender.hasPermission("iceprotect.freeprotect") ? "" : "Cost: $" + cost + "."));
    } catch (IOException e) {
      sender.sendMessage(
          ChatColor.RED + "(shouldn't happen) Failed to write regions file: " + e.getMessage());
      e.printStackTrace();
      return;
    }
  }