diff --git a/config.yml b/config.yml index c345b23..45ee4aa 100644 --- a/config.yml +++ b/config.yml @@ -40,9 +40,9 @@ Half Health Icon: "&c\u2764" Empty Health Icon: "&7\u2764" # Set names. Case sensitive! -Name Change: false +Name Change: true Name: -- Cow = Kuh +- SNOWMAN = Snow Golem # ActionHealth will be disabled for any world names added below. Case sensitive! Disabled worlds: @@ -66,4 +66,10 @@ Blacklist: # Show the health of the entity that the player is looking at. Show On Look: false -Look Distance: 10 \ No newline at end of file +Look Distance: 10 + +# Check if player can see entity before sending health. +Can See: true + +# Hide if action health if entity has invisible potion on. +Invisible Potion: true \ No newline at end of file diff --git a/out/production/ActionHealth/com/zeshanaslam/actionhealth/HealthUtil$1.class b/out/production/ActionHealth/com/zeshanaslam/actionhealth/HealthUtil$1.class index 407eda4..b90eed6 100644 Binary files a/out/production/ActionHealth/com/zeshanaslam/actionhealth/HealthUtil$1.class and b/out/production/ActionHealth/com/zeshanaslam/actionhealth/HealthUtil$1.class differ diff --git a/out/production/ActionHealth/com/zeshanaslam/actionhealth/HealthUtil.class b/out/production/ActionHealth/com/zeshanaslam/actionhealth/HealthUtil.class index d5b436e..b66b363 100644 Binary files a/out/production/ActionHealth/com/zeshanaslam/actionhealth/HealthUtil.class and b/out/production/ActionHealth/com/zeshanaslam/actionhealth/HealthUtil.class differ diff --git a/out/production/ActionHealth/com/zeshanaslam/actionhealth/SettingsManager.class b/out/production/ActionHealth/com/zeshanaslam/actionhealth/SettingsManager.class index 9e949d5..cfc81b2 100644 Binary files a/out/production/ActionHealth/com/zeshanaslam/actionhealth/SettingsManager.class and b/out/production/ActionHealth/com/zeshanaslam/actionhealth/SettingsManager.class differ diff --git a/plugin.yml b/plugin.yml index 6489331..ab82b46 100644 --- a/plugin.yml +++ b/plugin.yml @@ -1,6 +1,6 @@ name: ActionHealth main: com.zeshanaslam.actionhealth.Main -version: 3.1.7 +version: 3.1.8 softdepend: [MVdWPlaceholderAPI] commands: Actionhealth: diff --git a/src/com/zeshanaslam/actionhealth/HealthUtil.java b/src/com/zeshanaslam/actionhealth/HealthUtil.java index 34c10c6..9ad2bde 100644 --- a/src/com/zeshanaslam/actionhealth/HealthUtil.java +++ b/src/com/zeshanaslam/actionhealth/HealthUtil.java @@ -4,9 +4,11 @@ import be.maximvdw.placeholderapi.PlaceholderAPI; import com.sk89q.worldguard.protection.ApplicableRegionSet; import com.sk89q.worldguard.protection.regions.ProtectedRegion; import org.bukkit.ChatColor; +import org.bukkit.GameMode; import org.bukkit.Location; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; +import org.bukkit.potion.PotionEffectType; import org.bukkit.scheduler.BukkitRunnable; import java.lang.reflect.Field; @@ -21,6 +23,35 @@ public class HealthUtil { } public void sendHealth(Player receiver, LivingEntity entity, double health) { + if (plugin.settingsManager.canSee) { + + if (entity instanceof Player) { + Player player = (Player) entity; + + if (!receiver.canSee(player)) { + return; + } + } + } + + if (plugin.settingsManager.spectatorMode) { + + if (entity instanceof Player) { + Player player = (Player) entity; + + // Using string version for older versions + if (player.getGameMode().name().equals("SPECTATOR")) { + return; + } + } + } + + if (plugin.settingsManager.invisiblePotion) { + if (entity.hasPotionEffect(PotionEffectType.INVISIBILITY)) { + return; + } + } + if (plugin.settingsManager.delay) { new BukkitRunnable() { @@ -53,6 +84,7 @@ public class HealthUtil { if (plugin.settingsManager.blacklist.contains(name)) return null; + System.out.println(entity.getName()); if (plugin.settingsManager.stripName) name = ChatColor.stripColor(name); if (plugin.settingsManager.translate.containsKey(entity.getName())) name = plugin.settingsManager.translate.get(entity.getName()); diff --git a/src/com/zeshanaslam/actionhealth/SettingsManager.java b/src/com/zeshanaslam/actionhealth/SettingsManager.java index a54a6c3..76960e1 100644 --- a/src/com/zeshanaslam/actionhealth/SettingsManager.java +++ b/src/com/zeshanaslam/actionhealth/SettingsManager.java @@ -19,6 +19,9 @@ public class SettingsManager { public boolean checkPvP; public boolean stripName; public boolean rememberToggle; + public boolean canSee; + public boolean invisiblePotion; + public boolean spectatorMode; public String filledHeartIcon; public String halfHeartIcon; public String emptyHeartIcon; @@ -40,6 +43,7 @@ public class SettingsManager { worlds.clear(); regions.clear(); blacklist.clear(); + translate.clear(); if (plugin.taskID != -1) Bukkit.getScheduler().cancelTask(plugin.taskID); @@ -114,5 +118,23 @@ public class SettingsManager { } else { disableMessage = "&7ActionHealth has been &cdisabled&7."; } + + if (plugin.getConfig().contains("Can See")) { + canSee = plugin.getConfig().getBoolean("Can See"); + } else { + canSee = true; + } + + if (plugin.getConfig().contains("Invisible Potion")) { + invisiblePotion = plugin.getConfig().getBoolean("Invisible Potion"); + } else { + invisiblePotion = true; + } + + if (plugin.getConfig().contains("Spectator Mode")) { + spectatorMode = plugin.getConfig().getBoolean("Spectator Mode"); + } else { + spectatorMode = true; + } } }