Java Code Examples for br.net.fabiozumbi12.RedProtect.Bukkit.Region#isLeader()
The following examples show how to use
br.net.fabiozumbi12.RedProtect.Bukkit.Region#isLeader() .
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 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 2
Source File: PermissionHandler.java From RedProtect with GNU General Public License v3.0 | 5 votes |
private boolean regionPermLeader(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)); }
Example 3
Source File: PermissionHandler.java From RedProtect with GNU General Public License v3.0 | 5 votes |
private boolean regionPermAdmin(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))); }
Example 4
Source File: PermissionHandler.java From RedProtect with GNU General Public License v3.0 | 5 votes |
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 5
Source File: SimpleClansHook.java From RedProtect with GNU General Public License v3.0 | 5 votes |
public static boolean inWar(Region r, Player attack, Player defend) { if (!RedProtect.get().config.configRoot().hooks.clans.use_war) { return false; } if (!RedProtect.get().config.configRoot().hooks.clans.war_on_server_regions && r.isLeader(RedProtect.get().config.configRoot().region_settings.default_leader)) { return false; } ClanPlayer atClan = RedProtect.get().hooks.clanManager.getClanPlayer(attack); if (atClan == null) { return false; } ClanPlayer defCclan = RedProtect.get().hooks.clanManager.getClanPlayer(defend); return defCclan != null && atClan.getClan().isWarring(defCclan.getClan()); }
Example 6
Source File: CommandHandlers.java From RedProtect with GNU General Public License v3.0 | 5 votes |
public static void handleAddAdmin(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, "addadmin", 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.isLeader(sVictim)) { RedProtect.get().lang.sendMessage(src, ChatColor.RED + sVictim + " " + RedProtect.get().lang.get("cmdmanager.region.leader.already")); return; } if (!r.isAdmin(sVictim)) { r.addAdmin(sVictim); RedProtect.get().logger.addLog("(World " + r.getWorld() + ") Player " + src.getName() + " ADDED ADMIN " + sVictim + " to region " + r.getName()); RedProtect.get().lang.sendMessage(src, RedProtect.get().lang.get("general.color") + sVictim + " " + RedProtect.get().lang.get("cmdmanager.region.admin.added") + " " + r.getName()); if (pVictim != null && pVictim.isOnline() && !pVictim.equals(src)) { RedProtect.get().lang.sendMessage(pVictim, RedProtect.get().lang.get("cmdmanager.region.admin.youadded").replace("{region}", r.getName()) + " " + src.getName()); } } else { RedProtect.get().lang.sendMessage(src, ChatColor.RED + sVictim + " " + RedProtect.get().lang.get("cmdmanager.region.admin.already")); } } else if (src instanceof Player) { RedProtect.get().lang.sendMessage(src, "no.permission"); } }
Example 7
Source File: InfernalMobsHook.java From RedProtect with GNU General Public License v3.0 | 5 votes |
@EventHandler public void onInfernalSpawn(InfernalSpawnEvent event) { Region r = RedProtect.get().rm.getTopRegion(event.getEntity().getLocation()); if (r != null) { if (r.isLeader(RedProtect.get().config.configRoot().region_settings.default_leader)) { if (!RedProtect.get().config.configRoot().hooks.infernal_mobs.allow_server_regions) event.setCancelled(true); } else if (!RedProtect.get().config.configRoot().hooks.infernal_mobs.allow_player_regions) { event.setCancelled(true); } } }
Example 8
Source File: CommandHandlers.java From RedProtect with GNU General Public License v3.0 | 5 votes |
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 9
Source File: WorldFlatFileRegionManager.java From RedProtect with GNU General Public License v3.0 | 5 votes |
@Override public int getTotalRegionSize(String uuid) { Set<Region> regionslist = new HashSet<>(); for (Region r : regions.values()) { if (r.isLeader(uuid)) { regionslist.add(r); } } int total = 0; for (Region r2 : regionslist) { total += RedProtect.get().getUtil().simuleTotalRegionSize(uuid, r2); } return total; }
Example 10
Source File: WorldFlatFileRegionManager.java From RedProtect with GNU General Public License v3.0 | 5 votes |
@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 11
Source File: CopyFlagCommand.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 == 2) { World w = player.getWorld(); Region from = RedProtect.get().rm.getRegion(args[0], w.getName()); Region to = RedProtect.get().rm.getRegion(args[1], w.getName()); if (from == null || !from.isLeader(player)) { RedProtect.get().lang.sendMessage(player, RedProtect.get().lang.get("cmdmanager.region.doesntexist") + ": " + args[0]); return true; } if (to == null || !to.isLeader(player)) { RedProtect.get().lang.sendMessage(player, RedProtect.get().lang.get("cmdmanager.region.doesntexist") + ": " + args[1]); return true; } for (Map.Entry<String, Object> key : from.getFlags().entrySet()) { to.setFlag(sender, key.getKey(), key.getValue()); } RedProtect.get().lang.sendMessage(player, RedProtect.get().lang.get("cmdmanager.region.flag.copied") + args[0] + " > " + args[1]); RedProtect.get().logger.addLog("Player " + player.getName() + " Copied FLAGS from " + args[0] + " to " + args[1]); return true; } RedProtect.get().lang.sendCommandHelp(sender, "copyflag", true); return true; }
Example 12
Source File: WorldFlatFileRegionManager.java From RedProtect with GNU General Public License v3.0 | 5 votes |
@Override public Set<Region> getAdminRegions(String uuid) { SortedSet<Region> regionsp = new TreeSet<>(Comparator.comparing(Region::getName)); for (Region r : regions.values()) { if (r.isLeader(uuid) || r.isAdmin(uuid)) { regionsp.add(r); } } return regionsp; }
Example 13
Source File: WorldFlatFileRegionManager.java From RedProtect with GNU General Public License v3.0 | 5 votes |
@Override public Set<Region> getLeaderRegions(String pname) { SortedSet<Region> regionsp = new TreeSet<>(Comparator.comparing(Region::getName)); for (Region r : regions.values()) { if (r.isLeader(pname)) { regionsp.add(r); } } return regionsp; }
Example 14
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()); } } }
Example 15
Source File: SetMaxYCommand.java From RedProtect with GNU General Public License v3.0 | 4 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; Region r; //rp setmaxy <size> switch (args.length) { case 1: r = RedProtect.get().rm.getTopRegion(player.getLocation()); if (r == null) { RedProtect.get().lang.sendMessage(player, "cmdmanager.region.todo.that"); return true; } break; //rp setmaxy <size> [region] case 2: r = RedProtect.get().rm.getRegion(args[1], player.getWorld().getName()); if (r == null) { RedProtect.get().lang.sendMessage(player, RedProtect.get().lang.get("cmdmanager.region.doesntexist") + ": " + args[1]); return true; } break; //rp setmaxy <size> [region] [world] case 3: if (Bukkit.getWorld(args[2]) == null) { RedProtect.get().lang.sendMessage(player, "cmdmanager.region.invalidworld"); return true; } r = RedProtect.get().rm.getRegion(args[1], Bukkit.getWorld(args[2]).getName()); if (r == null) { RedProtect.get().lang.sendMessage(player, RedProtect.get().lang.get("cmdmanager.region.doesntexist") + ": " + args[1]); return true; } break; default: RedProtect.get().lang.sendCommandHelp(sender, "setmaxy", true); return true; } String from = String.valueOf(r.getMaxY()); try { int size = Integer.parseInt(args[0]); if ((size - r.getMinY()) <= 1) { RedProtect.get().lang.sendMessage(player, "cmdmanager.region.ysiszesmatch"); return true; } if (!r.isLeader(player) && !r.isAdmin(player) && !RedProtect.get().ph.hasPerm(player, "redprotect.command.admin.setmaxy")) { RedProtect.get().lang.sendMessage(player, "playerlistener.region.cantuse"); return true; } r.setMaxY(size); RedProtect.get().lang.sendMessage(player, RedProtect.get().lang.get("cmdmanager.region.setmaxy.success").replace("{region}", r.getName()).replace("{fromsize}", from).replace("{size}", String.valueOf(size))); RedProtect.get().logger.addLog("(World " + r.getWorld() + ") Player " + player.getName() + " SETMAXY of region " + r.getName() + " to " + args[0]); return true; } catch (NumberFormatException e) { RedProtect.get().lang.sendMessage(player, "cmdmanager.region.invalid.number"); return true; } }
Example 16
Source File: CanPurgeCommand.java From RedProtect with GNU General Public License v3.0 | 4 votes |
@Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { if (sender instanceof ConsoleCommandSender || !RedProtect.get().config.configRoot().purge.enabled) { HandleHelpPage(sender, 1); return true; } Player player = (Player) sender; Region r = RedProtect.get().rm.getTopRegion(player.getLocation()); if (r == null) { RedProtect.get().lang.sendMessage(player, "cmdmanager.region.doesntexist"); return true; } if (!r.isLeader(player) && !r.isAdmin(player) && !RedProtect.get().ph.hasPerm(player, "redprotect.command.admin.canpurge")) { RedProtect.get().lang.sendMessage(player, "playerlistener.region.cantuse"); return true; } boolean value = !r.canPurge(); if (args.length == 1) { value = Boolean.getBoolean(args[0]); } // Purge limit int limit = RedProtect.get().ph.getPurgeLimit(player); long amount = RedProtect.get().rm.getCanPurgePlayer(player.getUniqueId().toString(), player.getWorld().getName()); if (!value && amount >= limit) { RedProtect.get().lang.sendMessage(player, "playerlistener.region.purge-nolimit", new Replacer[]{ new Replacer("{limit}", String.valueOf(limit)), new Replacer("{total}", String.valueOf(amount)) }); return true; } r.setCanPurge(value); RedProtect.get().lang.sendMessage(player, "cmdmanager.region.canpurge.set", new Replacer[]{new Replacer("{value}", String.valueOf(value))}); RedProtect.get().logger.addLog("(World " + r.getWorld() + ") Player " + player.getName() + " CANPURGE " + r.getName() + " to " + value); return true; }
Example 17
Source File: SetMinYCommand.java From RedProtect with GNU General Public License v3.0 | 4 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; Region r; //rp setminy <size> switch (args.length) { case 1: r = RedProtect.get().rm.getTopRegion(player.getLocation()); if (r == null) { RedProtect.get().lang.sendMessage(player, "cmdmanager.region.todo.that"); return true; } break; //rp setminy <size> [region] case 2: r = RedProtect.get().rm.getRegion(args[1], player.getWorld().getName()); if (r == null) { RedProtect.get().lang.sendMessage(player, RedProtect.get().lang.get("cmdmanager.region.doesntexist") + ": " + args[1]); return true; } break; //rp setminy <size> [region] [database] case 3: if (Bukkit.getWorld(args[2]) == null) { RedProtect.get().lang.sendMessage(player, "cmdmanager.region.invalidworld"); return true; } r = RedProtect.get().rm.getRegion(args[2], Bukkit.getWorld(args[2]).getName()); if (r == null) { RedProtect.get().lang.sendMessage(player, RedProtect.get().lang.get("cmdmanager.region.doesntexist") + ": " + args[1]); return true; } break; default: RedProtect.get().lang.sendCommandHelp(sender, "setminy", true); return true; } String from = String.valueOf(r.getMinY()); try { int size = Integer.parseInt(args[0]); if ((r.getMaxY() - size) <= 1) { RedProtect.get().lang.sendMessage(player, "cmdmanager.region.ysiszesmatch"); return true; } if (!r.isLeader(player) && !r.isAdmin(player) && !RedProtect.get().ph.hasPerm(player, "redprotect.command.admin.setminy")) { RedProtect.get().lang.sendMessage(player, "playerlistener.region.cantuse"); return true; } r.setMinY(size); RedProtect.get().lang.sendMessage(player, RedProtect.get().lang.get("cmdmanager.region.setminy.success").replace("{region}", r.getName()).replace("{fromsize}", from).replace("{size}", String.valueOf(size))); RedProtect.get().logger.addLog("(World " + r.getWorld() + ") Player " + player.getName() + " SETMINY of region " + r.getName() + " to " + args[0]); return true; } catch (NumberFormatException e) { RedProtect.get().lang.sendMessage(player, "cmdmanager.region.invalid.number"); return true; } }
Example 18
Source File: CommandHandlers.java From RedProtect with GNU General Public License v3.0 | 4 votes |
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"); } }
Example 19
Source File: CommandHandlers.java From RedProtect with GNU General Public License v3.0 | 4 votes |
public static void handleRemoveLeader(CommandSender src, String sVictim, Region r) { Region rLow = null; Map<Integer, Region> regions = new HashMap<>(); if (src instanceof Player) { Player p = (Player) src; r = RedProtect.get().rm.getTopRegion(p.getLocation()); rLow = RedProtect.get().rm.getLowRegion(p.getLocation()); regions = RedProtect.get().rm.getGroupRegion(p.getLocation()); if (r == null) { RedProtect.get().lang.sendMessage(p, "cmdmanager.region.todo.that"); return; } } if (RedProtect.get().ph.hasRegionPermLeader(src, "removeleader", 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 (rLow != null && rLow != r && ((!RedProtect.get().ph.hasRegionPermLeader(src, "removeleader", rLow) || (regions.size() > 1 && rLow.isLeader(sVictim))))) { RedProtect.get().lang.sendMessage(src, RedProtect.get().lang.get("cmdmanager.region.leader.cantremove.lowregion").replace("{player}", sVictim) + " " + rLow.getName()); return; } if (r.isLeader(sVictim)) { if (r.leaderSize() > 1) { RedProtect.get().lang.sendMessage(src, RedProtect.get().lang.get("general.color") + sVictim + " " + RedProtect.get().lang.get("cmdmanager.region.admin.added") + " " + r.getName()); r.removeLeader(sVictim); RedProtect.get().logger.addLog("(World " + r.getWorld() + ") Player " + src.getName() + " DEMOTED TO ADMIN " + sVictim + " to region " + r.getName()); if (pVictim != null && pVictim.isOnline() && !pVictim.equals(src)) { RedProtect.get().lang.sendMessage(pVictim, RedProtect.get().lang.get("cmdmanager.region.leader.youdemoted").replace("{region}", r.getName()) + " " + src.getName()); } } else { RedProtect.get().lang.sendMessage(src, RedProtect.get().lang.get("cmdmanager.region.leader.cantremove").replace("{player}", sVictim)); } } else { RedProtect.get().lang.sendMessage(src, ChatColor.RED + sVictim + " " + RedProtect.get().lang.get("cmdmanager.region.leader.notleader")); } } else if (src instanceof Player) { RedProtect.get().lang.sendMessage(src, "no.permission"); } }
Example 20
Source File: CommandHandlers.java From RedProtect with GNU General Public License v3.0 | 4 votes |
public static void handleAddLeader(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.hasRegionPermLeader(src, "addleader", r)) { final Player pVictim = RedProtect.get().getServer().getPlayer(sVictim); if ((pVictim == null || !pVictim.isOnline()) && !src.hasPermission("redprotect.command.admin.addleader")) { RedProtect.get().lang.sendMessage(src, RedProtect.get().lang.get("cmdmanager.noplayer.online").replace("{player}", sVictim)); return; } if (!src.hasPermission("redprotect.command.admin.addleader")) { int claimLimit = RedProtect.get().ph.getPlayerClaimLimit(pVictim); int claimused = RedProtect.get().rm.getPlayerRegions(pVictim.getUniqueId().toString(), pVictim.getWorld().getName()); boolean claimUnlimited = RedProtect.get().ph.hasPerm(src, "redprotect.limits.claim.unlimited"); if (claimused >= claimLimit && claimLimit >= 0 && !claimUnlimited) { RedProtect.get().lang.sendMessage(src, RedProtect.get().lang.get("cmdmanager.region.addleader.limit").replace("{player}", pVictim.getName())); return; } } if (!r.isLeader(sVictim)) { if (src.hasPermission("redprotect.command.admin.addleader")) { r.addLeader(sVictim); RedProtect.get().logger.addLog("(World " + r.getWorld() + ") Player " + src.getName() + " ADDED LEADER " + sVictim + " to region " + r.getName()); RedProtect.get().lang.sendMessage(src, RedProtect.get().lang.get("general.color") + sVictim + " " + RedProtect.get().lang.get("cmdmanager.region.leader.added") + " " + r.getName()); if (pVictim != null && pVictim.isOnline() && !pVictim.equals(src)) { RedProtect.get().lang.sendMessage(pVictim, RedProtect.get().lang.get("cmdmanager.region.leader.youadded").replace("{region}", r.getName()) + " " + src.getName()); } return; } RedProtect.get().lang.sendMessage(src, RedProtect.get().lang.get("cmdmanager.region.leader.yousendrequest").replace("{player}", pVictim.getName())); RedProtect.get().lang.sendMessage(pVictim, RedProtect.get().lang.get("cmdmanager.region.leader.sendrequestto").replace("{region}", r.getName()).replace("{player}", src.getName())); RedProtect.get().alWait.put(pVictim, r.getID() + "@" + src.getName()); Bukkit.getScheduler().scheduleSyncDelayedTask(RedProtect.get(), () -> { if (RedProtect.get().alWait.containsKey(pVictim)) { RedProtect.get().alWait.remove(pVictim); if (src instanceof Player && ((Player) src).isOnline()) { RedProtect.get().lang.sendMessage(src, RedProtect.get().lang.get("cmdmanager.region.leader.requestexpired").replace("{player}", pVictim.getName())); } } }, RedProtect.get().config.configRoot().region_settings.leadership_request_time * 20); } else { RedProtect.get().lang.sendMessage(src, ChatColor.RED + sVictim + " " + RedProtect.get().lang.get("cmdmanager.region.leader.already")); } } else if (src instanceof Player) { RedProtect.get().lang.sendMessage(src, "no.permission"); } }