Fix listening for login start packets if ProtocolLib is installed

Another call on ProtocolLib's types removes all previous listening types

Fixes #163
This commit is contained in:
games647
2017-07-25 13:17:55 +02:00
parent 0459b0a5a1
commit c6da04de70
2 changed files with 3 additions and 5 deletions

View File

@ -82,8 +82,6 @@ public class FastLoginBukkit extends JavaPlugin implements PlatformPlugin<Comman
if (getServer().getPluginManager().isPluginEnabled("ProtocolSupport")) {
getServer().getPluginManager().registerEvents(new ProtocolSupportListener(this), this);
} else if (getServer().getPluginManager().isPluginEnabled("ProtocolLib")) {
//we are performing HTTP request on these so run it async (seperate from the Netty IO threads)
//they will be created with a static builder, because otherwise it will throw a
//java.lang.NoClassDefFoundError: com/comphenix/protocol/events/PacketListener if ProtocolSupport was
//only found

View File

@ -25,15 +25,15 @@ public class ProtocolLibListener extends PacketAdapter {
public ProtocolLibListener(FastLoginBukkit plugin) {
//run async in order to not block the server, because we are making api calls to Mojang
super(params().plugin(plugin)
.types(PacketType.Login.Client.START)
.types(PacketType.Login.Client.ENCRYPTION_BEGIN)
.types(PacketType.Login.Client.START, PacketType.Login.Client.ENCRYPTION_BEGIN)
.optionAsync());
this.plugin = plugin;
}
public static void register(FastLoginBukkit plugin) {
ProtocolLibrary.getProtocolManager().getAsynchronousManager()
ProtocolLibrary.getProtocolManager()
.getAsynchronousManager()
.registerAsyncHandler(new ProtocolLibListener(plugin))
.start(WORKER_THREADS);
}