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

The following examples show how to use br.net.fabiozumbi12.RedProtect.Bukkit.Region#setPrior() . 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: CommandHandlers.java    From RedProtect with GNU General Public License v3.0 5 votes vote down vote up
public static void handlePrioritySingle(Player p, int prior, String region) {
    Region r = RedProtect.get().rm.getRegion(region, p.getWorld().getName());
    if (RedProtect.get().ph.hasRegionPermLeader(p, "priority", r)) {
        if (r != null) {
            r.setPrior(prior);
            RedProtect.get().lang.sendMessage(p, RedProtect.get().lang.get("cmdmanager.region.priority.set").replace("{region}", r.getName()) + " " + prior);
            RedProtect.get().logger.addLog("(World " + r.getWorld() + ") Player " + p.getName() + " SET PRIORITY of region " + r.getName() + " to " + prior);
        } else {
            RedProtect.get().lang.sendMessage(p, "cmdmanager.region.todo.that");
        }
    }
}
 
Example 8
Source File: CommandHandlers.java    From RedProtect with GNU General Public License v3.0 5 votes vote down vote up
public static void handlePriority(Player p, int prior) {
    Region r = RedProtect.get().rm.getTopRegion(p.getLocation());
    if (RedProtect.get().ph.hasRegionPermLeader(p, "priority", r)) {
        if (r != null) {
            r.setPrior(prior);
            RedProtect.get().lang.sendMessage(p, RedProtect.get().lang.get("cmdmanager.region.priority.set").replace("{region}", r.getName()) + " " + prior);
            RedProtect.get().logger.addLog("(World " + r.getWorld() + ") Player " + p.getName() + " SET PRIORITY of region " + r.getName() + " to " + prior);
        } else {
            RedProtect.get().lang.sendMessage(p, "cmdmanager.region.todo.that");
        }
    }
}