public static String getRank(Player player) { if (player.hasPermission("admin")) { return "admin"; } if (player.hasPermission("yt")) { return "yt"; } if (player.hasPermission("mod")) { return "mod"; } if (player.hasPermission("helper")) { return "helper"; } if (player.hasPermission("builder")) { return "builder"; } if (player.hasPermission("overlord")) { return "overlord"; } if (player.hasPermission("phoenix")) { return "phoenix"; } if (player.hasPermission("titan")) { return "titan"; } if (player.hasPermission("hydra")) { return "hydra"; } if (player.hasPermission("hero")) { return "hero"; } return "default"; }
@EventHandler public void onDamageFisherman(EntityDamageByEntityEvent e) { if (this.pl.comecou) if (((e.getEntity() instanceof Player)) && ((e.getDamager() instanceof Player))) { Entity ent = e.getEntity(); Player player = (Player) e.getEntity(); Player damager = (Player) e.getDamager(); Player p = (Player) ent; if ((this.pl.km.temKit(player)) && (this.pl.km.getPlayerKit(player, this.pl.km.getKitByName("Fisherman"))) && (damager.getItemInHand() != null) && (damager.getItemInHand().getType() != null)) { if (damager.hasPermission("planeta.vip") && (damager.hasPermission("hg.youtuber"))) { BossBar.setMessage( damager, p.getName() + " - Fisherman (§bSopas " + AmountAPI.getAmount(p, Material.MUSHROOM_SOUP) + " §f)", 1); } else { BossBar.setMessage(damager, p.getName() + " - Fisherman", 1); } } } }
public boolean checkpermissionssilent(Player player, String action) { if (plugin.toggle) { return false; } try { if (player.isOp()) { return true; } try { if (player.hasPermission(action) || player.hasPermission(action.toLowerCase())) { return true; } else { return false; } } catch (Exception e) { e.printStackTrace(); plugin.report.report( 3327, "Couldnt check permission with bPermissions", e.getMessage(), "PermissionsChecker", e); return false; } } catch (Exception e) { plugin.Logger("Error on checking permissions!", "Error"); plugin.report.report( 3328, "Error on checking permissions", e.getMessage(), "PermissionsChecker", e); e.printStackTrace(); return false; } }
public boolean execute(CommandSender sender, String[] args) { Player player = (Player) sender; String name = player.getName(); FileConfiguration pconfig = plugin.getPlayerManager().getPlayer(name).getPlayerConfig().getConfig(); if (args.length == 0) { if (player.hasPermission("kessentials.nick")) { player.sendMessage(GREEN + "Your name is now " + name); player.setDisplayName(name); pconfig.set("nickname", name); nickname.setNickName(name, name); } else { noPermissionsMessage(player); } } else if (args.length == 1) { if (player.hasPermission("kessentials.nick")) { player.sendMessage(GREEN + "Your name is now " + args[0]); player.setDisplayName(name); pconfig.set("nickname", args[0]); nickname.setNickName(name, args[0]); } else { noPermissionsMessage(player); } } else { incorrectUsage(player, "/nick [name]"); } return false; }
public static void setKit(Player player, String kitname) { kitname = kitname.toLowerCase(); kitname = kitname.replace(".", ""); ConfigurationSection kit = BGFiles.kitconf.getConfigurationSection(kitname); if (kit == null && !kits.contains(kitname)) { BGChat.printPlayerChat(player, "That kit doesn't exist!"); return; } if (KIT.get(player) == kitname) return; if (player.hasPermission("bg.kit." + kitname) || player.hasPermission("bg.kit.*") || (plugin.SIMP_REW && plugin.winner(player)) || (plugin.REW && plugin.reward.BOUGHT_KITS.get(player.getName()) != null && plugin.reward.BOUGHT_KITS.get(player.getName()).equals(kitname))) { if (KIT.containsKey(player)) { KIT.remove(player); } KIT.put(player, kitname); char[] stringArray = kitname.toCharArray(); stringArray[0] = Character.toUpperCase(stringArray[0]); kitname = new String(stringArray); BGChat.printPlayerChat(player, "You have chosen " + kitname + " as your kit."); setKitDisplayName(player, kitname); } else { BGChat.printPlayerChat(player, plugin.NO_KIT_MSG); return; } }
public boolean check(final Player player, final Block brokenBlock, final ConfigurationCache cc) { boolean cancel = false; // Reach check only if not in creative mode! final boolean reach = cc.blockbreak.reachCheck && !player.hasPermission(Permissions.BLOCKBREAK_REACH); final boolean direction = cc.blockbreak.directionCheck && !player.hasPermission(Permissions.BLOCKBREAK_DIRECTION); final boolean noswing = cc.blockbreak.noswingCheck && !player.hasPermission(Permissions.BLOCKBREAK_NOSWING); if ((noswing || reach || direction) && brokenBlock != null) { final BaseData data = plugin.getData(player.getName()); if (noswing) { cancel = noswingCheck.check(player, data, cc); } if (!cancel && reach) { cancel = reachCheck.check(player, data, brokenBlock, cc); } if (!cancel && direction) { cancel = directionCheck.check(player, data, brokenBlock, cc); } } return cancel; }
/** * All permission checks should go through here. * * <p>Returns true if a player has a certain permission node. * * @param player * @param node * @return true if the player has this permission node. */ public boolean has(Player player, String node) { if (player.isOp()) return true; // return (plugin.isPermissions() && hasPermission(player, node)); /* * Node has been set or negated so return the actual value */ if (player.isPermissionSet(node)) return player.hasPermission(node); /* * Check for a parent with a wildcard */ final String[] parts = node.split("\\."); final StringBuilder builder = new StringBuilder(node.length()); for (String part : parts) { builder.append('*'); if (player.hasPermission("-" + builder.toString())) { return false; } if (player.hasPermission(builder.toString())) { return true; } builder.deleteCharAt(builder.length() - 1); builder.append(part).append('.'); } /* * No parent found so we don't have this node. */ return false; }
@Override public boolean onCommand(CommandSender sender, Command cmd, String laber, String[] args) { if (sender instanceof Player) { p = (Player) sender; if (!Manager.config.getBoolean("commands.CommandOi")) { disComm(p); return true; } } else { return false; } if (p.hasPermission("survival.oi")) { if (args.length == 0) { correctUse(p, "oi <player>"); } else { Player foropen = conPlayer(p, args[0], true); if (foropen != null) { if (!foropen.hasPermission("survival.nooi")) { p.openInventory(foropen.getInventory()); } else { p.sendMessage(ChatColor.RED + "Al jugador mencionado no le puedes abrir el inventario"); } } } } else { noPerm(p); } return true; }
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { if (!(sender instanceof Player)) { sender.sendMessage("�rro> �omente jogadores podem executar este comando!"); return true; } Player player = (Player) sender; if (cmd.getName().equalsIgnoreCase("tp")) { if (!player.hasPermission("hg.mod")) { player.sendMessage("Voc� n鉶 tem permissao para fazer isso!"); return true; } if (args.length == 0) { player.sendMessage("Use /tp [player] para ir at� um player!"); player.sendMessage("Use /s [player] para puxar um player at� voc�!"); return true; } if (args.length == 1) { Player target = Bukkit.getPlayerExact(args[0]); if ((target == null) || (!(target instanceof Player))) { player.sendMessage("�Jogador n鉶 encontrado!"); return true; } player.teleport(target); player.sendMessage("�Teleportado para " + target.getName()); return true; } if (args.length > 1) { player.sendMessage("�Use /tp [player] para ir at� um player!"); player.sendMessage("� Use /s [player] para puxar um player at� voc�!"); return true; } } else if (cmd.getName().equalsIgnoreCase("s")) { if (!player.hasPermission("hg.mod")) { player.sendMessage("�Voc� n鉶 tem permissao para fazer isso!"); return true; } if (args.length == 0) { player.sendMessage("�Use /tp [player] para ir at� um player!"); player.sendMessage("�Use /s [player] para puxar um player at� voc�!"); return true; } if (args.length == 1) { Player target = Bukkit.getPlayerExact(args[0]); if ((target == null) || (!(target instanceof Player))) { player.sendMessage("�Jogador n鉶 encontrado!"); return true; } target.teleport(player); player.sendMessage("�Voc� puxou -> " + target.getName()); return true; } if (args.length > 1) { player.sendMessage("Use /tp [player] para ir at� um player!"); player.sendMessage("Use /s [player] para puxar um player at� voc�!"); return true; } } return false; }
public void sendHelp(Player p) { if (p.hasPermission("pictureframe.create")) { p.sendMessage("Create a poster: " + ChatColor.GRAY + "/pf create [width] [height] <url>"); } if (p.hasPermission("pictureframe.reload")) { p.sendMessage("Reload all posters: " + ChatColor.GRAY + "/pf reload"); } }
public boolean hasPermission(Player player, String str) { if (player.hasPermission(str)) { return true; } else if (player.hasPermission("custom-items.*")) { return true; } return false; }
public boolean hasPortalPerm(Player p, Portal portal) { if (plugin.getConfig().getBoolean("UsePermissions")) { if ((p.hasPermission("upp.portal.*") || p.hasPermission("upp.admin") || p.hasPermission("upp.portal." + portal.getID()) || p.hasPermission("rpge.admin"))) return true; else return false; } else return true; }
@Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { Player player = null; if (sender instanceof Player) { player = (Player) sender; } if (command.getName().equalsIgnoreCase("convertxp")) { if (player == null) { return false; } else { if (player.hasPermission("convertxp.convert")) { if (args.length > 0) { try { int arg = Integer.parseInt(args[0]); } catch (NumberFormatException nfe) { player.sendMessage(ChatColor.DARK_AQUA + "Please enter a valid number"); return true; } convertxppart(player, args[0]); return true; } else { convertxp(player); return true; } } } } else if (command.getName().equalsIgnoreCase("getxp")) { if (player == null) { return false; } else { if (player.hasPermission("convertxp.getxp")) { getxp(player); return true; } } } else if (command.getName().equalsIgnoreCase("convertxpreload")) { if (player.hasPermission("convertxp.convertxpreload") || (player == null)) { reloadconfig(); return true; } } else if (command.getName().equalsIgnoreCase("convertxpinfo")) { if (player == null) { return false; } else { if (player.hasPermission("convertxp.convertxpinfo")) { convertxpinfo(player); return true; } } } return false; }
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void onCraft(CraftItemEvent event) { Player player = (Player) event.getWhoClicked(); if (!player.isOp() && (player.hasPermission("yapp.deny.craft.*") || player.hasPermission("yapp.deny.craft." + event.getCurrentItem().getTypeId()))) { event.setCancelled(true); } }
/** * Checks if two players are within a certain range from each other. * * @param player1 The first player. * @param player2 The second player. * @param maxDistance The max distance between the two players. Negative values will always return * true. * @param bypassPermission If one of the players has the permission this function will return * true. * @return True if the players are within the given range, false if not. */ public static boolean inRange( @NotNull Player player1, @NotNull Player player2, double maxDistance, @NotNull String bypassPermission) { return player1.hasPermission(bypassPermission) || player2.hasPermission(bypassPermission) || inRange(player1, player2, maxDistance); }
/** * We listen to BlockPlace events for obvious reasons. * * @param event the event */ @EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST) public void onBlockPlace(final BlockPlaceEvent event) { /* * ____ _ _ ____ _ * | __ )| | ___ ___| | __ | _ \| | __ _ ___ ___ * | _ \| |/ _ \ / __| |/ / | |_) | |/ _` |/ __/ _ \ * | |_) | | (_) | (__| < | __/| | (_| | (_| __/ * |____/|_|\___/ \___|_|\_\ |_| |_|\__,_|\___\___| */ final Block block = event.getBlockPlaced(); final Block blockAgainst = event.getBlockAgainst(); // We don't care about null blocks. if (block == null || blockAgainst == null) return; final Material mat = block.getType(); final Player player = event.getPlayer(); boolean cancelled = false; // Check if the block may be placed against a certain material. // TODO: Maybe make it an extra check after all. final int againstId = blockAgainst.getTypeId(); if (BlockProperties.isLiquid(againstId)) { if ((mat != Material.WATER_LILY || !BlockProperties.isLiquid(block.getRelative(BlockFace.DOWN).getTypeId())) && !player.hasPermission(Permissions.BLOCKPLACE_AGAINST_LIQUIDS)) cancelled = true; } else if (againstId == Material.AIR.getId()) { if (!player.hasPermission(Permissions.BLOCKPLACE_AGAINST_AIR)) cancelled = true; } // First, the fast place check. if (fastPlace.isEnabled(player)) { if (fastPlace.check(player, block)) cancelled = true; else // Combined speed: if (Improbable.check(player, 1f, System.currentTimeMillis())) cancelled = true; } // Second, the no swing check (player doesn't swing his arm when placing a lily pad). if (!cancelled && mat != Material.WATER_LILY && noSwing.isEnabled(player) && noSwing.check(player)) cancelled = true; // Third, the reach check. if (!cancelled && reach.isEnabled(player) && reach.check(player, block.getLocation())) cancelled = true; // Fourth, the direction check. if (!cancelled && direction.isEnabled(player) && direction.check(player, block.getLocation(), blockAgainst.getLocation())) cancelled = true; // If one of the checks requested to cancel the event, do so. if (cancelled) event.setCancelled(cancelled); }
public boolean hasPermission(Player player, String node) { if (player.hasPermission(node)) return true; while (node.contains(".")) { node = node.substring(0, node.lastIndexOf(".")); if (player.hasPermission(node)) return true; node = node.substring(0, node.length() - 1); if (player.hasPermission(node)) return true; } return player.hasPermission("*"); }
public boolean hasPortalAdminPerm(Player p) { if (plugin.getConfig().getBoolean("UsePermissions")) { if ((p.hasPermission("upp.admin") || p.hasPermission("rpge.admin") || p.hasPermission("upp.*") || p.hasPermission("rpge.*"))) return true; else return false; } else if (p.isOp()) return true; else return false; }
@EventHandler public void onDeath(PlayerDeathEvent e) throws IOException { Player p = e.getEntity(); if (p.hasPermission("kits.deathinv")) { InventoryNBTSer.setInv(p, plugin.folder); e.getDrops().clear(); } if (p.hasPermission("kits.deathexp")) { e.setDroppedExp(0); } }
/** * Removes a friend from an owned chunk Called when landlord remfriend is executed * * @param sender who executed the command * @param args given with command * @return boolean */ @Override public boolean execute(CommandSender sender, String[] args, String label) { if (!(sender instanceof Player)) { sender.sendMessage( Fonctions.replaceColor(Landlord.getMessages().getString("noConsole"))); // mess } else { if (args.length < 2) { sender.sendMessage( Fonctions.replaceColor(Landlord.getMessages().getString("usageLandUnfriend"))); // mess return true; } Player player = (Player) sender; if (!player.hasPermission("landlord.player.own")) { player.sendMessage( Fonctions.replaceColor(Landlord.getMessages().getString("noPermission"))); // mess return true; } Chunk currChunk = player.getLocation().getChunk(); /* * ************************************* * mark for possible change !!!!!!!!! * ************************************* */ Friend frd = Friend.friendFromOfflinePlayer(getOfflinePlayer(args[1])); OwnedLand land = OwnedLand.getLandFromDatabase( currChunk.getX(), currChunk.getZ(), currChunk.getWorld().getName()); if (land == null || (!land.ownerUUID().equals(player.getUniqueId()) && !player.hasPermission("landlord.admin.modifyfriends"))) { player.sendMessage( Fonctions.replaceColor(Landlord.getMessages().getString("noOwner"))); // mess return true; } if (!land.removeFriend(frd)) { player.sendMessage( Fonctions.replaceColor(Landlord.getMessages().getString("playerNotFriendLand")) .replaceAll("%pseudo%", args[1])); // mess return true; } if (plugin.getConfig().getBoolean("options.particleEffects", true)) { // conf land.highlightLand(player, Effect.VILLAGER_THUNDERCLOUD, 2); } plugin.getDatabase().save(land); if (plugin.getConfig().getBoolean("options.soundEffects", true)) { // conf player.playSound(player.getLocation(), Sound.ZOMBIE_INFECT, 10, .5f); } player.sendMessage( Fonctions.replaceColor(Landlord.getMessages().getString("playerIsNoLongerFriendLand")) .replaceAll("%pseudo%", args[1])); // mess } return true; }
@EventHandler(priority = EventPriority.LOW) public void onPreCraft(PrepareItemCraftEvent event) { List<HumanEntity> viewers = event.getViewers(); if (viewers == null || viewers.size() == 0) return; Player player = (Player) event.getViewers().get(0); if (!player.isOp() && (player.hasPermission("yapp.deny.craft.*") || player.hasPermission( "yapp.deny.craft." + event.getRecipe().getResult().getTypeId()))) { event.getInventory().setResult(null); } }
private boolean checkPerms(Player player, List<String> perms) { String debugMessage = "[p:" + player.getName() + "]"; boolean bool = false; for (String perm : perms) { debugMessage += " [" + perm + ":" + player.hasPermission(perm) + "]"; if (player.hasPermission(perm)) { bool = true; } } plugin.logDebug(debugMessage); return bool; }
/** * Returns true if the given player is allowed to loot the specified PhatLoot * * @param player The Player who is being checked for permission * @param phatLoot The PhatLoot in question * @return true if the player is allowed to loot the PhatLoot */ public static boolean canLoot(Player player, PhatLoot phatLoot) { // Check if the PhatLoot is restricted if (PhatLootsConfig.restrictAll || PhatLootsConfig.restricted.contains(phatLoot.name)) { return player.hasPermission("phatloots.loot.*") // Check for the loot all permission ? true : player.hasPermission( "phatloots.loot." + phatLoot.name); // Check if the Player has the specific loot permission } else { return true; } }
@Override public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { if (sender instanceof Player) { Player p = (Player) sender; if ((p.hasPermission("advancedrename.relore")) || (p.hasPermission("advancedrename.*"))) { if (args.length >= 1) { if ((p.getItemInHand() != null) && (p.getItemInHand().getType() != Material.AIR)) { String name = args[0]; for (int i = 0; i < args.length; i++) { name = name + " " + args[i]; } name = ChatColor.translateAlternateColorCodes('&', name); if ((name.contains(";"))) { ItemStack i = p.getItemInHand(); ItemMeta im = i.getItemMeta(); String[] lore = name.split(";"); List<String> il = new ArrayList<String>(); for (int l = 1; l < lore.length; l++) { il.add(lore[l]); } im.setLore(il); i.setItemMeta(im); p.updateInventory(); p.sendMessage(Main.pr + "�uccessfully lore set for the item."); return true; } else { ItemStack i = p.getItemInHand(); ItemMeta im = i.getItemMeta(); List<String> il = new ArrayList<String>(); il.add(name); im.setLore(il); i.setItemMeta(im); p.updateInventory(); p.sendMessage(Main.pr + "�uccessfully lore set for the item."); return true; } } else { p.sendMessage(Main.pr + "Please hold a Item in your hand."); return true; } } } else { p.sendMessage(Main.pr + "You dont have permission to use this command!"); return true; } } else { sender.sendMessage("[AdvancedRename] You must be a player to relore a item."); return true; } return false; }
public static Integer getMaxIslandsFor(Player p) { if (p.hasPermission("atv.unlimited")) return 999; if (p.hasPermission("atv.islands.50")) return 50; if (p.hasPermission("atv.islands.30")) return 30; if (p.hasPermission("atv.islands.20")) return 20; if (p.hasPermission("atv.islands.14")) return 14; if (p.hasPermission("atv.islands.8")) return 8; if (p.hasPermission("atv.islands.5")) return 5; if (IslandManager.getTotalLevel(p) >= 150) return 5; if (IslandManager.getTotalLevel(p) >= 100) return 4; if (p.hasPermission("atv.islands.3")) return 3; if (IslandManager.getTotalLevel(p) >= 50) return 3; return getMaxIslands(); }
@Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { if (args.length != 0) { plugin.sendMessageWarning( sender, ChatColor.translateAlternateColorCodes( '&', plugin.languageGetConfig().getString("buyland.general.parameters"))); plugin.sendMessageInfo(sender, "Usage: /buyland list"); } else { // See if the person requesting the information is a player if (sender instanceof Player) { Player player = (Player) sender; String playerName = player.getName(); // See if the player has permission to this command if (player.hasPermission("buyland.list") || player.hasPermission("buyland.all")) { // State who the list is for plugin.sendMessageInfo(sender, "You own regions: "); // Loop through all the worlds for (World world : Bukkit.getWorlds()) { // get the list of regions for the selected world Map<String, ProtectedRegion> regionMap = WGBukkit.getRegionManager(world).getRegions(); // Loop through all the regions for (ProtectedRegion region : regionMap.values()) { // see if the person is an owner of the region if (region.isOwner(playerName)) { // see if the region is buyable if (region.getFlag(DefaultFlag.BUYABLE) == null) { // if it is null, it is not purchased by anyone. } else { // See if the region was purchased. if (region.getFlag(DefaultFlag.BUYABLE) == false) { // list this as owned by the player in question plugin.sendMessageInfo( sender, " " + world.getName() + ": " + region.getId(), false); } } } } } } } else { plugin.sendMessageInfo(sender, "Currently not available at console."); } } // command was utilized. return true; }
private static void setKitDisplayName(Player player, String kitname) { if (plugin.winner(player)) player.setDisplayName( "§8[" + kitname + "] §r" + ChatColor.GOLD + player.getName() + ChatColor.WHITE); else if (player.hasPermission("bg.admin.color") || player.hasPermission("bg.admin.*")) player.setDisplayName( "§8[" + kitname + "] §r" + ChatColor.RED + player.getName() + ChatColor.WHITE); else if (player.hasPermission("bg.vip.color") || player.hasPermission("bg.vip.*")) player.setDisplayName( "§8[" + kitname + "] §r" + ChatColor.BLUE + player.getName() + ChatColor.WHITE); else player.setDisplayName( "§8[" + kitname + "] §r" + ChatColor.WHITE + player.getName() + ChatColor.WHITE); }
public void help(Player sender, String[] args) { sender.sendMessage(ChatColor.DARK_AQUA + "======== IceProtect ========"); if (args.length == 0 || args.length == 1) { if (sender.hasPermission("iceprotect.buy")) { sender.sendMessage(ChatColor.YELLOW + "For help with buying regions, use /pr help buying"); } sender.sendMessage(ChatColor.YELLOW + "For all the possible flags, use /pr help flags"); sender.sendMessage(ChatColor.YELLOW + "For help with the commands, use /pr help commands"); } else if (args[1].equals("commands") || args[1].equals("cmd")) { if (sender.hasPermission("iceprotect.freeprotect")) { sender.sendMessage( ChatColor.YELLOW + "You can protect regions up to $" + Economy.maxDonatorAllowedCost + " for free."); } else { sender.sendMessage(ChatColor.YELLOW + "Regions cost $0.1 per block."); } sender.sendMessage(ChatColor.YELLOW + "Use a wooden axe to select a region."); sender.sendMessage(ChatColor.YELLOW + "Members can build and interact in the area."); sender.sendMessage(ChatColor.YELLOW + "To check how much a region will cost, use /pr price"); sender.sendMessage(ChatColor.YELLOW + "To make a protected region, use /pr def <name>"); sender.sendMessage(ChatColor.YELLOW + "To allow members, use /pr allow <player> <name>"); sender.sendMessage(ChatColor.YELLOW + "To deny member, use /pr deny <player> <name>"); sender.sendMessage(ChatColor.YELLOW + "To add flags, use /pr flags <name> <flag> <value>"); sender.sendMessage(ChatColor.YELLOW + "To delete a region, use /pr delete <name>"); sender.sendMessage(ChatColor.YELLOW + "To see all the regions made by you, use /pr list"); } else if (args[1].equals("flags")) { sender.sendMessage(ChatColor.YELLOW + "chest-access: Allow or block chest access."); sender.sendMessage(ChatColor.YELLOW + "ice-form: Allow or block ice from forming."); sender.sendMessage(ChatColor.YELLOW + "ice-melt: Allow or block ice from melting."); sender.sendMessage(ChatColor.YELLOW + "snow-fall: Allow or block snow from forming."); sender.sendMessage(ChatColor.YELLOW + "snow-melt: Allow or block snow from melting."); sender.sendMessage( ChatColor.YELLOW + "use: Allow or block the ability to use doors, buttons,"); sender.sendMessage(ChatColor.YELLOW + "pressure plates, levers, note blocks, chests, etc.."); } else if (args[1].equals("buying") && sender.hasPermission("iceprotect.buy")) { sender.sendMessage(ChatColor.YELLOW + "You can buy the region you're in if it's for sale"); sender.sendMessage(ChatColor.YELLOW + "Check if it is with /pr forsale"); sender.sendMessage(ChatColor.YELLOW + "Buy it with /pr buy"); } else { if (sender.hasPermission("iceprotect.buy")) { sender.sendMessage(ChatColor.YELLOW + "For help with buying regions, use /pr help buying"); } sender.sendMessage(ChatColor.YELLOW + "For all the possible flags, use /pr help flags"); sender.sendMessage(ChatColor.YELLOW + "For help with the commands, use /pr help commands"); } sender.sendMessage(ChatColor.DARK_AQUA + "=========================="); }
@EventHandler public void onPlayerAction(PlayerInteractEvent e) { Player player = e.getPlayer(); if ((e.getAction() == Action.RIGHT_CLICK_AIR || (e.getAction() == Action.RIGHT_CLICK_BLOCK) && !e.isCancelled())) { ItemStack item = player.getItemInHand(); if (item.getType() == Material.BOW || item.getType() == Material.SNOW_BALL || item.getType() == Material.EGG || item.getType() == Material.POTION) return; RPGItem rItem = ItemManager.toRPGItem(item); if (rItem == null) return; if (!WorldGuard.canPvP(player.getLocation()) && !rItem.ignoreWorldGuard) return; if (rItem.getHasPermission() == true && player.hasPermission(rItem.getPermission()) == false) { e.setCancelled(true); player.sendMessage( ChatColor.RED + String.format( Locale.get("message.error.permission", Locale.getPlayerLocale(player)))); } rItem.rightClick(player); if (player.getItemInHand().getTypeId() != 0) { RPGItem.updateItem(item, Locale.getPlayerLocale(player)); } else player.setItemInHand(null); player.updateInventory(); } else if (e.getAction() == Action.LEFT_CLICK_AIR || e.getAction() == Action.LEFT_CLICK_BLOCK) { ItemStack item = player.getItemInHand(); if (item.getType() == Material.BOW || item.getType() == Material.SNOW_BALL || item.getType() == Material.EGG || item.getType() == Material.POTION) return; RPGItem rItem = ItemManager.toRPGItem(item); if (rItem == null) return; if (!WorldGuard.canPvP(player.getLocation()) && !rItem.ignoreWorldGuard) return; if (rItem.getHasPermission() == true && player.hasPermission(rItem.getPermission()) == false) { e.setCancelled(true); player.sendMessage( ChatColor.RED + String.format( Locale.get("message.error.permission", Locale.getPlayerLocale(player)))); } rItem.leftClick(player); RPGItem.updateItem(item, Locale.getPlayerLocale(player)); } }
@Override public boolean getAttribute(String key) { key = "plotsquared_user_attributes." + key; if (EconHandler.manager == null || player.hasPermission("plotsquared_user_attributes.*")) { Object v = getMeta(key); return v == null ? false : (Boolean) v; } Permission perm = Bukkit.getServer().getPluginManager().getPermission(key); if (perm == null) { perm = new Permission(key, PermissionDefault.FALSE); Bukkit.getServer().getPluginManager().addPermission(perm); Bukkit.getServer().getPluginManager().recalculatePermissionDefaults(perm); } return player.hasPermission(key); }