diff --git a/build.gradle b/build.gradle index 9dd51b3..4581b76 100644 --- a/build.gradle +++ b/build.gradle @@ -1,10 +1,10 @@ plugins { id 'java' - id("xyz.jpenilla.run-paper") version("1.0.6") + id("xyz.jpenilla.run-paper") version("2.1.0") } tasks { runServer { - minecraftVersion("1.19.1") + minecraftVersion("1.20.1") } } @@ -27,7 +27,7 @@ repositories { } dependencies { - compileOnly 'io.papermc.paper:paper-api:1.19.1-R0.1-SNAPSHOT' + compileOnly 'io.papermc.paper:paper-api:1.20.1-R0.1-SNAPSHOT' } /*processResources { diff --git a/src/main/java/plugin/manhunt/manhunt_plugin/game/ManhuntGame.java b/src/main/java/plugin/manhunt/manhunt_plugin/game/ManhuntGame.java index d46c9dd..69513c1 100644 --- a/src/main/java/plugin/manhunt/manhunt_plugin/game/ManhuntGame.java +++ b/src/main/java/plugin/manhunt/manhunt_plugin/game/ManhuntGame.java @@ -132,7 +132,7 @@ public void onTargetDeath(PlayerRespawnEvent event) { Player target = event.getPlayer(); if (target == this.target) { for (Player player : players) { - player.sendMessage(target.getName() + " has died. The Hunters Win!"); + player.sendRawMessage(target.getName() + " has died. The Hunters Win!"); } EndGame.endgame(this); } diff --git a/src/main/java/plugin/manhunt/manhunt_plugin/gui/JoinGui.java b/src/main/java/plugin/manhunt/manhunt_plugin/gui/JoinGui.java index 945765f..6d50060 100644 --- a/src/main/java/plugin/manhunt/manhunt_plugin/gui/JoinGui.java +++ b/src/main/java/plugin/manhunt/manhunt_plugin/gui/JoinGui.java @@ -20,7 +20,7 @@ public void openNewGui(Player player) { joingui = Bukkit.createInventory(null, 54, Component.text("Select a Game to Join")); int i = 0; for (ManhuntGame game : ManhuntPlugin.gameData.currentGames) { - joingui.setItem(i, TargetGui.playerHeadMap.get(game.target)); + joingui.setItem(i, TargetGui.playerToHeadMap.get(game.target)); i++; } @@ -38,7 +38,7 @@ public void guiClickEvent(InventoryClickEvent event) { Player player = (Player) event.getWhoClicked(); ItemStack targethead = null; - for (ItemStack head : TargetGui.headPlayermap.keySet()) { + for (ItemStack head : TargetGui.headToPlayermap.keySet()) { if (event.getCurrentItem() != null) { if (event.getCurrentItem().getItemMeta().equals(head.getItemMeta())) { targethead = head; @@ -50,7 +50,7 @@ public void guiClickEvent(InventoryClickEvent event) { Bukkit.getScheduler().scheduleSyncDelayedTask(ManhuntPlugin.getInstance(), player::closeInventory); } - target = TargetGui.headPlayermap.get(targethead); + target = TargetGui.headToPlayermap.get(targethead); for (ManhuntGame game : ManhuntPlugin.gameData.currentGames) { if (game.target == target && !game.players.contains(player)) { game.onHunterJoin(player); diff --git a/src/main/java/plugin/manhunt/manhunt_plugin/gui/TargetGui.java b/src/main/java/plugin/manhunt/manhunt_plugin/gui/TargetGui.java index ccd5bfc..11f3d46 100644 --- a/src/main/java/plugin/manhunt/manhunt_plugin/gui/TargetGui.java +++ b/src/main/java/plugin/manhunt/manhunt_plugin/gui/TargetGui.java @@ -7,8 +7,6 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.inventory.InventoryClickEvent; -import org.bukkit.event.player.PlayerJoinEvent; -import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.SkullMeta; @@ -19,15 +17,16 @@ public class TargetGui implements Listener { static Inventory targetgui; - static HashMap playerHeadMap = new HashMap<>(); - static HashMap headPlayermap = new HashMap<>(); + static HashMap playerToHeadMap = new HashMap<>(); + static HashMap headToPlayermap = new HashMap<>(); public Player target; public void openNewGui(Player player) { targetgui = Bukkit.createInventory(null, 54, Component.text("Select a Target")); + createHitList(); int i = 0; - for (ItemStack head : playerHeadMap.values()) { + for (ItemStack head : playerToHeadMap.values()) { targetgui.setItem(i, head); i++; @@ -35,20 +34,18 @@ public void openNewGui(Player player) { player.openInventory(targetgui); } - @EventHandler - public void headRegistry(PlayerJoinEvent event) { - Player player = event.getPlayer(); - ItemStack playerhead = new ItemStack(Material.PLAYER_HEAD); - playerhead.editMeta(SkullMeta.class, meta -> meta.setOwningPlayer(player)); - ((SkullMeta) playerhead.getItemMeta()).getOwningPlayer(); - playerHeadMap.put(player, playerhead); - headPlayermap.put(playerhead, player); - } - - @EventHandler - public void onPlayerQuit(PlayerQuitEvent event) { - playerHeadMap.remove(event.getPlayer()); - headPlayermap.values().remove(event.getPlayer()); + private void createHitList() { + playerToHeadMap.clear(); + headToPlayermap.clear(); + for (Player player : Bukkit.getOnlinePlayers()) { + ItemStack playerhead = new ItemStack(Material.PLAYER_HEAD); + playerhead.editMeta(SkullMeta.class, meta -> meta.setOwningPlayer(player)); + playerhead.editMeta( + itemMeta -> itemMeta.displayName(Component.text(player.getName())) + ); + playerToHeadMap.put(player, playerhead); + headToPlayermap.put(playerhead, player); + } } @EventHandler @@ -62,7 +59,7 @@ public void guiClickEvent(InventoryClickEvent event) { Player player = (Player) event.getWhoClicked(); ItemStack targethead = null; - for (ItemStack head : headPlayermap.keySet()) { + for (ItemStack head : headToPlayermap.keySet()) { if (event.getCurrentItem() != null) { if (event.getCurrentItem().getItemMeta().equals(head.getItemMeta())) { targethead = head; @@ -76,10 +73,9 @@ public void guiClickEvent(InventoryClickEvent event) { return; } - target = headPlayermap.get(targethead); + target = headToPlayermap.get(targethead); Bukkit.getScheduler().scheduleSyncDelayedTask(ManhuntPlugin.getInstance(), player::closeInventory); new ManhuntGame(player, target); - } }