Skip to content

Commit 7fe0234

Browse files
committed
fix for older MC versions
fixes #81
1 parent 6385814 commit 7fe0234

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

src/main/java/lol/hyper/toolstats/events/EntityDamage.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public class EntityDamage implements Listener {
3939

4040
private final ToolStats toolStats;
4141
public final Set<UUID> trackedMobs = new HashSet<>();
42-
private final List<EntityDamageEvent.DamageCause> ignoredCauses = Arrays.asList(EntityDamageEvent.DamageCause.SUICIDE, EntityDamageEvent.DamageCause.VOID, EntityDamageEvent.DamageCause.CUSTOM, EntityDamageEvent.DamageCause.KILL);
42+
private final List<String> ignoredDamageCauses = Arrays.asList("SUICIDE", "VOID", "CUSTOM", "KILL");
4343

4444
public EntityDamage(ToolStats toolStats) {
4545
this.toolStats = toolStats;
@@ -57,8 +57,8 @@ public void onDamage(EntityDamageByEntityEvent event) {
5757
LivingEntity mobBeingAttacked = (LivingEntity) event.getEntity();
5858

5959
// ignore void and /kill damage
60-
EntityDamageEvent.DamageCause cause = event.getCause();
61-
if (ignoredCauses.contains(cause)) {
60+
String cause = event.getCause().toString().toUpperCase();
61+
if (ignoredDamageCauses.contains(cause)) {
6262
return;
6363
}
6464

@@ -166,8 +166,8 @@ public void onDamage(EntityDamageEvent event) {
166166
}
167167

168168
// ignore void and /kill damage
169-
EntityDamageEvent.DamageCause cause = event.getCause();
170-
if (ignoredCauses.contains(cause)) {
169+
String cause = event.getCause().toString().toUpperCase();
170+
if (ignoredDamageCauses.contains(cause)) {
171171
return;
172172
}
173173

@@ -196,8 +196,8 @@ public void onDamage(EntityDamageByBlockEvent event) {
196196
}
197197

198198
// ignore void and /kill damage
199-
EntityDamageEvent.DamageCause cause = event.getCause();
200-
if (ignoredCauses.contains(cause)) {
199+
String cause = event.getCause().toString().toUpperCase();
200+
if (ignoredDamageCauses.contains(cause)) {
201201
return;
202202
}
203203

src/main/java/lol/hyper/toolstats/events/SheepShear.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,14 @@ public void onShear(PlayerInteractEntityEvent event) {
6464
return;
6565
}
6666

67-
Sheep sheep = (Sheep) entity;
6867
// make sure the sheep is not sheared
68+
Sheep sheep = (Sheep) entity;
6969
if (sheep.isSheared()) {
7070
return;
7171
}
7272

7373
// update the stats
74-
ItemStack finalShears = shears;
75-
addLore(finalShears);
74+
addLore(shears);
7675
}
7776

7877
private static @Nullable ItemStack getShears(Player player) {

0 commit comments

Comments
 (0)