From 031874bc4103794ce61a2bdd7215c67230d0bd71 Mon Sep 17 00:00:00 2001 From: Luca Date: Tue, 23 Nov 2021 13:34:45 +0100 Subject: [PATCH] Added game data and menu --- .../listeners/game/GameEndListener.java | 4 ++-- .../tilly/bedwars/managers/GameManager.java | 23 ++++++++++++++++++- .../bedwars/menus/queue/PlayAGameMenu.java | 1 + .../playerdata/PlayerCurrentGameData.java | 14 +++++++++++ .../tilly/bedwars/playerdata/PlayerData.java | 3 +-- .../scoreboard/ScoreboardProvider.java | 6 ++--- .../bedwars/runnables/RespawnRunnable.java | 3 ++- 7 files changed, 45 insertions(+), 9 deletions(-) create mode 100644 src/main/java/rip/tilly/bedwars/playerdata/PlayerCurrentGameData.java diff --git a/src/main/java/rip/tilly/bedwars/listeners/game/GameEndListener.java b/src/main/java/rip/tilly/bedwars/listeners/game/GameEndListener.java index 0322bf3..df5ec6f 100644 --- a/src/main/java/rip/tilly/bedwars/listeners/game/GameEndListener.java +++ b/src/main/java/rip/tilly/bedwars/listeners/game/GameEndListener.java @@ -37,8 +37,8 @@ public class GameEndListener implements Listener { PlayerData playerData = this.plugin.getPlayerDataManager().getPlayerData(player.getUniqueId()); playerData.setLastDamager(null); - playerData.setGameKills(0); - playerData.setGameBedsDestroyed(0); + playerData.getCurrentGameData().setGameKills(0); + playerData.getCurrentGameData().setGameBedsDestroyed(0); String winnerTitle = CC.translate("&aVICTORY!"); String losingTitle = CC.translate("&cDEFEAT!"); diff --git a/src/main/java/rip/tilly/bedwars/managers/GameManager.java b/src/main/java/rip/tilly/bedwars/managers/GameManager.java index 4435ffc..5ced080 100644 --- a/src/main/java/rip/tilly/bedwars/managers/GameManager.java +++ b/src/main/java/rip/tilly/bedwars/managers/GameManager.java @@ -14,6 +14,7 @@ import rip.tilly.bedwars.game.arena.Arena; import rip.tilly.bedwars.events.GameEndEvent; import rip.tilly.bedwars.events.GameStartEvent; import rip.tilly.bedwars.managers.hotbar.impl.HotbarItem; +import rip.tilly.bedwars.playerdata.PlayerCurrentGameData; import rip.tilly.bedwars.playerdata.PlayerData; import rip.tilly.bedwars.playerdata.PlayerState; import rip.tilly.bedwars.utils.ItemBuilder; @@ -209,12 +210,32 @@ public class GameManager { this.plugin.getPlayerDataManager().resetPlayer(player, true); } - public List getGameItems() { + public List getGameItems(PlayerCurrentGameData currentGameData) { List allItems = new ArrayList<>(); ItemStack sword = new ItemBuilder(Material.WOOD_SWORD).build(); allItems.add(sword); + if (currentGameData.isShears()) { + ItemStack shears = new ItemBuilder(Material.SHEARS).build(); + allItems.add(shears); + } + + if (currentGameData.getAxeLevel() > 0) { + if (currentGameData.getAxeLevel() == 1) { + + } + if (currentGameData.getAxeLevel() == 1) { + + } + if (currentGameData.getAxeLevel() == 1) { + + } + if (currentGameData.getAxeLevel() == 1) { + + } + } + return allItems; } diff --git a/src/main/java/rip/tilly/bedwars/menus/queue/PlayAGameMenu.java b/src/main/java/rip/tilly/bedwars/menus/queue/PlayAGameMenu.java index 0d9a5c0..a2a0800 100644 --- a/src/main/java/rip/tilly/bedwars/menus/queue/PlayAGameMenu.java +++ b/src/main/java/rip/tilly/bedwars/menus/queue/PlayAGameMenu.java @@ -68,6 +68,7 @@ public class PlayAGameMenu extends Menu { @Override public void clicked(Player player, int slot, ClickType clickType, int hotbarButton) { BedWars.getInstance().getQueueManager().addPlayerToQueue(player, BedWars.getInstance().getPlayerDataManager().getPlayerData(player.getUniqueId()), gameType); + playNeutral(player); } } } diff --git a/src/main/java/rip/tilly/bedwars/playerdata/PlayerCurrentGameData.java b/src/main/java/rip/tilly/bedwars/playerdata/PlayerCurrentGameData.java new file mode 100644 index 0000000..67cedfb --- /dev/null +++ b/src/main/java/rip/tilly/bedwars/playerdata/PlayerCurrentGameData.java @@ -0,0 +1,14 @@ +package rip.tilly.bedwars.playerdata; + +import lombok.Data; + +@Data +public class PlayerCurrentGameData { + + private int gameKills; + private int gameBedsDestroyed; + + private int pickaxeLevel = 0; + private int axeLevel = 0; + private boolean shears = false; +} diff --git a/src/main/java/rip/tilly/bedwars/playerdata/PlayerData.java b/src/main/java/rip/tilly/bedwars/playerdata/PlayerData.java index 003af61..76cf2a2 100644 --- a/src/main/java/rip/tilly/bedwars/playerdata/PlayerData.java +++ b/src/main/java/rip/tilly/bedwars/playerdata/PlayerData.java @@ -18,6 +18,7 @@ public class PlayerData { private PlayerState playerState = PlayerState.SPAWN; private PlayerSettings playerSettings = new PlayerSettings(); + private PlayerCurrentGameData currentGameData = new PlayerCurrentGameData(); private PlayerTeam playerTeam; @@ -37,8 +38,6 @@ public class PlayerData { private int bedsDestroyed; private Player lastDamager; - private int gameKills; - private int gameBedsDestroyed; public PlayerData(UUID uniqueId) { this.uniqueId = uniqueId; diff --git a/src/main/java/rip/tilly/bedwars/providers/scoreboard/ScoreboardProvider.java b/src/main/java/rip/tilly/bedwars/providers/scoreboard/ScoreboardProvider.java index e0e3725..95954b2 100644 --- a/src/main/java/rip/tilly/bedwars/providers/scoreboard/ScoreboardProvider.java +++ b/src/main/java/rip/tilly/bedwars/providers/scoreboard/ScoreboardProvider.java @@ -221,7 +221,7 @@ public class ScoreboardProvider implements BoardAdapter { if (yourTeam.isHasBed()) { lines.add("&7[" + yourTeam.getPlayerTeam().getChatColor() + yourTeam.getPlayerTeam().getSmallName() + "&7] &a&l✓ &7(You)"); } else if (yourTeam.getPlayingPlayers().size() > 0) { - lines.add("&7[" + yourTeam.getPlayerTeam().getChatColor() + yourTeam.getPlayerTeam().getSmallName() + "&7] &f" + yourTeam.getPlayingPlayers().size() + " &7(YOU)"); + lines.add("&7[" + yourTeam.getPlayerTeam().getChatColor() + yourTeam.getPlayerTeam().getSmallName() + "&7] &f" + yourTeam.getPlayingPlayers().size() + " &7(You)"); } else { lines.add("&7[" + yourTeam.getPlayerTeam().getChatColor() + yourTeam.getPlayerTeam().getSmallName() + "&7] &c&l✗ &7(You)"); } @@ -233,8 +233,8 @@ public class ScoreboardProvider implements BoardAdapter { lines.add("&7[" + opposingTeam.getPlayerTeam().getChatColor() + opposingTeam.getPlayerTeam().getSmallName() + "&7] &c&l✗"); } lines.add(" "); - lines.add("&fKills: &d" + playerData.getGameKills()); - lines.add("&fBeds Destroyed: &d" + playerData.getGameBedsDestroyed()); + lines.add("&fKills: &d" + playerData.getCurrentGameData().getGameKills()); + lines.add("&fBeds Destroyed: &d" + playerData.getCurrentGameData().getGameBedsDestroyed()); lines.add(" "); lines.add("&dtilly.rip"); lines.add(CC.scoreboardBar); diff --git a/src/main/java/rip/tilly/bedwars/runnables/RespawnRunnable.java b/src/main/java/rip/tilly/bedwars/runnables/RespawnRunnable.java index 58edec7..c8f7a91 100644 --- a/src/main/java/rip/tilly/bedwars/runnables/RespawnRunnable.java +++ b/src/main/java/rip/tilly/bedwars/runnables/RespawnRunnable.java @@ -47,7 +47,7 @@ public class RespawnRunnable extends BukkitRunnable { this.player.playSound(this.player.getLocation(), Sound.ORB_PICKUP, 10F, 1F); this.player.getInventory().setArmorContents(this.plugin.getGameManager().getGameArmor(playerData)); - for (ItemStack stack : this.plugin.getGameManager().getGameItems()) { + for (ItemStack stack : this.plugin.getGameManager().getGameItems(this.playerData.getCurrentGameData())) { this.player.getInventory().addItem(stack); } @@ -70,6 +70,7 @@ public class RespawnRunnable extends BukkitRunnable { this.game.getTeams().forEach(team -> team.playingPlayers().forEach(gamePlayer -> gamePlayer.hidePlayer(this.player))); this.player.getInventory().clear(); + this.player.getInventory().setArmorContents(null); this. player.updateInventory(); this.player.setHealth(this.player.getMaxHealth());