Merge pull request 'Add ranked rework' (#336) from Ranked into master
Einige Prüfungen sind fehlgeschlagen
SteamWarCI Build failed
Einige Prüfungen sind fehlgeschlagen
SteamWarCI Build failed
Reviewed-on: #336 Reviewed-by: Lixfel <lixfel@steamwar.de>
Dieser Commit ist enthalten in:
Commit
6ce1be850a
@ -25,7 +25,6 @@ import java.util.Set;
|
|||||||
|
|
||||||
public enum ArenaMode {
|
public enum ArenaMode {
|
||||||
NORMAL,
|
NORMAL,
|
||||||
RANKED,
|
|
||||||
EVENT,
|
EVENT,
|
||||||
TEST,
|
TEST,
|
||||||
CHECK,
|
CHECK,
|
||||||
@ -38,7 +37,6 @@ public enum ArenaMode {
|
|||||||
public static final Set<ArenaMode> Check = Collections.unmodifiableSet(EnumSet.of(CHECK));
|
public static final Set<ArenaMode> Check = Collections.unmodifiableSet(EnumSet.of(CHECK));
|
||||||
public static final Set<ArenaMode> Event = Collections.unmodifiableSet(EnumSet.of(EVENT));
|
public static final Set<ArenaMode> Event = Collections.unmodifiableSet(EnumSet.of(EVENT));
|
||||||
public static final Set<ArenaMode> Test = Collections.unmodifiableSet(EnumSet.of(TEST, CHECK));
|
public static final Set<ArenaMode> Test = Collections.unmodifiableSet(EnumSet.of(TEST, CHECK));
|
||||||
public static final Set<ArenaMode> Ranked = Collections.unmodifiableSet(EnumSet.of(RANKED));
|
|
||||||
public static final Set<ArenaMode> Prepare = Collections.unmodifiableSet(EnumSet.of(PREPARE));
|
public static final Set<ArenaMode> Prepare = Collections.unmodifiableSet(EnumSet.of(PREPARE));
|
||||||
public static final Set<ArenaMode> Replay = Collections.unmodifiableSet(EnumSet.of(REPLAY, TEST));
|
public static final Set<ArenaMode> Replay = Collections.unmodifiableSet(EnumSet.of(REPLAY, TEST));
|
||||||
|
|
||||||
@ -46,9 +44,9 @@ public enum ArenaMode {
|
|||||||
public static final Set<ArenaMode> AntiTest = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(TEST, CHECK)));
|
public static final Set<ArenaMode> AntiTest = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(TEST, CHECK)));
|
||||||
public static final Set<ArenaMode> AntiEvent = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(EVENT)));
|
public static final Set<ArenaMode> AntiEvent = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(EVENT)));
|
||||||
public static final Set<ArenaMode> AntiPrepare = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(PREPARE)));
|
public static final Set<ArenaMode> AntiPrepare = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(PREPARE)));
|
||||||
public static final Set<ArenaMode> VariableTeams = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(RANKED, EVENT, REPLAY)));
|
public static final Set<ArenaMode> VariableTeams = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(EVENT, REPLAY)));
|
||||||
public static final Set<ArenaMode> RankedEvent = Collections.unmodifiableSet(EnumSet.of(RANKED, EVENT, REPLAY));
|
public static final Set<ArenaMode> RankedEvent = Collections.unmodifiableSet(EnumSet.of(EVENT, REPLAY));
|
||||||
public static final Set<ArenaMode> Restartable = Collections.unmodifiableSet(EnumSet.of(NORMAL, RANKED));
|
public static final Set<ArenaMode> Restartable = Collections.unmodifiableSet(EnumSet.of(NORMAL));
|
||||||
public static final Set<ArenaMode> NotRestartable = Collections.unmodifiableSet(EnumSet.of(EVENT, REPLAY));
|
public static final Set<ArenaMode> NotRestartable = Collections.unmodifiableSet(EnumSet.of(EVENT, REPLAY));
|
||||||
public static final Set<ArenaMode> SoloLeader = Collections.unmodifiableSet(EnumSet.of(TEST, CHECK, PREPARE));
|
public static final Set<ArenaMode> SoloLeader = Collections.unmodifiableSet(EnumSet.of(TEST, CHECK, PREPARE));
|
||||||
public static final Set<ArenaMode> NotOnBau = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(TEST, CHECK, PREPARE, REPLAY)));
|
public static final Set<ArenaMode> NotOnBau = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(TEST, CHECK, PREPARE, REPLAY)));
|
||||||
|
@ -92,7 +92,6 @@ public class Config {
|
|||||||
public static final String TeamChatDetection;
|
public static final String TeamChatDetection;
|
||||||
public static final UUID BlueLeader;
|
public static final UUID BlueLeader;
|
||||||
public static final UUID RedLeader;
|
public static final UUID RedLeader;
|
||||||
public static final boolean Ranked;
|
|
||||||
|
|
||||||
//Active win conditions
|
//Active win conditions
|
||||||
public static final Set<Winconditions> ActiveWinconditions;
|
public static final Set<Winconditions> ActiveWinconditions;
|
||||||
@ -370,12 +369,9 @@ public class Config {
|
|||||||
|
|
||||||
CheckSchemID = Integer.parseInt(System.getProperty("checkSchemID", "0"));
|
CheckSchemID = Integer.parseInt(System.getProperty("checkSchemID", "0"));
|
||||||
PrepareSchemID = Integer.parseInt(System.getProperty("prepareSchemID", "0"));
|
PrepareSchemID = Integer.parseInt(System.getProperty("prepareSchemID", "0"));
|
||||||
Ranked = Boolean.parseBoolean(System.getProperty("ranked", "false"));
|
|
||||||
ReplayID = Integer.parseInt(System.getProperty("replay", "0"));
|
ReplayID = Integer.parseInt(System.getProperty("replay", "0"));
|
||||||
|
|
||||||
if(Ranked){
|
if(CheckSchemID != 0){
|
||||||
mode = ArenaMode.RANKED;
|
|
||||||
}else if(CheckSchemID != 0){
|
|
||||||
mode = ArenaMode.CHECK;
|
mode = ArenaMode.CHECK;
|
||||||
}else if(PrepareSchemID != 0){
|
}else if(PrepareSchemID != 0){
|
||||||
mode = ArenaMode.PREPARE;
|
mode = ArenaMode.PREPARE;
|
||||||
|
@ -87,7 +87,6 @@ public class FightSystem extends JavaPlugin {
|
|||||||
new PrepareSchem();
|
new PrepareSchem();
|
||||||
new TestJoin();
|
new TestJoin();
|
||||||
new NormalJoin();
|
new NormalJoin();
|
||||||
new RankedJoin();
|
|
||||||
new RunningWorldInteraction();
|
new RunningWorldInteraction();
|
||||||
new PersonalKitCreator();
|
new PersonalKitCreator();
|
||||||
new ArrowStopper();
|
new ArrowStopper();
|
||||||
@ -114,7 +113,6 @@ public class FightSystem extends JavaPlugin {
|
|||||||
new WinconditionHeartRatioTimeout();
|
new WinconditionHeartRatioTimeout();
|
||||||
new WinconditionTimeTechKO();
|
new WinconditionTimeTechKO();
|
||||||
new EventTeamOffWincondition();
|
new EventTeamOffWincondition();
|
||||||
new RankedPlayerLeftWincondition();
|
|
||||||
new WinconditionPercentTimeout();
|
new WinconditionPercentTimeout();
|
||||||
|
|
||||||
new HellsBells();
|
new HellsBells();
|
||||||
|
@ -180,7 +180,6 @@ UI_PLAYER_LEAVES=
|
|||||||
UI_LEADER_JOINS=§a§l» {0}Leader {1}
|
UI_LEADER_JOINS=§a§l» {0}Leader {1}
|
||||||
UI_PLAYER_DEATH={0}{1} §7ist gestorben
|
UI_PLAYER_DEATH={0}{1} §7ist gestorben
|
||||||
UI_PLAYER_LEAVE={0}{1} §7hat den Kampf verlassen
|
UI_PLAYER_LEAVE={0}{1} §7hat den Kampf verlassen
|
||||||
UI_ELO=§7ELO von {0}{1}§8: §7{2}§8»§e{3}
|
|
||||||
UI_WIN={0}Sieg {1}
|
UI_WIN={0}Sieg {1}
|
||||||
UI_DRAW=§7Unentschieden
|
UI_DRAW=§7Unentschieden
|
||||||
|
|
||||||
@ -232,7 +231,6 @@ WIN_FIGHTLEADER=
|
|||||||
WIN_PERCENT={0} §7zu beschädigt
|
WIN_PERCENT={0} §7zu beschädigt
|
||||||
WIN_OFFLINE_BOTH=§7Beide Teams offline
|
WIN_OFFLINE_BOTH=§7Beide Teams offline
|
||||||
WIN_OFFLINE={0} §7offline
|
WIN_OFFLINE={0} §7offline
|
||||||
WIN_RANKED_LEFT={0} §7hat den Kampf verlassen
|
|
||||||
WIN_ALL_DEAD={0}Alle Spieler kampfunfähig
|
WIN_ALL_DEAD={0}Alle Spieler kampfunfähig
|
||||||
WIN_LEADER_DEAD={0} kampfunfähig
|
WIN_LEADER_DEAD={0} kampfunfähig
|
||||||
WIN_TIME_OVER=§7Zeit abgelaufen
|
WIN_TIME_OVER=§7Zeit abgelaufen
|
||||||
|
@ -1,52 +0,0 @@
|
|||||||
/*
|
|
||||||
This file is a part of the SteamWar software.
|
|
||||||
|
|
||||||
Copyright (C) 2020 SteamWar.de-Serverteam
|
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU Affero General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU Affero General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Affero General Public License
|
|
||||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package de.steamwar.fightsystem.listener;
|
|
||||||
|
|
||||||
import de.steamwar.fightsystem.ArenaMode;
|
|
||||||
import de.steamwar.fightsystem.Config;
|
|
||||||
import de.steamwar.fightsystem.fight.Fight;
|
|
||||||
import de.steamwar.fightsystem.fight.FightTeam;
|
|
||||||
import de.steamwar.fightsystem.states.FightState;
|
|
||||||
import de.steamwar.fightsystem.states.StateDependentListener;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
|
||||||
|
|
||||||
public class RankedJoin implements Listener {
|
|
||||||
|
|
||||||
public RankedJoin() {
|
|
||||||
new StateDependentListener(ArenaMode.Ranked, FightState.PreLeaderSetup, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@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().addMember(player);
|
|
||||||
}else if(Fight.getRedTeam().canbeLeader(player)) {
|
|
||||||
Fight.getRedTeam().addMember(player);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
package de.steamwar.fightsystem.utils;
|
package de.steamwar.fightsystem.utils;
|
||||||
|
|
||||||
|
import de.steamwar.comms.packets.FightEndsPacket;
|
||||||
import de.steamwar.fightsystem.ArenaMode;
|
import de.steamwar.fightsystem.ArenaMode;
|
||||||
import de.steamwar.fightsystem.Config;
|
import de.steamwar.fightsystem.Config;
|
||||||
import de.steamwar.fightsystem.FightSystem;
|
import de.steamwar.fightsystem.FightSystem;
|
||||||
@ -30,16 +31,17 @@ import de.steamwar.fightsystem.record.FileRecorder;
|
|||||||
import de.steamwar.fightsystem.states.FightState;
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
import de.steamwar.fightsystem.states.OneShotStateDependent;
|
import de.steamwar.fightsystem.states.OneShotStateDependent;
|
||||||
import de.steamwar.fightsystem.winconditions.Wincondition;
|
import de.steamwar.fightsystem.winconditions.Wincondition;
|
||||||
import de.steamwar.sql.Elo;
|
|
||||||
import de.steamwar.sql.SchematicNode;
|
import de.steamwar.sql.SchematicNode;
|
||||||
import de.steamwar.sql.SteamwarUser;
|
import de.steamwar.sql.SteamwarUser;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.time.temporal.ChronoUnit;
|
import java.time.temporal.ChronoUnit;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static de.steamwar.sql.Fight.create;
|
import static de.steamwar.sql.Fight.create;
|
||||||
import static de.steamwar.sql.Fight.setReplay;
|
import static de.steamwar.sql.Fight.setReplay;
|
||||||
@ -61,7 +63,7 @@ public class FightStatistics {
|
|||||||
new OneShotStateDependent(ArenaMode.SeriousFight, FightState.Spectate, () -> Bukkit.getScheduler().runTask(FightSystem.getPlugin(), this::disable));
|
new OneShotStateDependent(ArenaMode.SeriousFight, FightState.Spectate, () -> Bukkit.getScheduler().runTask(FightSystem.getPlugin(), this::disable));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void enable(){
|
private void enable() {
|
||||||
starttime = Timestamp.from(Instant.now());
|
starttime = Timestamp.from(Instant.now());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -84,32 +86,32 @@ public class FightStatistics {
|
|||||||
|
|
||||||
int win = 0;
|
int win = 0;
|
||||||
double blueResult;
|
double blueResult;
|
||||||
if(winner == Fight.getBlueTeam()) {
|
if (winner == Fight.getBlueTeam()) {
|
||||||
win = 1;
|
win = 1;
|
||||||
blueResult = 1;
|
blueResult = 1;
|
||||||
}else if(winner == Fight.getRedTeam()) {
|
} else if (winner == Fight.getRedTeam()) {
|
||||||
win = 2;
|
win = 2;
|
||||||
blueResult = 0;
|
blueResult = 0;
|
||||||
}else{
|
} else {
|
||||||
blueResult = 0.5;
|
blueResult = 0.5;
|
||||||
}
|
}
|
||||||
|
|
||||||
Integer blueSchem;
|
Integer blueSchem;
|
||||||
Integer redSchem;
|
Integer redSchem;
|
||||||
try{
|
try {
|
||||||
blueSchem = SchematicNode.getSchematicNode(Fight.getBlueTeam().getSchematic()).getId();
|
blueSchem = SchematicNode.getSchematicNode(Fight.getBlueTeam().getSchematic()).getId();
|
||||||
}catch(SecurityException e){
|
} catch (SecurityException e) {
|
||||||
blueSchem = null;
|
blueSchem = null;
|
||||||
}
|
}
|
||||||
try{
|
try {
|
||||||
redSchem = SchematicNode.getSchematicNode(Fight.getRedTeam().getSchematic()).getId();
|
redSchem = SchematicNode.getSchematicNode(Fight.getRedTeam().getSchematic()).getId();
|
||||||
}catch(SecurityException e){
|
} catch (SecurityException e) {
|
||||||
redSchem = null;
|
redSchem = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
int remainingTime = 0;
|
int remainingTime = 0;
|
||||||
Countdown timeOverCountdown = Wincondition.getTimeOverCountdown();
|
Countdown timeOverCountdown = Wincondition.getTimeOverCountdown();
|
||||||
if(timeOverCountdown != null){
|
if (timeOverCountdown != null) {
|
||||||
remainingTime = timeOverCountdown.getTimeLeft();
|
remainingTime = timeOverCountdown.getTimeLeft();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -122,43 +124,35 @@ public class FightStatistics {
|
|||||||
for (FightPlayer fp : Fight.getRedTeam().getPlayers())
|
for (FightPlayer fp : Fight.getRedTeam().getPlayers())
|
||||||
savePlayerStats(fp, fightId);
|
savePlayerStats(fp, fightId);
|
||||||
|
|
||||||
if(ArenaMode.Event.contains(Config.mode)) {
|
if (ArenaMode.Event.contains(Config.mode)) {
|
||||||
FightSystem.getEventFight().setFight(fightId);
|
FightSystem.getEventFight().setFight(fightId);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
setReplay(fightId, new FileInputStream(FileRecorder.getFile()));
|
setReplay(fightId, new FileInputStream(FileRecorder.getFile()));
|
||||||
}catch(Exception e){
|
} catch (Exception e) {
|
||||||
Bukkit.getLogger().log(Level.INFO, "Failed to save replay", e);
|
Bukkit.getLogger().log(Level.INFO, "Failed to save replay", e);
|
||||||
}
|
}
|
||||||
}catch(Exception e){
|
} catch (Exception e) {
|
||||||
Bukkit.getLogger().log(Level.SEVERE, "Failed to save statistics", e);
|
Bukkit.getLogger().log(Level.SEVERE, "Failed to save statistics", e);
|
||||||
}
|
}
|
||||||
replayLock = false;
|
replayLock = false;
|
||||||
|
|
||||||
if(Config.Ranked){
|
if (!Bukkit.getOnlinePlayers().isEmpty()) {
|
||||||
int blueElo = Elo.getElo(blueLeader, gameMode);
|
Player p = Bukkit.getOnlinePlayers().iterator().next();
|
||||||
int redElo = Elo.getElo(redLeader, gameMode);
|
new FightEndsPacket((byte) win, blueSchem == null ? 0 : blueSchem, redSchem == null ? 0 : redSchem, Fight.getBlueTeam().getPlayers().stream().map(FightPlayer::getPlayer).map(SteamwarUser::get).map(SteamwarUser::getId).collect(Collectors.toList()), Fight.getRedTeam().getPlayers().stream().map(FightPlayer::getPlayer).map(SteamwarUser::get).map(SteamwarUser::getId).collect(Collectors.toList())).send(p);
|
||||||
double redWinExpectation = 1 / (1 + Math.pow(10, (blueElo - redElo) / 400f));
|
|
||||||
double blueWinExpectation = 1 / (1 + Math.pow(10, (redElo - blueElo) / 400f));
|
|
||||||
int newBlueElo = (int) Math.round(blueElo + K * (blueResult - blueWinExpectation));
|
|
||||||
int newRedElo = (int) Math.round(redElo + K * (1 - blueResult - redWinExpectation));
|
|
||||||
Elo.setElo(blueLeader, gameMode, newBlueElo);
|
|
||||||
Elo.setElo(redLeader, gameMode, newRedElo);
|
|
||||||
FightSystem.broadcast("UI_ELO", Fight.getBlueTeam().getPrefix(), SteamwarUser.get(blueLeader).getUserName(), blueElo, newBlueElo);
|
|
||||||
FightSystem.broadcast("UI_ELO", Fight.getRedTeam().getPrefix(), SteamwarUser.get(redLeader).getUserName(), redElo, newRedElo);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getLeader(FightTeam team){
|
private int getLeader(FightTeam team) {
|
||||||
if(team.getLeader() != null)
|
if (team.getLeader() != null)
|
||||||
return SteamwarUser.get(team.getLeader().getPlayer().getUniqueId()).getId();
|
return SteamwarUser.get(team.getLeader().getPlayer().getUniqueId()).getId();
|
||||||
else if(team.getDesignatedLeader() != null)
|
else if (team.getDesignatedLeader() != null)
|
||||||
return SteamwarUser.get(team.getDesignatedLeader()).getId();
|
return SteamwarUser.get(team.getDesignatedLeader()).getId();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void savePlayerStats(FightPlayer fp, int fightId){
|
private void savePlayerStats(FightPlayer fp, int fightId) {
|
||||||
SteamwarUser user = SteamwarUser.get(fp.getPlayer().getUniqueId());
|
SteamwarUser user = SteamwarUser.get(fp.getPlayer().getUniqueId());
|
||||||
de.steamwar.sql.FightPlayer.create(fightId, user.getId(), fp.getTeam().isBlue(), fp.getKit().getName(), fp.getKills(), !fp.isLiving());
|
de.steamwar.sql.FightPlayer.create(fightId, user.getId(), fp.getTeam().isBlue(), fp.getKit().getName(), fp.getKills(), !fp.isLiving());
|
||||||
}
|
}
|
||||||
|
@ -1,50 +0,0 @@
|
|||||||
/*
|
|
||||||
This file is a part of the SteamWar software.
|
|
||||||
|
|
||||||
Copyright (C) 2020 SteamWar.de-Serverteam
|
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU Affero General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU Affero General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Affero General Public License
|
|
||||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package de.steamwar.fightsystem.winconditions;
|
|
||||||
|
|
||||||
import de.steamwar.fightsystem.ArenaMode;
|
|
||||||
import de.steamwar.fightsystem.fight.Fight;
|
|
||||||
import de.steamwar.fightsystem.fight.FightTeam;
|
|
||||||
import de.steamwar.fightsystem.states.FightState;
|
|
||||||
import de.steamwar.fightsystem.states.StateDependentListener;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
|
||||||
|
|
||||||
public class RankedPlayerLeftWincondition extends Wincondition implements Listener {
|
|
||||||
|
|
||||||
public RankedPlayerLeftWincondition(){
|
|
||||||
super("LeaderQuit");
|
|
||||||
new StateDependentListener(ArenaMode.Ranked, FightState.Setup, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void handlePlayerQuit(PlayerQuitEvent event) {
|
|
||||||
Player player = event.getPlayer();
|
|
||||||
FightTeam team = isTarget(player);
|
|
||||||
if(team == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if(team.isPlayerLeader(player)) {
|
|
||||||
win(Fight.getOpposite(team), "WIN_RANKED_LEFT", team.getPrefix() + team.getLeader().getPlayer().getName());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
In neuem Issue referenzieren
Einen Benutzer sperren