Add support for Floodgate 2.0

This commit is contained in:
Smart123s
2021-05-08 16:26:58 +02:00
parent c1d3f278f7
commit 1b7b2ff2b5
3 changed files with 29 additions and 6 deletions

View File

@ -124,6 +124,7 @@
</dependency>
<!-- Bedrock player bridge -->
<!-- Should be removed one Floodgate 2.0 gets a stable release -->
<dependency>
<groupId>org.geysermc</groupId>
<artifactId>floodgate-bungee</artifactId>
@ -131,6 +132,15 @@
<scope>provided</scope>
</dependency>
<!-- Bedrock player bridge -->
<!-- Version 2.0 -->
<dependency>
<groupId>org.geysermc.floodgate</groupId>
<artifactId>bungee</artifactId>
<version>2.0-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<!--Login plugin-->
<dependency>
<groupId>me.vik1395</groupId>

View File

@ -87,8 +87,15 @@ public class FastLoginBungee extends Plugin implements PlatformPlugin<CommandSen
//events
PluginManager pluginManager = getProxy().getPluginManager();
boolean floodgateAvail = pluginManager.getPlugin("floodgate") != null;
ConnectListener connectListener = new ConnectListener(this, core.getRateLimiter(), floodgateAvail);
//check Floodgate version
String floodgateVersion = "0";
Plugin floodgatePlugin = pluginManager.getPlugin("floodgate");
if (floodgatePlugin != null) {
floodgatePlugin.getDescription().getVersion();
}
ConnectListener connectListener = new ConnectListener(this, core.getRateLimiter(), floodgateVersion);
pluginManager.registerListener(this, connectListener);
pluginManager.registerListener(this, new PluginMessageListener(this));

View File

@ -98,12 +98,12 @@ public class ConnectListener implements Listener {
private final FastLoginBungee plugin;
private final RateLimiter rateLimiter;
private final Property[] emptyProperties = {};
private final boolean floodGateAvailable;
private final String floodgateVersion;
public ConnectListener(FastLoginBungee plugin, RateLimiter rateLimiter, boolean floodgateAvailable) {
public ConnectListener(FastLoginBungee plugin, RateLimiter rateLimiter, String floodgateVersion) {
this.plugin = plugin;
this.rateLimiter = rateLimiter;
this.floodGateAvailable = floodgateAvailable;
this.floodgateVersion = floodgateVersion;
}
@EventHandler
@ -211,6 +211,12 @@ public class ConnectListener implements Listener {
// 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);
if (floodgateVersion.startsWith("1")) {
return FloodgateAPI.isBedrockPlayer(correctedUUID);
} else if (floodgateVersion.startsWith("2")) {
return FloodgateAPI.isBedrockPlayer(correctedUUID);
}
return false;
}
}