49 Zeilen
1.7 KiB
Java
49 Zeilen
1.7 KiB
Java
package me.yaruma.fightsystem.winconditions;
|
|
|
|
import me.yaruma.fightsystem.FightSystem;
|
|
import me.yaruma.fightsystem.fight.Fight;
|
|
import me.yaruma.fightsystem.fight.FightPlayer;
|
|
import me.yaruma.fightsystem.fight.FightTeam;
|
|
import org.bukkit.Bukkit;
|
|
import org.bukkit.entity.Player;
|
|
import org.bukkit.event.EventHandler;
|
|
import org.bukkit.event.Listener;
|
|
import org.bukkit.event.entity.PlayerDeathEvent;
|
|
import org.bukkit.event.player.PlayerQuitEvent;
|
|
|
|
public class WinconditionAllDead implements Listener {
|
|
|
|
FightSystem instance = FightSystem.getPlugin();
|
|
|
|
@EventHandler
|
|
public void handlePlayerDeath(PlayerDeathEvent event) {
|
|
if(!Methods.isEnabled("WinConditions.AllDead")) return;
|
|
Player player = event.getEntity().getPlayer();
|
|
if(Fight.getPlayerTeam(player) == null) return;
|
|
FightTeam fightTeam = Fight.getPlayerTeam(player);
|
|
FightTeam oppositeFightTeam = Fight.getOpposite(fightTeam);
|
|
|
|
if(fightTeam.allPlayersOut()) {
|
|
Bukkit.broadcastMessage(FightSystem.PREFIX + "§cAlle Spieler aus dem Team von " + fightTeam.getLeader().getPlayer().getName() + " §csind gestorben!");
|
|
instance.setSpectateState(oppositeFightTeam);
|
|
return;
|
|
}
|
|
}
|
|
|
|
@EventHandler
|
|
public void handlePlayerQuit(PlayerQuitEvent event) {
|
|
if(!Methods.isEnabled("WinConditions.AllDead")) return;
|
|
Player player = event.getPlayer();
|
|
if(Fight.getPlayerTeam(player) == null) return;
|
|
FightTeam fightTeam = Fight.getPlayerTeam(player);
|
|
FightTeam oppositeFightTeam = Fight.getOpposite(fightTeam);
|
|
|
|
if(fightTeam.allPlayersOut()) {
|
|
instance.setSpectateState(oppositeFightTeam);
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
}
|