Fix SWCommand.Register
Fix SWCommand.Mapper
Dieser Commit ist enthalten in:
Ursprung
9adf9f139b
Commit
09e6f0baa8
23
SpigotCore_Main/src/de/steamwar/acommand/TestCommand.java
Normale Datei
23
SpigotCore_Main/src/de/steamwar/acommand/TestCommand.java
Normale Datei
@ -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) {
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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);
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren