Added options to hide health

This commit is contained in:
Zeshan Aslam 2017-06-22 16:32:24 -04:00
parent 3173beaefb
commit 33d27d089d
7 changed files with 64 additions and 4 deletions

View File

@ -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
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

View File

@ -1,6 +1,6 @@
name: ActionHealth
main: com.zeshanaslam.actionhealth.Main
version: 3.1.7
version: 3.1.8
softdepend: [MVdWPlaceholderAPI]
commands:
Actionhealth:

View File

@ -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());

View File

@ -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;
}
}
}