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() {
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

@ -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")

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) {