/** * * 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; }
/*** * Bukkit API requires us to bind each existing command individually * to a separate class if we want to utilize such a class. * Here, we'll just pass each command to the class' onCommand function, * saving us the trouble of writing a list of all possible commands. */ public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) { return cListener.onCommand(sender, cmd, commandLabel, args); }
/** * * 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; }