forked from TuxCoding/FastLogin
Ignore proxied bedrock players (Fixes #328)
This commit is contained in:
@ -19,7 +19,7 @@ So they don't need to enter passwords. This is also called auto login (auto-logi
|
||||
* No client modifications needed
|
||||
* Good performance by using async operations
|
||||
* Locale messages
|
||||
* Import the database from similar plugins
|
||||
* Support for Bedrock players proxied through FloodGate
|
||||
|
||||
## Issues
|
||||
|
||||
|
@ -60,6 +60,11 @@
|
||||
<id>codemc-repo</id>
|
||||
<url>https://repo.codemc.io/repository/maven-public/</url>
|
||||
</repository>
|
||||
|
||||
<repository>
|
||||
<id>nukkitx-repo</id>
|
||||
<url>https://repo.nukkitx.com/maven-snapshots/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
@ -78,6 +83,14 @@
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- Bedrock player bridge -->
|
||||
<dependency>
|
||||
<groupId>org.geysermc</groupId>
|
||||
<artifactId>floodgate-bungee</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<!--Login plugin-->
|
||||
<dependency>
|
||||
<groupId>me.vik1395</groupId>
|
||||
|
@ -26,6 +26,7 @@ import net.md_5.bungee.api.connection.PendingConnection;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
import net.md_5.bungee.api.connection.Server;
|
||||
import net.md_5.bungee.api.plugin.Plugin;
|
||||
import net.md_5.bungee.api.plugin.PluginManager;
|
||||
import net.md_5.bungee.api.scheduler.GroupedThreadFactory;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
@ -53,9 +54,12 @@ public class FastLoginBungee extends Plugin implements PlatformPlugin<CommandSen
|
||||
}
|
||||
|
||||
//events
|
||||
ConnectListener connectListener = new ConnectListener(this, core.getRateLimiter());
|
||||
getProxy().getPluginManager().registerListener(this, connectListener);
|
||||
getProxy().getPluginManager().registerListener(this, new PluginMessageListener(this));
|
||||
PluginManager pluginManager = getProxy().getPluginManager();
|
||||
boolean floodgateAvail = pluginManager.getPlugin("floodgate") != null;
|
||||
ConnectListener connectListener = new ConnectListener(this, core.getRateLimiter(), floodgateAvail);
|
||||
|
||||
pluginManager.registerListener(this, connectListener);
|
||||
pluginManager.registerListener(this, new PluginMessageListener(this));
|
||||
|
||||
//this is required to listen to incoming messages from the server
|
||||
getProxy().registerChannel(NamespaceKey.getCombined(getName(), ChangePremiumMessage.CHANGE_CHANNEL));
|
||||
|
@ -30,6 +30,8 @@ import net.md_5.bungee.connection.LoginResult.Property;
|
||||
import net.md_5.bungee.event.EventHandler;
|
||||
import net.md_5.bungee.event.EventPriority;
|
||||
|
||||
import org.geysermc.floodgate.FloodgateAPI;
|
||||
|
||||
/**
|
||||
* Enables online mode logins for specified users and sends plugin message to the Bukkit version of this plugin in
|
||||
* order to clear that the connection is online mode.
|
||||
@ -37,13 +39,14 @@ import net.md_5.bungee.event.EventPriority;
|
||||
public class ConnectListener implements Listener {
|
||||
|
||||
private final FastLoginBungee plugin;
|
||||
private final Property[] emptyProperties = {};
|
||||
|
||||
private final RateLimiter rateLimiter;
|
||||
|
||||
private static final MethodHandle uniqueIdSetter;
|
||||
private final Property[] emptyProperties = {};
|
||||
private final boolean floodGateAvailable;
|
||||
|
||||
|
||||
private static final String UUID_FIELD_NAME = "uniqueId";
|
||||
private static final MethodHandle uniqueIdSetter;
|
||||
|
||||
static {
|
||||
MethodHandle setHandle = null;
|
||||
@ -60,14 +63,15 @@ public class ConnectListener implements Listener {
|
||||
uniqueIdSetter = setHandle;
|
||||
}
|
||||
|
||||
public ConnectListener(FastLoginBungee plugin, RateLimiter rateLimiter) {
|
||||
public ConnectListener(FastLoginBungee plugin, RateLimiter rateLimiter, boolean floodgateAvailable) {
|
||||
this.plugin = plugin;
|
||||
this.rateLimiter = rateLimiter;
|
||||
this.floodGateAvailable = floodgateAvailable;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPreLogin(PreLoginEvent preLoginEvent) {
|
||||
if (preLoginEvent.isCancelled()) {
|
||||
if (preLoginEvent.isCancelled() || isBedrockPlayer(preLoginEvent.getConnection().getUniqueId())) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -164,4 +168,11 @@ public class ConnectListener implements Listener {
|
||||
plugin.getSession().remove(player.getPendingConnection());
|
||||
plugin.getCore().getPendingConfirms().remove(player.getUniqueId());
|
||||
}
|
||||
|
||||
private boolean isBedrockPlayer(UUID correctedUUID) {
|
||||
// Floodgate will set a correct UUID at the beginning of the PreLoginEvent
|
||||
// and will cancel the online mode login for those players
|
||||
// Therefore we just ignore those
|
||||
return floodGateAvailable && FloodgateAPI.isBedrockPlayer(correctedUUID);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user