Archiviert
1
0
Dieser Commit ist enthalten in:
yoyosource 2022-09-03 14:33:00 +02:00
Ursprung 669375e751
Commit 2325190cf1
4 geänderte Dateien mit 20 neuen und 23 gelöschten Zeilen

Datei anzeigen

@ -45,7 +45,7 @@ public class ChallengeCommand extends SWCommand {
}
@Register(description = "CHALLENGE_USAGE")
public void challenge(@Validator("fabric") ProxiedPlayer player, @Validator("target") ProxiedPlayer target, @Mapper("nonHistoricArenaMode") @OptionalValue("") @AllowNull ArenaMode arenaMode, @Mapper("arenaMap") @OptionalValue("") @AllowNull String map) {
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);
@ -69,7 +69,7 @@ public class ChallengeCommand extends SWCommand {
});
}
@Validator("target")
@Validator(value = "target", local = true)
public TypeValidator<ProxiedPlayer> targetValidator() {
return (sender, value, messageSender) -> {
if (value == null) {

Datei anzeigen

@ -35,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:
*
@ -132,18 +130,10 @@ public class FightCommand extends SWCommand {
static void createArena(ProxiedPlayer player, String precommand, boolean allowMerging, ArenaMode arenaMode, String map, boolean historic, FightCallback callback) {
ChatSender sender = ChatSender.of(player);
if (sender.user().isPunishedWithMessage(sender, Punishment.PunishmentType.NoFightServer)) {
return;
}
if(alreadyInArena(player))
return;
if(ModLoaderBlocker.isFabric(player) && !precommand.equals("/bau testarena ")) {
sender.system("MODLOADER_DENIED");
return;
}
if (arenaMode == null) {
getModes(sender, precommand, historic);
return;
@ -254,8 +244,8 @@ public class FightCommand extends SWCommand {
inventory.open();
}
@Register(description = "CHALLENGE_USAGE")
public void challenge(@Validator("fabric") ProxiedPlayer player, @Mapper("nonHistoricArenaMode") @OptionalValue("") @AllowNull ArenaMode arenaMode, @Mapper("arenaMap") @OptionalValue("") @AllowNull String map) {
@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"

Datei anzeigen

@ -32,11 +32,11 @@ public class HistoricCommand extends SWCommand {
super("historic", null);
}
@Register(description = "CHALLENGE_USAGE")
public void challenge(@Validator("fabric") ProxiedPlayer player, @Mapper("nonHistoricArenaMode") @OptionalValue("") @AllowNull ArenaMode arenaMode, @Mapper("arenaMap") @OptionalValue("") @AllowNull String map) {
@Register
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) -> {
Subserver arena = new ServerStarter().arena(mode, m).blueLeader(p).start();
Message.broadcast("CHALLENGE_BROADCAST", "CHALLENGE_BROADCAST_HOVER",
Message.broadcast("HISTORIC_BROADCAST", "HISTORIC_BROADCAST_HOVER",
new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/arena " + arena.getServer().getName()), mode.getDisplayName(), p.getName());
});
}

Datei anzeigen

@ -21,9 +21,11 @@ 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;
@ -36,14 +38,19 @@ import java.util.List;
public class TypeMappers {
public static void init() {
SWCommandUtils.addValidator("fabric", fabricChecker());
SWCommandUtils.addValidator("arenaPlayer", fabricChecker());
SWCommandUtils.addMapper("nonHistoricArenaMode", arenaModeTypeMapper(false));
SWCommandUtils.addMapper("historicArenaMode", arenaModeTypeMapper(true));
SWCommandUtils.addMapper("arenaMap", arenaMapTypeMapper());
}
public static TypeValidator<ProxiedPlayer> fabricChecker() {
private static TypeValidator<ProxiedPlayer> fabricChecker() {
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;
@ -52,7 +59,7 @@ public class TypeMappers {
};
}
public static TypeMapper<ArenaMode> arenaModeTypeMapper(boolean historic) {
private static TypeMapper<ArenaMode> arenaModeTypeMapper(boolean historic) {
return new TypeMapper<ArenaMode>() {
@Override
public ArenaMode map(CommandSender commandSender, String[] previousArguments, String s) {
@ -66,7 +73,7 @@ public class TypeMappers {
};
}
public static TypeMapper<String> arenaMapTypeMapper() {
private static TypeMapper<String> arenaMapTypeMapper() {
return new TypeMapper<String>() {
@Override
public String map(CommandSender commandSender, String[] previousArguments, String s) {