TechKO & FightTeamRemove fix (untested due to Server "belegt")
Dieser Commit ist enthalten in:
Ursprung
f5b1f23b63
Commit
b95cd479e0
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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(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!"));
|
||||
} 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.shutdown();
|
||||
}
|
||||
Bukkit.broadcastMessage(FightSystem.PREFIX + "§aDer Spieler §6" + fightTeam.getLeader().getPlayer().getName() + " §aist nun Leader von Team " + fightTeam.getName() + "§a!");
|
||||
}else{
|
||||
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());
|
||||
}else if(fightState == FightState.PRE_RUNNING || fightState == FightState.RUNNING){
|
||||
fightTeam.getFightPlayer(player).setOut(true);
|
||||
Bukkit.broadcastMessage(FightSystem.PREFIX + "§cDer Spieler §6" + player.getName() + " §chat den Kampf verlassen!");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -62,18 +62,19 @@ public class WinconditionTechKO {
|
||||
|
||||
if(teamRedWater.isEmpty()) {
|
||||
Bukkit.getScheduler().cancelTask(taskID);
|
||||
Bukkit.broadcastMessage(FightSystem.PREFIX + "§6Das Team " + Config.TeamRedPrefix + Config.TeamRedName + " §6ist Tech K.O. !");
|
||||
Bukkit.broadcastMessage(FightSystem.PREFIX + "§6Das Team " + Config.TeamRedPrefix + Config.TeamRedName + " §6ist Tech K.O.!");
|
||||
FightSystem.getPlugin().setSpectateState(Fight.getBlueTeam());
|
||||
FightSystem.getPlugin().getWaterRemover().stop();
|
||||
} else if(teamBlueWater.isEmpty()) {
|
||||
Bukkit.getScheduler().cancelTask(taskID);
|
||||
Bukkit.broadcastMessage(FightSystem.PREFIX + "§6Das Team " + Config.TeamBluePrefix + Config.TeamBlueName + " §6ist Tech K.O. !");
|
||||
Bukkit.broadcastMessage(FightSystem.PREFIX + "§6Das Team " + Config.TeamBluePrefix + Config.TeamBlueName + " §6ist Tech K.O.!");
|
||||
FightSystem.getPlugin().setSpectateState(Fight.getRedTeam());
|
||||
FightSystem.getPlugin().getWaterRemover().stop();
|
||||
}
|
||||
}
|
||||
|
||||
public static void removeWater() {
|
||||
if(!Config.TechKO) return;
|
||||
|
||||
//Team Red
|
||||
Iterator itrRed = teamRedWater.iterator();
|
||||
@ -85,7 +86,7 @@ public class WinconditionTechKO {
|
||||
}
|
||||
if(teamRedWater.isEmpty()) {
|
||||
Bukkit.getScheduler().cancelTask(taskID);
|
||||
Bukkit.broadcastMessage(FightSystem.PREFIX + "§6Das Team " + Config.TeamRedPrefix + Config.TeamRedName + " §6ist Tech K.O. !");
|
||||
Bukkit.broadcastMessage(FightSystem.PREFIX + "§6Das Team " + Config.TeamRedPrefix + Config.TeamRedName + " §6ist Tech K.O.!");
|
||||
FightSystem.getPlugin().setSpectateState(Fight.getBlueTeam());
|
||||
FightSystem.getPlugin().getWaterRemover().stop();
|
||||
}
|
||||
@ -100,7 +101,7 @@ public class WinconditionTechKO {
|
||||
}
|
||||
if(teamBlueWater.isEmpty()) {
|
||||
Bukkit.getScheduler().cancelTask(taskID);
|
||||
Bukkit.broadcastMessage(FightSystem.PREFIX + "§6Das Team " + Config.TeamBluePrefix + Config.TeamBlueName + " §6ist Tech K.O. !");
|
||||
Bukkit.broadcastMessage(FightSystem.PREFIX + "§6Das Team " + Config.TeamBluePrefix + Config.TeamBlueName + " §6ist Tech K.O.!");
|
||||
FightSystem.getPlugin().setSpectateState(Fight.getRedTeam());
|
||||
FightSystem.getPlugin().getWaterRemover().stop();
|
||||
}
|
||||
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren