SteamWar/FightSystem
Archiviert
13
1

Fix join listener

Signed-off-by: Lixfel <agga-games@gmx.de>
Dieser Commit ist enthalten in:
Lixfel 2020-07-19 15:53:10 +02:00
Ursprung a95800e815
Commit 7858a87b60
2 geänderte Dateien mit 33 neuen und 1 gelöschten Zeilen

Datei anzeigen

@ -14,7 +14,7 @@ import java.util.EnumSet;
public class NormalJoinListener extends BasicListener { public class NormalJoinListener extends BasicListener {
public NormalJoinListener() { public NormalJoinListener() {
super(Config.event() || Config.test() ? EnumSet.noneOf(FightState.class) : EnumSet.of(FightState.PRE_LEADER_SETUP)); super(Config.event() || Config.test() || Config.Ranked ? EnumSet.noneOf(FightState.class) : EnumSet.of(FightState.PRE_LEADER_SETUP));
} }
@EventHandler @EventHandler

Datei anzeigen

@ -0,0 +1,32 @@
package de.steamwar.fightsystem.listener;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightTeam;
import de.steamwar.fightsystem.states.FightState;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerJoinEvent;
import java.util.EnumSet;
public class RankedJoinListener extends BasicListener {
public RankedJoinListener() {
super(!Config.event() && Config.Ranked ? EnumSet.of(FightState.PRE_SCHEM_SETUP) : EnumSet.noneOf(FightState.class));
}
@EventHandler
public void handlePlayerJoin(PlayerJoinEvent event) {
Player player = event.getPlayer();
FightTeam fightTeam = Fight.getPlayerTeam(player);
if (fightTeam == null) {
if(!player.getUniqueId().equals(Config.RedLeader) && Fight.getBlueTeam().canbeLeader(player)) {
Fight.getBlueTeam().setLeader(Fight.getBlueTeam().addMember(player));
}else if(Fight.getRedTeam().canbeLeader(player)) {
Fight.getRedTeam().setLeader(Fight.getRedTeam().addMember(player));
}
}
}
}