SteamWar/FightSystem
Archiviert
13
1

TechKO & FightTeamRemove fix (untested due to Server "belegt")

Dieser Commit ist enthalten in:
lixfel 2019-04-14 15:07:40 +02:00
Ursprung f5b1f23b63
Commit b95cd479e0
3 geänderte Dateien mit 26 neuen und 65 gelöschten Zeilen

Datei anzeigen

@ -100,7 +100,11 @@ public class FightTeam {
}
public void removePlayer(Player player) {
FightPlayer fightPlayer = Fight.getPlayerTeam(player).getFightPlayer(player);
FightPlayer fightPlayer = getFightPlayer(player);
if(fightPlayer == null){
System.out.println("FightPlayer == null! : " + player.getName());
return;
}
players.remove(fightPlayer);
if(fightPlayer.isLeader())
this.leader = null;
@ -152,13 +156,6 @@ public class FightTeam {
}
schem.paste(w, v, false, true, aT).flushQueue();
teleportToSpawn();
Bukkit.getScheduler().scheduleSyncDelayedTask(FightSystem.getPlugin(), new Runnable() {
@Override
public void run() {
Bukkit.broadcastMessage("ADD WATER");
WinconditionTechKO.addWater();
}
}, 20*10L);
}
public void setSchematic(Schematic schematic){
@ -166,6 +163,7 @@ public class FightTeam {
if(Fight.getOpposite(this).hasSchematic()){
pasteSchematic();
Fight.getOpposite(this).pasteSchematic();
Bukkit.getScheduler().scheduleSyncDelayedTask(FightSystem.getPlugin(), () -> WinconditionTechKO.addWater(), 20*10L);
}
}

Datei anzeigen

@ -2,21 +2,18 @@ package me.yaruma.fightsystem.listener;
import me.yaruma.fightsystem.FightSystem;
import me.yaruma.fightsystem.fight.Fight;
import me.yaruma.fightsystem.fight.FightPlayer;
import me.yaruma.fightsystem.fight.FightState;
import me.yaruma.fightsystem.fight.FightTeam;
import me.yaruma.fightsystem.utils.Config;
import me.yaruma.fightsystem.utils.countdown.Countdown;
import me.yaruma.fightsystem.utils.countdown.FinishNoPlayersOnline;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerQuitEvent;
public class PlayerQuitListener implements Listener {
@EventHandler
@EventHandler(priority = EventPriority.HIGH)
public void handlePlayerQuit(PlayerQuitEvent event) {
event.setQuitMessage(null);
@ -25,51 +22,21 @@ public class PlayerQuitListener implements Listener {
FightTeam fightTeam = Fight.getPlayerTeam(player);
FightState fightState = FightSystem.getPlugin().getFightState();
if(!fightTeam.getFightPlayer(player).isLeader()) {
if(fightState == FightState.PRE_RUNNING
|| fightState == FightState.RUNNING) {
fightTeam.getFightPlayer(player).setOut(true);
} else if(fightState == FightState.SETUP) {
fightTeam.removePlayer(player);
}
Bukkit.broadcastMessage(FightSystem.PREFIX + "§cDer Spieler §6" + player.getName() + " §chat den Kampf verlassen!");
} else {
if(fightState == FightState.SETUP){
fightTeam.removePlayer(player);
if(fightTeam.isPlayerLeader(player)){
if(!fightTeam.getPlayers().isEmpty()) {
fightTeam.setLeader(fightTeam.getPlayers().get(0));
Bukkit.broadcastMessage(FightSystem.PREFIX + "§aDer Spieler §6" + fightTeam.getLeader().getPlayer().getDisplayName() + " §aist nun Leader von Team " + (fightTeam.getName() == Fight.getRedTeam().getName() ?
Config.TeamRedPrefix + Config.TeamRedName : Config.TeamBluePrefix + Config.TeamBlueName + "§a!"));
Bukkit.broadcastMessage(FightSystem.PREFIX + "§aDer Spieler §6" + fightTeam.getLeader().getPlayer().getName() + " §aist nun Leader von Team " + fightTeam.getName() + "§a!");
}else{
for(Player players : Bukkit.getServer().getOnlinePlayers()) {
if(Fight.getPlayerTeam(players) == null) {
if(fightTeam.getLeader() == null) {
FightPlayer fightPlayer = new FightPlayer(players, false);
fightTeam.setLeader(fightPlayer);
Bukkit.broadcastMessage(FightSystem.PREFIX + "§aDer Spieler §6" + fightTeam.getLeader().getPlayer().getDisplayName() + " §aist nun Leader von Team " + (fightTeam.getName() == Fight.getRedTeam().getName() ?
Config.TeamRedPrefix + Config.TeamRedName : Config.TeamBluePrefix + Config.TeamBlueName + "§a!"));
}
}
}
if(fightTeam.getLeader() == null) {
Bukkit.broadcastMessage(FightSystem.PREFIX + "§6Es gibt keine Spieler mehr die den Leader ersetzen können! \n Server stoppt...");
Bukkit.broadcastMessage(FightSystem.PREFIX + "§6Team " + fightTeam.getName() + " hat keine Spieler mehr.\n Server stoppt...");
Bukkit.shutdown();
}
}
}else if(fightState == FightState.PRE_RUNNING || fightState == FightState.RUNNING){
fightTeam.getFightPlayer(player).setOut(true);
if(!Config.AllDead && !Config.CaptainDead)
Bukkit.broadcastMessage(FightSystem.PREFIX + "§cDer Spieler §6" + player.getName() + " §chat den Kampf verlassen!");
}
}
if(fightTeam.getPlayers().isEmpty() && FightSystem.getPlugin().getFightState() == FightState.SETUP) {
Bukkit.broadcastMessage(FightSystem.PREFIX + "§cAlle Spieler aus dem Team " + fightTeam.getName() + " §chaben den Kampf verlassen!");
Countdown countdown = new Countdown(30, new FinishNoPlayersOnline());
countdown.startTimer(FightSystem.getPlugin());
}
}
}

Datei anzeigen

@ -74,6 +74,7 @@ public class WinconditionTechKO {
}
public static void removeWater() {
if(!Config.TechKO) return;
//Team Red
Iterator itrRed = teamRedWater.iterator();
@ -108,12 +109,7 @@ public class WinconditionTechKO {
public static void startAutoChecker() {
if(!Config.TechKO) return;
taskID = Bukkit.getScheduler().scheduleAsyncRepeatingTask(FightSystem.getPlugin(), new Runnable() {
@Override
public void run() {
addWater();
}
}, 0, 20*20);
taskID = Bukkit.getScheduler().scheduleAsyncRepeatingTask(FightSystem.getPlugin(), () -> addWater(), 0, 20*20);
}
}