Archiviert
1
0

Update ChallengeCommand

Update FightCommand
Update HistoricCommand
Dieser Commit ist enthalten in:
yoyosource 2022-09-01 18:39:08 +02:00
Ursprung 7de6402a63
Commit 669375e751
3 geänderte Dateien mit 56 neuen und 45 gelöschten Zeilen

Datei anzeigen

@ -46,7 +46,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) {
FightCommand.createArena(player, "/challenge " + target.getName() + " ", false, args, 0, false, (p, mode, 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(p);
@ -62,9 +62,9 @@ public class ChallengeCommand extends SWCommand {
challenges.get(p).add(target);
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_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 " + p.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));
}
});
}

Datei anzeigen

@ -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;
@ -45,7 +46,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 +130,43 @@ 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);
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;
}
if (map == null) {
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 +254,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(description = "CHALLENGE_USAGE")
public void challenge(@Validator("fabric") 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.
*/

Datei anzeigen

@ -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(description = "CHALLENGE_USAGE")
public void challenge(@Validator("fabric") 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",
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<>();
}
}