diff --git a/src/main/java/eu/decentsoftware/holograms/plugin/features/DamageDisplayFeature.java b/src/main/java/eu/decentsoftware/holograms/plugin/features/DamageDisplayFeature.java index f8803dfc..3062e271 100644 --- a/src/main/java/eu/decentsoftware/holograms/plugin/features/DamageDisplayFeature.java +++ b/src/main/java/eu/decentsoftware/holograms/plugin/features/DamageDisplayFeature.java @@ -8,6 +8,7 @@ import eu.decentsoftware.holograms.api.utils.location.LocationUtils; import org.bukkit.Location; import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.HandlerList; @@ -20,6 +21,10 @@ public class DamageDisplayFeature extends AbstractFeature implements Listener { private static final DecentHolograms PLUGIN = DecentHologramsAPI.get(); private int duration = 40; private String appearance = "&c+ {damage}"; + private boolean displayForPlayers = true; + private boolean displayForMobs = true; + private boolean zeroDamage = false; + private double heightOffset = 0.0; public DamageDisplayFeature() { super("damage_display"); @@ -35,6 +40,12 @@ public void reload() { duration = config.getInt("damage-display.duration", duration); appearance = config.getString("damage-display.appearance", appearance); + heightOffset = config.getDouble("healing-display.height", heightOffset); + + displayForPlayers = config.getBoolean("damage-display.players", displayForPlayers); + displayForMobs = config.getBoolean("damage-display.mobs", displayForMobs); + zeroDamage = config.getBoolean("damage-display.mobs", zeroDamage); + if (enabled) { this.enable(); } @@ -70,12 +81,22 @@ public void onDamage(EntityDamageEvent e) { } double damage = e.getFinalDamage(); - if (damage <= 0d) { + + if (damage <= 0d && !zeroDamage) { return; } Entity entity = e.getEntity(); - Location location = LocationUtils.randomizeLocation(entity.getLocation().clone().add(0, 1, 0)); + + if (entity instanceof Player && !displayForPlayers) { + return; + } + + if (!(entity instanceof Player) && !displayForMobs) { + return; + } + + Location location = LocationUtils.randomizeLocation(entity.getLocation().clone().add(0, 1 + heightOffset, 0)); String text = appearance.replace("{damage}", FeatureCommons.formatNumber(damage)); PLUGIN.getHologramManager().spawnTemporaryHologramLine(location, text, duration); } diff --git a/src/main/java/eu/decentsoftware/holograms/plugin/features/HealingDisplayFeature.java b/src/main/java/eu/decentsoftware/holograms/plugin/features/HealingDisplayFeature.java index 7e6b1b81..42ff1da2 100644 --- a/src/main/java/eu/decentsoftware/holograms/plugin/features/HealingDisplayFeature.java +++ b/src/main/java/eu/decentsoftware/holograms/plugin/features/HealingDisplayFeature.java @@ -8,6 +8,7 @@ import eu.decentsoftware.holograms.api.utils.location.LocationUtils; import org.bukkit.Location; import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.HandlerList; @@ -20,6 +21,9 @@ public class HealingDisplayFeature extends AbstractFeature implements Listener { private static final DecentHolograms PLUGIN = DecentHologramsAPI.get(); private int duration = 40; private String appearance = "&a+ {heal}"; + private boolean displayForPlayers = true; + private boolean displayForMobs = true; + private double heightOffset = 0.0; public HealingDisplayFeature() { super("healing_display"); @@ -35,6 +39,11 @@ public void reload() { duration = config.getInt("healing-display.duration", duration); appearance = config.getString("healing-display.appearance", appearance); + heightOffset = config.getDouble("healing-display.height", heightOffset); + + displayForPlayers = config.getBoolean("damage-display.players", displayForPlayers); + displayForMobs = config.getBoolean("damage-display.mobs", displayForMobs); + if (enabled) { this.enable(); } @@ -64,7 +73,7 @@ public String getDescription() { } @EventHandler(priority = EventPriority.HIGHEST) - public void onDamage(EntityRegainHealthEvent e) { + public void onRegain(EntityRegainHealthEvent e) { if (e.isCancelled()) { return; } @@ -75,7 +84,16 @@ public void onDamage(EntityRegainHealthEvent e) { } Entity entity = e.getEntity(); - Location location = LocationUtils.randomizeLocation(entity.getLocation().clone().add(0, 1, 0)); + + if (entity instanceof Player && !displayForPlayers) { + return; + } + + if (!(entity instanceof Player) && !displayForMobs) { + return; + } + + Location location = LocationUtils.randomizeLocation(entity.getLocation().clone().add(0, 1 + heightOffset, 0)); String text = appearance.replace("{heal}", FeatureCommons.formatNumber(heal)); PLUGIN.getHologramManager().spawnTemporaryHologramLine(location, text, duration); } diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 3c40c115..0e524d4d 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -69,11 +69,19 @@ allow-placeholders-inside-animations: false damage-display: # Do you want this feature enabled? [true/false] enabled: false + # Do you want to display damage for players? [true/false] + players: true + # Do you want to display damage for mobs? [true/false] + mobs: true + # Do you want to display 0 (or less) damage? [true/false] + zero-damage: false # How long will the hologram stay in ticks duration: 40 # Damage placeholder: {damage} # Animations and Placeholders DO work here appearance: '&c{damage}' + # Height offset + height: 0 @@ -88,12 +96,17 @@ damage-display: healing-display: # Do you want this feature enabled? [true/false] enabled: false + # Do you want to display healing for players? [true/false] + players: true + # Do you want to display healing for mobs? [true/false] + mobs: true # How long will the hologram stay in ticks duration: 40 # Heal placeholder: {heal} # Animations and Placeholders DO work here appearance: '&a+ {heal}' - + # Height offset + height: 0 # # # # # # # # # # # # # # # # #