Java Code Examples for br.net.fabiozumbi12.RedProtect.Bukkit.Region#getArea()
The following examples show how to use
br.net.fabiozumbi12.RedProtect.Bukkit.Region#getArea() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RedProtectUtil.java From RedProtect with GNU General Public License v3.0 | 6 votes |
public int getUpdatedPrior(Region region) { int regionarea = region.getArea(); int prior = region.getPrior(); Region topRegion = RedProtect.get().rm.getTopRegion(region.getWorld(), region.getCenterX(), region.getCenterY(), region.getCenterZ()); Region lowRegion = RedProtect.get().rm.getLowRegion(region.getWorld(), region.getCenterX(), region.getCenterY(), region.getCenterZ()); if ((topRegion != null && topRegion.getID().equals(region.getID())) || (lowRegion != null && lowRegion.getID().equals(region.getID()))) { return prior; } if (lowRegion != null) { if (regionarea > lowRegion.getArea()) { prior = lowRegion.getPrior() - 1; } else if (regionarea < lowRegion.getArea() && regionarea < topRegion.getArea()) { prior = topRegion.getPrior() + 1; } else if (regionarea < topRegion.getArea()) { prior = topRegion.getPrior() + 1; } } return prior; }
Example 2
Source File: RedProtectUtil.java From RedProtect with GNU General Public License v3.0 | 6 votes |
public int simuleTotalRegionSize(String player, Region r2) { int total = 0; int regs = 0; for (Location loc : r2.get4Points(r2.getCenterY())) { Map<Integer, Region> pregs = RedProtect.get().rm.getGroupRegion(loc); pregs.remove(r2.getPrior()); Region other; if (pregs.size() > 0) { other = pregs.get(Collections.max(pregs.keySet())); } else { continue; } if (!r2.getID().equals(other.getID()) && r2.getPrior() > other.getPrior() && other.isLeader(player)) { regs++; } } if (regs != 4) { total += r2.getArea(); } return total; }
Example 3
Source File: WorldMySQLRegionManager.java From RedProtect with GNU General Public License v3.0 | 6 votes |
@Override public Region getTopRegion(int x, int y, int z) { Map<Integer, Region> regionlist = new HashMap<>(); int max = 0; for (Region r : this.getRegions(x, y, z)) { if (x <= r.getMaxMbrX() && x >= r.getMinMbrX() && y <= r.getMaxY() && y >= r.getMinY() && z <= r.getMaxMbrZ() && z >= r.getMinMbrZ()) { if (regionlist.containsKey(r.getPrior())) { Region reg1 = regionlist.get(r.getPrior()); int Prior = r.getPrior(); if (reg1.getArea() >= r.getArea()) { r.setPrior(Prior + 1); } else { reg1.setPrior(Prior + 1); } } regionlist.put(r.getPrior(), r); } } if (regionlist.size() > 0) { max = Collections.max(regionlist.keySet()); } return regionlist.get(max); }
Example 4
Source File: WorldMySQLRegionManager.java From RedProtect with GNU General Public License v3.0 | 6 votes |
@Override public Region getLowRegion(int x, int y, int z) { Map<Integer, Region> regionlist = new HashMap<>(); int min = 0; for (Region r : this.getRegions(x, y, z)) { if (x <= r.getMaxMbrX() && x >= r.getMinMbrX() && y <= r.getMaxY() && y >= r.getMinY() && z <= r.getMaxMbrZ() && z >= r.getMinMbrZ()) { if (regionlist.containsKey(r.getPrior())) { Region reg1 = regionlist.get(r.getPrior()); int Prior = r.getPrior(); if (reg1.getArea() >= r.getArea()) { r.setPrior(Prior + 1); } else { reg1.setPrior(Prior + 1); } } regionlist.put(r.getPrior(), r); } } if (regionlist.size() > 0) { min = Collections.min(regionlist.keySet()); } return regionlist.get(min); }
Example 5
Source File: WorldMySQLRegionManager.java From RedProtect with GNU General Public License v3.0 | 6 votes |
public Map<Integer, Region> getGroupRegion(int x, int y, int z) { Map<Integer, Region> regionlist = new HashMap<>(); for (Region r : this.getRegions(x, y, z)) { if (x <= r.getMaxMbrX() && x >= r.getMinMbrX() && y <= r.getMaxY() && y >= r.getMinY() && z <= r.getMaxMbrZ() && z >= r.getMinMbrZ()) { if (regionlist.containsKey(r.getPrior())) { Region reg1 = regionlist.get(r.getPrior()); int Prior = r.getPrior(); if (reg1.getArea() >= r.getArea()) { r.setPrior(Prior + 1); } else { reg1.setPrior(Prior + 1); } } regionlist.put(r.getPrior(), r); } } return regionlist; }
Example 6
Source File: WorldFlatFileRegionManager.java From RedProtect with GNU General Public License v3.0 | 6 votes |
@Override public Region getTopRegion(int x, int y, int z) { Map<Integer, Region> regionlist = new HashMap<>(); int max = 0; for (Region r : regions.values()) { if (x <= r.getMaxMbrX() && x >= r.getMinMbrX() && y <= r.getMaxY() && y >= r.getMinY() && z <= r.getMaxMbrZ() && z >= r.getMinMbrZ()) { if (regionlist.containsKey(r.getPrior())) { Region reg1 = regionlist.get(r.getPrior()); int Prior = r.getPrior(); if (reg1.getArea() >= r.getArea()) { r.setPrior(Prior + 1); } else { reg1.setPrior(Prior + 1); } } regionlist.put(r.getPrior(), r); } } if (regionlist.size() > 0) { max = Collections.max(regionlist.keySet()); } return regionlist.get(max); }
Example 7
Source File: WorldFlatFileRegionManager.java From RedProtect with GNU General Public License v3.0 | 6 votes |
@Override public Region getLowRegion(int x, int y, int z) { Map<Integer, Region> regionlist = new HashMap<>(); int min = 0; for (Region r : regions.values()) { if (x <= r.getMaxMbrX() && x >= r.getMinMbrX() && y <= r.getMaxY() && y >= r.getMinY() && z <= r.getMaxMbrZ() && z >= r.getMinMbrZ()) { if (regionlist.containsKey(r.getPrior())) { Region reg1 = regionlist.get(r.getPrior()); int Prior = r.getPrior(); if (reg1.getArea() >= r.getArea()) { r.setPrior(Prior + 1); } else { reg1.setPrior(Prior + 1); } } regionlist.put(r.getPrior(), r); } } if (regionlist.size() > 0) { min = Collections.min(regionlist.keySet()); } return regionlist.get(min); }
Example 8
Source File: WorldFlatFileRegionManager.java From RedProtect with GNU General Public License v3.0 | 6 votes |
@Override public Map<Integer, Region> getGroupRegion(int x, int y, int z) { Map<Integer, Region> regionlist = new HashMap<>(); for (Region r : regions.values()) { if (x <= r.getMaxMbrX() && x >= r.getMinMbrX() && y <= r.getMaxY() && y >= r.getMinY() && z <= r.getMaxMbrZ() && z >= r.getMinMbrZ()) { if (regionlist.containsKey(r.getPrior())) { Region reg1 = regionlist.get(r.getPrior()); int Prior = r.getPrior(); if (reg1.getArea() >= r.getArea()) { r.setPrior(Prior + 1); } else { reg1.setPrior(Prior + 1); } } regionlist.put(r.getPrior(), r); } } return regionlist; }
Example 9
Source File: RedProtectUtil.java From RedProtect with GNU General Public License v3.0 | 5 votes |
public Location DenyEnterPlayer(World wFrom, Location from, Location to, Region r, boolean checkSec) { Location setTo = to; for (int i = 0; i < r.getArea() + 10; i++) { Region r1 = RedProtect.get().rm.getTopRegion(wFrom.getName(), from.getBlockX() + i, from.getBlockY(), from.getBlockZ()); Region r2 = RedProtect.get().rm.getTopRegion(wFrom.getName(), from.getBlockX() - i, from.getBlockY(), from.getBlockZ()); Region r3 = RedProtect.get().rm.getTopRegion(wFrom.getName(), from.getBlockX(), from.getBlockY(), from.getBlockZ() + i); Region r4 = RedProtect.get().rm.getTopRegion(wFrom.getName(), from.getBlockX(), from.getBlockY(), from.getBlockZ() - i); Region r5 = RedProtect.get().rm.getTopRegion(wFrom.getName(), from.getBlockX() + i, from.getBlockY(), from.getBlockZ() + i); Region r6 = RedProtect.get().rm.getTopRegion(wFrom.getName(), from.getBlockX() - i, from.getBlockY(), from.getBlockZ() - i); if (r1 != r) { setTo = from.add(+i, 0, 0); break; } if (r2 != r) { setTo = from.add(-i, 0, 0); break; } if (r3 != r) { setTo = from.add(0, 0, +i); break; } if (r4 != r) { setTo = from.add(0, 0, -i); break; } if (r5 != r) { setTo = from.add(+i, 0, +i); break; } if (r6 != r) { setTo = from.add(-i, 0, -i); break; } } if (checkSec && !isSecure(setTo)) { wFrom.getBlockAt(setTo.clone().add(0, -1, 0)).setType(Material.GRASS); } return setTo; }
Example 10
Source File: ValueCommand.java From RedProtect with GNU General Public License v3.0 | 5 votes |
@Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { if (sender instanceof ConsoleCommandSender) { HandleHelpPage(sender, 1); return true; } Player player = (Player) sender; if (args.length == 0) { Region r = RedProtect.get().rm.getTopRegion(player.getLocation()); if (r != null) { if (RedProtect.get().ph.hasRegionPermLeader(player, "value", r)) { if (r.getArea() <= RedProtect.get().config.ecoRoot().max_area_toget_value) { r.setValue(EconomyManager.getRegionValue(r)); RedProtect.get().lang.sendMessage(player, RedProtect.get().lang.get("cmdmanager.value.is").replace("{value}", EconomyManager.getFormatted(r.getValue()) + " " + RedProtect.get().config.ecoRoot().economy_name)); RedProtect.get().logger.debug(LogLevel.DEFAULT, "Region Value: " + r.getValue()); return true; } else { RedProtect.get().lang.sendMessage(player, RedProtect.get().lang.get("cmdmanager.value.areabig").replace("{maxarea}", String.valueOf(RedProtect.get().config.ecoRoot().max_area_toget_value))); return true; } } else { RedProtect.get().lang.sendMessage(player, "playerlistener.region.cantuse"); return true; } } else { RedProtect.get().lang.sendMessage(player, "cmdmanager.region.todo.that"); return true; } } RedProtect.get().lang.sendCommandHelp(sender, "value", true); return true; }
Example 11
Source File: RegionManager.java From RedProtect with GNU General Public License v3.0 | 5 votes |
public int regenAll(String player) { int delay = 0; for (Region r : getLeaderRegions(player)) { if (r.getArea() <= RedProtect.get().config.configRoot().purge.regen.max_area_regen) { WEHook.regenRegion(r, Bukkit.getWorld(r.getWorld()), r.getMaxLocation(), r.getMinLocation(), delay, null, true); delay = delay + 10; } } return delay / 10; }
Example 12
Source File: CommandHandlers.java From RedProtect with GNU General Public License v3.0 | 4 votes |
public static void handleDelete(Player p) { Region r = RedProtect.get().rm.getTopRegion(p.getLocation()); if (RedProtect.get().ph.hasRegionPermLeader(p, "delete", r)) { if (r == null) { RedProtect.get().lang.sendMessage(p, "cmdmanager.region.todo.that"); return; } int claims = RedProtect.get().config.configRoot().region_settings.can_delete_first_home_after_claims; if (!r.canDelete() && (claims == -1 || RedProtect.get().rm.getPlayerRegions(p.getUniqueId().toString(), p.getWorld().getName()) < claims) && !p.hasPermission("redprotect.bypass")) { if (claims != -1) { RedProtect.get().lang.sendMessage(p, RedProtect.get().lang.get("cmdmanager.region.cantdeletefirst-claims").replace("{claims}", "" + claims)); } else { RedProtect.get().lang.sendMessage(p, RedProtect.get().lang.get("cmdmanager.region.cantdeletefirst")); } return; } DeleteRegionEvent event = new DeleteRegionEvent(r, p); Bukkit.getPluginManager().callEvent(event); if (event.isCancelled()) { return; } String rname = r.getName(); String w = r.getWorld(); RedProtect.get().rm.remove(r, w); RedProtect.get().lang.sendMessage(p, RedProtect.get().lang.get("cmdmanager.region.deleted") + " " + rname); RedProtect.get().logger.addLog("(World " + w + ") Player " + p.getName() + " REMOVED region " + rname); // Handle money if (RedProtect.get().config.ecoRoot().claim_cost_per_block.enable && RedProtect.get().hooks.vault && !p.hasPermission("redprotect.eco.bypass")) { long reco = r.getArea() * RedProtect.get().config.ecoRoot().claim_cost_per_block.cost_per_block; if (!RedProtect.get().config.ecoRoot().claim_cost_per_block.y_is_free) { reco = reco * Math.abs(r.getMaxY() - r.getMinY()); } if (reco > 0) { RedProtect.get().economy.depositPlayer(p, reco); p.sendMessage(RedProtect.get().lang.get("economy.region.deleted").replace("{price}", RedProtect.get().config.ecoRoot().economy_symbol + reco + " " + RedProtect.get().config.ecoRoot().economy_name)); } } } else { RedProtect.get().lang.sendMessage(p, "no.permission"); } }
Example 13
Source File: DynmapHook.java From RedProtect with GNU General Public License v3.0 | 4 votes |
public void addMark(Region r) { AreaMarker am = MSet.findAreaMarker(r.getID()); double[] x = new double[4]; double[] z = new double[4]; int i = 0; for (Location l : r.get4Points(90)) { x[i] = l.getBlockX() + 0.500; z[i] = l.getBlockZ() + 0.500; i++; } if (am == null) { am = MSet.createAreaMarker(r.getID(), r.getName(), false, r.getWorld(), x, z, true); } else { am.setCornerLocations(x, z); } String rName = RedProtect.get().lang.get("region.name") + " <span style=\"font-weight:bold;\">" + r.getName() + "</span><br>"; String area = RedProtect.get().lang.get("region.area") + " <span style=\"font-weight:bold;\">" + r.getArea() + "</span>"; am.setDescription(ChatColor.stripColor(rName + area)); if (RedProtect.get().config.configRoot().hooks.dynmap.show_leaders_admins) { String leader = RedProtect.get().lang.get("region.leaders") + " <span style=\"font-weight:bold;\">" + r.getLeadersDesc() + "</span><br>"; String admin = RedProtect.get().lang.get("region.admins") + " <span style=\"font-weight:bold;\">" + r.getAdminDesc() + "</span><br>"; am.setDescription(ChatColor.stripColor(rName + leader + admin + area)); } int center = -1; if (RedProtect.get().config.configRoot().hooks.dynmap.cuboid_region.enabled) { am.setRangeY(r.getMinLocation().getBlockY() + 0.500, r.getMaxLocation().getBlockY() + 0.500); } else { center = RedProtect.get().config.configRoot().hooks.dynmap.cuboid_region.if_disable_set_center; am.setRangeY(center, center); } String type = "player"; if (r.isLeader(RedProtect.get().config.configRoot().region_settings.default_leader)) type = "server"; am.setLineStyle( RedProtect.get().config.configRoot().hooks.dynmap.marker.get(type).border_weight, RedProtect.get().config.configRoot().hooks.dynmap.marker.get(type).border_opacity, Integer.decode(RedProtect.get().config.configRoot().hooks.dynmap.marker.get(type).border_color.replace("#", "0x"))); am.setFillStyle( RedProtect.get().config.configRoot().hooks.dynmap.marker.get(type).fill_opacity, Integer.decode(RedProtect.get().config.configRoot().hooks.dynmap.marker.get(type).fill_color.replace("#", "0x"))); if (RedProtect.get().config.configRoot().hooks.dynmap.show_icon) { Marker m = MSet.findMarker(r.getID()); if (center == -1) { center = r.getCenterY(); } MarkerIcon icon = MApi.getMarkerIcon(RedProtect.get().config.configRoot().hooks.dynmap.marker.get(type).marker_icon); if (m == null) { MSet.createMarker(r.getID(), r.getName(), r.getWorld(), r.getCenterX(), center, r.getCenterZ(), icon, true); } else { m.setLocation(r.getWorld(), r.getCenterX(), center, r.getCenterZ()); } } }