From 2aceb8d47598ebfa3b995dd8290da4745c2bc23d Mon Sep 17 00:00:00 2001 From: Lixfel Date: Sat, 17 Apr 2021 18:00:57 +0200 Subject: [PATCH] Kampfleiter /win command Signed-off-by: Lixfel --- .../de/steamwar/fightsystem/FightSystem.java | 1 + .../fightsystem/commands/WinCommand.java | 49 +++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 FightSystem_Main/src/de/steamwar/fightsystem/commands/WinCommand.java diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/FightSystem.java b/FightSystem_Main/src/de/steamwar/fightsystem/FightSystem.java index 5458ae0..16a8072 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/FightSystem.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/FightSystem.java @@ -125,6 +125,7 @@ public class FightSystem extends JavaPlugin { new LockschemCommand(); new StateCommand(); new SkipCommand(); + new WinCommand(); new OneShotStateDependent(ArenaMode.All, FightState.PreRunning, () -> Bukkit.broadcastMessage(PREFIX + "§aDer Kampf beginnt!")); new OneShotStateDependent(ArenaMode.All, FightState.Running, () -> Bukkit.broadcastMessage(PREFIX + "§aArena freigegeben!")); diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/commands/WinCommand.java b/FightSystem_Main/src/de/steamwar/fightsystem/commands/WinCommand.java new file mode 100644 index 0000000..90aafa6 --- /dev/null +++ b/FightSystem_Main/src/de/steamwar/fightsystem/commands/WinCommand.java @@ -0,0 +1,49 @@ +package de.steamwar.fightsystem.commands; + +import de.steamwar.fightsystem.ArenaMode; +import de.steamwar.fightsystem.FightSystem; +import de.steamwar.fightsystem.fight.Fight; +import de.steamwar.fightsystem.states.FightState; +import de.steamwar.fightsystem.states.StateDependentCommand; +import org.bukkit.Bukkit; +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +public class WinCommand implements CommandExecutor { + + public WinCommand() { + new StateDependentCommand(ArenaMode.Event, FightState.Ingame, "win", this); + } + + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + if(!(sender instanceof Player)) { + return false; + } + Player p = (Player) sender; + + if (p != FightSystem.getEventLeiter()) { + p.sendMessage(FightSystem.PREFIX + "§cDu bist kein Kampfleiter!"); + return false; + } + + if(args.length == 0){ + p.sendMessage(FightSystem.PREFIX + "/win [Team or Tie]"); + return false; + } + + if(args[0].equalsIgnoreCase(Fight.getBlueTeam().getName())){ + Bukkit.broadcastMessage(FightSystem.PREFIX + "§cDer Kampfleiter hat den Kampf entschieden!"); + FightSystem.setSpectateState(Fight.getBlueTeam(), "Referee"); + }else if(args[0].equalsIgnoreCase(Fight.getRedTeam().getName())){ + Bukkit.broadcastMessage(FightSystem.PREFIX + "§cDer Kampfleiter hat den Kampf entschieden!"); + FightSystem.setSpectateState(Fight.getRedTeam(), "Referee"); + }else if(args[0].equalsIgnoreCase("tie")){ + Bukkit.broadcastMessage(FightSystem.PREFIX + "§cDer Kampfleiter hat den Kampf entschieden!"); + FightSystem.setSpectateState(null, "Referee"); + } + return false; + } +} -- 2.39.5