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

The following examples show how to use br.net.fabiozumbi12.RedProtect.Bukkit.Region#isMember() . 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: PermissionHandler.java    From RedProtect with GNU General Public License v3.0 5 votes vote down vote up
private boolean regionPermMember(Player p, String s, Region poly) {
    String adminperm = "redprotect.command.admin." + s;
    String userperm = "redprotect.command." + s;
    if (poly == null) {
        return this.hasPerm(p, adminperm) || this.hasPerm(p, userperm);
    }
    return this.hasPerm(p, adminperm) || (this.hasPerm(p, userperm) && (poly.isLeader(p) || poly.isAdmin(p) || poly.isMember(p)));
}
 
Example 2
Source File: CommandHandlers.java    From RedProtect with GNU General Public License v3.0 5 votes vote down vote up
public static void handleRemoveMember(CommandSender src, String sVictim, Region r) {
    if (src instanceof Player) {
        Player p = (Player) src;
        r = RedProtect.get().rm.getTopRegion(p.getLocation());
        if (r == null) {
            RedProtect.get().lang.sendMessage(p, "cmdmanager.region.todo.that");
            return;
        }
    }

    if (RedProtect.get().ph.hasRegionPermAdmin(src, "removemember", r)) {

        Player pVictim = RedProtect.get().getServer().getPlayer(sVictim);

        if (RedProtect.get().getUtil().PlayerToUUID(sVictim) == null) {
            RedProtect.get().lang.sendMessage(src, RedProtect.get().lang.get("cmdmanager.noplayer.thisname").replace("{player}", sVictim));
            return;
        }

        if ((r.isMember(sVictim) || r.isAdmin(sVictim)) && !r.isLeader(sVictim)) {
            RedProtect.get().lang.sendMessage(src, RedProtect.get().lang.get("general.color") + sVictim + " " + RedProtect.get().lang.get("cmdmanager.region.member.removed") + " " + r.getName());
            r.removeMember(sVictim);
            RedProtect.get().logger.addLog("(World " + r.getWorld() + ") Player " + src.getName() + " REMOVED MEMBER " + sVictim + " to region " + r.getName());
            if (pVictim != null && pVictim.isOnline() && !pVictim.equals(src)) {
                RedProtect.get().lang.sendMessage(pVictim, RedProtect.get().lang.get("cmdmanager.region.member.youremoved").replace("{region}", r.getName()) + " " + src.getName());
            }
        } else {
            RedProtect.get().lang.sendMessage(src, ChatColor.RED + sVictim + " " + RedProtect.get().lang.get("cmdmanager.region.member.notmember"));
        }
    } else if (src instanceof Player) {
        RedProtect.get().lang.sendMessage(src, "no.permission");
    }
}
 
Example 3
Source File: WorldFlatFileRegionManager.java    From RedProtect with GNU General Public License v3.0 5 votes vote down vote up
@Override
public Set<Region> getMemberRegions(String uuid) {
    SortedSet<Region> regionsp = new TreeSet<>(Comparator.comparing(Region::getName));
    for (Region r : regions.values()) {
        if (r.isLeader(uuid) || r.isAdmin(uuid) || r.isMember(uuid)) {
            regionsp.add(r);
        }
    }
    return regionsp;
}
 
Example 4
Source File: CommandHandlers.java    From RedProtect with GNU General Public License v3.0 4 votes vote down vote up
public static void handleAddMember(CommandSender src, String sVictim, Region r) {
    if (src instanceof Player) {
        Player p = (Player) src;
        r = RedProtect.get().rm.getTopRegion(p.getLocation());
        if (r == null) {
            RedProtect.get().lang.sendMessage(p, "cmdmanager.region.todo.that");
            return;
        }
    }

    if (RedProtect.get().ph.hasRegionPermAdmin(src, "addmember", r)) {
        if (RedProtect.get().getUtil().PlayerToUUID(sVictim) == null) {
            RedProtect.get().lang.sendMessage(src, RedProtect.get().lang.get("cmdmanager.noplayer.thisname").replace("{player}", sVictim));
            return;
        }

        Player pVictim = RedProtect.get().getServer().getPlayer(sVictim);

        if (r.isLeader(sVictim)) {
            RedProtect.get().lang.sendMessage(src, ChatColor.RED + sVictim + " " + RedProtect.get().lang.get("cmdmanager.region.leader.already"));
            return;
        }

        if (r.isAdmin(sVictim)) {
            r.addMember(sVictim);
            RedProtect.get().logger.addLog("(World " + r.getWorld() + ") Player " + src.getName() + " ADDED MEMBER " + sVictim + " to region " + r.getName());
            RedProtect.get().lang.sendMessage(src, RedProtect.get().lang.get("general.color") + sVictim + " " + RedProtect.get().lang.get("cmdmanager.region.member.demoted") + " " + r.getName());
            if (pVictim != null && pVictim.isOnline()) {
                RedProtect.get().lang.sendMessage(pVictim, RedProtect.get().lang.get("cmdmanager.region.admin.youdemoted").replace("{region}", r.getName()) + " " + src.getName());
            }
        } else if (!r.isMember(sVictim)) {
            r.addMember(sVictim);
            RedProtect.get().logger.addLog("(World " + r.getWorld() + ") Player " + src.getName() + " ADDED MEMBER " + sVictim + " to region " + r.getName());
            RedProtect.get().lang.sendMessage(src, RedProtect.get().lang.get("general.color") + sVictim + " " + RedProtect.get().lang.get("cmdmanager.region.member.added") + " " + r.getName());
            if (pVictim != null && pVictim.isOnline() && !pVictim.equals(src)) {
                RedProtect.get().lang.sendMessage(pVictim, RedProtect.get().lang.get("cmdmanager.region.member.youadded").replace("{region}", r.getName()) + " " + src.getName());
            }
        } else {
            RedProtect.get().lang.sendMessage(src, ChatColor.RED + sVictim + " " + RedProtect.get().lang.get("cmdmanager.region.member.already"));
        }
    } else if (src instanceof Player) {
        RedProtect.get().lang.sendMessage(src, "no.permission");
    }
}