2019-09-05 18:26:13 +02:00
|
|
|
package de.steamwar.fightsystem.winconditions;
|
|
|
|
|
|
|
|
import de.steamwar.fightsystem.FightSystem;
|
|
|
|
import de.steamwar.fightsystem.fight.Fight;
|
|
|
|
import de.steamwar.fightsystem.fight.FightTeam;
|
2019-11-16 08:37:33 +01:00
|
|
|
import de.steamwar.fightsystem.Config;
|
2019-09-05 18:26:13 +02:00
|
|
|
import org.bukkit.Bukkit;
|
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
import org.bukkit.event.EventHandler;
|
|
|
|
import org.bukkit.event.entity.PlayerDeathEvent;
|
|
|
|
import org.bukkit.event.player.PlayerQuitEvent;
|
|
|
|
|
|
|
|
public class WinconditionAllDead extends PlayerWincondition {
|
|
|
|
|
|
|
|
public WinconditionAllDead(){
|
2020-01-11 15:44:40 +01:00
|
|
|
super(Config.AllDead);
|
2019-09-05 18:26:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@EventHandler
|
|
|
|
public void handlePlayerDeath(PlayerDeathEvent event) {
|
2019-12-22 15:20:50 +01:00
|
|
|
handleDeath(event.getEntity().getPlayer(), " §cist gestorben!");
|
2019-09-05 18:26:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@EventHandler
|
|
|
|
public void handlePlayerQuit(PlayerQuitEvent event) {
|
2019-12-22 15:20:50 +01:00
|
|
|
handleDeath(event.getPlayer(), " §chat den Kampf verlassen!");
|
|
|
|
}
|
2019-09-05 18:26:13 +02:00
|
|
|
|
2019-12-22 15:20:50 +01:00
|
|
|
private void handleDeath(Player player, String message){
|
2019-09-05 18:26:13 +02:00
|
|
|
if(!isTarget(player))
|
|
|
|
return;
|
|
|
|
|
|
|
|
FightTeam fightTeam = Fight.getPlayerTeam(player);
|
2019-12-22 15:20:50 +01:00
|
|
|
assert fightTeam != null; // Checked with isTarget
|
2019-09-05 18:26:13 +02:00
|
|
|
if(fightTeam.allPlayersOut()) {
|
2019-12-22 15:20:50 +01:00
|
|
|
Bukkit.broadcastMessage(FightSystem.PREFIX + "§cDer letzte Spieler aus " + fightTeam.getColoredName() + message);
|
2020-01-23 17:33:29 +01:00
|
|
|
FightSystem.setSpectateState(Fight.getOpposite(fightTeam), "AllDead");
|
2019-09-05 18:26:13 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|