This commit is contained in:
Trixkz 2021-11-21 15:09:12 -05:00
commit 018c8921e5
4 changed files with 43 additions and 9 deletions

View File

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

View File

@ -57,7 +57,20 @@ public class PlayerDataListener implements Listener {
Player player = event.getPlayer(); Player player = event.getPlayer();
PlayerData playerData = this.plugin.getPlayerDataManager().getPlayerData(player.getUniqueId()); 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 @EventHandler
@ -67,7 +80,20 @@ public class PlayerDataListener implements Listener {
Player player = event.getPlayer(); Player player = event.getPlayer();
PlayerData playerData = this.plugin.getPlayerDataManager().getPlayerData(player.getUniqueId()); 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 @EventHandler
@ -76,6 +102,12 @@ public class PlayerDataListener implements Listener {
this.plugin.getPlayerDataManager().resetPlayer(event.getPlayer(), true); 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) { private void handleDataSave(PlayerData playerData) {
if (playerData != null) { if (playerData != null) {
this.plugin.getPlayerDataManager().deletePlayer(playerData.getUniqueId()); this.plugin.getPlayerDataManager().deletePlayer(playerData.getUniqueId());

View File

@ -57,7 +57,7 @@ public class HotbarManager {
} }
private void loadQueueItems() { private void loadQueueItems() {
spawnItems.add(new HotbarItem( queueItems.add(new HotbarItem(
ItemUtil.createUnbreakableItem( ItemUtil.createUnbreakableItem(
Material.INK_SACK, CC.translate("&e&l» &cLeave Queue &e&l«"), 1, (short) 1 Material.INK_SACK, CC.translate("&e&l» &cLeave Queue &e&l«"), 1, (short) 1
), 8, true, "LEAVE_QUEUE") ), 8, true, "LEAVE_QUEUE")
@ -65,17 +65,17 @@ public class HotbarManager {
} }
private void loadPartyItems() { private void loadPartyItems() {
spawnItems.add(new HotbarItem( partyItems.add(new HotbarItem(
ItemUtil.createUnbreakableItem( ItemUtil.createUnbreakableItem(
Material.GOLD_SWORD, CC.translate("&e&l» &dParty Games &e&l«"), 1, (short) 0 Material.GOLD_SWORD, CC.translate("&e&l» &dParty Games &e&l«"), 1, (short) 0
), 0, true, "PARTY_GAMES") ), 0, true, "PARTY_GAMES")
); );
spawnItems.add(new HotbarItem( partyItems.add(new HotbarItem(
ItemUtil.createUnbreakableItem( ItemUtil.createUnbreakableItem(
Material.NETHER_STAR, CC.translate("&e&l» &dParty Info &e&l«"), 1, (short) 0 Material.NETHER_STAR, CC.translate("&e&l» &dParty Info &e&l«"), 1, (short) 0
), 4, true, "PARTY_INFO") ), 4, true, "PARTY_INFO")
); );
spawnItems.add(new HotbarItem( partyItems.add(new HotbarItem(
ItemUtil.createUnbreakableItem( ItemUtil.createUnbreakableItem(
Material.INK_SACK, CC.translate("&e&l» &cLeave Party &e&l«"), 1, (short) 1 Material.INK_SACK, CC.translate("&e&l» &cLeave Party &e&l«"), 1, (short) 1
), 8, true, "PARTY_LEAVE") ), 8, true, "PARTY_LEAVE")
@ -83,12 +83,12 @@ public class HotbarManager {
} }
private void loadSpectatorItems() { private void loadSpectatorItems() {
spawnItems.add(new HotbarItem( spectatorItems.add(new HotbarItem(
ItemUtil.createUnbreakableItem( ItemUtil.createUnbreakableItem(
Material.COMPASS, CC.translate("&e&l» &dPlayer Tracker &e&l«"), 1, (short) 0 Material.COMPASS, CC.translate("&e&l» &dPlayer Tracker &e&l«"), 1, (short) 0
), 0, true, "SPECTATOR_MENU") ), 0, true, "SPECTATOR_MENU")
); );
spawnItems.add(new HotbarItem( spectatorItems.add(new HotbarItem(
ItemUtil.createUnbreakableItem( ItemUtil.createUnbreakableItem(
Material.INK_SACK, CC.translate("&e&l» &cLeave Spectator Mode &e&l«"), 1, (short) 1 Material.INK_SACK, CC.translate("&e&l» &cLeave Spectator Mode &e&l«"), 1, (short) 1
), 8, true, "SPECTATOR_LEAVE") ), 8, true, "SPECTATOR_LEAVE")

View File

@ -71,7 +71,7 @@ public class PartyManager {
this.parties.put(player.getUniqueId(), party); this.parties.put(player.getUniqueId(), party);
this.plugin.getPlayerDataManager().resetPlayer(player, false); 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) { private void disbandParty(Party party) {