41 Zeilen
1.3 KiB
Java
41 Zeilen
1.3 KiB
Java
package de.steamwar.fightsystem.winconditions;
|
|
|
|
import de.steamwar.fightsystem.FightSystem;
|
|
import de.steamwar.fightsystem.fight.Fight;
|
|
import de.steamwar.fightsystem.fight.FightTeam;
|
|
import de.steamwar.fightsystem.Config;
|
|
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) {
|
|
handleDeath(event.getEntity().getPlayer(), " §cist gestorben!");
|
|
}
|
|
|
|
@EventHandler
|
|
public void handlePlayerQuit(PlayerQuitEvent event) {
|
|
handleDeath(event.getPlayer(), " §chat den Kampf verlassen!");
|
|
}
|
|
|
|
private void handleDeath(Player player, String message){
|
|
if(!isTarget(player))
|
|
return;
|
|
|
|
FightTeam fightTeam = Fight.getPlayerTeam(player);
|
|
assert fightTeam != null; // Checked with isTarget
|
|
if(fightTeam.isPlayerLeader(player)) {
|
|
Bukkit.broadcastMessage(FightSystem.PREFIX + "§cDer Leader von " + fightTeam.getColoredName() + message);
|
|
FightSystem.setSpectateState(Fight.getOpposite(fightTeam));
|
|
}
|
|
}
|
|
}
|