From 3701f6f5ff10fa97d6816d5f57c85f7213f7fb3e Mon Sep 17 00:00:00 2001 From: yoyosource Date: Mon, 22 Aug 2022 21:06:10 +0200 Subject: [PATCH] Fix validators --- src/de/steamwar/command/CommandPart.java | 4 ++-- src/de/steamwar/command/SubCommand.java | 4 ++-- testsrc/de/steamwar/command/ValidatorCommand.java | 2 ++ 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/de/steamwar/command/CommandPart.java b/src/de/steamwar/command/CommandPart.java index 7ecdb58..4931ef0 100644 --- a/src/de/steamwar/command/CommandPart.java +++ b/src/de/steamwar/command/CommandPart.java @@ -182,10 +182,10 @@ class CommandPart { })) { return new CheckArgumentResult(false, null); } - return new CheckArgumentResult(value != null, value); } + return new CheckArgumentResult(value != null, value); } catch (Exception e) { + return new CheckArgumentResult(false, null); } - return new CheckArgumentResult(false, null); } } diff --git a/src/de/steamwar/command/SubCommand.java b/src/de/steamwar/command/SubCommand.java index 8626f1d..9a497e5 100644 --- a/src/de/steamwar/command/SubCommand.java +++ b/src/de/steamwar/command/SubCommand.java @@ -75,7 +75,7 @@ public class SubCommand { if (!validator.validate(sender, sender, (s, objectArgs) -> { abstractSWCommand.sendMessage(sender, s, objectArgs); })) { - throw new CommandNoHelpException(); + return false; } } method.setAccessible(true); @@ -87,7 +87,7 @@ public class SubCommand { if (!validator.validate(sender, sender, (s, objectArgs) -> { abstractSWCommand.sendMessage(sender, s, objectArgs); })) { - throw new CommandNoHelpException(); + return false; } } objects.add(0, senderFunction.apply(sender)); diff --git a/testsrc/de/steamwar/command/ValidatorCommand.java b/testsrc/de/steamwar/command/ValidatorCommand.java index ea95a5e..b0e4a36 100644 --- a/testsrc/de/steamwar/command/ValidatorCommand.java +++ b/testsrc/de/steamwar/command/ValidatorCommand.java @@ -43,11 +43,13 @@ public class ValidatorCommand extends TestSWCommand { @Register public void onError(String sender, @ErrorMessage("Hello World") int error) { + System.out.println("onError: " + sender + " " + error); throw new ExecutionIdentifier("RunOnError"); } @Register public void onError(String sender, double error) { + System.out.println("onError: " + sender + " " + error); throw new ExecutionIdentifier("RunOnErrorDouble"); }