Use static builder to make it independent from ProtocolLib without throwing NoClassDefFoundError

This commit is contained in:
games647
2016-12-16 15:49:40 +01:00
parent 7f96d55084
commit 0082cc6536
4 changed files with 19 additions and 9 deletions

View File

@@ -65,7 +65,7 @@
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.10.2-R0.1-SNAPSHOT</version>
<version>1.11-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
@@ -80,7 +80,7 @@
<groupId>com.github.ProtocolSupport</groupId>
<artifactId>ProtocolSupport</artifactId>
<!--4.25.dev-->
<version>5554413b51</version>
<version>a4f060dc46</version>
</dependency>
<!--Login Plugins-->

View File

@@ -1,8 +1,6 @@
package com.github.games647.fastlogin.bukkit;
import com.avaje.ebeaninternal.api.ClassUtil;
import com.comphenix.protocol.AsynchronousManager;
import com.comphenix.protocol.ProtocolLibrary;
import com.github.games647.fastlogin.bukkit.commands.CrackedCommand;
import com.github.games647.fastlogin.bukkit.commands.ImportCommand;
import com.github.games647.fastlogin.bukkit.commands.PremiumCommand;
@@ -89,13 +87,13 @@ public class FastLoginBukkit extends JavaPlugin implements PlatformPlugin<Comman
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)
AsynchronousManager asynchronousManager = ProtocolLibrary.getProtocolManager().getAsynchronousManager();
StartPacketListener startPacketListener = new StartPacketListener(this);
EncryptionPacketListener encryptionPacketListener = new EncryptionPacketListener(this);
//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
StartPacketListener.register(this, WORKER_THREADS);
EncryptionPacketListener.register(this, WORKER_THREADS);
asynchronousManager.registerAsyncHandler(startPacketListener).start(WORKER_THREADS);
asynchronousManager.registerAsyncHandler(encryptionPacketListener).start(WORKER_THREADS);
getServer().getPluginManager().registerEvents(new LoginSkinApplyListener(this), this);
} else {
getLogger().warning("Either ProtocolLib or ProtocolSupport have to be installed "

View File

@@ -1,6 +1,7 @@
package com.github.games647.fastlogin.bukkit.listener.protocollib;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.ProtocolLibrary;
import com.comphenix.protocol.events.PacketAdapter;
import com.comphenix.protocol.events.PacketEvent;
import com.github.games647.fastlogin.bukkit.FastLoginBukkit;
@@ -35,6 +36,11 @@ public class EncryptionPacketListener extends PacketAdapter {
this.plugin = plugin;
}
public static void register(FastLoginBukkit plugin, int workerThreads) {
ProtocolLibrary.getProtocolManager().getAsynchronousManager()
.registerAsyncHandler(new EncryptionPacketListener(plugin)).start(workerThreads);
}
/**
* C->S : Handshake State=2
* C->S : Login Start

View File

@@ -1,6 +1,7 @@
package com.github.games647.fastlogin.bukkit.listener.protocollib;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.ProtocolLibrary;
import com.comphenix.protocol.events.PacketAdapter;
import com.comphenix.protocol.events.PacketContainer;
import com.comphenix.protocol.events.PacketEvent;
@@ -38,6 +39,11 @@ public class StartPacketListener extends PacketAdapter {
this.plugin = plugin;
}
public static void register(FastLoginBukkit plugin, int workerThreads) {
ProtocolLibrary.getProtocolManager().getAsynchronousManager()
.registerAsyncHandler(new StartPacketListener(plugin)).start(workerThreads);
}
/**
* C->S : Handshake State=2
* C->S : Login Start