From 1b10c96dc6768f4803d05783bbe2297a161fa187 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Thu, 25 Mar 2021 20:10:50 +0100 Subject: [PATCH] Optimize imports SubCommand --- .../src/de/steamwar/command/SubCommand.java | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/SpigotCore_Main/src/de/steamwar/command/SubCommand.java b/SpigotCore_Main/src/de/steamwar/command/SubCommand.java index 8dd4aec..8d50f73 100644 --- a/SpigotCore_Main/src/de/steamwar/command/SubCommand.java +++ b/SpigotCore_Main/src/de/steamwar/command/SubCommand.java @@ -21,7 +21,6 @@ package de.steamwar.command; import org.bukkit.command.CommandSender; -import java.io.IOException; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.lang.reflect.Parameter; @@ -107,16 +106,16 @@ class SubCommand { List tabComplete(CommandSender commandSender, String[] args) { List argsList = Arrays.asList(args); - for (int i = 0; i < subCommand.length; i++) { + for (String value : subCommand) { String s = argsList.remove(0); - if (argsList.isEmpty()) return Collections.singletonList(subCommand[i]); - if (!subCommand[i].equals(s)) return Collections.emptyList(); + if (argsList.isEmpty()) return Collections.singletonList(value); + if (!value.equals(s)) return Collections.emptyList(); } - for (int i = 0; i < arguments.length; i++) { + for (TypeMapper argument : arguments) { String s = argsList.remove(0); - if (argsList.isEmpty()) return arguments[i].tabCompletes(s); + if (argsList.isEmpty()) return argument.tabCompletes(s); try { - arguments[i].map(s); + argument.map(s); } catch (Exception e) { return Collections.emptyList(); }