mirror of
https://github.com/zeshan321/ActionHealth.git
synced 2024-06-24 13:44:58 +02:00
Added options to hide health
This commit is contained in:
parent
3173beaefb
commit
33d27d089d
10
config.yml
10
config.yml
|
@ -40,9 +40,9 @@ Half Health Icon: "&c\u2764"
|
||||||
Empty Health Icon: "&7\u2764"
|
Empty Health Icon: "&7\u2764"
|
||||||
|
|
||||||
# Set names. Case sensitive!
|
# Set names. Case sensitive!
|
||||||
Name Change: false
|
Name Change: true
|
||||||
Name:
|
Name:
|
||||||
- Cow = Kuh
|
- SNOWMAN = Snow Golem
|
||||||
|
|
||||||
# ActionHealth will be disabled for any world names added below. Case sensitive!
|
# ActionHealth will be disabled for any world names added below. Case sensitive!
|
||||||
Disabled worlds:
|
Disabled worlds:
|
||||||
|
@ -67,3 +67,9 @@ Blacklist:
|
||||||
# Show the health of the entity that the player is looking at.
|
# Show the health of the entity that the player is looking at.
|
||||||
Show On Look: false
|
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
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -1,6 +1,6 @@
|
||||||
name: ActionHealth
|
name: ActionHealth
|
||||||
main: com.zeshanaslam.actionhealth.Main
|
main: com.zeshanaslam.actionhealth.Main
|
||||||
version: 3.1.7
|
version: 3.1.8
|
||||||
softdepend: [MVdWPlaceholderAPI]
|
softdepend: [MVdWPlaceholderAPI]
|
||||||
commands:
|
commands:
|
||||||
Actionhealth:
|
Actionhealth:
|
||||||
|
|
|
@ -4,9 +4,11 @@ import be.maximvdw.placeholderapi.PlaceholderAPI;
|
||||||
import com.sk89q.worldguard.protection.ApplicableRegionSet;
|
import com.sk89q.worldguard.protection.ApplicableRegionSet;
|
||||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.potion.PotionEffectType;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
|
@ -21,6 +23,35 @@ public class HealthUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendHealth(Player receiver, LivingEntity entity, double health) {
|
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) {
|
if (plugin.settingsManager.delay) {
|
||||||
|
|
||||||
new BukkitRunnable() {
|
new BukkitRunnable() {
|
||||||
|
@ -53,6 +84,7 @@ public class HealthUtil {
|
||||||
|
|
||||||
if (plugin.settingsManager.blacklist.contains(name)) return null;
|
if (plugin.settingsManager.blacklist.contains(name)) return null;
|
||||||
|
|
||||||
|
System.out.println(entity.getName());
|
||||||
if (plugin.settingsManager.stripName) name = ChatColor.stripColor(name);
|
if (plugin.settingsManager.stripName) name = ChatColor.stripColor(name);
|
||||||
if (plugin.settingsManager.translate.containsKey(entity.getName()))
|
if (plugin.settingsManager.translate.containsKey(entity.getName()))
|
||||||
name = plugin.settingsManager.translate.get(entity.getName());
|
name = plugin.settingsManager.translate.get(entity.getName());
|
||||||
|
|
|
@ -19,6 +19,9 @@ public class SettingsManager {
|
||||||
public boolean checkPvP;
|
public boolean checkPvP;
|
||||||
public boolean stripName;
|
public boolean stripName;
|
||||||
public boolean rememberToggle;
|
public boolean rememberToggle;
|
||||||
|
public boolean canSee;
|
||||||
|
public boolean invisiblePotion;
|
||||||
|
public boolean spectatorMode;
|
||||||
public String filledHeartIcon;
|
public String filledHeartIcon;
|
||||||
public String halfHeartIcon;
|
public String halfHeartIcon;
|
||||||
public String emptyHeartIcon;
|
public String emptyHeartIcon;
|
||||||
|
@ -40,6 +43,7 @@ public class SettingsManager {
|
||||||
worlds.clear();
|
worlds.clear();
|
||||||
regions.clear();
|
regions.clear();
|
||||||
blacklist.clear();
|
blacklist.clear();
|
||||||
|
translate.clear();
|
||||||
|
|
||||||
if (plugin.taskID != -1) Bukkit.getScheduler().cancelTask(plugin.taskID);
|
if (plugin.taskID != -1) Bukkit.getScheduler().cancelTask(plugin.taskID);
|
||||||
|
|
||||||
|
@ -114,5 +118,23 @@ public class SettingsManager {
|
||||||
} else {
|
} else {
|
||||||
disableMessage = "&7ActionHealth has been &cdisabled&7.";
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user