death messages, give item fix

This commit is contained in:
Tyler Murphy 2021-08-13 23:02:09 -04:00
parent e11185cf2d
commit ecb33764ef
5 changed files with 19 additions and 5 deletions

View file

@ -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 doImmediateRespawn true");
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "gamerule logAdminCommands false"); Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "gamerule logAdminCommands false");
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "gamerule naturalRegeneration 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 // Register Commands
CommandManager.registerCommands(); CommandManager.registerCommands();

View file

@ -39,7 +39,6 @@ public class Store {
} }
public static int getPlayerData(String playerName, String key) { public static int getPlayerData(String playerName, String key) {
if(playerData == null) return 0;
if(playerData.get(playerName + " " + key) == null) { if(playerData.get(playerName + " " + key) == null) {
return 0; return 0;
} else { } else {

View file

@ -41,6 +41,9 @@ public class Start implements ICommand {
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "gamerule doImmediateRespawn true"); Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "gamerule doImmediateRespawn true");
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "gamerule logAdminCommands false"); Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "gamerule logAdminCommands false");
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "gamerule naturalRegeneration 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<String,Integer>(); playerData = new HashMap<String,Integer>();
for(Player player : playerList.values()) { for(Player player : playerList.values()) {
resetPlayerData(player.getName(),true); resetPlayerData(player.getName(),true);

View file

@ -2,6 +2,7 @@ package net.tylermurphy.hideAndSeek.manager;
import static net.tylermurphy.hideAndSeek.Store.*; import static net.tylermurphy.hideAndSeek.Store.*;
import org.bukkit.Bukkit;
import org.bukkit.GameMode; import org.bukkit.GameMode;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
@ -11,6 +12,8 @@ import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffect;
import net.md_5.bungee.api.ChatColor;
public class EventManager implements Listener { public class EventManager implements Listener {
@EventHandler @EventHandler
@ -43,6 +46,13 @@ public class EventManager implements Listener {
@EventHandler @EventHandler
public void onDeath(PlayerDeathEvent event) { public void onDeath(PlayerDeathEvent event) {
if(status.equals("Playing")) { 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(), "Death", 1);
setPlayerData(event.getEntity().getName(), "GiveStatus", 1); setPlayerData(event.getEntity().getName(), "GiveStatus", 1);
} }

View file

@ -149,6 +149,10 @@ public class TickManager {
} }
for(Player player : playerList.values()) { for(Player player : playerList.values()) {
player.addPotionEffect(new PotionEffect(PotionEffectType.DOLPHINS_GRACE, 1000000, 1, false, false)); 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) { if(getPlayerData(player.getName(),"GiveStatus") > 0) {
setPlayerData(player.getName(),"GiveStatus",0); setPlayerData(player.getName(),"GiveStatus",0);
player.getInventory().clear(); player.getInventory().clear();
@ -193,10 +197,6 @@ public class TickManager {
player.getInventory().addItem(potion); player.getInventory().addItem(potion);
} }
} }
if(getPlayerData(player.getName(),"Death") > 0) {
setPlayerData(player.getName(),"Death",0);
Seeker.addEntry(player.getName());
}
} }
for(String playerName : Seeker.getEntries()) { for(String playerName : Seeker.getEntries()) {
Player player = playerList.get(playerName); Player player = playerList.get(playerName);