private Noun<?> getNounFor(String arg) { Noun<?> n = null; for (Noun<?> noun : nouns) { if (RandomUtils.contains(noun.getNames(), arg)) n = noun; } return n; }
protected <T extends CPermissible> void handleCommandUnspecific0( Noun<T> n, CommandSender sender, String[] args) throws CommandException { Verb<T> verb = null; for (Verb<T> verb1 : n.getVerbs()) { if (RandomUtils.contains(verb1.getNames(), args[2])) verb = verb1; } if (verb == null) throw new ArgumentRequirementException("The verb you specified is not valid!"); if (!sender.hasPermission(getPermission(n, verb))) throw new PermissionException("You do not have permission for this command!"); if (args.length - 3 < verb.getRequiredArguments()) throw new ArgumentRequirementException("You have not specified enough arguments!"); T target = n.get(args[1]); String[] strings = args.length <= 3 ? new String[] {} : Arrays.copyOfRange(args, 3, args.length); if (target == null && !verb.canAcceptNullTarget()) throw new ArgumentRequirementException("The target you specified is invalid!"); else if (target == null) strings = new String[] {args[1]}; verb.perform(sender, target, strings); Core.getPermissionsManager().save(); Core.getPermissionsManager().reloadPermissions(); if (Core.getNetworkManager() != null) Core.getNetworkManager().sendMassNetCommand(new PermissionsReloadNetCommand()); }