Check if Geyser and Floodgate are installed before accessing them

This commit is contained in:
Smart123s
2021-03-20 13:38:41 +01:00
parent 57e797f1be
commit 0cbf2a4e20
3 changed files with 31 additions and 22 deletions

View File

@ -48,6 +48,10 @@ 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(Bukkit.getServer().getPluginManager().getPlugin("Geyser-Spigot") != null &&
Bukkit.getServer().getPluginManager().getPlugin("floodgate-bukkit") != null) {
//TODO: Does this return null if a player is connected through Geyser Online mode?
FloodgatePlayer floodgatePlayer = FloodgateAPI.getPlayer(player.getUniqueId()); FloodgatePlayer floodgatePlayer = FloodgateAPI.getPlayer(player.getUniqueId());
if (floodgatePlayer != null) { if (floodgatePlayer != null) {
StoredProfile profile = plugin.getCore().getStorage().loadProfile(player.getName()); StoredProfile profile = plugin.getCore().getStorage().loadProfile(player.getName());
@ -56,12 +60,11 @@ public class ConnectionListener implements Listener {
session = new BukkitLoginSession(player.getName(), profile.isSaved()); session = new BukkitLoginSession(player.getName(), profile.isSaved());
session.setVerified(true); session.setVerified(true);
//start auto login
//TODO: configurate auto login for floodgate players //TODO: configurate auto login for floodgate players
//TODO: fix bug: registering as bedrock player breaks java auto login //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) { 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 {

View File

@ -12,6 +12,7 @@ import com.github.games647.fastlogin.core.shared.event.FastLoginPreLoginEvent;
import java.security.PublicKey; import java.security.PublicKey;
import java.util.Random; import java.util.Random;
import org.bukkit.Bukkit;
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.GeyserConnector;
@ -46,6 +47,7 @@ public class NameCheckTask extends JoinManagement<Player, CommandSender, Protoco
public void run() { public void run() {
try { try {
// check if the player is connecting through Geyser // check if the player is connecting through Geyser
if(Bukkit.getServer().getPluginManager().getPlugin("Geyser-Spigot") != null) {
if (GeyserConnector.getInstance().getDefaultAuthType() == AuthType.FLOODGATE) { if (GeyserConnector.getInstance().getDefaultAuthType() == AuthType.FLOODGATE) {
// the Floodgate API requires UUID, which is inaccessible at this state // the Floodgate API requires UUID, which is inaccessible at this state
// workaround: iterate over Geyser's player's usernames // workaround: iterate over Geyser's player's usernames
@ -58,6 +60,7 @@ public class NameCheckTask extends JoinManagement<Player, CommandSender, Protoco
} }
} }
} }
}
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);

View File

@ -20,6 +20,9 @@ softdepend:
- ProtocolLib - ProtocolLib
# Premium variable # Premium variable
- PlaceholderAPI - PlaceholderAPI
# Floodgate
- floodgate-bukkit
- Geyser-Spigot
# Auth plugins # Auth plugins
- AuthMe - AuthMe
- LoginSecurity - LoginSecurity