diff --git a/src/main/java/net/citizensnpcs/command/CommandAnnotationProcessor.java b/src/main/java/net/citizensnpcs/command/CommandAnnotationProcessor.java new file mode 100644 index 000000000..98d211813 --- /dev/null +++ b/src/main/java/net/citizensnpcs/command/CommandAnnotationProcessor.java @@ -0,0 +1,9 @@ +package net.citizensnpcs.command; + +import java.lang.annotation.Annotation; + +import org.bukkit.command.CommandSender; + +public interface CommandAnnotationProcessor { + void process(CommandSender sender, CommandContext context, T instance, Object[] args); +} diff --git a/src/main/java/net/citizensnpcs/command/CommandManager.java b/src/main/java/net/citizensnpcs/command/CommandManager.java index cb65d144b..89a5a4d4d 100644 --- a/src/main/java/net/citizensnpcs/command/CommandManager.java +++ b/src/main/java/net/citizensnpcs/command/CommandManager.java @@ -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()) {