diff --git a/config.yml b/config.yml index 7d37126..c6c1a3e 100644 --- a/config.yml +++ b/config.yml @@ -3,32 +3,34 @@ # {health} shows current health of the mob or player. # {maxhealth} shows the max health of the mob or player. # {usestyle} will use the defined chars. - Health Message: '&7&l{name}: {usestyle}' # The message the player is sent to the player if they have actionhealth disabled. # {name} shows the name of the player. Toggle Message: '' -# Strip Name. +# Message sent to player when player enables actionhealth +# {name} shows the name of the player. +On Enable: '&7ActionHealth has been &cenabled&7.' +# Message sent to player when player disables actionhealth +# {name} shows the name of the player. +On Disable: '&7ActionHealth has been &cdisabled&7.' + +# Strip Name. Strip Name: true # If enabled players with the permission 'ActionHealth.Health' will only see the action health message. - Use Permissions: false # If set to false player will not see health messages from mobs. - Show Mob: true # If set to false player will not see health messages from other players. Show Player: 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. # This also uses more resources :( - Delay Message: false # Style Health diff --git a/out/production/ActionHealth/com/zeshanaslam/actionhealth/HealthCommand.class b/out/production/ActionHealth/com/zeshanaslam/actionhealth/HealthCommand.class index 1db9b00..01beaf3 100644 Binary files a/out/production/ActionHealth/com/zeshanaslam/actionhealth/HealthCommand.class and b/out/production/ActionHealth/com/zeshanaslam/actionhealth/HealthCommand.class differ diff --git a/out/production/ActionHealth/com/zeshanaslam/actionhealth/HealthListeners.class b/out/production/ActionHealth/com/zeshanaslam/actionhealth/HealthListeners.class index 40bf094..e931fff 100644 Binary files a/out/production/ActionHealth/com/zeshanaslam/actionhealth/HealthListeners.class and b/out/production/ActionHealth/com/zeshanaslam/actionhealth/HealthListeners.class differ diff --git a/out/production/ActionHealth/com/zeshanaslam/actionhealth/LookThread.class b/out/production/ActionHealth/com/zeshanaslam/actionhealth/LookThread.class index bf6e84e..97d8bb5 100644 Binary files a/out/production/ActionHealth/com/zeshanaslam/actionhealth/LookThread.class and b/out/production/ActionHealth/com/zeshanaslam/actionhealth/LookThread.class differ diff --git a/out/production/ActionHealth/com/zeshanaslam/actionhealth/SettingsManager.class b/out/production/ActionHealth/com/zeshanaslam/actionhealth/SettingsManager.class index d7f1d5f..7de2460 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 e9cd788..7c6f75d 100644 --- a/plugin.yml +++ b/plugin.yml @@ -1,6 +1,6 @@ name: ActionHealth main: com.zeshanaslam.actionhealth.Main -version: 3.1.4 +version: 3.1.5 commands: Actionhealth: description: Actionhealth main command. \ No newline at end of file diff --git a/src/com/zeshanaslam/actionhealth/HealthCommand.java b/src/com/zeshanaslam/actionhealth/HealthCommand.java index 61a7ea0..cc38381 100644 --- a/src/com/zeshanaslam/actionhealth/HealthCommand.java +++ b/src/com/zeshanaslam/actionhealth/HealthCommand.java @@ -39,11 +39,11 @@ public class HealthCommand implements CommandExecutor { if (plugin.toggle.contains(player.getUniqueId())) { plugin.toggle.remove(player.getUniqueId()); - player.sendMessage(ChatColor.GRAY + "ActionHealth has been " + ChatColor.RED + "enabled" + ChatColor.GRAY + "."); + player.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.settingsManager.enableMessage).replace("{name}", player.getName())); } else { plugin.toggle.add(player.getUniqueId()); - player.sendMessage(ChatColor.GRAY + "ActionHealth has been " + ChatColor.RED + "disabled" + ChatColor.GRAY + "."); + player.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.settingsManager.disableMessage).replace("{name}", player.getName())); } if (plugin.settingsManager.rememberToggle) { diff --git a/src/com/zeshanaslam/actionhealth/HealthListeners.java b/src/com/zeshanaslam/actionhealth/HealthListeners.java index b6b90ef..bea9f15 100644 --- a/src/com/zeshanaslam/actionhealth/HealthListeners.java +++ b/src/com/zeshanaslam/actionhealth/HealthListeners.java @@ -39,10 +39,6 @@ public class HealthListeners implements Listener { Entity damaged = event.getEntity(); - if (event.getDamager().getUniqueId() == damaged.getUniqueId()) { - return; - } - if (event.getDamager() instanceof Projectile) { Projectile projectile = (Projectile) event.getDamager(); @@ -60,6 +56,10 @@ public class HealthListeners implements Listener { return; } + if (player.getUniqueId() == damaged.getUniqueId()) { + return; + } + if (plugin.toggle.contains(player.getUniqueId())) { if (plugin.settingsManager.toggleMessage != null && !plugin.settingsManager.toggleMessage.equals("")) { plugin.healthUtil.sendActionBar(player, plugin.settingsManager.toggleMessage.replace("{name}", player.getName())); @@ -78,6 +78,10 @@ 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.settingsManager.showPlayers) { @@ -94,6 +98,9 @@ public class HealthListeners implements Listener { } if (plugin.toggle.contains(player.getUniqueId())) { + if (plugin.settingsManager.toggleMessage != null && !plugin.settingsManager.toggleMessage.equals("")) { + plugin.healthUtil.sendActionBar(player, plugin.settingsManager.toggleMessage.replace("{name}", player.getName())); + } return; } diff --git a/src/com/zeshanaslam/actionhealth/LookThread.java b/src/com/zeshanaslam/actionhealth/LookThread.java index 903c672..a0af10f 100644 --- a/src/com/zeshanaslam/actionhealth/LookThread.java +++ b/src/com/zeshanaslam/actionhealth/LookThread.java @@ -37,7 +37,7 @@ public class LookThread extends BukkitRunnable { name = livingEntity.getCustomName(); } - if (!plugin.settingsManager.blacklist.contains(name)) { + if (!plugin.settingsManager.blacklist.contains(name) && !livingEntity.hasMetadata("NPC")) { plugin.healthUtil.sendHealth(player, livingEntity, livingEntity.getHealth()); } } diff --git a/src/com/zeshanaslam/actionhealth/SettingsManager.java b/src/com/zeshanaslam/actionhealth/SettingsManager.java index 3b2d685..0091718 100644 --- a/src/com/zeshanaslam/actionhealth/SettingsManager.java +++ b/src/com/zeshanaslam/actionhealth/SettingsManager.java @@ -31,6 +31,8 @@ public class SettingsManager { public double lookDistance; public List blacklist = new ArrayList<>(); public String toggleMessage; + public String enableMessage; + public String disableMessage; public SettingsManager(Main plugin) { // Clear settings for reloads @@ -96,5 +98,17 @@ public class SettingsManager { if (plugin.getConfig().contains("Toggle Message")) { toggleMessage = plugin.getConfig().getString("Toggle Message"); } + + if (plugin.getConfig().contains("On Enable")) { + enableMessage = plugin.getConfig().getString("On Enable"); + } else { + enableMessage = "&7ActionHealth has been &cenabled&7."; + } + + if (plugin.getConfig().contains("On Disable")) { + disableMessage = plugin.getConfig().getString("On Disable"); + } else { + disableMessage = "&7ActionHealth has been &cdisabled&7."; + } } }