Skip to content

Commit

Permalink
small optimization for older servers
Browse files Browse the repository at this point in the history
  • Loading branch information
ManInMyVan committed Jan 2, 2025
1 parent 61e5064 commit 1ce5a53
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/main/java/ac/grim/grimac/player/GrimPlayer.java
Original file line number Diff line number Diff line change
Expand Up @@ -804,11 +804,6 @@ public boolean isUsingBukkitItem() {
Consumer<Player> resetActiveBukkitItem0 = null;

try {
try { // paper 1.16+
LivingEntity.class.getMethod("clearActiveItem");
resetActiveBukkitItem0 = LivingEntity::clearActiveItem;
} catch (NoSuchMethodException ignored) {}

if (version == ServerVersion.V_1_8_8) {
Class<?> EntityHuman = Class.forName("net.minecraft.server.v1_8_R3.EntityHuman");
Method getHandle = Class.forName("org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer").getMethod("getHandle");
Expand Down Expand Up @@ -878,6 +873,10 @@ public boolean isUsingBukkitItem() {
};
} else if (version.isNewerThanOrEquals(ServerVersion.V_1_17_1)) {
isUsingBukkitItem0 = player -> player.getItemInUse() != null;
try { // paper only
LivingEntity.class.getMethod("clearActiveItem");
resetActiveBukkitItem0 = LivingEntity::clearActiveItem;
} catch (NoSuchMethodException ignored) {}
}
} catch (ClassNotFoundException | NoSuchMethodException e) {
throw new RuntimeException(e);
Expand Down

0 comments on commit 1ce5a53

Please sign in to comment.