Skip to content

Commit 4b3ccf4

Browse files
committed
Event priorities, and disabled worlds for the new health bar feature.
1 parent 9279760 commit 4b3ccf4

6 files changed

Lines changed: 25 additions & 6 deletions

File tree

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>me.nik</groupId>
88
<artifactId>CombatPlus</artifactId>
9-
<version>1.4.11</version>
9+
<version>1.4.12</version>
1010
<packaging>jar</packaging>
1111

1212
<name>CombatPlus</name>

src/main/java/me/nik/combatplus/files/Config.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,9 @@ public enum Setting {
126126

127127
ENCHANTED_APPLE_CRAFTING("enchanted_golden_apple_crafting", false, "Should we make Enchanted Golden Apples craftable again?"),
128128

129-
HEALTHBAR_ENABLED("healthbar", true, "Would you like Combat Plus to send an Actionbar message to the Attacker indicating the Target's Health and Damage Dealt?"),
129+
HEALTHBAR("healthbar", "", "Healthbar Properties"),
130+
HEALTHBAR_ENABLED("healthbar.enabled", true, "Would you like Combat Plus to send an Actionbar message to the Attacker indicating the Target's Health and Damage Dealt?"),
131+
HEALTHBAR_WORLDS("healthbar.disabled_worlds", Collections.singletonList("example_world"), "Worlds listed below will be ignored from applying the above features"),
130132

131133
FIXES("fixes", "", "Fixes properties"),
132134
FIX_PROJECTILES("fixes.projectile_fixer", true, "Improves Projectile Velocity"),

src/main/java/me/nik/combatplus/listeners/FishingRodKnockback.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import org.bukkit.entity.LivingEntity;
1212
import org.bukkit.entity.Player;
1313
import org.bukkit.event.EventHandler;
14+
import org.bukkit.event.EventPriority;
1415
import org.bukkit.event.Listener;
1516
import org.bukkit.event.entity.EntityDamageByEntityEvent;
1617
import org.bukkit.event.entity.EntityDamageEvent;
@@ -23,7 +24,7 @@ public class FishingRodKnockback implements Listener {
2324
Bring back old fishing rod behavior
2425
*/
2526

26-
@EventHandler
27+
@EventHandler(priority = EventPriority.HIGHEST)
2728
public void onRodLand(ProjectileHitEvent e) {
2829
Entity rodHook = e.getEntity();
2930
if (e.getEntityType() != EntityType.FISHING_HOOK) return;
@@ -60,7 +61,7 @@ public void onRodLand(ProjectileHitEvent e) {
6061
Messenger.debug(holder, "&3Fishing Rod Knockback &f&l>> &6Velocity: &a" + livingEntity.getVelocity().toString());
6162
}
6263

63-
@EventHandler
64+
@EventHandler(priority = EventPriority.HIGHEST)
6465
public void onHook(PlayerFishEvent e) {
6566
if (!Config.Setting.FISHING_ROD_CANCEL_DRAG.getBoolean()) return;
6667
if (e.getState() != PlayerFishEvent.State.CAUGHT_ENTITY) return;

src/main/java/me/nik/combatplus/listeners/HealthBar.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,29 @@
11
package me.nik.combatplus.listeners;
22

33
import me.nik.combatplus.utils.Messenger;
4+
import me.nik.combatplus.utils.WorldUtils;
45
import net.md_5.bungee.api.ChatMessageType;
56
import net.md_5.bungee.api.chat.TextComponent;
67
import org.bukkit.attribute.Attribute;
78
import org.bukkit.entity.LivingEntity;
89
import org.bukkit.entity.Player;
910
import org.bukkit.event.EventHandler;
11+
import org.bukkit.event.EventPriority;
1012
import org.bukkit.event.Listener;
1113
import org.bukkit.event.entity.EntityDamageByEntityEvent;
1214

1315
public class HealthBar implements Listener {
1416

15-
@EventHandler
17+
private final WorldUtils worldUtils = new WorldUtils();
18+
19+
@EventHandler(priority = EventPriority.LOWEST)
1620
public void onCombat(EntityDamageByEntityEvent e) {
1721
if (!(e.getDamager() instanceof Player)) return;
22+
23+
if (worldUtils.healthBarDisabledWorlds((Player) e.getDamager())) return;
24+
1825
if (!(e.getEntity() instanceof LivingEntity)) return;
26+
1927
Player p = (Player) e.getDamager();
2028
LivingEntity entity = (LivingEntity) e.getEntity();
2129

src/main/java/me/nik/combatplus/utils/WorldUtils.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,12 @@ public boolean offhandDisabledWorlds(Player player) {
5252
}
5353
return false;
5454
}
55+
56+
public boolean healthBarDisabledWorlds(Player player) {
57+
for (String world : Config.Setting.HEALTHBAR_WORLDS.getStringList()) {
58+
if (player.getWorld().getName().equalsIgnoreCase(world))
59+
return true;
60+
}
61+
return false;
62+
}
5563
}

version.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.4.11
1+
1.4.12

0 commit comments

Comments
 (0)