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

View file

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