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,103 @@ 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("fabric") ProxiedPlayer player, @Mapper("target") ProxiedPlayer target, String... args) {
|
||||
FightCommand.createArena(player, "/challenge " + target.getName() + " ", false, args, 0, false, (p, mode, map) -> {
|
||||
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, map):"");
|
||||
|
||||
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() + " " + map));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Validator("fabric")
|
||||
public TypeValidator<ProxiedPlayer> fabricChecker() {
|
||||
YoyoNow markierte diese Unterhaltung als gelöst
|
||||
return (sender, value, messageSender) -> {
|
||||
if (ModLoaderBlocker.isFabric(value)) {
|
||||
messageSender.send("MODLOADER_DENIED");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
}
|
||||
|
||||
@Mapper("target")
|
||||
public TypeMapper<ProxiedPlayer> targetMapper() {
|
||||
return new TypeMapper<ProxiedPlayer>() {
|
||||
@Override
|
||||
public ProxiedPlayer map(CommandSender commandSender, String[] previousArguments, String s) {
|
||||
return BungeeCord.getInstance().getPlayer(s);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean validate(CommandSender sender, ProxiedPlayer value, MessageSender 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;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<String> tabCompletes(CommandSender sender, String[] previousArguments, String s) {
|
||||
return BungeeCord.getInstance().getPlayers().stream().map(ProxiedPlayer::getDisplayName).collect(Collectors.toList());
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
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<>();
|
||||
}
|
||||
}
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren
Könnte der Validator nicht noch local sein? Weil targets gibts häufiger mal im BungeeCore und Challenge-Targets gibts halt nur im ChallengeCommand.