Java Code Examples for br.net.fabiozumbi12.RedProtect.Bukkit.Region#isAdmin()
The following examples show how to use
br.net.fabiozumbi12.RedProtect.Bukkit.Region#isAdmin() .
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 |
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 2
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 3
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 4
Source File: CommandHandlers.java From RedProtect with GNU General Public License v3.0 | 5 votes |
public static void handleRemoveAdmin(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, "removeadmin", 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.isAdmin(sVictim)) { RedProtect.get().lang.sendMessage(src, RedProtect.get().lang.get("general.color") + sVictim + " " + RedProtect.get().lang.get("cmdmanager.region.member.added") + " " + r.getName()); r.removeAdmin(sVictim); RedProtect.get().logger.addLog("(World " + r.getWorld() + ") Player " + src.getName() + " DEMOTED TO 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.admin.youdemoted").replace("{region}", r.getName()) + " " + src.getName()); } } else { RedProtect.get().lang.sendMessage(src, ChatColor.RED + sVictim + " " + RedProtect.get().lang.get("cmdmanager.region.admin.notadmin")); } } else if (src instanceof Player) { RedProtect.get().lang.sendMessage(src, "no.permission"); } }
Example 5
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 6
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 7
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 8
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 9
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 10
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 11
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; } }