From fa9268ce1b1599743efc42ef65f8eb3fdcf1d465 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Tue, 30 Mar 2021 17:56:17 +0200 Subject: [PATCH] Fix NegativeArraySizeException in SWCommandUtils --- SpigotCore_Main/src/de/steamwar/command/SWCommand.java | 1 - SpigotCore_Main/src/de/steamwar/command/SWCommandUtils.java | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/SpigotCore_Main/src/de/steamwar/command/SWCommand.java b/SpigotCore_Main/src/de/steamwar/command/SWCommand.java index ed29dde..240766b 100644 --- a/SpigotCore_Main/src/de/steamwar/command/SWCommand.java +++ b/SpigotCore_Main/src/de/steamwar/command/SWCommand.java @@ -103,7 +103,6 @@ public abstract class SWCommand { } if (!parameters[parameters.length - 1].isVarArgs()) { Bukkit.getLogger().log(Level.WARNING, "The method '" + method.toString() + "' is lacking the varArgs parameters as last Argument"); - return; } if (parameters[parameters.length - 1].getType().getComponentType() != String.class) { Bukkit.getLogger().log(Level.WARNING, "The method '" + method.toString() + "' is lacking the varArgs parameters of type '" + String.class.getTypeName() + "' as last Argument"); diff --git a/SpigotCore_Main/src/de/steamwar/command/SWCommandUtils.java b/SpigotCore_Main/src/de/steamwar/command/SWCommandUtils.java index a4c678d..dc34536 100644 --- a/SpigotCore_Main/src/de/steamwar/command/SWCommandUtils.java +++ b/SpigotCore_Main/src/de/steamwar/command/SWCommandUtils.java @@ -115,7 +115,7 @@ public class SWCommandUtils { arguments[arguments.length - 1] = varArgument; } else { for (int i = 0; i < parameters.length - (varArgType != null ? 1 : 0); i++) { - arguments[i + 1] = parameters[i].map(Arrays.copyOf(args, Math.min(index - 1, 0)), args[index]); + arguments[i + 1] = parameters[i].map(Arrays.copyOf(args, Math.max(index - 1, 0)), args[index]); index++; if (arguments[i + 1] == null) { throw new CommandParseException(); @@ -128,7 +128,7 @@ public class SWCommandUtils { arguments[arguments.length - 1] = varArgument; for (int i = 0; i < length; i++) { - Object value = parameters[parameters.length - 1].map(Arrays.copyOf(args, Math.min(index - 1, 0)), args[index]); + Object value = parameters[parameters.length - 1].map(Arrays.copyOf(args, Math.max(index - 1, 0)), args[index]); if (value == null) { throw new CommandParseException(); }