Avoid using ServerListPingEvent workaround on fixed Paper builds (#1925)

Fixes #1924

PaperMC/Paper#884 has been fixed in recent Paper builds (1368+),
which means the workaround is no longer necessary. Disable it when
running a fixed build.
This commit is contained in:
Minecrell 2018-03-26 09:15:55 +02:00 committed by Trent Hensler
parent 61c1485083
commit ecd6c5f81a
1 changed files with 13 additions and 8 deletions

View File

@ -25,15 +25,20 @@ public class EssentialsServerListener implements Listener {
public EssentialsServerListener(final IEssentials ess) {
this.ess = ess;
setSampleText = ReflUtil.getMethodCached(ServerListPingEvent.class, "setSampleText", List.class);
getSampleText = ReflUtil.getMethodCached(ServerListPingEvent.class, "getSampleText");
if (setSampleText != null && getSampleText != null) {
ess.getLogger().info("Using Paper 1.12+ ServerListPingEvent methods");
isPaperSample = true;
} else {
ess.getLogger().info("Using Spigot 1.7.10+ ServerListPingEvent iterator");
isPaperSample = false;
if (ReflUtil.getClassCached("com.destroystokyo.paper.event.server.PaperServerListPingEvent") == null) {
// This workaround is only necessary for older Paper builds
setSampleText = ReflUtil.getMethodCached(ServerListPingEvent.class, "setSampleText", List.class);
getSampleText = ReflUtil.getMethodCached(ServerListPingEvent.class, "getSampleText");
if (setSampleText != null && getSampleText != null) {
ess.getLogger().info("Using Paper 1.12+ ServerListPingEvent methods");
isPaperSample = true;
return;
}
}
ess.getLogger().info("Using Spigot 1.7.10+ ServerListPingEvent iterator");
isPaperSample = false;
}
@EventHandler(priority = EventPriority.LOWEST)