SteamWar/SpigotCore
Archiviert
13
0

CommandFramework3 #94

Manuell gemergt
Zeanon hat 71 Commits von CommandFramework3 nach master 2021-03-30 21:15:40 +02:00 zusammengeführt
4 geänderte Dateien mit 8 neuen und 8 gelöschten Zeilen
Nur Änderungen aus Commit 25d72ab376 werden angezeigt - Alle Commits anzeigen

Datei anzeigen

@ -37,7 +37,7 @@ public class TestCommand extends SWCommand {
}
// One Help Command, the first Parameter should be some kind of CommandSender
// The second argument can only be a varAgrs string of what arguments were tried to map
// The second argument can only be a varArgs string of what arguments were tried to map
@Register(help = true)
public void testHelp(Player player, String... args) {
player.sendMessage("This is your help message");
@ -68,7 +68,7 @@ public class TestCommand extends SWCommand {
.collect(Collectors.toList());
return new TypeMapper<Material>() {
@Override
public Material map(String s) {
public Material map(String[] previous, String s) {
return Material.valueOf(s.toUpperCase());
}

Datei anzeigen

@ -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(args[index]);
arguments[i + 1] = parameters[i].map(Arrays.copyOf(args, Math.min(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(args[index]);
Object value = parameters[parameters.length - 1].map(Arrays.copyOf(args, Math.min(index - 1, 0)), args[index]);
if (value == null) {
throw new CommandParseException();
}
@ -156,7 +156,7 @@ public class SWCommandUtils {
public static <T> TypeMapper<T> createMapper(Function<String, T> mapper, BiFunction<CommandSender, String, List<String>> tabCompleter) {
return new TypeMapper<T>() {
@Override
public T map(String s) {
public T map(String[] previous, String s) {
return mapper.apply(s);
}

Datei anzeigen

@ -114,7 +114,7 @@ class SubCommand {
String s = argsList.remove(0);
if (argsList.isEmpty()) return argument.tabCompletes(commandSender, Arrays.copyOf(args, args.length - 1), s);
try {
if (argument.map(s) == null) {
if (argument.map(Arrays.copyOf(args, argsList.size()), s) == null) {
return null;
}
} catch (Exception e) {
@ -126,7 +126,7 @@ class SubCommand {
String s = argsList.remove(0);
if (argsList.isEmpty()) return arguments[arguments.length - 1].tabCompletes(commandSender, Arrays.copyOf(args, args.length - 1), s);
try {
if (arguments[arguments.length - 1].map(s) == null) {
if (arguments[arguments.length - 1].map(Arrays.copyOf(args, argsList.size()), s) == null) {
return null;
}
} catch (Exception e) {

Datei anzeigen

@ -24,7 +24,7 @@ import org.bukkit.command.CommandSender;
import java.util.List;
public interface TypeMapper<T> {
T map(String s);
T map(String[] previousArguments, String s);
List<String> tabCompletes(CommandSender commandSender, String[] previousArguments, String s);
}