diff --git a/src/main/java/rip/tilly/bedwars/BedWars.java b/src/main/java/rip/tilly/bedwars/BedWars.java index 4995c6e..3247781 100644 --- a/src/main/java/rip/tilly/bedwars/BedWars.java +++ b/src/main/java/rip/tilly/bedwars/BedWars.java @@ -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); diff --git a/src/main/java/rip/tilly/bedwars/listeners/PlayerDataListener.java b/src/main/java/rip/tilly/bedwars/listeners/PlayerDataListener.java index 46a1ce6..d8d4ae1 100644 --- a/src/main/java/rip/tilly/bedwars/listeners/PlayerDataListener.java +++ b/src/main/java/rip/tilly/bedwars/listeners/PlayerDataListener.java @@ -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()); diff --git a/src/main/java/rip/tilly/bedwars/managers/party/PartyManager.java b/src/main/java/rip/tilly/bedwars/managers/party/PartyManager.java index 6bab269..9e72993 100644 --- a/src/main/java/rip/tilly/bedwars/managers/party/PartyManager.java +++ b/src/main/java/rip/tilly/bedwars/managers/party/PartyManager.java @@ -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) {