More compat for args

This commit is contained in:
fullwall 2012-12-07 14:29:48 +08:00
parent 7d676a2302
commit b7cf0109da
2 changed files with 11 additions and 2 deletions

View File

@ -0,0 +1,9 @@
package net.citizensnpcs.command;
import java.lang.annotation.Annotation;
import org.bukkit.command.CommandSender;
public interface CommandAnnotationProcessor<T extends Annotation> {
void process(CommandSender sender, CommandContext context, T instance, Object[] args);
}

View File

@ -107,7 +107,7 @@ public class CommandManager {
if (method == null && parent == null)
throw new UnhandledCommandException();
if (!serverCommands.contains(method) && methodArgs[1] instanceof ConsoleCommandSender)
if (!serverCommands.contains(method) && sender instanceof ConsoleCommandSender)
throw new ServerCommandException();
if (!hasPermission(method, sender))
@ -266,7 +266,7 @@ public class CommandManager {
private void processRequirements(CommandSender sender, Object[] methodArgs, CommandContext context,
Requirements cmdRequirements) throws RequirementMissingException {
NPC npc = (NPC) methodArgs[2];
NPC npc = (methodArgs.length >= 3 && methodArgs[2] instanceof NPC) ? (NPC) methodArgs[2] : null;
// Requirements
if (cmdRequirements.selected()) {