diff --git a/src/de/steamwar/bungeecore/ArenaMode.java b/src/de/steamwar/bungeecore/ArenaMode.java index a661712..aa78a05 100644 --- a/src/de/steamwar/bungeecore/ArenaMode.java +++ b/src/de/steamwar/bungeecore/ArenaMode.java @@ -42,6 +42,7 @@ public class ArenaMode { private final List chatNames; private final String serverJar; private final List maps; + private final boolean historic; private ArenaMode(String internalName, Configuration config){ this.internalName = internalName; @@ -49,6 +50,7 @@ public class ArenaMode { this.serverJar = config.getString("serverJar"); this.chatNames = config.getStringList("chatNames"); this.maps = config.getStringList("maps"); + this.historic = config.getBoolean("historic"); allModes.add(this); byInternal.put(internalName, this); @@ -92,4 +94,8 @@ public class ArenaMode { public boolean hasChatName(){ return !chatNames.isEmpty(); } + + public boolean isHistoric(){ + return historic; + } } diff --git a/src/de/steamwar/bungeecore/BungeeCore.java b/src/de/steamwar/bungeecore/BungeeCore.java index 50283bb..0d6a862 100644 --- a/src/de/steamwar/bungeecore/BungeeCore.java +++ b/src/de/steamwar/bungeecore/BungeeCore.java @@ -92,6 +92,7 @@ public class BungeeCore extends Plugin { new BugCommand(); new WhoisCommand(); new RegelnCommand(); + new HistoricCommand(); new EventStarter(); new Broadcaster(); diff --git a/src/de/steamwar/bungeecore/commands/ChallengeCommand.java b/src/de/steamwar/bungeecore/commands/ChallengeCommand.java index 3b3636b..456c904 100644 --- a/src/de/steamwar/bungeecore/commands/ChallengeCommand.java +++ b/src/de/steamwar/bungeecore/commands/ChallengeCommand.java @@ -35,7 +35,7 @@ public class ChallengeCommand extends BasicCommand { return; } - FightCommand.createArena(sender, "/challenge " + target.getName() + " ", args, 1, (player, mode, map) -> { + FightCommand.createArena(sender, "/challenge " + target.getName() + " ", args, 1, false, (player, mode, map) -> { if(challenges.containsKey(target) && challenges.get(target).contains(player)){ challenges.remove(target); challenges.remove(player); diff --git a/src/de/steamwar/bungeecore/commands/FightCommand.java b/src/de/steamwar/bungeecore/commands/FightCommand.java index d744552..458d479 100644 --- a/src/de/steamwar/bungeecore/commands/FightCommand.java +++ b/src/de/steamwar/bungeecore/commands/FightCommand.java @@ -46,11 +46,11 @@ public class FightCommand extends BasicCommand { return null; } - private static void getModes(CommandSender sender, String precommand){ + private static void getModes(CommandSender sender, String precommand, boolean historic){ TextComponent start = new TextComponent(); TextComponent current = start; for(ArenaMode mode : ArenaMode.getAllModes()){ - if(!mode.hasChatName()) + if(!mode.hasChatName() || mode.isHistoric() != historic) continue; String command = precommand + mode.getChatName(); current.setBold(true); @@ -104,7 +104,7 @@ public class FightCommand extends BasicCommand { return false; } - static void createArena(CommandSender sender, String precommand, String[] args, int startArg, FightCallback callback){ + static void createArena(CommandSender sender, String precommand, String[] args, int startArg, boolean historic, FightCallback callback){ if(!(sender instanceof ProxiedPlayer)) return; @@ -113,7 +113,7 @@ public class FightCommand extends BasicCommand { return; if(args.length < startArg+1){ - getModes(sender, precommand); + getModes(sender, precommand, historic); return; } @@ -139,7 +139,7 @@ public class FightCommand extends BasicCommand { @Override public void execute(CommandSender sender, String[] args) { - createArena(sender, "/fight ", args, 0, (player, mode, map) -> { + createArena(sender, "/fight ", args, 0, false, (player, mode, map) -> { Subserver arena = SubserverSystem.startArena(mode, map, 0, null, null, player.getUniqueId(), null); arena.sendPlayer(player); TextComponent tc = new TextComponent(BungeeCore.CHAT_PREFIX + "§7Klicke §ehier§7, um §e" + mode.getDisplayName() + " §7gegen §e" + player.getName() + " §7zu §7kämpfen!"); diff --git a/src/de/steamwar/bungeecore/commands/HelpCommand.java b/src/de/steamwar/bungeecore/commands/HelpCommand.java index f34c36f..493d739 100644 --- a/src/de/steamwar/bungeecore/commands/HelpCommand.java +++ b/src/de/steamwar/bungeecore/commands/HelpCommand.java @@ -41,6 +41,11 @@ public class HelpCommand extends BasicCommand { tc.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/challenge")); sender.sendMessage(tc); + tc = new TextComponent(BungeeCore.CHAT_PREFIX + "§7Starte mit §8/§ehistoric §7einen historischen Kampf!"); + tc.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("§eHistorische Kämpfe").create())); + tc.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/historic")); + sender.sendMessage(tc); + tc = new TextComponent(BungeeCore.CHAT_PREFIX + "§8/§eteam§7 für das Teamsystem!"); tc.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("§eTeamverwaltung").create())); tc.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/team")); diff --git a/src/de/steamwar/bungeecore/commands/HistoricCommand.java b/src/de/steamwar/bungeecore/commands/HistoricCommand.java new file mode 100644 index 0000000..078b9d9 --- /dev/null +++ b/src/de/steamwar/bungeecore/commands/HistoricCommand.java @@ -0,0 +1,45 @@ +package de.steamwar.bungeecore.commands; + +import de.steamwar.bungeecore.ArenaMode; +import de.steamwar.bungeecore.BungeeCore; +import de.steamwar.bungeecore.Subserver; +import de.steamwar.bungeecore.SubserverSystem; +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.chat.ComponentBuilder; +import net.md_5.bungee.api.chat.HoverEvent; +import net.md_5.bungee.api.chat.TextComponent; + +import java.util.LinkedList; + +public class HistoricCommand extends BasicCommand { + public HistoricCommand() { + super("historic", null); + } + + @Override + public void execute(CommandSender sender, String[] args) { + FightCommand.createArena(sender, "/historic ", args, 0, true, (player, mode, map) -> { + Subserver arena = SubserverSystem.startArena(mode, map, 0, null, null, player.getUniqueId(), null); + arena.sendPlayer(player); + TextComponent tc = new TextComponent(BungeeCore.CHAT_PREFIX + "§7Historischer §e" + mode.getDisplayName() + "§8-§7Kampf von §e" + player.getName() + " §8!"); + tc.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("§aGegen §7" + player.getName() + " §ekämpfen").create())); + tc.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/join " + player.getName())); + ProxyServer.getInstance().broadcast(tc); + }); + } + + @Override + public Iterable onTabComplete(CommandSender commandSender, String[] args) { + if(args.length == 1){ + return ArenaMode.getAllChatNames(); + }else if(args.length == 2){ + ArenaMode mode = ArenaMode.getByChat(args[1]); + if(mode == null) + return new LinkedList<>(); + return mode.getMaps(); + } + return new LinkedList<>(); + } +}