Merge remote-tracking branch 'origin/CommandFramework' into CommandFramework
Dieser Commit ist enthalten in:
Commit
e01d9b6b90
@ -5,8 +5,6 @@ import de.steamwar.bausystem.world.ScriptListener;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.command.SWCommandUtils;
|
||||
import de.steamwar.command.TypeMapper;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.*;
|
||||
@ -47,18 +45,13 @@ public class CommandScriptVars extends SWCommand {
|
||||
}
|
||||
|
||||
@Register
|
||||
public void booleanValueCommand(Player p, String varName, @Mapper(value = "BooleanString") int value) {
|
||||
valueCommand(p, varName, value);
|
||||
}
|
||||
|
||||
@Register
|
||||
public void valueCommand(Player p, String varName, int value) {
|
||||
public void booleanValueCommand(Player p, String varName, int value) {
|
||||
ScriptListener.GLOBAL_VARIABLES.computeIfAbsent(p, player -> new HashMap<>()).put(varName, value);
|
||||
p.sendMessage(BauSystem.PREFIX + varName + " auf " + value + " gesetzt");
|
||||
}
|
||||
|
||||
@Register
|
||||
public void removeCommand(Player p, String varName, @Mapper(value = "ClearString") String remove) {
|
||||
public void removeCommand(Player p, String varName, @Mapper(value = "Delete") String remove) {
|
||||
if (!ScriptListener.GLOBAL_VARIABLES.containsKey(p)) {
|
||||
p.sendMessage(BauSystem.PREFIX + "§cKeine globalen Variablen definiert");
|
||||
return;
|
||||
@ -78,23 +71,23 @@ public class CommandScriptVars extends SWCommand {
|
||||
});
|
||||
}
|
||||
|
||||
@Mapper(value = "ClearString", local = true)
|
||||
@Mapper(value = "Delete", local = true)
|
||||
public TypeMapper<String> clearStringTypeMapper() {
|
||||
List<String> tabCompletes = Arrays.asList("delete", "clear", "remove");
|
||||
return SWCommandUtils.createMapper(s -> s, s -> tabCompletes);
|
||||
}
|
||||
|
||||
@Mapper(value = "BooleanString", local = true)
|
||||
public TypeMapper<Object> booleanStringTypeMapper() {
|
||||
List<String> tabCompletes = Arrays.asList("yes", "no", "true", "false");
|
||||
return SWCommandUtils.createMapper(s -> {
|
||||
if (s.equalsIgnoreCase("yes") || s.equals("true")) {
|
||||
return 1;
|
||||
}
|
||||
if (s.equalsIgnoreCase("no") || s.equals("false")) {
|
||||
return 0;
|
||||
if (s.equalsIgnoreCase("delete") || s.equalsIgnoreCase("clear") || s.equalsIgnoreCase("remove")) {
|
||||
return s;
|
||||
}
|
||||
return null;
|
||||
}, s -> tabCompletes);
|
||||
}
|
||||
|
||||
@ClassMapper(value = int.class, local = true)
|
||||
public TypeMapper<Integer> integerTypeMapper() {
|
||||
List<String> tabCompletes = Arrays.asList("true", "false", "yes", "no");
|
||||
return SWCommandUtils.createMapper(s -> {
|
||||
if (s.equalsIgnoreCase("remove") || s.equalsIgnoreCase("clear") || s.equalsIgnoreCase("delete")) return null;
|
||||
return ScriptListener.parseValue(s);
|
||||
}, s -> tabCompletes);
|
||||
}
|
||||
}
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren