mirror of
https://github.com/TuxCoding/FastLogin.git
synced 2025-07-29 18:27:36 +02:00
Implement allowFloodgateNameConflict
Check config.yml for details.
This commit is contained in:
@ -14,6 +14,8 @@ import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerLoginEvent;
|
||||
import org.bukkit.event.player.PlayerLoginEvent.Result;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.geysermc.connector.GeyserConnector;
|
||||
import org.geysermc.connector.network.session.GeyserSession;
|
||||
import org.geysermc.floodgate.FloodgateAPI;
|
||||
import org.geysermc.floodgate.FloodgatePlayer;
|
||||
|
||||
@ -50,18 +52,49 @@ public class ConnectionListener implements Listener {
|
||||
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 Offline mode?
|
||||
FloodgatePlayer floodgatePlayer = FloodgateAPI.getPlayer(player.getUniqueId());
|
||||
if (floodgatePlayer != null) {
|
||||
StoredProfile profile = plugin.getCore().getStorage().loadProfile(player.getName());
|
||||
Bukkit.getServer().getPluginManager().getPlugin("floodgate-bukkit") != null) {
|
||||
FloodgatePlayer floodgatePlayer = null;
|
||||
|
||||
//create fake session to make auto login work
|
||||
// check if the player is really connected through Geyser
|
||||
for (GeyserSession geyserPlayer : GeyserConnector.getInstance().getPlayers()) {
|
||||
if (geyserPlayer.getName().equals(player.getName())) {
|
||||
// this also returns a floodgatePlayer for linked Java accounts
|
||||
// that's why the Geyser Server's player list also has to be checked
|
||||
//TODO: does this return null if a player is connected through Geyser Offline mode?
|
||||
floodgatePlayer = FloodgateAPI.getPlayer(player.getUniqueId());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (floodgatePlayer != null) {
|
||||
plugin.getLog().info(
|
||||
"Player {} is connecting through Geyser Floodgate.",
|
||||
player.getName());
|
||||
String allowNameConflict = plugin.getCore().getConfig().getString("allowFloodgateNameConflict");
|
||||
if (allowNameConflict.equalsIgnoreCase("linked") &&
|
||||
floodgatePlayer.fetchLinkedPlayer() == null) {
|
||||
plugin.getLog().info(
|
||||
"Bedrock Player {}'s name conflits an existing Java Premium Player's name",
|
||||
player.getName());
|
||||
player.kickPlayer("This name is allready in use by a Premium Java Player");
|
||||
|
||||
}
|
||||
if (!allowNameConflict.equalsIgnoreCase("true") && !allowNameConflict.equalsIgnoreCase("linked")) {
|
||||
plugin.getLog().error(
|
||||
"Invalid value detected for 'allowNameConflict' in FasttLogin/config.yml. Aborting login of Player {}",
|
||||
player.getName());
|
||||
return;
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
//TODO: configurate auto login for floodgate players
|
||||
//TODO: fix bug: registering as bedrock player breaks java auto login
|
||||
// TODO: configurate auto login for floodgate players
|
||||
// TODO: fix bug: registering as bedrock player breaks java auto login
|
||||
|
||||
}
|
||||
}
|
||||
if (session == null) {
|
||||
|
@ -47,17 +47,17 @@ public class NameCheckTask extends JoinManagement<Player, CommandSender, Protoco
|
||||
public void run() {
|
||||
try {
|
||||
// check if the player is connecting through Geyser
|
||||
if(Bukkit.getServer().getPluginManager().getPlugin("Geyser-Spigot") != null) {
|
||||
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;
|
||||
}
|
||||
if (!plugin.getCore().getConfig().getString("allowFloodgateNameConflict").equalsIgnoreCase("false") &&
|
||||
Bukkit.getServer().getPluginManager().getPlugin("Geyser-Spigot") != null &&
|
||||
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(
|
||||
"Skipping name conflict checking for player {}",
|
||||
username);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -194,19 +194,22 @@ autoLogin: true
|
||||
# This enables auto login for every player connecting through Floodgate.
|
||||
# Possible values: false, true, linked
|
||||
# Linked means that only Bedrock accounts linked to a Java account will be logged in automatically
|
||||
autoLoginFloodgate: false
|
||||
# !!! DO NOT REMOVE THE APOSTROPHE !!!
|
||||
autoLoginFloodgate: 'false'
|
||||
|
||||
# This enables Floodgate players to join the server, even if autoRegister is true and there's an existing Java Premium
|
||||
# account with the same name
|
||||
# Possible values:
|
||||
# false: Check for Premium Java name conflicts as described in 'autoRegister'
|
||||
# 'autoRegister' must be 'true' for this to work
|
||||
# true: Bypass 'autoRegister's name conflict checking
|
||||
# linked: Bedrock accounts linked to a Java account will be allowed to join with conflicting names
|
||||
# Note: Linking a new account requires players to log in with a non-linked Bedrock account first
|
||||
# Enabling this will make linking new Bedrock players impossible
|
||||
# More information on linking accounts: https://github.com/GeyserMC/Geyser/wiki/Floodgate#account-linking
|
||||
# Releated Floodgate issue: https://github.com/GeyserMC/Floodgate/issues/37
|
||||
allowFloodgateNameConflict: false
|
||||
# !!! DO NOT REMOVE THE APOSTROPHE !!!
|
||||
allowFloodgateNameConflict: 'false'
|
||||
|
||||
# This enables auto registering every player connecting through Floodgate.
|
||||
autoRegisterFloodgate: false
|
||||
|
Reference in New Issue
Block a user