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 + "."); } }
public void sellRegion(Player sender, String[] args) { if (!sender.hasPermission("iceprotect.sell")) { sender.sendMessage(ChatColor.RED + "You don't have permission!"); return; } if (args.length != 2) { sender.sendMessage(ChatColor.RED + "Something went wrong!"); sender.sendMessage(ChatColor.RED + "Usage: /psell <region_name> <price>"); return; } if (!ProtectedRegion.isValidId(args[0])) { sender.sendMessage(ChatColor.RED + "Invalid region name specified!"); return; } RegionManager mgr = plugin.getGlobalRegionManager().get(sender.getLocation().getWorld()); if (!mgr.hasRegion(args[0])) { sender.sendMessage(ChatColor.RED + "Nonexistent region name specified!"); return; } regionsForSale.setProperty("regions." + args[0] + ".price", Double.parseDouble(args[1])); regionsForSale.setProperty("regions." + args[0] + ".seller", sender.getName()); regionsForSale.save(); sender.sendMessage( ChatColor.GREEN + "You successfully added " + ChatColor.YELLOW + args[0] + ChatColor.GREEN + " to the sell list."); }