Skip to content

Commit 2afb49e

Browse files
committed
Add fallback to method not in older Spigot versions
1 parent 60a0806 commit 2afb49e

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/main/java/com/laytonsmith/abstraction/bukkit/entities/BukkitMCHumanEntity.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,12 @@ public void setCooldown(MCMaterial material, int ticks) {
9595

9696
@Override
9797
public float getAttackCooldown() {
98-
return he.getAttackCooldown();
98+
try {
99+
return he.getAttackCooldown();
100+
} catch (NoSuchMethodError ex) {
101+
// probably before 1.15.2
102+
return 1.0f;
103+
}
99104
}
100105

101106
@Override

src/main/java/com/laytonsmith/core/functions/PlayerManagement.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5603,7 +5603,8 @@ public Integer[] numArgs() {
56035603
@Override
56045604
public String docs() {
56055605
return "double {[player]} Gets the charge value of the player's attack cooldown. This is a "
5606-
+ " double with range 0.0-1.0 inclusive. 1.0 is fully charged, while 0.0 is no charge.";
5606+
+ " double with range 0.0-1.0 inclusive. 1.0 is fully charged, while 0.0 is no charge."
5607+
+ " (Spigot versions prior to 1.15.2 will always return 1.0)";
56075608
}
56085609

56095610
@Override

0 commit comments

Comments
 (0)