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
|
* No client modifications needed
|
||||||
* Good performance by using async operations
|
* Good performance by using async operations
|
||||||
* Locale messages
|
* Locale messages
|
||||||
* Import the database from similar plugins
|
* Support for Bedrock players proxied through FloodGate
|
||||||
|
|
||||||
## Issues
|
## Issues
|
||||||
|
|
||||||
|
@ -60,6 +60,11 @@
|
|||||||
<id>codemc-repo</id>
|
<id>codemc-repo</id>
|
||||||
<url>https://repo.codemc.io/repository/maven-public/</url>
|
<url>https://repo.codemc.io/repository/maven-public/</url>
|
||||||
</repository>
|
</repository>
|
||||||
|
|
||||||
|
<repository>
|
||||||
|
<id>nukkitx-repo</id>
|
||||||
|
<url>https://repo.nukkitx.com/maven-snapshots/</url>
|
||||||
|
</repository>
|
||||||
</repositories>
|
</repositories>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
@ -78,6 +83,14 @@
|
|||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Bedrock player bridge -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.geysermc</groupId>
|
||||||
|
<artifactId>floodgate-bungee</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!--Login plugin-->
|
<!--Login plugin-->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>me.vik1395</groupId>
|
<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.ProxiedPlayer;
|
||||||
import net.md_5.bungee.api.connection.Server;
|
import net.md_5.bungee.api.connection.Server;
|
||||||
import net.md_5.bungee.api.plugin.Plugin;
|
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 net.md_5.bungee.api.scheduler.GroupedThreadFactory;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
@ -53,9 +54,12 @@ public class FastLoginBungee extends Plugin implements PlatformPlugin<CommandSen
|
|||||||
}
|
}
|
||||||
|
|
||||||
//events
|
//events
|
||||||
ConnectListener connectListener = new ConnectListener(this, core.getRateLimiter());
|
PluginManager pluginManager = getProxy().getPluginManager();
|
||||||
getProxy().getPluginManager().registerListener(this, connectListener);
|
boolean floodgateAvail = pluginManager.getPlugin("floodgate") != null;
|
||||||
getProxy().getPluginManager().registerListener(this, new PluginMessageListener(this));
|
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
|
//this is required to listen to incoming messages from the server
|
||||||
getProxy().registerChannel(NamespaceKey.getCombined(getName(), ChangePremiumMessage.CHANGE_CHANNEL));
|
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.EventHandler;
|
||||||
import net.md_5.bungee.event.EventPriority;
|
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
|
* 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.
|
* 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 {
|
public class ConnectListener implements Listener {
|
||||||
|
|
||||||
private final FastLoginBungee plugin;
|
private final FastLoginBungee plugin;
|
||||||
private final Property[] emptyProperties = {};
|
|
||||||
|
|
||||||
private final RateLimiter rateLimiter;
|
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 String UUID_FIELD_NAME = "uniqueId";
|
||||||
|
private static final MethodHandle uniqueIdSetter;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
MethodHandle setHandle = null;
|
MethodHandle setHandle = null;
|
||||||
@ -60,14 +63,15 @@ public class ConnectListener implements Listener {
|
|||||||
uniqueIdSetter = setHandle;
|
uniqueIdSetter = setHandle;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ConnectListener(FastLoginBungee plugin, RateLimiter rateLimiter) {
|
public ConnectListener(FastLoginBungee plugin, RateLimiter rateLimiter, boolean floodgateAvailable) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
this.rateLimiter = rateLimiter;
|
this.rateLimiter = rateLimiter;
|
||||||
|
this.floodGateAvailable = floodgateAvailable;
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPreLogin(PreLoginEvent preLoginEvent) {
|
public void onPreLogin(PreLoginEvent preLoginEvent) {
|
||||||
if (preLoginEvent.isCancelled()) {
|
if (preLoginEvent.isCancelled() || isBedrockPlayer(preLoginEvent.getConnection().getUniqueId())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -164,4 +168,11 @@ public class ConnectListener implements Listener {
|
|||||||
plugin.getSession().remove(player.getPendingConnection());
|
plugin.getSession().remove(player.getPendingConnection());
|
||||||
plugin.getCore().getPendingConfirms().remove(player.getUniqueId());
|
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