SteamWar/FightSystem
Archiviert
13
1
Dieses Repository wurde am 2024-08-05 archiviert. Du kannst Dateien ansehen und es klonen, aber nicht pushen oder Issues/Pull-Requests öffnen.
FightSystem/src/me/yaruma/fightsystem/winconditions/WinconditionAllDead.java
Yaruma3341 5c56e47732 PercentSystem rework; Issues: #18 #19 #20
Signed-off-by: Yaruma3341 <yaruma3341@gmail.com>
2019-02-18 20:05:21 +01:00

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;
}
}
}