From 834969959a88cecc5dee4a4824034a744ab53018 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Thu, 8 Jul 2021 23:34:41 +0200 Subject: [PATCH] CMDoS because Brigadier --- .../steamwar/command/SWCommandBrigadier.java | 31 ------------------- 1 file changed, 31 deletions(-) diff --git a/SpigotCore_Main/src/de/steamwar/command/SWCommandBrigadier.java b/SpigotCore_Main/src/de/steamwar/command/SWCommandBrigadier.java index 5d30862..f2f9b5f 100644 --- a/SpigotCore_Main/src/de/steamwar/command/SWCommandBrigadier.java +++ b/SpigotCore_Main/src/de/steamwar/command/SWCommandBrigadier.java @@ -152,37 +152,6 @@ class SWCommandBrigadier implements SWCommand.SWCommandInterface { SWCommand.dispatcher.register(literalArgumentBuilder); } - private void add(Class annotation, Method method, IntPredicate parameterTester, boolean firstParameter, Class returnType, BiConsumer consumer) { - T[] anno = SWCommandUtils.getAnnotation(method, annotation); - if (anno == null || anno.length == 0) return; - - Parameter[] parameters = method.getParameters(); - if (!parameterTester.test(parameters.length)) { - Bukkit.getLogger().log(Level.WARNING, "The method '" + method + "' is lacking parameters or has too many"); - return; - } - if (firstParameter && !CommandSender.class.isAssignableFrom(parameters[0].getType())) { - Bukkit.getLogger().log(Level.WARNING, "The method '" + method + "' is lacking the first parameter of type '" + CommandSender.class.getTypeName() + "'"); - return; - } - if (returnType != null && method.getReturnType() != returnType) { - Bukkit.getLogger().log(Level.WARNING, "The method '" + method + "' is lacking the desired return type '" + returnType.getTypeName() + "'"); - return; - } - Arrays.stream(anno).forEach(t -> consumer.accept(t, parameters)); - } - - private void addMapper(Class annotation, Method method, IntPredicate parameterTester, boolean firstParameter, Class returnType, BiConsumer> consumer) { - add(annotation, method, parameterTester, firstParameter, returnType, (anno, parameters) -> { - try { - method.setAccessible(true); - consumer.accept(anno, (TypeMapper) method.invoke(swCommand)); - } catch (Exception e) { - throw new SecurityException(e.getMessage(), e); - } - }); - } - @Override public void unregister() { SWCommandUtils.knownCommandMap.remove(command.getName());