From 6fe4dbe13ad30c62c5bc258a544ebe843455d9c5 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Tue, 12 Sep 2023 21:48:42 +0200 Subject: [PATCH] Automatic Random arena when not specified Signed-off-by: Lixfel --- .../bungeecore/commands/FightCommand.java | 38 +------------------ .../bungeecore/commands/TypeMappers.java | 9 +---- .../steamwar/messages/BungeeCore.properties | 1 - .../messages/BungeeCore_de.properties | 1 - 4 files changed, 3 insertions(+), 46 deletions(-) diff --git a/src/de/steamwar/bungeecore/commands/FightCommand.java b/src/de/steamwar/bungeecore/commands/FightCommand.java index 42499ee..231f741 100644 --- a/src/de/steamwar/bungeecore/commands/FightCommand.java +++ b/src/de/steamwar/bungeecore/commands/FightCommand.java @@ -87,34 +87,6 @@ public class FightCommand extends SWCommand { sender.sendMessage(ChatMessageType.SYSTEM, start); } - private static void getMaps(ChatSender sender, String precommand, ArenaMode mode){ - TextComponent start = new TextComponent(); - TextComponent current = start; - if(mode.getMaps().size() > 1){ - String command = precommand + mode.getChatName() + " Random"; - start.setBold(true); - start.setColor(ChatColor.GRAY); - start.setText(sender.parseToPlain("FIGHT_ARENA_RANDOM") + " "); - start.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new Text("§e" + command))); - start.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, command)); - current = new TextComponent(); - } - - for(String map : mode.getMaps()){ - String command = precommand + mode.getChatName() + " " + map; - current.setBold(true); - current.setColor(ChatColor.GRAY); - current.setText(map + " "); - current.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new Text("§e" + command))); - current.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, command)); - if(current != start) - start.addExtra(current); - current = new TextComponent(); - } - - sender.sendMessage(ChatMessageType.SYSTEM, start); - } - private static boolean alreadyInArena(ProxiedPlayer player){ Subserver subserver = Subserver.getSubserver(player); if(subserver != null && subserver.getType() == Servertype.ARENA){ @@ -136,16 +108,8 @@ public class FightCommand extends SWCommand { return; } - if (map == null) { - if (arenaMode.getMaps().size() == 1) { - map = arenaMode.getRandomMap(); - } else { - getMaps(sender, precommand, arenaMode); - return; - } - } else if (map.equalsIgnoreCase("random")) { + if (map == null) map = arenaMode.getRandomMap(); - } if (!allowMerging) { callback.run(player, arenaMode, map); diff --git a/src/de/steamwar/bungeecore/commands/TypeMappers.java b/src/de/steamwar/bungeecore/commands/TypeMappers.java index 5b5b409..7ae85ab 100644 --- a/src/de/steamwar/bungeecore/commands/TypeMappers.java +++ b/src/de/steamwar/bungeecore/commands/TypeMappers.java @@ -21,18 +21,16 @@ package de.steamwar.bungeecore.commands; import de.steamwar.bungeecore.ArenaMode; import de.steamwar.bungeecore.listeners.mods.ModLoaderBlocker; -import de.steamwar.sql.Punishment; import de.steamwar.command.SWCommandUtils; import de.steamwar.command.TypeMapper; import de.steamwar.command.TypeValidator; import de.steamwar.messages.ChatSender; +import de.steamwar.sql.Punishment; 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 { @@ -78,7 +76,6 @@ public class TypeMappers { @Override public String map(CommandSender commandSender, String[] previousArguments, String s) { if (previousArguments.length == 0) return null; - if (s.equalsIgnoreCase("random")) return "random"; return ArenaMode.getByChat(previousArguments[previousArguments.length - 1]).convertToRealMapName(s); } @@ -87,9 +84,7 @@ public class TypeMappers { if (previousArguments.length == 0) return null; ArenaMode arenaMode = ArenaMode.getByChat(previousArguments[previousArguments.length - 1]); if (arenaMode == null) return null; - List stringList = new ArrayList<>(arenaMode.getMaps()); - stringList.add("random"); - return stringList; + return arenaMode.getMaps(); } }; } diff --git a/src/de/steamwar/messages/BungeeCore.properties b/src/de/steamwar/messages/BungeeCore.properties index 89b2228..4414a96 100644 --- a/src/de/steamwar/messages/BungeeCore.properties +++ b/src/de/steamwar/messages/BungeeCore.properties @@ -269,7 +269,6 @@ EVENTRESCHEDULE_STARTING=§aFight starts in 30s #FightCommand FIGHT_UNKNOWN_GAMEMODE=§cUnknown gamemode: {0} FIGHT_UNKNOWN_ARENA=§cThe desired arena does not exist. -FIGHT_ARENA_RANDOM=Random FIGHT_IN_ARENA=§cYou are already in an arena. FIGHT_BROADCAST=§7Click §ehere§7 to fight §e{0} §7against §e{1}! FIGHT_BROADCAST_HOVER=§aFight §eagainst §7{1} diff --git a/src/de/steamwar/messages/BungeeCore_de.properties b/src/de/steamwar/messages/BungeeCore_de.properties index 46b3ba1..3ad52ba 100644 --- a/src/de/steamwar/messages/BungeeCore_de.properties +++ b/src/de/steamwar/messages/BungeeCore_de.properties @@ -253,7 +253,6 @@ EVENTRESCHEDULE_STARTING=§aKampf startet in 30s #FightCommand FIGHT_UNKNOWN_GAMEMODE=§cUnbekannter Spielmodus: {0} FIGHT_UNKNOWN_ARENA=§cDie gewünschte Arena gibt es nicht. -FIGHT_ARENA_RANDOM=Random FIGHT_IN_ARENA=§cDu befindest dich bereits in einer Arena. FIGHT_BROADCAST=§7Klicke §ehier§7, um §e{0} §7gegen §e{1} §7zu §7kämpfen! FIGHT_BROADCAST_HOVER=§aGegen §7{1} §ekämpfen