From 20037e986f3807a35fe194a2735982a50c766e55 Mon Sep 17 00:00:00 2001 From: Tyler Murphy Date: Sat, 21 Aug 2021 22:02:11 -0400 Subject: [PATCH] hunder and standby health rewrite --- pom.xml | 2 +- .../hideAndSeek/commands/About.java | 2 +- .../hideAndSeek/manager/EventManager.java | 26 ++++++++++++------- .../hideAndSeek/manager/TickManager.java | 17 ++---------- src/main/resources/plugin.yml | 2 +- 5 files changed, 22 insertions(+), 27 deletions(-) diff --git a/pom.xml b/pom.xml index 3ab63ff..04b658d 100644 --- a/pom.xml +++ b/pom.xml @@ -1,7 +1,7 @@ 4.0.0 net.tylermurphy HideAndSeek - 1.1.0 + 1.1.1 Hide and Seek Plugin diff --git a/src/main/java/net/tylermurphy/hideAndSeek/commands/About.java b/src/main/java/net/tylermurphy/hideAndSeek/commands/About.java index 7c00369..2150b92 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/commands/About.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/commands/About.java @@ -9,7 +9,7 @@ public class About implements ICommand { public void execute(CommandSender sender, String[] args) { sender.sendMessage( - String.format("%s%sHide and Seek %s(1.1.0%s)\n", ChatColor.AQUA, ChatColor.BOLD, ChatColor.GRAY,ChatColor.WHITE,ChatColor.GRAY) + + String.format("%s%sHide and Seek %s(1.1.1%s)\n", ChatColor.AQUA, ChatColor.BOLD, ChatColor.GRAY,ChatColor.WHITE,ChatColor.GRAY) + String.format("%sAuthor: %s[KenshinEto]\n", ChatColor.GRAY, ChatColor.WHITE) + String.format("%sHelp Command: %s/hs %shelp", ChatColor.GRAY, ChatColor.AQUA, ChatColor.WHITE) ); diff --git a/src/main/java/net/tylermurphy/hideAndSeek/manager/EventManager.java b/src/main/java/net/tylermurphy/hideAndSeek/manager/EventManager.java index 9983202..0221eda 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/manager/EventManager.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/manager/EventManager.java @@ -15,6 +15,7 @@ import org.bukkit.event.Listener; import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityRegainHealthEvent; import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason; +import org.bukkit.event.entity.FoodLevelChangeEvent; import org.bukkit.event.entity.ProjectileLaunchEvent; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerQuitEvent; @@ -54,6 +55,10 @@ public class EventManager implements Listener { @EventHandler public void onPlayerDamage(EntityDamageEvent event) { if(event.getEntity() instanceof Player) { + if(!status.equals("Playing")) { + event.setCancelled(true); + return; + } Player player = (Player) event.getEntity(); if(player.getHealth()-event.getDamage() < 0) { if(spawnPosition == null) return; @@ -61,16 +66,14 @@ public class EventManager implements Listener { player.setHealth(player.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue()); player.teleport(new Location(player.getWorld(), spawnPosition.getX(), spawnPosition.getY(), spawnPosition.getZ())); Functions.playSound(player, Sound.ENTITY_PLAYER_DEATH, 1, 1); - if(status.equals("Playing")) { - Functions.resetPlayer(player); - if(Hider.hasEntry(event.getEntity().getName())) { - Bukkit.broadcastMessage(String.format(messagePrefix + "%s%s%s has died and become a seeker", ChatColor.GOLD, event.getEntity().getName(), ChatColor.WHITE)); - } - if(Seeker.hasEntry(event.getEntity().getName())) { - Bukkit.broadcastMessage(String.format(messagePrefix + "%s%s%s has been beat by a hider", ChatColor.RED, event.getEntity().getName(), ChatColor.WHITE)); - } - Seeker.addEntry(player.getName()); + Functions.resetPlayer(player); + if(Hider.hasEntry(event.getEntity().getName())) { + Bukkit.broadcastMessage(String.format(messagePrefix + "%s%s%s has died and become a seeker", ChatColor.GOLD, event.getEntity().getName(), ChatColor.WHITE)); } + if(Seeker.hasEntry(event.getEntity().getName())) { + Bukkit.broadcastMessage(String.format(messagePrefix + "%s%s%s has been beat by a hider", ChatColor.RED, event.getEntity().getName(), ChatColor.WHITE)); + } + Seeker.addEntry(player.getName()); } } @@ -99,6 +102,11 @@ public class EventManager implements Listener { } } + @EventHandler + public void onFoodLevelChange(FoodLevelChangeEvent event) { + event.setCancelled(false); + } + @EventHandler public void onPlayerRegainHealth(EntityRegainHealthEvent event) { if(event.getRegainReason() == RegainReason.SATIATED || event.getRegainReason() == RegainReason.REGEN) diff --git a/src/main/java/net/tylermurphy/hideAndSeek/manager/TickManager.java b/src/main/java/net/tylermurphy/hideAndSeek/manager/TickManager.java index 10c7c84..9172b0b 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/manager/TickManager.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/manager/TickManager.java @@ -31,14 +31,8 @@ public class TickManager { } Functions.emptyOfflinePlayers(); - - for(Player player : playerList.values()) { - player.addPotionEffect(new PotionEffect(PotionEffectType.SATURATION, 1000000, 127, false, false)); - } - - if(status.equals("Standby") || status.equals("Setup")) { - onStandby(); - } else if(status.equals("Starting")) { + + if(status.equals("Starting")) { onStarting(); } else if(status.equals("Playing")) { onPlaying(); @@ -56,13 +50,6 @@ public class TickManager { } } - private static void onStandby() { - for(Player player : playerList.values()) { - player.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, 1000000, 127, false, false)); - } - - } - private static void onStarting() { for(String playerName : Seeker.getEntries()) { Player player = playerList.get(playerName); diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 5f5ddb2..2fdb769 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -1,6 +1,6 @@ name: HideAndSeek main: net.tylermurphy.hideAndSeek.Main -version: 1.1.0 +version: 1.1.1 author: KenshinEto load: STARTUP api-version: 1.17