Skip to content

Commit 999738e

Browse files
author
games647
authored
Merge pull request #715 from Smart123s/fix/bukkit/noplibload
Fix plugin start without ProtocolLib installed
2 parents 9b04ea5 + 7951c4c commit 999738e

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

bukkit/src/main/java/com/github/games647/fastlogin/bukkit/FastLoginBukkit.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
*/
2626
package com.github.games647.fastlogin.bukkit;
2727

28-
import com.comphenix.protocol.ProtocolLibrary;
2928
import com.github.games647.fastlogin.bukkit.command.CrackedCommand;
3029
import com.github.games647.fastlogin.bukkit.command.PremiumCommand;
3130
import com.github.games647.fastlogin.bukkit.listener.ConnectionListener;
@@ -121,7 +120,7 @@ public void onEnable() {
121120

122121
if (isPluginInstalled("floodgate")) {
123122
if (getConfig().getBoolean("floodgatePrefixWorkaround")){
124-
ProtocolLibrary.getProtocolManager().addPacketListener(new ManualNameChange(this, floodgateService));
123+
ManualNameChange.register(this, floodgateService);
125124
logger.info("Floodgate prefix injection workaround has been enabled.");
126125
logger.info("If you have problems joining the server, try disabling it in the configuration.");
127126
} else {

bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/protocollib/ManualNameChange.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@
3636

3737
import static com.comphenix.protocol.PacketType.Login.Client.START;
3838

39+
import com.comphenix.protocol.ProtocolLibrary;
40+
3941
/**
4042
* Manually inject Floodgate player name prefixes.
4143
* <br>
@@ -57,6 +59,14 @@ public ManualNameChange(FastLoginBukkit plugin, FloodgateService floodgate) {
5759
this.floodgate = floodgate;
5860
}
5961

62+
public static void register(FastLoginBukkit plugin, FloodgateService floodgate) {
63+
// they will be created with a static builder, because otherwise it will throw a NoClassDefFoundError
64+
ProtocolLibrary.getProtocolManager()
65+
.getAsynchronousManager()
66+
.registerAsyncHandler(new ManualNameChange(plugin, floodgate))
67+
.start();
68+
}
69+
6070
@Override
6171
public void onPacketReceiving(PacketEvent packetEvent) {
6272
PacketContainer packet = packetEvent.getPacket();

0 commit comments

Comments
 (0)