From 37d308346ef917c0e495a84a326d5a3d4b644ed7 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Wed, 5 May 2021 10:02:07 +0200 Subject: [PATCH] Optimize SWCommand --- SpigotCore_Main/src/de/steamwar/command/SWCommand.java | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/SpigotCore_Main/src/de/steamwar/command/SWCommand.java b/SpigotCore_Main/src/de/steamwar/command/SWCommand.java index 20f1d5c..3b6245d 100644 --- a/SpigotCore_Main/src/de/steamwar/command/SWCommand.java +++ b/SpigotCore_Main/src/de/steamwar/command/SWCommand.java @@ -47,14 +47,8 @@ public abstract class SWCommand { this.command = new Command(command, "", "/" + command, Arrays.asList(aliases)) { @Override public boolean execute(CommandSender sender, String alias, String[] args) { - // if (commandList.stream().filter(s -> s.invoke(sender, args)).findFirst().isPresent()) return false; - // if (commandHelpList.stream().filter(s -> s.invoke(sender, args)).findFirst().isPresent()) return false; - for (SubCommand subCommand : commandList) { - if (subCommand.invoke(sender, args)) return false; - } - for (SubCommand subCommand : commandHelpList) { - if (subCommand.invoke(sender, args)) return false; - } + if (commandList.stream().anyMatch(s -> s.invoke(sender, args))) return false; + commandHelpList.stream().anyMatch(s -> s.invoke(sender, args)); return false; }