This commit is contained in:
Luca 2021-11-21 21:06:50 +01:00
parent e2d3417072
commit 8b64728700
3 changed files with 37 additions and 3 deletions

View File

@ -54,6 +54,8 @@ public final class BedWars extends JavaPlugin {
public void onEnable() {
instance = this;
this.saveDefaultConfig();
this.mainConfig = new Config("config", this);
this.arenasConfig = new Config("arenas", this);

View File

@ -57,7 +57,20 @@ public class PlayerDataListener implements Listener {
Player player = event.getPlayer();
PlayerData playerData = this.plugin.getPlayerDataManager().getPlayerData(player.getUniqueId());
handleDataSave(playerData);
switch (playerData.getPlayerState()) {
case PLAYING:
this.plugin.getGameManager().removePlayerFromGame(player, playerData);
break;
case QUEUE:
// remove from queue
break;
case SPECTATING:
// remove spectator
break;
}
this.handleLeave(player);
this.handleDataSave(playerData);
}
@EventHandler
@ -67,7 +80,20 @@ public class PlayerDataListener implements Listener {
Player player = event.getPlayer();
PlayerData playerData = this.plugin.getPlayerDataManager().getPlayerData(player.getUniqueId());
handleDataSave(playerData);
switch (playerData.getPlayerState()) {
case PLAYING:
this.plugin.getGameManager().removePlayerFromGame(player, playerData);
break;
case QUEUE:
// remove from queue
break;
case SPECTATING:
// remove spectator
break;
}
this.handleLeave(player);
this.handleDataSave(playerData);
}
@EventHandler
@ -76,6 +102,12 @@ public class PlayerDataListener implements Listener {
this.plugin.getPlayerDataManager().resetPlayer(event.getPlayer(), true);
}
private void handleLeave(Player player) {
this.plugin.getPartyManager().leaveParty(player);
this.plugin.getGameManager().removeGameRequests(player.getUniqueId());
this.plugin.getPartyManager().removePartyInvites(player.getUniqueId());
}
private void handleDataSave(PlayerData playerData) {
if (playerData != null) {
this.plugin.getPlayerDataManager().deletePlayer(playerData.getUniqueId());

View File

@ -71,7 +71,7 @@ public class PartyManager {
this.parties.put(player.getUniqueId(), party);
this.plugin.getPlayerDataManager().resetPlayer(player, false);
player.sendMessage(CC.translate("Successfully created a party!"));
player.sendMessage(CC.translate("&aSuccessfully created a party!"));
}
private void disbandParty(Party party) {