Commands #427
@ -1 +1 @@
|
||||
Subproject commit 3701f6f5ff10fa97d6816d5f57c85f7213f7fb3e
|
||||
Subproject commit 6e6d34905ac39bd2ed9548729041febadd42da2f
|
@ -26,8 +26,8 @@ public class BuilderCloudCommand extends SWCommand {
|
||||
}
|
||||
|
||||
@Register(description = "BUILDERCLOUD_USAGE")
|
||||
public void genericCommand(ProxiedPlayer player, @ErrorMessage("BUILDERCLOUD_VERSION") ServerStarter.Version version, @Mapper("map") String map, @OptionalValue("") @Mapper("generator") Optional<File> generator) {
|
||||
new ServerStarter().builder(version, map, generator.orElse(null)).send(player).start();
|
||||
public void genericCommand(ProxiedPlayer player, @ErrorMessage("BUILDERCLOUD_VERSION") ServerStarter.Version version, @Mapper("map") String map, @OptionalValue("") @Mapper("generator") @AllowNull File generator) {
|
||||
new ServerStarter().builder(version, map, generator).send(player).start();
|
||||
}
|
||||
|
||||
@ClassMapper(value = ServerStarter.Version.class, local = true)
|
||||
@ -79,24 +79,24 @@ public class BuilderCloudCommand extends SWCommand {
|
||||
|
||||
@Cached(global = true)
|
||||
@Mapper(value = "generator", local = true)
|
||||
private TypeMapper<Optional<File>> generatorTypeMapper() {
|
||||
private TypeMapper<File> generatorTypeMapper() {
|
||||
|
||||
return new TypeMapper<Optional<File>>() {
|
||||
return new TypeMapper<File>() {
|
||||
@Override
|
||||
public Optional<File> map(CommandSender commandSender, String[] previousArguments, String s) {
|
||||
public File map(CommandSender commandSender, String[] previousArguments, String s) {
|
||||
if(s.equals(""))
|
||||
return Optional.empty();
|
||||
return null;
|
||||
|
||||
File folder = getWorldFolder(previousArguments, 2);
|
||||
|
||||
if(folder == null)
|
||||
return null;
|
||||
throw new SecurityException();
|
||||
|
||||
File generator = new File(folder, s + ".dat");
|
||||
if(!generator.exists() || !generator.isFile())
|
||||
return null;
|
||||
throw new SecurityException();
|
||||
|
||||
return Optional.of(generator);
|
||||
return generator;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -22,86 +22,79 @@ package de.steamwar.bungeecore.commands;
|
||||
import de.steamwar.bungeecore.*;
|
||||
import de.steamwar.bungeecore.listeners.mods.ModLoaderBlocker;
|
||||
import de.steamwar.bungeecore.sql.IgnoreSystem;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.command.TypeMapper;
|
||||
import de.steamwar.command.TypeValidator;
|
||||
import net.md_5.bungee.BungeeCord;
|
||||
import net.md_5.bungee.api.CommandSender;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
import net.md_5.bungee.api.chat.ClickEvent;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedList;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static de.steamwar.bungeecore.Storage.challenges;
|
||||
|
||||
public class ChallengeCommand extends BasicCommand {
|
||||
public class ChallengeCommand extends SWCommand {
|
||||
|
||||
public ChallengeCommand() {
|
||||
super("challenge", "");
|
||||
super("challenge");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
if(args.length < 1){
|
||||
Message.send("CHALLENGE_USAGE", sender);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(sender instanceof ProxiedPlayer))
|
||||
return;
|
||||
|
||||
if(ModLoaderBlocker.isFabric((ProxiedPlayer) sender)) {
|
||||
Message.send("MODLOADER_DENIED", sender);
|
||||
return;
|
||||
}
|
||||
|
||||
ProxiedPlayer target = ProxyServer.getInstance().getPlayer(args[0]);
|
||||
if(target == null){
|
||||
Message.send("CHALLENGE_OFFLINE", sender);
|
||||
return;
|
||||
}else if(target == sender){
|
||||
Message.send("CHALLENGE_SELF", sender);
|
||||
return;
|
||||
}else if (IgnoreSystem.isIgnored(target, (ProxiedPlayer) sender)) {
|
||||
Message.send("CHALLENGE_IGNORED", sender);
|
||||
return;
|
||||
}
|
||||
|
||||
Subserver subserver = Subserver.getSubserver(target);
|
||||
if(subserver != null && subserver.getType() == Servertype.ARENA){
|
||||
Message.send("CHALLENGE_INARENA", sender);
|
||||
return;
|
||||
}
|
||||
|
||||
FightCommand.createArena(sender, "/challenge " + target.getName() + " ", false, args, 1, false, (player, mode, map) -> {
|
||||
if(challenges.containsKey(target) && challenges.get(target).contains(player)){
|
||||
@Register(description = "CHALLENGE_USAGE")
|
||||
public void challenge(@Validator("arenaPlayer") ProxiedPlayer player, @Validator("target") ProxiedPlayer target, @Mapper("nonHistoricArenaMode") @OptionalValue("") @AllowNull ArenaMode arenaMode, @Mapper("arenaMap") @OptionalValue("") @AllowNull String map) {
|
||||
FightCommand.createArena(player, "/challenge " + target.getName() + " ", false, arenaMode, map, false, (p, mode, m) -> {
|
||||
if(challenges.containsKey(target) && challenges.get(target).contains(p)){
|
||||
challenges.remove(target);
|
||||
challenges.remove(player);
|
||||
challenges.remove(p);
|
||||
|
||||
Subserver arena = new ServerStarter().arena(mode, map).blueLeader(player).redLeader(target).start();
|
||||
Message.broadcast("CHALLENGE_BROADCAST", "CHALLENGE_BROADCAST_HOVER",
|
||||
new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/arena " + arena.getServer().getName()), mode.getDisplayName(), player.getName(), target.getName());
|
||||
new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/arena " + arena.getServer().getName()), mode.getDisplayName(), p.getName(), target.getName());
|
||||
}else{
|
||||
if(!challenges.containsKey(player)){
|
||||
challenges.put(player, new LinkedList<>());
|
||||
if(!challenges.containsKey(p)){
|
||||
challenges.put(p, new LinkedList<>());
|
||||
}
|
||||
|
||||
challenges.get(player).add(target);
|
||||
challenges.get(p).add(target);
|
||||
|
||||
Message.send("CHALLENGE_CHALLENGED", player, target.getName(), mode.getDisplayName());
|
||||
Message.send("CHALLENGE_CHALLENGED_TARGET", target, player.getName(), mode.getDisplayName(), mode.getMaps().size()!=1?Message.parse("CHALLENGE_CHALLENGED_MAP", target, map):"");
|
||||
Message.send("CHALLENGE_CHALLENGED", p, target.getName(), mode.getDisplayName());
|
||||
Message.send("CHALLENGE_CHALLENGED_TARGET", target, p.getName(), mode.getDisplayName(), mode.getMaps().size() != 1 ? Message.parse("CHALLENGE_CHALLENGED_MAP", target, m) : "");
|
||||
|
||||
Message.send("CHALLENGE_ACCEPT", target, Message.parse("CHALLENGE_ACCEPT_HOVER", target), new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/challenge " + player.getName() + " " + mode.getChatName() + " " + map));
|
||||
Message.send("CHALLENGE_ACCEPT", target, Message.parse("CHALLENGE_ACCEPT_HOVER", target), new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/challenge " + p.getName() + " " + mode.getChatName() + " " + m));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Validator(value = "target", local = true)
|
||||
public TypeValidator<ProxiedPlayer> targetValidator() {
|
||||
YoyoNow markierte diese Unterhaltung als gelöst
|
||||
return (sender, value, messageSender) -> {
|
||||
if (value == null) {
|
||||
messageSender.send("CHALLENGE_OFFLINE");
|
||||
return false;
|
||||
}
|
||||
if (sender == value) {
|
||||
messageSender.send("CHALLENGE_SELF");
|
||||
return false;
|
||||
}
|
||||
if (IgnoreSystem.isIgnored(value, (ProxiedPlayer) sender)) {
|
||||
messageSender.send("CHALLENGE_IGNORED");
|
||||
return false;
|
||||
}
|
||||
|
||||
Subserver subserver = Subserver.getSubserver(value);
|
||||
if (subserver != null && subserver.getType() == Servertype.ARENA) {
|
||||
messageSender.send("CHALLENGE_INARENA");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
}
|
||||
|
||||
public static void remove(ProxiedPlayer player){
|
||||
challenges.remove(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<String> onTabComplete(CommandSender commandSender, String[] args) {
|
||||
if(args.length == 2)
|
||||
return ArenaMode.getAllChatNames(false);
|
||||
return new ArrayList<>();
|
||||
}
|
||||
}
|
||||
|
@ -24,6 +24,7 @@ import de.steamwar.bungeecore.inventory.SWInventory;
|
||||
import de.steamwar.bungeecore.inventory.SWItem;
|
||||
import de.steamwar.bungeecore.listeners.mods.ModLoaderBlocker;
|
||||
import de.steamwar.bungeecore.sql.Punishment;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.messages.ChatSender;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import net.md_5.bungee.api.ChatMessageType;
|
||||
@ -34,8 +35,6 @@ import net.md_5.bungee.api.chat.TextComponent;
|
||||
import net.md_5.bungee.api.chat.hover.content.Text;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
|
||||
import java.util.LinkedList;
|
||||
|
||||
/**
|
||||
* Jeder Fightcommand (auch bau testarena und challenge) haben folgende Optionskette:
|
||||
*
|
||||
@ -45,7 +44,7 @@ import java.util.LinkedList;
|
||||
* Sollte die Map fehlen, kann sie mit getMap() bestimmt werden.
|
||||
*/
|
||||
|
||||
public class FightCommand extends BasicCommand {
|
||||
public class FightCommand extends SWCommand {
|
||||
|
||||
public FightCommand() {
|
||||
super("fight", "", "f");
|
||||
@ -129,6 +128,35 @@ public class FightCommand extends BasicCommand {
|
||||
return false;
|
||||
}
|
||||
|
||||
static void createArena(ProxiedPlayer player, String precommand, boolean allowMerging, ArenaMode arenaMode, String map, boolean historic, FightCallback callback) {
|
||||
ChatSender sender = ChatSender.of(player);
|
||||
|
||||
Lixfel markierte diese Unterhaltung als gelöst
Lixfel
hat
Ich würde das FightCallback hier zu einem Runnable machen, da die Commands (wenn das dann aufgerufen wird) ja selbst auch schon Player, ArenaMode und Map haben. Dann musst du auch nicht überall mit m, p und arenaMode hantieren... Ich würde das FightCallback hier zu einem Runnable machen, da die Commands (wenn das dann aufgerufen wird) ja selbst auch schon Player, ArenaMode und Map haben. Dann musst du auch nicht überall mit m, p und arenaMode hantieren...
YoyoNow
hat
Sicher das das geht, ich weiß nicht ob es wirklich da ist aber sollte gehen, würde ich aber gerne erst machen wenn ich auch den 'bau test' Befehl umgebaut habe. Sicher das das geht, ich weiß nicht ob es wirklich da ist aber sollte gehen, würde ich aber gerne erst machen wenn ich auch den 'bau test' Befehl umgebaut habe.
Lixfel
hat
Ja, ich bin mir sicher, dass das geht (bau test hat ja dann selbe Architektur) Ja, ich bin mir sicher, dass das geht (bau test hat ja dann selbe Architektur)
YoyoNow
hat
Darf ich das auch erst dann machen? Darf ich das auch erst dann machen?
Lixfel
hat
Ja Ja
Lixfel
hat
Bzw. erst danach (nicht zeitgleich mit Baucommand, der wird so schon Kopfzerbrechend genug) Bzw. erst danach (nicht zeitgleich mit Baucommand, der wird so schon Kopfzerbrechend genug)
YoyoNow
hat
ok ok
|
||||
if(alreadyInArena(player))
|
||||
return;
|
||||
YoyoNow markierte diese Unterhaltung als gelöst
Lixfel
hat
Könnte man diese Prüfung nicht in den "fabric" Validator packen? (Bzw. ihn dann arenaPlayer nennen oder so) Könnte man diese Prüfung nicht in den "fabric" Validator packen? (Bzw. ihn dann arenaPlayer nennen oder so)
|
||||
|
||||
if (arenaMode == null) {
|
||||
getModes(sender, precommand, historic);
|
||||
return;
|
||||
}
|
||||
|
||||
if (map == null) {
|
||||
YoyoNow markierte diese Unterhaltung als gelöst
Lixfel
hat
Prüfst du das nicht schon immer mit dem Fabric-Validator? Prüfst du das nicht schon immer mit dem Fabric-Validator?
|
||||
if (arenaMode.getMaps().size() == 1) {
|
||||
map = arenaMode.getRandomMap();
|
||||
} else {
|
||||
getMaps(sender, precommand, arenaMode);
|
||||
return;
|
||||
}
|
||||
} else if (map.equalsIgnoreCase("random")) {
|
||||
map = arenaMode.getRandomMap();
|
||||
}
|
||||
|
||||
if (!allowMerging) {
|
||||
callback.run(player, arenaMode, map);
|
||||
} else {
|
||||
suggestMerging(player, arenaMode, map, callback);
|
||||
}
|
||||
}
|
||||
|
||||
static void createArena(CommandSender s, String precommand, boolean allowMerging, String[] args, int startArg, boolean historic, FightCallback callback){
|
||||
if(!(s instanceof ProxiedPlayer))
|
||||
return;
|
||||
@ -216,28 +244,15 @@ public class FightCommand extends BasicCommand {
|
||||
inventory.open();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
createArena(sender, "/fight ", true, args, 0, false, (player, mode, map) -> {
|
||||
Subserver arena = new ServerStarter().arena(mode, map).blueLeader(player).start();
|
||||
@Register
|
||||
public void challenge(@Validator("arenaPlayer") ProxiedPlayer player, @Mapper("nonHistoricArenaMode") @OptionalValue("") @AllowNull ArenaMode arenaMode, @Mapper("arenaMap") @OptionalValue("") @AllowNull String map) {
|
||||
createArena(player, "/fight ", true, arenaMode, map, false, (p, mode, m) -> {
|
||||
Subserver arena = new ServerStarter().arena(mode, m).blueLeader(p).start();
|
||||
Message.broadcast("FIGHT_BROADCAST", "FIGHT_BROADCAST_HOVER"
|
||||
, new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/arena " + arena.getServer().getName()), mode.getDisplayName(), player.getName());
|
||||
, new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/arena " + arena.getServer().getName()), mode.getDisplayName(), p.getName());
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<String> onTabComplete(CommandSender commandSender, String[] args) {
|
||||
if(args.length == 1){
|
||||
return ArenaMode.getAllChatNames(false);
|
||||
}else if(args.length == 2){
|
||||
ArenaMode mode = ArenaMode.getByChat(args[1]);
|
||||
if(mode == null)
|
||||
return new LinkedList<>();
|
||||
return mode.getMaps();
|
||||
}
|
||||
return new LinkedList<>();
|
||||
}
|
||||
|
||||
/**
|
||||
* Is called when arena parameters are clear.
|
||||
YoyoNow markierte diese Unterhaltung als gelöst
Veraltet
Lixfel
hat
CHALLENGE_USAGE? Meines Wissens nach gibt es keine Möglichkeit, den Fight-Command zu einem Fehler zu bringen. CHALLENGE_USAGE? Meines Wissens nach gibt es keine Möglichkeit, den Fight-Command zu einem Fehler zu bringen.
|
||||
*/
|
||||
|
@ -23,35 +23,21 @@ import de.steamwar.bungeecore.ArenaMode;
|
||||
import de.steamwar.bungeecore.Message;
|
||||
import de.steamwar.bungeecore.ServerStarter;
|
||||
import de.steamwar.bungeecore.Subserver;
|
||||
import net.md_5.bungee.api.CommandSender;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import net.md_5.bungee.api.chat.ClickEvent;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
|
||||
import java.util.LinkedList;
|
||||
|
||||
public class HistoricCommand extends BasicCommand {
|
||||
public class HistoricCommand extends SWCommand {
|
||||
public HistoricCommand() {
|
||||
super("historic", null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
FightCommand.createArena(sender, "/historic ", true, args, 0, true, (player, mode, map) -> {
|
||||
Subserver arena = new ServerStarter().arena(mode, map).blueLeader(player).start();
|
||||
Message.broadcast("HISTORIC_BROADCAST", "HISTORIC_BROADCAST_HOVER"
|
||||
, new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/arena " + arena.getServer().getName()), mode.getDisplayName(), player.getName());
|
||||
@Register
|
||||
YoyoNow markierte diese Unterhaltung als gelöst
Veraltet
Lixfel
hat
Auch hier wieder so eine merkwürdige CHALLENGE_USAGE. Auch hier wieder so eine merkwürdige CHALLENGE_USAGE.
|
||||
public void challenge(@Validator("arenaPlayer") ProxiedPlayer player, @Mapper("nonHistoricArenaMode") @OptionalValue("") @AllowNull ArenaMode arenaMode, @Mapper("arenaMap") @OptionalValue("") @AllowNull String map) {
|
||||
FightCommand.createArena(player, "/historic ", true, arenaMode, map, true, (p, mode, m) -> {
|
||||
YoyoNow markierte diese Unterhaltung als gelöst
Veraltet
Lixfel
hat
Leerzeichen nach /historic! Leerzeichen nach /historic!
|
||||
Subserver arena = new ServerStarter().arena(mode, m).blueLeader(p).start();
|
||||
Message.broadcast("HISTORIC_BROADCAST", "HISTORIC_BROADCAST_HOVER",
|
||||
YoyoNow markierte diese Unterhaltung als gelöst
Veraltet
Lixfel
hat
Wie wäre es mit HISTORIC statt CHALLENGE? Wie wäre es mit HISTORIC statt CHALLENGE?
|
||||
new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/arena " + arena.getServer().getName()), mode.getDisplayName(), p.getName());
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<String> onTabComplete(CommandSender commandSender, String[] args) {
|
||||
if(args.length == 1){
|
||||
return ArenaMode.getAllChatNames(true);
|
||||
}else if(args.length == 2){
|
||||
ArenaMode mode = ArenaMode.getByChat(args[1]);
|
||||
if(mode == null)
|
||||
return new LinkedList<>();
|
||||
return mode.getMaps();
|
||||
}
|
||||
return new LinkedList<>();
|
||||
}
|
||||
}
|
||||
|
95
src/de/steamwar/bungeecore/commands/TypeMappers.java
Normale Datei
@ -0,0 +1,95 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2020 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bungeecore.commands;
|
||||
|
||||
import de.steamwar.bungeecore.ArenaMode;
|
||||
import de.steamwar.bungeecore.listeners.mods.ModLoaderBlocker;
|
||||
import de.steamwar.bungeecore.sql.Punishment;
|
||||
import de.steamwar.command.SWCommandUtils;
|
||||
import de.steamwar.command.TypeMapper;
|
||||
import de.steamwar.command.TypeValidator;
|
||||
import de.steamwar.messages.ChatSender;
|
||||
import lombok.experimental.UtilityClass;
|
||||
import net.md_5.bungee.api.CommandSender;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
@UtilityClass
|
||||
public class TypeMappers {
|
||||
|
||||
public static void init() {
|
||||
SWCommandUtils.addValidator("arenaPlayer", arenaPlayer());
|
||||
SWCommandUtils.addMapper("nonHistoricArenaMode", arenaModeTypeMapper(false));
|
||||
SWCommandUtils.addMapper("historicArenaMode", arenaModeTypeMapper(true));
|
||||
SWCommandUtils.addMapper("arenaMap", arenaMapTypeMapper());
|
||||
}
|
||||
YoyoNow markierte diese Unterhaltung als gelöst
Lixfel
hat
Könnte man diese Konstruktoren nicht private machen? Könnte man diese Konstruktoren nicht private machen?
|
||||
|
||||
private static TypeValidator<ProxiedPlayer> arenaPlayer() {
|
||||
return (sender, value, messageSender) -> {
|
||||
ChatSender player = ChatSender.of(value);
|
||||
if (player.user().isPunishedWithMessage(player, Punishment.PunishmentType.NoFightServer)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (ModLoaderBlocker.isFabric(value)) {
|
||||
messageSender.send("MODLOADER_DENIED");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
}
|
||||
|
||||
private static TypeMapper<ArenaMode> arenaModeTypeMapper(boolean historic) {
|
||||
return new TypeMapper<ArenaMode>() {
|
||||
@Override
|
||||
public ArenaMode map(CommandSender commandSender, String[] previousArguments, String s) {
|
||||
return ArenaMode.getByChat(s);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<String> tabCompletes(CommandSender sender, String[] previousArguments, String s) {
|
||||
return ArenaMode.getAllChatNames(historic);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private static TypeMapper<String> arenaMapTypeMapper() {
|
||||
return new TypeMapper<String>() {
|
||||
@Override
|
||||
public String map(CommandSender commandSender, String[] previousArguments, String s) {
|
||||
if (s.equalsIgnoreCase("random")) return "random";
|
||||
ArenaMode arenaMode = ArenaMode.getByChat(previousArguments[previousArguments.length - 1]);
|
||||
if (arenaMode.getMaps().contains(s)) return s;
|
||||
YoyoNow markierte diese Unterhaltung als gelöst
Lixfel
hat
Könnte hier nicht eine NPE fliegen, wenn der User keinen gültigen ArenaMode angegeben hat? Könnte hier nicht eine NPE fliegen, wenn der User keinen gültigen ArenaMode angegeben hat?
YoyoNow
hat
Da der ArenaMode nicht matched bevor das hier genutzt wird sollte es nicht so das problem sein, und wenn dann matched der command halt nicht Da der ArenaMode nicht matched bevor das hier genutzt wird sollte es nicht so das problem sein, und wenn dann matched der command halt nicht
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<String> tabCompletes(CommandSender sender, String[] previousArguments, String s) {
|
||||
ArenaMode arenaMode = ArenaMode.getByChat(previousArguments[previousArguments.length - 1]);
|
||||
List<String> stringList = new ArrayList<>(arenaMode.getMaps());
|
||||
stringList.add("random");
|
||||
return stringList;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
@ -19,6 +19,7 @@
|
||||
|
||||
package de.steamwar.command;
|
||||
|
||||
import de.steamwar.bungeecore.commands.TypeMappers;
|
||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||
import lombok.experimental.UtilityClass;
|
||||
import net.md_5.bungee.BungeeCord;
|
||||
@ -32,5 +33,7 @@ public class TypeUtils {
|
||||
static void init() {
|
||||
SWCommandUtils.addMapper(ProxiedPlayer.class, SWCommandUtils.createMapper(BungeeCord.getInstance()::getPlayer, (s) -> BungeeCord.getInstance().getPlayers().stream().map(ProxiedPlayer::getName).collect(Collectors.toList())));
|
||||
SWCommandUtils.addMapper(SteamwarUser.class, SWCommandUtils.createMapper(SteamwarUser::get, s -> BungeeCord.getInstance().getPlayers().stream().map(ProxiedPlayer::getName).collect(Collectors.toList())));
|
||||
|
||||
TypeMappers.init();
|
||||
}
|
||||
}
|
||||
|
Könnte der Validator nicht noch local sein? Weil targets gibts häufiger mal im BungeeCore und Challenge-Targets gibts halt nur im ChallengeCommand.