SteamWar/BauSystem
Archiviert
13
0

Update BauSystem to new CommandFramework #217

Manuell gemergt
YoyoNow hat 63 Commits von CommandFramework nach master 2021-04-02 18:08:26 +02:00 zusammengeführt
Nur Änderungen aus Commit 932da846a2 werden angezeigt - Alle Commits anzeigen

Datei anzeigen

@ -5,8 +5,6 @@ import de.steamwar.bausystem.world.ScriptListener;
import de.steamwar.command.SWCommand; import de.steamwar.command.SWCommand;
import de.steamwar.command.SWCommandUtils; import de.steamwar.command.SWCommandUtils;
import de.steamwar.command.TypeMapper; import de.steamwar.command.TypeMapper;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import java.util.*; import java.util.*;
@ -47,18 +45,13 @@ public class CommandScriptVars extends SWCommand {
} }
@Register @Register
public void booleanValueCommand(Player p, String varName, @Mapper(value = "BooleanString") int value) { public void booleanValueCommand(Player p, String varName, int value) {
valueCommand(p, varName, value);
}
@Register
public void valueCommand(Player p, String varName, int value) {
ScriptListener.GLOBAL_VARIABLES.computeIfAbsent(p, player -> new HashMap<>()).put(varName, value); ScriptListener.GLOBAL_VARIABLES.computeIfAbsent(p, player -> new HashMap<>()).put(varName, value);
p.sendMessage(BauSystem.PREFIX + varName + " auf " + value + " gesetzt"); p.sendMessage(BauSystem.PREFIX + varName + " auf " + value + " gesetzt");
} }
@Register @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)) { if (!ScriptListener.GLOBAL_VARIABLES.containsKey(p)) {
p.sendMessage(BauSystem.PREFIX + "§cKeine globalen Variablen definiert"); p.sendMessage(BauSystem.PREFIX + "§cKeine globalen Variablen definiert");
return; return;
@ -78,23 +71,23 @@ public class CommandScriptVars extends SWCommand {
}); });
} }
@Mapper(value = "ClearString", local = true) @Mapper(value = "Delete", local = true)
public TypeMapper<String> clearStringTypeMapper() { public TypeMapper<String> clearStringTypeMapper() {
List<String> tabCompletes = Arrays.asList("delete", "clear", "remove"); 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 -> { return SWCommandUtils.createMapper(s -> {
if (s.equalsIgnoreCase("yes") || s.equals("true")) { if (s.equalsIgnoreCase("delete") || s.equalsIgnoreCase("clear") || s.equalsIgnoreCase("remove")) {
return 1; return s;
}
if (s.equalsIgnoreCase("no") || s.equals("false")) {
return 0;
} }
return null; return null;
}, s -> tabCompletes); }, 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);
}
} }