Bug fixes and new config option
- Fixed "Use Permission" not working. - Added option to disable showing NPC health. - Fixed "Show On Look" not checking if entities match requirements.
This commit is contained in:
parent
8c238ea3d6
commit
11abb7a617
|
@ -36,6 +36,9 @@ Show Mob: true
|
|||
# If set to false player will not see health messages from other players.
|
||||
Show Player: true
|
||||
|
||||
# If set to false player will not see health messages from npcs.
|
||||
Show NPC: true
|
||||
|
||||
# If set to true player will get the message in a delay to get 100% accurate health. Useful for plugins that add damage by reading item lore.
|
||||
Delay Message: false
|
||||
# Amount delayed by
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -1,6 +1,6 @@
|
|||
name: ActionHealth
|
||||
main: com.zeshanaslam.actionhealth.Main
|
||||
version: 3.3.3
|
||||
version: 3.3.4
|
||||
softdepend: [PlaceholderAPI, MVdWPlaceholderAPI, WorldGuard, mcMMO]
|
||||
commands:
|
||||
Actionhealth:
|
||||
|
|
|
@ -41,12 +41,11 @@ public class LookThread extends BukkitRunnable {
|
|||
List<LivingEntity> entities = TargetHelper.getLivingTargets(player, plugin.configStore.lookDistance);
|
||||
if (!entities.isEmpty()) {
|
||||
for (LivingEntity livingEntity : entities) {
|
||||
if (livingEntity.getType().name().equals("ARMOR_STAND")) continue;
|
||||
if (player.getWorld() != livingEntity.getWorld()) continue;
|
||||
if (!plugin.healthUtil.matchesRequirements(player, livingEntity)) continue;
|
||||
|
||||
String name = plugin.healthUtil.getName(livingEntity);
|
||||
|
||||
if (TargetHelper.canSee(player, livingEntity.getLocation(), transparentTypeIds) && !plugin.configStore.blacklist.contains(name) && !livingEntity.hasMetadata("NPC")) {
|
||||
if (TargetHelper.canSee(player, livingEntity.getLocation(), transparentTypeIds) && !plugin.configStore.blacklist.contains(name)) {
|
||||
plugin.healthUtil.sendHealth(player, livingEntity, livingEntity.getHealth());
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -43,6 +43,7 @@ public class ConfigStore {
|
|||
public boolean hasMVdWPlaceholderAPI;
|
||||
public boolean hasPlaceholderAPI;
|
||||
public int limitHealth;
|
||||
public boolean showNPC;
|
||||
|
||||
public ConfigStore(Main plugin) {
|
||||
// Clear settings for reloads
|
||||
|
@ -70,6 +71,7 @@ public class ConfigStore {
|
|||
usePerms = plugin.getConfig().getBoolean("Use Permissions");
|
||||
showMobs = plugin.getConfig().getBoolean("Show Mob");
|
||||
showPlayers = plugin.getConfig().getBoolean("Show Player");
|
||||
showNPC = plugin.getConfig().getBoolean("Show NPC");
|
||||
delay = plugin.getConfig().getBoolean("Delay Message");
|
||||
if (plugin.getConfig().contains("Delay Tick")) {
|
||||
delayTick = plugin.getConfig().getLong("Delay Tick");
|
||||
|
|
|
@ -27,44 +27,13 @@ public class HealthListeners implements Listener {
|
|||
return;
|
||||
}
|
||||
|
||||
if (plugin.healthUtil.isDisabled(event.getDamager().getLocation())) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (plugin.configStore.worlds.contains(event.getDamager().getWorld().getName())) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (plugin.configStore.usePerms && !event.getDamager().hasPermission("ActionHealth.Health")) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if the setting 'Show Player' is enabled
|
||||
if (event.getEntity() instanceof Player) {
|
||||
if (!plugin.configStore.showPlayers) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Entity damaged = event.getEntity();
|
||||
if (damaged.getType().name().equals("ARMOR_STAND")) return;
|
||||
|
||||
if (event.getDamager() instanceof Projectile) {
|
||||
Projectile projectile = (Projectile) event.getDamager();
|
||||
|
||||
if (projectile.getShooter() instanceof Player) {
|
||||
Player player = (Player) projectile.getShooter();
|
||||
|
||||
if (!plugin.configStore.showMobs) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (player.getUniqueId() == damaged.getUniqueId()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (plugin.toggle.contains(player.getUniqueId())) {
|
||||
sendMessage(player);
|
||||
if (!plugin.healthUtil.matchesRequirements(player, damaged)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -79,27 +48,7 @@ public class HealthListeners implements Listener {
|
|||
if (event.getDamager() instanceof Player) {
|
||||
Player player = (Player) event.getDamager();
|
||||
|
||||
if (player.getUniqueId() == damaged.getUniqueId()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if the setting 'Show Player' is enabled
|
||||
if (event.getEntity() instanceof Player) {
|
||||
if (!plugin.configStore.showPlayers) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (player.hasMetadata("NPC")) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!plugin.configStore.showMobs) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (plugin.toggle.contains(player.getUniqueId())) {
|
||||
sendMessage(player);
|
||||
if (!plugin.healthUtil.matchesRequirements(player, damaged)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -111,12 +60,6 @@ public class HealthListeners implements Listener {
|
|||
}
|
||||
}
|
||||
|
||||
private void sendMessage(Player player) {
|
||||
if (plugin.configStore.toggleMessage != null && !plugin.configStore.toggleMessage.equals("")) {
|
||||
plugin.healthUtil.sendActionBar(player, plugin.configStore.toggleMessage.replace("{name}", player.getName()));
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onJoin(PlayerJoinEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
|
|
|
@ -6,6 +6,7 @@ import com.zeshanaslam.actionhealth.support.PreAction;
|
|||
import org.apache.commons.lang.WordUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.metadata.MetadataValue;
|
||||
|
@ -284,4 +285,48 @@ public class HealthUtil {
|
|||
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean matchesRequirements(Player player, Entity damaged) {
|
||||
if (damaged.getType().name().equals("ARMOR_STAND"))
|
||||
return false;
|
||||
|
||||
if (player.getWorld() != damaged.getWorld())
|
||||
return false;
|
||||
|
||||
if (damaged instanceof Player) {
|
||||
if (!plugin.configStore.showPlayers)
|
||||
return false;
|
||||
|
||||
if (!plugin.configStore.showNPC && damaged.hasMetadata("NPC"))
|
||||
return false;
|
||||
} else {
|
||||
if (!plugin.configStore.showMobs)
|
||||
return false;
|
||||
}
|
||||
|
||||
if (plugin.healthUtil.isDisabled(player.getLocation()))
|
||||
return false;
|
||||
|
||||
if (plugin.configStore.worlds.contains(player.getWorld().getName()))
|
||||
return false;
|
||||
|
||||
if (plugin.configStore.usePerms && !player.hasPermission("ActionHealth.Health"))
|
||||
return false;
|
||||
|
||||
if (player.getUniqueId() == damaged.getUniqueId())
|
||||
return false;
|
||||
|
||||
if (plugin.toggle.contains(player.getUniqueId())) {
|
||||
sendMessage(player);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void sendMessage(Player player) {
|
||||
if (plugin.configStore.toggleMessage != null && !plugin.configStore.toggleMessage.equals("")) {
|
||||
plugin.healthUtil.sendActionBar(player, plugin.configStore.toggleMessage.replace("{name}", player.getName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue