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/hotbar/HotbarManager.java b/src/main/java/rip/tilly/bedwars/managers/hotbar/HotbarManager.java index 7f12d8c..1487443 100644 --- a/src/main/java/rip/tilly/bedwars/managers/hotbar/HotbarManager.java +++ b/src/main/java/rip/tilly/bedwars/managers/hotbar/HotbarManager.java @@ -57,7 +57,7 @@ public class HotbarManager { } private void loadQueueItems() { - spawnItems.add(new HotbarItem( + queueItems.add(new HotbarItem( ItemUtil.createUnbreakableItem( Material.INK_SACK, CC.translate("&e&l» &cLeave Queue &e&l«"), 1, (short) 1 ), 8, true, "LEAVE_QUEUE") @@ -65,17 +65,17 @@ public class HotbarManager { } private void loadPartyItems() { - spawnItems.add(new HotbarItem( + partyItems.add(new HotbarItem( ItemUtil.createUnbreakableItem( Material.GOLD_SWORD, CC.translate("&e&l» &dParty Games &e&l«"), 1, (short) 0 ), 0, true, "PARTY_GAMES") ); - spawnItems.add(new HotbarItem( + partyItems.add(new HotbarItem( ItemUtil.createUnbreakableItem( Material.NETHER_STAR, CC.translate("&e&l» &dParty Info &e&l«"), 1, (short) 0 ), 4, true, "PARTY_INFO") ); - spawnItems.add(new HotbarItem( + partyItems.add(new HotbarItem( ItemUtil.createUnbreakableItem( Material.INK_SACK, CC.translate("&e&l» &cLeave Party &e&l«"), 1, (short) 1 ), 8, true, "PARTY_LEAVE") @@ -83,12 +83,12 @@ public class HotbarManager { } private void loadSpectatorItems() { - spawnItems.add(new HotbarItem( + spectatorItems.add(new HotbarItem( ItemUtil.createUnbreakableItem( Material.COMPASS, CC.translate("&e&l» &dPlayer Tracker &e&l«"), 1, (short) 0 ), 0, true, "SPECTATOR_MENU") ); - spawnItems.add(new HotbarItem( + spectatorItems.add(new HotbarItem( ItemUtil.createUnbreakableItem( Material.INK_SACK, CC.translate("&e&l» &cLeave Spectator Mode &e&l«"), 1, (short) 1 ), 8, true, "SPECTATOR_LEAVE") 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) {