From 66c50bf6e67141beaebff313b79b00029842128b Mon Sep 17 00:00:00 2001 From: yoyosource Date: Wed, 8 Dec 2021 18:45:48 +0100 Subject: [PATCH] Hotfix SubCommand --- .../src/de/steamwar/command/SubCommand.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/SpigotCore_Main/src/de/steamwar/command/SubCommand.java b/SpigotCore_Main/src/de/steamwar/command/SubCommand.java index f83aa76..997cdea 100644 --- a/SpigotCore_Main/src/de/steamwar/command/SubCommand.java +++ b/SpigotCore_Main/src/de/steamwar/command/SubCommand.java @@ -103,6 +103,21 @@ class SubCommand { } private GuardChecker getGuardChecker(Parameter parameter, Map localGuardChecker) { + SWCommand.ClassGuard classGuard = parameter.getAnnotation(SWCommand.ClassGuard.class); + if (classGuard != null) { + if (classGuard.value() == null) { + String s = parameter.getType().getTypeName(); + if (parameter.isVarArgs()) { + s = parameter.getType().getComponentType().getTypeName(); + } + return localGuardChecker.getOrDefault(s, GUARD_FUNCTIONS.getOrDefault(s, null)); + } + GuardChecker current = localGuardChecker.getOrDefault(classGuard.value().getTypeName(), GUARD_FUNCTIONS.getOrDefault(classGuard.value().getTypeName(), null)); + if (current == null) { + Bukkit.getLogger().log(Level.WARNING, () -> "The guard checker with name '" + classGuard.value().getTypeName() + "' is neither a local guard checker nor a global one"); + } + return current; + } SWCommand.Guard guard = parameter.getAnnotation(SWCommand.Guard.class); if (guard != null) { if (guard.value() == null || guard.value().isEmpty()) {