/** * * UNMUTE - unmutes a player * * @param sender * @param args * @return */ public static Boolean run(CommandSender sender, String alias, String[] args) { // check if we have any parameters if (args.length > 0) { // check permissions and roll it :) Boolean hasPerms = true; if (sender instanceof Player) { hasPerms = Permissions.checkPerms((Player) sender, "cex.unmute"); } // permissions ok, mute the player if (hasPerms) { unmute(sender, args, "unmute", alias); } } else { // show usage Commands.showCommandHelpAndUsage(sender, "cex_unmute", alias); } return true; }
/** * * Give - Gives a player an item Could be improved in the future by adding enchantment support * * @param sender * @param args * @return */ public static boolean run(CommandSender sender, String alias, String[] args) { if (sender instanceof Player) { Player player = (Player) sender; if (Utils.checkCommandSpam(player, "cex_give")) { return true; } } if (sender instanceof Player) { Player player = (Player) sender; if (Utils.checkCommandSpam(player, "cex_give")) { return true; } } if (args.length < 2 || args.length > 3) { System.out.println("Incorrect args"); Commands.showCommandHelpAndUsage(sender, "cex_give", alias); } else { String item; short damage = 0; int amount = 64; Player target = Bukkit.getPlayer(args[0]); if (target == null) { LogHelper.showInfo("invalidPlayer", sender, ChatColor.RED); return true; } if (args[1].contains(":")) { String[] data = args[1].split(":"); item = data[0]; try { damage = Short.valueOf(args[1].split(":")[1]); } catch (Exception e) { LogHelper.showInfo("itemIncorrectDamageValue", sender, ChatColor.RED); Commands.showCommandHelpAndUsage(sender, "cex_give", alias); return true; } } else { item = args[1]; } if (args.length == 3) { try { amount = Integer.valueOf(args[2]); } catch (Exception e) { LogHelper.showInfo("itemIncorrectDamageValue", sender, ChatColor.RED); Commands.showCommandHelpAndUsage(sender, "cex_give", alias); return true; } } if (Utils.closestMatches(item).size() > 0) { List<Material> matches = Utils.closestMatches(item); giveItem(sender, target, matches.get(0), amount, damage); } else { LogHelper.showInfo("itemNotFound", sender, ChatColor.RED); } } return true; }