From ecb33764efff72b671e64705457040ac648a8bf5 Mon Sep 17 00:00:00 2001 From: Tyler Murphy Date: Fri, 13 Aug 2021 23:02:09 -0400 Subject: [PATCH] death messages, give item fix --- src/main/java/net/tylermurphy/hideAndSeek/Main.java | 2 ++ src/main/java/net/tylermurphy/hideAndSeek/Store.java | 1 - .../net/tylermurphy/hideAndSeek/commands/Start.java | 3 +++ .../tylermurphy/hideAndSeek/manager/EventManager.java | 10 ++++++++++ .../tylermurphy/hideAndSeek/manager/TickManager.java | 8 ++++---- 5 files changed, 19 insertions(+), 5 deletions(-) diff --git a/src/main/java/net/tylermurphy/hideAndSeek/Main.java b/src/main/java/net/tylermurphy/hideAndSeek/Main.java index 615a813..47d0387 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/Main.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/Main.java @@ -50,6 +50,8 @@ public class Main extends JavaPlugin implements Listener { Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "gamerule doImmediateRespawn true"); Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "gamerule logAdminCommands false"); Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "gamerule naturalRegeneration false"); + Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "gamerule keepInventory false"); + Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "gamerule showDeathMessages false"); // Register Commands CommandManager.registerCommands(); diff --git a/src/main/java/net/tylermurphy/hideAndSeek/Store.java b/src/main/java/net/tylermurphy/hideAndSeek/Store.java index d628ad1..05122b3 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/Store.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/Store.java @@ -39,7 +39,6 @@ public class Store { } public static int getPlayerData(String playerName, String key) { - if(playerData == null) return 0; if(playerData.get(playerName + " " + key) == null) { return 0; } else { diff --git a/src/main/java/net/tylermurphy/hideAndSeek/commands/Start.java b/src/main/java/net/tylermurphy/hideAndSeek/commands/Start.java index baf1e46..8c0056b 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/commands/Start.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/commands/Start.java @@ -41,6 +41,9 @@ public class Start implements ICommand { Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "gamerule doImmediateRespawn true"); Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "gamerule logAdminCommands false"); Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "gamerule naturalRegeneration false"); + Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "gamerule keepInventory false"); + Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "gamerule showDeathMessages false"); + playerData = new HashMap(); for(Player player : playerList.values()) { resetPlayerData(player.getName(),true); diff --git a/src/main/java/net/tylermurphy/hideAndSeek/manager/EventManager.java b/src/main/java/net/tylermurphy/hideAndSeek/manager/EventManager.java index 99825f7..8a4923e 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/manager/EventManager.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/manager/EventManager.java @@ -2,6 +2,7 @@ package net.tylermurphy.hideAndSeek.manager; import static net.tylermurphy.hideAndSeek.Store.*; +import org.bukkit.Bukkit; import org.bukkit.GameMode; import org.bukkit.Location; import org.bukkit.event.EventHandler; @@ -11,6 +12,8 @@ import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.potion.PotionEffect; +import net.md_5.bungee.api.ChatColor; + public class EventManager implements Listener { @EventHandler @@ -43,6 +46,13 @@ public class EventManager implements Listener { @EventHandler public void onDeath(PlayerDeathEvent event) { if(status.equals("Playing")) { + if(Hider.hasEntry(event.getEntity().getName())) { + Bukkit.getServer().broadcastMessage(String.format(messagePrefix + "%s%s has died", ChatColor.GOLD, event.getEntity().getName())); + } + if(Seeker.hasEntry(event.getEntity().getName())) { + Bukkit.getServer().broadcastMessage(String.format(messagePrefix + "%s%s has died", ChatColor.RED, event.getEntity().getName())); + } + setPlayerData(event.getEntity().getName(), "Death", 1); setPlayerData(event.getEntity().getName(), "GiveStatus", 1); } diff --git a/src/main/java/net/tylermurphy/hideAndSeek/manager/TickManager.java b/src/main/java/net/tylermurphy/hideAndSeek/manager/TickManager.java index 5ee491a..7b6cedf 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/manager/TickManager.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/manager/TickManager.java @@ -149,6 +149,10 @@ public class TickManager { } for(Player player : playerList.values()) { player.addPotionEffect(new PotionEffect(PotionEffectType.DOLPHINS_GRACE, 1000000, 1, false, false)); + if(getPlayerData(player.getName(),"Death") > 0) { + setPlayerData(player.getName(),"Death",0); + Seeker.addEntry(player.getName()); + } if(getPlayerData(player.getName(),"GiveStatus") > 0) { setPlayerData(player.getName(),"GiveStatus",0); player.getInventory().clear(); @@ -193,10 +197,6 @@ public class TickManager { player.getInventory().addItem(potion); } } - if(getPlayerData(player.getName(),"Death") > 0) { - setPlayerData(player.getName(),"Death",0); - Seeker.addEntry(player.getName()); - } } for(String playerName : Seeker.getEntries()) { Player player = playerList.get(playerName);