Skip to content

Commit

Permalink
Update to 1.20.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Epicjii committed Jul 13, 2023
1 parent b017c70 commit d108ee0
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 29 deletions.
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -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")
}
}

Expand All @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/plugin/manhunt/manhunt_plugin/gui/JoinGui.java
Original file line number Diff line number Diff line change
Expand Up @@ -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++;
}
Expand All @@ -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;
Expand All @@ -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);
Expand Down
40 changes: 18 additions & 22 deletions src/main/java/plugin/manhunt/manhunt_plugin/gui/TargetGui.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -19,36 +17,35 @@

public class TargetGui implements Listener {
static Inventory targetgui;
static HashMap<Player, ItemStack> playerHeadMap = new HashMap<>();
static HashMap<ItemStack, Player> headPlayermap = new HashMap<>();
static HashMap<Player, ItemStack> playerToHeadMap = new HashMap<>();
static HashMap<ItemStack, Player> 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++;
}
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
Expand All @@ -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;
Expand All @@ -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);

}
}

0 comments on commit d108ee0

Please sign in to comment.