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
3 geänderte Dateien mit 28 neuen und 5 gelöschten Zeilen
Nur Änderungen aus Commit 09e6f0baa8 werden angezeigt - Alle Commits anzeigen

Datei anzeigen

@ -0,0 +1,23 @@
package de.steamwar.acommand;
import de.steamwar.command.SWCommand;
import org.bukkit.Material;
import org.bukkit.entity.Player;
public class TestCommand extends SWCommand {
public TestCommand() {
super("test");
}
@Register
public void test(Player player) {
}
@Register({"two"})
public void testTwo(Player player, int i, @Mapper("Hello World") Material material) {
}
}

Datei anzeigen

@ -105,7 +105,7 @@ public abstract class SWCommand {
String name = clazz.getTypeName();
Mapper mapper = parameter.getAnnotation(Mapper.class);
if (mapper != null) {
name = mapper.mapper();
name = mapper.value();
}
if (!SWCommandUtils.MAPPER_FUNCTIONS.containsKey(name)) return false;
}
@ -124,13 +124,13 @@ public abstract class SWCommand {
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD})
protected @interface Register {
String[] subCommand() default {};
String[] value() default {};
}
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.PARAMETER})
protected @interface Mapper {
String mapper();
String value();
}
}

Datei anzeigen

@ -25,7 +25,7 @@ class SubCommand {
Parameter[] parameters = method.getParameters();
commandSenderFunction = sender -> parameters[0].getType().cast(sender);
SWCommand.Register register = method.getAnnotation(SWCommand.Register.class);
subCommand = register.subCommand();
subCommand = register.value();
arguments = new TypeMapper[parameters.length - 1];
for (int i = 1; i < parameters.length; i++) {
@ -59,7 +59,7 @@ class SubCommand {
String name = clazz.getTypeName();
SWCommand.Mapper mapper = parameter.getAnnotation(SWCommand.Mapper.class);
if (mapper != null) {
name = mapper.mapper();
name = mapper.value();
}
arguments[i] = SWCommandUtils.MAPPER_FUNCTIONS.getOrDefault(name, SWCommandUtils.ERROR_FUNCTION);