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 WinconditionCaptainDead extends PlayerWincondition {
|
|
|
|
|
|
|
|
public WinconditionCaptainDead(){
|
|
|
|
init(Config.CaptainDead);
|
|
|
|
}
|
|
|
|
|
|
|
|
@EventHandler
|
|
|
|
public void handlePlayerDeath(PlayerDeathEvent event) {
|
|
|
|
Player player = event.getEntity().getPlayer();
|
|
|
|
|
|
|
|
if(!isTarget(player))
|
|
|
|
return;
|
|
|
|
|
|
|
|
FightTeam fightTeam = Fight.getPlayerTeam(player);
|
|
|
|
if(fightTeam.isPlayerLeader(player)) {
|
2019-11-21 16:09:58 +01:00
|
|
|
Bukkit.broadcastMessage(FightSystem.PREFIX + "§cDer Leader von " + fightTeam.getPrefix() + fightTeam.getColoredName() + " §cist gestorben!");
|
2019-09-05 18:26:13 +02:00
|
|
|
FightSystem.setSpectateState(Fight.getOpposite(fightTeam));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@EventHandler
|
|
|
|
public void handlePlayerQuit(PlayerQuitEvent event) {
|
|
|
|
Player player = event.getPlayer();
|
|
|
|
|
|
|
|
if(!isTarget(player))
|
|
|
|
return;
|
|
|
|
|
|
|
|
FightTeam fightTeam = Fight.getPlayerTeam(player);
|
|
|
|
if(fightTeam.isPlayerLeader(player)) {
|
2019-11-21 16:09:58 +01:00
|
|
|
Bukkit.broadcastMessage(FightSystem.PREFIX + "§cDer Leader von " + fightTeam.getPrefix() + fightTeam.getColoredName() + " §chat den Kampf verlassen!");
|
2019-09-05 18:26:13 +02:00
|
|
|
FightSystem.setSpectateState(Fight.getOpposite(fightTeam));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|