diff --git a/src/main/java/rip/tilly/bedwars/BedWars.java b/src/main/java/rip/tilly/bedwars/BedWars.java index b04d900..1b48bf8 100644 --- a/src/main/java/rip/tilly/bedwars/BedWars.java +++ b/src/main/java/rip/tilly/bedwars/BedWars.java @@ -124,7 +124,7 @@ public final class BedWars extends JavaPlugin { private void loadListeners() { Arrays.asList( - new PlayerDataListener(), new RandomListeners(), new InteractListener(), new ButtonListener(), + new PlayerDataListener(), new RandomListeners(), new InteractListener(), new ButtonListener(), new MenuListener(), new GameStartListener(), new GameEndListener(), new WorldListener(), new MovementListener(), new PlayerKillListener() ).forEach(listener -> this.getServer().getPluginManager().registerEvents(listener, this)); diff --git a/src/main/java/rip/tilly/bedwars/listeners/InteractListener.java b/src/main/java/rip/tilly/bedwars/listeners/InteractListener.java index 2336c59..fff462c 100644 --- a/src/main/java/rip/tilly/bedwars/listeners/InteractListener.java +++ b/src/main/java/rip/tilly/bedwars/listeners/InteractListener.java @@ -10,8 +10,10 @@ import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.material.TrapDoor; import rip.tilly.bedwars.BedWars; +import rip.tilly.bedwars.game.GameType; import rip.tilly.bedwars.managers.hotbar.impl.HotbarItem; import rip.tilly.bedwars.menus.queue.QueueMenu; +import rip.tilly.bedwars.menusystem.menu.PlayAGameMenu; import rip.tilly.bedwars.playerdata.PlayerData; import rip.tilly.bedwars.playerdata.PlayerState; @@ -75,7 +77,9 @@ public class InteractListener implements Listener { case SPAWN: switch (hotbarItem.getActionType()) { case QUEUE_MENU: - new QueueMenu().openMenu(player); + for (GameType gameType : GameType.values()) { + new PlayAGameMenu(this.plugin.getPlayerMenuUtil(player), gameType).open(); + } break; case SETTINGS_MENU: diff --git a/src/main/java/rip/tilly/bedwars/listeners/MenuListener.java b/src/main/java/rip/tilly/bedwars/listeners/MenuListener.java new file mode 100644 index 0000000..a4abf1a --- /dev/null +++ b/src/main/java/rip/tilly/bedwars/listeners/MenuListener.java @@ -0,0 +1,27 @@ +package rip.tilly.bedwars.listeners; + +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.inventory.InventoryClickEvent; +import org.bukkit.inventory.InventoryHolder; +import rip.tilly.bedwars.menusystem.Menu; + +public class MenuListener implements Listener { + + @EventHandler + public void onMenuClick(InventoryClickEvent event) { + InventoryHolder holder = event.getInventory().getHolder(); + + if (holder instanceof Menu) { + event.setCancelled(true); + + if (event.getCurrentItem() == null) { + return; + } + + Menu menu = (Menu) holder; + + menu.handleMenu(event); + } + } +} diff --git a/src/main/java/rip/tilly/bedwars/menusystem/menu/PlayAGameMenu.java b/src/main/java/rip/tilly/bedwars/menusystem/menu/PlayAGameMenu.java index 8a882b2..22f46f0 100644 --- a/src/main/java/rip/tilly/bedwars/menusystem/menu/PlayAGameMenu.java +++ b/src/main/java/rip/tilly/bedwars/menusystem/menu/PlayAGameMenu.java @@ -4,6 +4,8 @@ import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.inventory.ItemStack; +import rip.tilly.bedwars.BedWars; +import rip.tilly.bedwars.game.GameType; import rip.tilly.bedwars.menusystem.Menu; import rip.tilly.bedwars.menusystem.PlayerMenuUtil; import rip.tilly.bedwars.utils.CC; @@ -14,8 +16,14 @@ import java.util.List; public class PlayAGameMenu extends Menu { - public PlayAGameMenu(PlayerMenuUtil playerMenuUtil) { + private BedWars main = BedWars.getInstance(); + + private GameType gameType; + + public PlayAGameMenu(PlayerMenuUtil playerMenuUtil, GameType gameType) { super(playerMenuUtil); + + this.gameType = gameType; } @Override @@ -54,6 +62,8 @@ public class PlayAGameMenu extends Menu { bedWars1v1Lore.add(CC.translate("")); bedWars1v1Lore.add(CC.translate("&9You have to start somewhere,")); bedWars1v1Lore.add(CC.translate("&9so why not start here?")); + bedWars1v1Lore.add(CC.translate("")); + bedWars1v1Lore.add(CC.translate("&fPlaying: &b" + this.main.getGameManager().getPlayingByType(this.gameType))); ItemStack bedWars1v1ItemStack = new ItemBuilder(Material.WOOD_SWORD).name(CC.translate("&dBedWars 1v1")).lore(bedWars1v1Lore).build(); @@ -61,6 +71,8 @@ public class PlayAGameMenu extends Menu { bedWars2v2Lore.add(CC.translate("")); bedWars2v2Lore.add(CC.translate("&9Adapt, overcome, and conquer,")); bedWars2v2Lore.add(CC.translate("&9you are advancing rapidly")); + bedWars2v2Lore.add(CC.translate("")); + bedWars2v2Lore.add(CC.translate("&fPlaying: &b" + this.main.getGameManager().getPlayingByType(this.gameType))); ItemStack bedWars2v2ItemStack = new ItemBuilder(Material.STONE_SWORD).name(CC.translate("&dBedWars 2v2")).lore(bedWars2v2Lore).build(); @@ -69,6 +81,9 @@ public class PlayAGameMenu extends Menu { bedWars3v3Lore.add(CC.translate("&9How crazy is this,")); bedWars3v3Lore.add(CC.translate("&9it seems like it was just yesterday")); bedWars3v3Lore.add(CC.translate("&9since you started")); + bedWars3v3Lore.add(CC.translate("")); + bedWars3v3Lore.add(CC.translate("&fPlaying: &b" + this.main.getGameManager().getPlayingByType(this.gameType))); + ItemStack bedWars3v3ItemStack = new ItemBuilder(Material.IRON_SWORD).name(CC.translate("&dBedWars 3v3")).lore(bedWars3v3Lore).build(); @@ -77,6 +92,8 @@ public class PlayAGameMenu extends Menu { bedWars4v4Lore.add(CC.translate("&9You are now a master,")); bedWars4v4Lore.add(CC.translate("&9you can go up against")); bedWars4v4Lore.add(CC.translate("&9the undefeated PvP bot &7(Coming soon)")); + bedWars4v4Lore.add(CC.translate("")); + bedWars4v4Lore.add(CC.translate("&fPlaying: &b" + this.main.getGameManager().getPlayingByType(this.gameType))); ItemStack bedWars4v4ItemStack = new ItemBuilder(Material.DIAMOND_SWORD).name(CC.translate("&dBedWars 4v4")).lore(bedWars4v4Lore).build(); 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 695be2d..c066e29 100644 --- a/src/main/java/rip/tilly/bedwars/providers/scoreboard/ScoreboardProvider.java +++ b/src/main/java/rip/tilly/bedwars/providers/scoreboard/ScoreboardProvider.java @@ -48,28 +48,28 @@ public class ScoreboardProvider implements AssembleAdapter { List lines = new ArrayList(); lines.add(CC.scoreboardBar); - boolean inParty = this.main.getPartyManager().getParty(playerData.getUniqueId()) != null; - if (inParty) { + + if (this.main.getPartyManager().getParty(playerData.getUniqueId()) != null) { Party party = this.main.getPartyManager().getParty(playerData.getUniqueId()); lines.add("&9Party Leader: &d" + Bukkit.getPlayer(party.getLeader()).getName()); lines.add("&9Party Members: &d" + party.getMembers().size() + "&7/&d" + party.getLimit()); lines.add(CC.scoreboardBar); } - lines.add("&fOnline: &d" + this.main.getServer().getOnlinePlayers().size()); - lines.add("&fPlaying: &d" + this.main.getGameManager().getPlaying()); - if (playerData.getPlayerState() == PlayerState.QUEUE) { QueueEntry queueEntry = this.main.getQueueManager().getQueueEntry(playerData.getUniqueId()); if (queueEntry != null) { long queueTime = System.currentTimeMillis() - (this.main.getQueueManager().getPlayerQueueTime(playerData.getUniqueId())); String formattedQueueTime = TimeUtils.formatIntoMMSS(Math.round(queueTime / 1000L)); - lines.add(CC.scoreboardBar); lines.add("&e" + queueEntry.getGameType().getName() + " Queue"); lines.add("&fTime: &d" + formattedQueueTime); + lines.add(CC.scoreboardBar); } } + lines.add("&fOnline: &d" + this.main.getServer().getOnlinePlayers().size()); + lines.add("&fPlaying: &d" + this.main.getGameManager().getPlaying()); + lines.add(" "); lines.add("&fLevel: &d" + playerData.getLevel());