mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2024-11-04 19:15:57 +00:00
Use reflection-based detection for pickup listener in player listener (#2151)
Allows the plugin to start up on Glowstone correctly. Tested on Spigot 1.12.2, Spigot 1.9.4 and Glowstone 2018.7.0, works correctly on all.
This commit is contained in:
parent
f3f4395da7
commit
9576ea25a6
1 changed files with 12 additions and 4 deletions
|
@ -7,7 +7,6 @@ import com.earth2me.essentials.textreader.TextPager;
|
|||
import com.earth2me.essentials.utils.DateUtil;
|
||||
import com.earth2me.essentials.utils.LocationUtil;
|
||||
import net.ess3.api.IEssentials;
|
||||
import net.ess3.nms.refl.ReflUtil;
|
||||
|
||||
import org.bukkit.BanEntry;
|
||||
import org.bukkit.BanList;
|
||||
|
@ -57,10 +56,10 @@ public class EssentialsPlayerListener implements Listener {
|
|||
|
||||
public void registerEvents() {
|
||||
ess.getServer().getPluginManager().registerEvents(this, ess);
|
||||
if (ReflUtil.getNmsVersionObject().isLowerThan(ReflUtil.V1_12_R1)) {
|
||||
ess.getServer().getPluginManager().registerEvents(new PlayerListenerPre1_12(), ess);
|
||||
} else {
|
||||
if (isEntityPickupEvent()) {
|
||||
ess.getServer().getPluginManager().registerEvents(new PlayerListener1_12(), ess);
|
||||
} else {
|
||||
ess.getServer().getPluginManager().registerEvents(new PlayerListenerPre1_12(), ess);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -786,6 +785,15 @@ public class EssentialsPlayerListener implements Listener {
|
|||
user.updateActivityOnInteract(true);
|
||||
}
|
||||
|
||||
private static boolean isEntityPickupEvent() {
|
||||
try {
|
||||
Class.forName("org.bukkit.event.entity.EntityPickupItemEvent");
|
||||
return true;
|
||||
} catch (ClassNotFoundException ignored) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private final class PlayerListenerPre1_12 implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
|
|
Loading…
Reference in a new issue