mirror of
https://github.com/TuxCoding/FastLogin.git
synced 2025-07-30 10:47:33 +02:00
Implement auto login for Floodgate players
This is buggy in most cases.
This commit is contained in:
@ -226,6 +226,13 @@
|
|||||||
<version>1.2.0-SNAPSHOT</version>
|
<version>1.2.0-SNAPSHOT</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.geysermc</groupId>
|
||||||
|
<artifactId>floodgate-bukkit</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!--No maven repository :(-->
|
<!--No maven repository :(-->
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@ -3,6 +3,7 @@ package com.github.games647.fastlogin.bukkit.listener;
|
|||||||
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;
|
||||||
import com.github.games647.fastlogin.bukkit.task.ForceLoginTask;
|
import com.github.games647.fastlogin.bukkit.task.ForceLoginTask;
|
||||||
|
import com.github.games647.fastlogin.core.StoredProfile;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -13,6 +14,8 @@ import org.bukkit.event.player.PlayerJoinEvent;
|
|||||||
import org.bukkit.event.player.PlayerLoginEvent;
|
import org.bukkit.event.player.PlayerLoginEvent;
|
||||||
import org.bukkit.event.player.PlayerLoginEvent.Result;
|
import org.bukkit.event.player.PlayerLoginEvent.Result;
|
||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
|
import org.geysermc.floodgate.FloodgateAPI;
|
||||||
|
import org.geysermc.floodgate.FloodgatePlayer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This listener tells authentication plugins if the player has a premium account and we checked it successfully. So the
|
* This listener tells authentication plugins if the player has a premium account and we checked it successfully. So the
|
||||||
@ -45,7 +48,20 @@ public class ConnectionListener implements Listener {
|
|||||||
// cases: Paper (firing BungeeCord message before PlayerJoinEvent) or not running BungeeCord and already
|
// cases: Paper (firing BungeeCord message before PlayerJoinEvent) or not running BungeeCord and already
|
||||||
// having the login session from the login process
|
// having the login session from the login process
|
||||||
BukkitLoginSession session = plugin.getSession(player.getAddress());
|
BukkitLoginSession session = plugin.getSession(player.getAddress());
|
||||||
if (session == null) {
|
FloodgatePlayer floodgatePlayer = FloodgateAPI.getPlayer(player.getUniqueId());
|
||||||
|
if (floodgatePlayer != null) {
|
||||||
|
StoredProfile profile = plugin.getCore().getStorage().loadProfile(player.getName());
|
||||||
|
|
||||||
|
//create fake session to make auto login work
|
||||||
|
session = new BukkitLoginSession(player.getName(), profile.isSaved());
|
||||||
|
session.setVerified(true);
|
||||||
|
|
||||||
|
//start auto login
|
||||||
|
//TODO: configurate auto login for floodgate players
|
||||||
|
//TODO: fix bug: registering as bedrock player breaks java auto login
|
||||||
|
Runnable forceLoginTask = new ForceLoginTask(plugin.getCore(), player, session);
|
||||||
|
Bukkit.getScheduler().runTaskAsynchronously(plugin, forceLoginTask);
|
||||||
|
} else if (session == null) {
|
||||||
String sessionId = plugin.getSessionId(player.getAddress());
|
String sessionId = plugin.getSessionId(player.getAddress());
|
||||||
plugin.getLog().info("No on-going login session for player: {} with ID {}", player, sessionId);
|
plugin.getLog().info("No on-going login session for player: {} with ID {}", player, sessionId);
|
||||||
} else {
|
} else {
|
||||||
|
@ -14,6 +14,9 @@ import java.util.Random;
|
|||||||
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.geysermc.connector.GeyserConnector;
|
||||||
|
import org.geysermc.connector.common.AuthType;
|
||||||
|
import org.geysermc.connector.network.session.GeyserSession;
|
||||||
|
|
||||||
public class NameCheckTask extends JoinManagement<Player, CommandSender, ProtocolLibLoginSource>
|
public class NameCheckTask extends JoinManagement<Player, CommandSender, ProtocolLibLoginSource>
|
||||||
implements Runnable {
|
implements Runnable {
|
||||||
@ -42,6 +45,19 @@ public class NameCheckTask extends JoinManagement<Player, CommandSender, Protoco
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
|
// check if the player is connecting through Geyser
|
||||||
|
if (GeyserConnector.getInstance().getDefaultAuthType() == AuthType.FLOODGATE) {
|
||||||
|
// the Floodgate API requires UUID, which is inaccessible at this state
|
||||||
|
// workaround: iterate over Geyser's player's usernames
|
||||||
|
for (GeyserSession geyserPlayer : GeyserConnector.getInstance().getPlayers()) {
|
||||||
|
if (geyserPlayer.getName().equals(username)) {
|
||||||
|
plugin.getLog().info(
|
||||||
|
"Player {} is connecting through Geyser Floodgate.",
|
||||||
|
username);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
super.onLogin(username, new ProtocolLibLoginSource(packetEvent, player, random, publicKey));
|
super.onLogin(username, new ProtocolLibLoginSource(packetEvent, player, random, publicKey));
|
||||||
} finally {
|
} finally {
|
||||||
ProtocolLibrary.getProtocolManager().getAsynchronousManager().signalPacketTransmission(packetEvent);
|
ProtocolLibrary.getProtocolManager().getAsynchronousManager().signalPacketTransmission(packetEvent);
|
||||||
|
@ -90,21 +90,6 @@ public class ProtocolLibListener extends PacketAdapter {
|
|||||||
String username = packet.getGameProfiles().read(0).getName();
|
String username = packet.getGameProfiles().read(0).getName();
|
||||||
plugin.getLog().trace("GameProfile {} with {} connecting", sessionKey, username);
|
plugin.getLog().trace("GameProfile {} with {} connecting", sessionKey, username);
|
||||||
|
|
||||||
// check if the player is connecting through Geyser
|
|
||||||
if (GeyserConnector.getInstance().getDefaultAuthType() == AuthType.FLOODGATE) {
|
|
||||||
// the Floodgate API requires UUID, which is inaccessible at this state
|
|
||||||
// workaround: iterate over Geyser's player's usernames
|
|
||||||
for (GeyserSession geyserPlayer : GeyserConnector.getInstance().getPlayers()) {
|
|
||||||
if (geyserPlayer.getName().equals(username)) {
|
|
||||||
plugin.getLog().info(
|
|
||||||
"Player {} is connecting throught Geyser Floodgate. FastLogin will not check this player.",
|
|
||||||
username);
|
|
||||||
// TODO: auto login (WHEN?)
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
packetEvent.getAsyncMarker().incrementProcessingDelay();
|
packetEvent.getAsyncMarker().incrementProcessingDelay();
|
||||||
Runnable nameCheckTask = new NameCheckTask(plugin, packetEvent, random, player, username, keyPair.getPublic());
|
Runnable nameCheckTask = new NameCheckTask(plugin, packetEvent, random, player, username, keyPair.getPublic());
|
||||||
plugin.getScheduler().runAsync(nameCheckTask);
|
plugin.getScheduler().runAsync(nameCheckTask);
|
||||||
|
Reference in New Issue
Block a user