Remove existing Floodgate integration from Bungee

This commit is contained in:
Smart123s
2021-06-20 09:42:40 +02:00
parent 8f43cc0978
commit af83604c94
5 changed files with 3 additions and 79 deletions

View File

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

View File

@ -1,9 +0,0 @@
package com.github.games647.fastlogin.bungee.hook.floodgate;
import java.util.UUID;
public interface FloodgateHook {
boolean isBedrockPlayer(UUID uuid);
}

View File

@ -1,14 +0,0 @@
package com.github.games647.fastlogin.bungee.hook.floodgate;
import org.geysermc.floodgate.FloodgateAPI;
import java.util.UUID;
public class FloodgateV1Hook implements FloodgateHook {
@Override
public boolean isBedrockPlayer(UUID uuid) {
return FloodgateAPI.isBedrockPlayer(uuid);
}
}

View File

@ -1,21 +0,0 @@
package com.github.games647.fastlogin.bungee.hook.floodgate;
import org.geysermc.floodgate.api.FloodgateApi;
import org.geysermc.floodgate.api.InstanceHolder;
import java.util.UUID;
public class FloodgateV2Hook implements FloodgateHook {
private FloodgateApi floodgateApi;
public FloodgateV2Hook() {
this.floodgateApi = InstanceHolder.getApi();
}
@Override
public boolean isBedrockPlayer(UUID uuid) {
return floodgateApi.isFloodgatePlayer(uuid);
}
}

View File

@ -28,9 +28,6 @@ package com.github.games647.fastlogin.bungee.listener;
import com.github.games647.craftapi.UUIDAdapter;
import com.github.games647.fastlogin.bungee.BungeeLoginSession;
import com.github.games647.fastlogin.bungee.FastLoginBungee;
import com.github.games647.fastlogin.bungee.hook.floodgate.FloodgateHook;
import com.github.games647.fastlogin.bungee.hook.floodgate.FloodgateV1Hook;
import com.github.games647.fastlogin.bungee.hook.floodgate.FloodgateV2Hook;
import com.github.games647.fastlogin.bungee.task.AsyncPremiumCheck;
import com.github.games647.fastlogin.bungee.task.ForceLoginTask;
import com.github.games647.fastlogin.core.RateLimiter;
@ -96,26 +93,16 @@ public class ConnectListener implements Listener {
private final FastLoginBungee plugin;
private final RateLimiter rateLimiter;
private final Property[] emptyProperties = {};
private final FloodgateHook floodgateHook;
public ConnectListener(FastLoginBungee plugin, RateLimiter rateLimiter, String floodgateVersion) {
public ConnectListener(FastLoginBungee plugin, RateLimiter rateLimiter) {
this.plugin = plugin;
this.rateLimiter = rateLimiter;
// Get the appropriate floodgate api hook based on the version
if (floodgateVersion.startsWith("1")) {
this.floodgateHook = new FloodgateV1Hook();
} else if (floodgateVersion.startsWith("2")) {
this.floodgateHook = new FloodgateV2Hook();
} else {
this.floodgateHook = null;
}
}
@EventHandler
public void onPreLogin(PreLoginEvent preLoginEvent) {
PendingConnection connection = preLoginEvent.getConnection();
if (preLoginEvent.isCancelled() || isBedrockPlayer(connection.getUniqueId())) {
if (preLoginEvent.isCancelled()) {
return;
}
@ -212,16 +199,4 @@ 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
if (floodgateHook == null || correctedUUID == null) {
// Also ignore if not set by floodgate or any other plugin
return false;
}
return this.floodgateHook.isBedrockPlayer(correctedUUID);
}
}