From 839d0f030f4b38cf6edabdfdeb0cddc051e618ca Mon Sep 17 00:00:00 2001 From: TudbuT Date: Mon, 4 Jul 2022 19:52:57 +0200 Subject: [PATCH] more stuff --- .../tudbut/tryumph/events/EventListener.java | 56 +++++++++---------- 1 file changed, 26 insertions(+), 30 deletions(-) diff --git a/src/de/tudbut/tryumph/events/EventListener.java b/src/de/tudbut/tryumph/events/EventListener.java index ffbbe68..bd772c4 100644 --- a/src/de/tudbut/tryumph/events/EventListener.java +++ b/src/de/tudbut/tryumph/events/EventListener.java @@ -21,37 +21,33 @@ public class EventListener { Method method = methods[i]; if(method.getDeclaredAnnotations().length == 0) continue; - if( - method.getParameterCount() != 3 || - method.getParameterTypes()[0] != Request.class || - method.getParameterTypes()[1] != Callback.class || - method.getParameterTypes()[2] != Callback.class || - method.getReturnType() != void.class - ) { - continue; - } - boolean usable = true; - if(method.getDeclaredAnnotation(GET.class) != null && !request.method.equals("GET")) { - usable = false; - } - if(method.getDeclaredAnnotation(POST.class) != null && !request.method.equals("POST")) { - usable = false; - } - Path pathA = method.getDeclaredAnnotation(Path.class); - if(pathA != null && !request.realPath.matches("^" + pathA.value() + "$")) { - usable = false; - } - RequestMethod methodA = method.getDeclaredAnnotation(RequestMethod.class); - if(methodA != null && !request.method.matches("^" + methodA.value() + "$")) { - usable = false; - } + if(method.getReturnType() == void.class) { + boolean usable = true; + if(method.getDeclaredAnnotation(GET.class) != null && !request.method.equals("GET")) { + usable = false; + } + if(method.getDeclaredAnnotation(POST.class) != null && !request.method.equals("POST")) { + usable = false; + } + Path pathA = method.getDeclaredAnnotation(Path.class); + if(pathA != null && !request.realPath.matches("^" + pathA.value() + "$")) { + usable = false; + } + RequestMethod methodA = method.getDeclaredAnnotation(RequestMethod.class); + if(methodA != null && !request.method.matches("^" + methodA.value() + "$")) { + usable = false; + } - if(usable) { - try { - method.invoke(catcher, request, res, rej); - } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { - e.printStackTrace(); - } + if(usable) { + try { + method.invoke(catcher, request, res, rej); + } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + e.printStackTrace(); + } + } + } + else if(method.getReturnType() == Response.class) { + } } }