Java Code Examples for br.net.fabiozumbi12.RedProtect.Bukkit.Region#getMinMbrZ()

The following examples show how to use br.net.fabiozumbi12.RedProtect.Bukkit.Region#getMinMbrZ() . 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: WorldMySQLRegionManager.java    From RedProtect with GNU General Public License v3.0 6 votes vote down vote up
@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 2
Source File: WorldMySQLRegionManager.java    From RedProtect with GNU General Public License v3.0 6 votes vote down vote up
@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 3
Source File: WorldMySQLRegionManager.java    From RedProtect with GNU General Public License v3.0 6 votes vote down vote up
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 4
Source File: WorldFlatFileRegionManager.java    From RedProtect with GNU General Public License v3.0 6 votes vote down vote up
@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 5
Source File: WorldFlatFileRegionManager.java    From RedProtect with GNU General Public License v3.0 6 votes vote down vote up
@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 6
Source File: WorldFlatFileRegionManager.java    From RedProtect with GNU General Public License v3.0 6 votes vote down vote up
@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 7
Source File: RegionManager.java    From RedProtect with GNU General Public License v3.0 5 votes vote down vote up
public Region renameRegion(String newName, Region old) {
    Region newr = new Region(newName, old.getAdmins(), old.getMembers(), old.getLeaders(), new int[]{old.getMinMbrX(), old.getMinMbrX(), old.getMaxMbrX(), old.getMaxMbrX()},
            new int[]{old.getMinMbrZ(), old.getMinMbrZ(), old.getMaxMbrZ(), old.getMaxMbrZ()}, old.getMinY(), old.getMaxY(), old.getPrior(), old.getWorld(), old.getDate(), old.getFlags(), old.getWelcome(), old.getValue(), old.getTPPoint(), old.canDelete(), old.canPurge());

    this.add(newr, newr.getWorld());
    this.remove(old, old.getWorld());
    return newr;
}
 
Example 8
Source File: EconomyManager.java    From RedProtect with GNU General Public License v3.0 4 votes vote down vote up
public static long getRegionValue(Region r) {
    long regionCost = 0;
    World w = RedProtect.get().getServer().getWorld(r.getWorld());
    int maxX = r.getMaxMbrX();
    int minX = r.getMinMbrX();
    int maxZ = r.getMaxMbrZ();
    int minZ = r.getMinMbrZ();
    int factor;
    for (int x = minX; x < maxX; x++) {
        for (int y = 0; y < 256; y++) {
            for (int z = minZ; z < maxZ; z++) {

                Block b = w.getBlockAt(x, y, z);
                if (b.isEmpty()) {
                    continue;
                }

                if (b.getState() instanceof InventoryHolder) {
                    Inventory inv = ((InventoryHolder) b.getState()).getInventory();

                    if (inv.getSize() == 54) {
                        factor = 2;
                    } else {
                        factor = 1;
                    }

                    for (ItemStack item : inv.getContents()) {
                        if (item == null || item.getAmount() == 0) {
                            continue;
                        }
                        regionCost = regionCost + ((RedProtect.get().config.ecoRoot().items.values.getOrDefault(item.getType().name(), 0L) * item.getAmount()) / factor);
                        if (item.getEnchantments().size() > 0) {
                            for (Enchantment enchant : item.getEnchantments().keySet()) {
                                regionCost = regionCost + ((RedProtect.get().config.ecoRoot().enchantments.values.getOrDefault(enchant.getName(), 0L) * item.getEnchantments().get(enchant)) / factor);
                            }
                        }
                    }
                } else {
                    regionCost = regionCost + RedProtect.get().config.ecoRoot().items.values.getOrDefault(b.getType().name(), 0L);
                }
            }
        }
    }
    return regionCost;
}