forked from TuxCoding/FastLogin
Fix using asynchronous manager in synchronous mode
This commit is contained in:
@ -25,7 +25,6 @@
|
|||||||
*/
|
*/
|
||||||
package com.github.games647.fastlogin.bukkit;
|
package com.github.games647.fastlogin.bukkit;
|
||||||
|
|
||||||
import com.comphenix.protocol.ProtocolLibrary;
|
|
||||||
import com.github.games647.fastlogin.bukkit.command.CrackedCommand;
|
import com.github.games647.fastlogin.bukkit.command.CrackedCommand;
|
||||||
import com.github.games647.fastlogin.bukkit.command.PremiumCommand;
|
import com.github.games647.fastlogin.bukkit.command.PremiumCommand;
|
||||||
import com.github.games647.fastlogin.bukkit.listener.ConnectionListener;
|
import com.github.games647.fastlogin.bukkit.listener.ConnectionListener;
|
||||||
@ -208,9 +207,9 @@ public class FastLoginBukkit extends JavaPlugin implements PlatformPlugin<Comman
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isPluginInstalled("ProtocolLib")) {
|
// if (isPluginInstalled("ProtocolLib")) {
|
||||||
ProtocolLibrary.getProtocolManager().getAsynchronousManager().unregisterAsyncHandlers(this);
|
// ProtocolLibrary.getProtocolManager().getAsynchronousManager().unregisterAsyncHandlers(this);
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
public FastLoginCore<Player, CommandSender, FastLoginBukkit> getCore() {
|
public FastLoginCore<Player, CommandSender, FastLoginBukkit> getCore() {
|
||||||
|
@ -25,7 +25,6 @@
|
|||||||
*/
|
*/
|
||||||
package com.github.games647.fastlogin.bukkit.listener.protocollib;
|
package com.github.games647.fastlogin.bukkit.listener.protocollib;
|
||||||
|
|
||||||
import com.comphenix.protocol.ProtocolLibrary;
|
|
||||||
import com.comphenix.protocol.events.PacketAdapter;
|
import com.comphenix.protocol.events.PacketAdapter;
|
||||||
import com.comphenix.protocol.events.PacketContainer;
|
import com.comphenix.protocol.events.PacketContainer;
|
||||||
import com.comphenix.protocol.events.PacketEvent;
|
import com.comphenix.protocol.events.PacketEvent;
|
||||||
@ -62,10 +61,10 @@ public class ManualNameChange extends PacketAdapter {
|
|||||||
|
|
||||||
public static void register(FastLoginBukkit plugin, FloodgateService floodgate) {
|
public static void register(FastLoginBukkit plugin, FloodgateService floodgate) {
|
||||||
// they will be created with a static builder, because otherwise it will throw a NoClassDefFoundError
|
// they will be created with a static builder, because otherwise it will throw a NoClassDefFoundError
|
||||||
ProtocolLibrary.getProtocolManager()
|
// ProtocolLibrary.getProtocolManager()
|
||||||
.getAsynchronousManager()
|
// .getAsynchronousManager()
|
||||||
.registerAsyncHandler(new ManualNameChange(plugin, floodgate))
|
// .registerAsyncHandler(new ManualNameChange(plugin, floodgate))
|
||||||
.start();
|
// .start();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -25,7 +25,6 @@
|
|||||||
*/
|
*/
|
||||||
package com.github.games647.fastlogin.bukkit.listener.protocollib;
|
package com.github.games647.fastlogin.bukkit.listener.protocollib;
|
||||||
|
|
||||||
import com.comphenix.protocol.ProtocolLibrary;
|
|
||||||
import com.comphenix.protocol.events.PacketEvent;
|
import com.comphenix.protocol.events.PacketEvent;
|
||||||
import com.github.games647.fastlogin.bukkit.BukkitLoginSession;
|
import com.github.games647.fastlogin.bukkit.BukkitLoginSession;
|
||||||
import com.github.games647.fastlogin.bukkit.FastLoginBukkit;
|
import com.github.games647.fastlogin.bukkit.FastLoginBukkit;
|
||||||
@ -70,11 +69,11 @@ public class NameCheckTask extends JoinManagement<Player, CommandSender, Protoco
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
// try {
|
||||||
super.onLogin(username, new ProtocolLibLoginSource(player, random, serverKey, clientKey));
|
super.onLogin(username, new ProtocolLibLoginSource(player, random, serverKey, clientKey));
|
||||||
} finally {
|
// } finally {
|
||||||
ProtocolLibrary.getProtocolManager().getAsynchronousManager().signalPacketTransmission(packetEvent);
|
// ProtocolLibrary.getProtocolManager().getAsynchronousManager().signalPacketTransmission(packetEvent);
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -106,9 +105,9 @@ public class NameCheckTask extends JoinManagement<Player, CommandSender, Protoco
|
|||||||
BukkitLoginSession playerSession = new BukkitLoginSession(username, verify, clientKey, registered, profile);
|
BukkitLoginSession playerSession = new BukkitLoginSession(username, verify, clientKey, registered, profile);
|
||||||
plugin.putSession(player.getAddress(), playerSession);
|
plugin.putSession(player.getAddress(), playerSession);
|
||||||
//cancel only if the player has a paid account otherwise login as normal offline player
|
//cancel only if the player has a paid account otherwise login as normal offline player
|
||||||
synchronized (packetEvent.getAsyncMarker().getProcessingLock()) {
|
// synchronized (packetEvent.getAsyncMarker().getProcessingLock()) {
|
||||||
packetEvent.setCancelled(true);
|
packetEvent.setCancelled(true);
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -152,12 +152,13 @@ public class ProtocolLibListener extends PacketAdapter {
|
|||||||
} else {
|
} else {
|
||||||
byte[] expectedVerifyToken = session.getVerifyToken();
|
byte[] expectedVerifyToken = session.getVerifyToken();
|
||||||
if (verifyNonce(sender, packetEvent.getPacket(), session.getClientPublicKey(), expectedVerifyToken)) {
|
if (verifyNonce(sender, packetEvent.getPacket(), session.getClientPublicKey(), expectedVerifyToken)) {
|
||||||
packetEvent.getAsyncMarker().incrementProcessingDelay();
|
// packetEvent.getAsyncMarker().incrementProcessingDelay();
|
||||||
|
|
||||||
Runnable verifyTask = new VerifyResponseTask(
|
Runnable verifyTask = new VerifyResponseTask(
|
||||||
plugin, packetEvent, sender, session, sharedSecret, keyPair
|
plugin, packetEvent, sender, session, sharedSecret, keyPair
|
||||||
);
|
);
|
||||||
plugin.getScheduler().runAsync(verifyTask);
|
verifyTask.run();
|
||||||
|
// plugin.getScheduler().runAsync(verifyTask);
|
||||||
} else {
|
} else {
|
||||||
sender.kickPlayer(plugin.getCore().getMessage("invalid-verify-token"));
|
sender.kickPlayer(plugin.getCore().getMessage("invalid-verify-token"));
|
||||||
}
|
}
|
||||||
@ -229,11 +230,12 @@ public class ProtocolLibListener extends PacketAdapter {
|
|||||||
|
|
||||||
plugin.getLog().trace("GameProfile {} with {} connecting", sessionKey, username);
|
plugin.getLog().trace("GameProfile {} with {} connecting", sessionKey, username);
|
||||||
|
|
||||||
packetEvent.getAsyncMarker().incrementProcessingDelay();
|
// packetEvent.getAsyncMarker().incrementProcessingDelay();
|
||||||
Runnable nameCheckTask = new NameCheckTask(
|
Runnable nameCheckTask = new NameCheckTask(
|
||||||
plugin, random, player, packetEvent, username, clientKey.orElse(null), keyPair.getPublic()
|
plugin, random, player, packetEvent, username, clientKey.orElse(null), keyPair.getPublic()
|
||||||
);
|
);
|
||||||
plugin.getScheduler().runAsync(nameCheckTask);
|
// plugin.getScheduler().runAsync(nameCheckTask);
|
||||||
|
nameCheckTask.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
private Optional<ClientPublicKey> verifyPublicKey(WrappedProfileKeyData profileKey) {
|
private Optional<ClientPublicKey> verifyPublicKey(WrappedProfileKeyData profileKey) {
|
||||||
|
@ -108,11 +108,11 @@ public class VerifyResponseTask implements Runnable {
|
|||||||
verifyResponse(session);
|
verifyResponse(session);
|
||||||
} finally {
|
} finally {
|
||||||
//this is a fake packet; it shouldn't be sent to the server
|
//this is a fake packet; it shouldn't be sent to the server
|
||||||
synchronized (packetEvent.getAsyncMarker().getProcessingLock()) {
|
// synchronized (packetEvent.getAsyncMarker().getProcessingLock()) {
|
||||||
packetEvent.setCancelled(true);
|
packetEvent.setCancelled(true);
|
||||||
}
|
// }
|
||||||
|
|
||||||
ProtocolLibrary.getProtocolManager().getAsynchronousManager().signalPacketTransmission(packetEvent);
|
// ProtocolLibrary.getProtocolManager().getAsynchronousManager().signalPacketTransmission(packetEvent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user