mirror of
https://github.com/TuxCoding/FastLogin.git
synced 2025-07-30 10:47:33 +02:00
Remove existing Floodgate integration from Bungee
This commit is contained in:
@ -86,14 +86,7 @@ public class FastLoginBungee extends Plugin implements PlatformPlugin<CommandSen
|
|||||||
//events
|
//events
|
||||||
PluginManager pluginManager = getProxy().getPluginManager();
|
PluginManager pluginManager = getProxy().getPluginManager();
|
||||||
|
|
||||||
//check Floodgate version
|
ConnectListener connectListener = new ConnectListener(this, core.getRateLimiter());
|
||||||
String floodgateVersion = "0";
|
|
||||||
Plugin floodgatePlugin = pluginManager.getPlugin("floodgate");
|
|
||||||
if (floodgatePlugin != null) {
|
|
||||||
floodgateVersion = floodgatePlugin.getDescription().getVersion();
|
|
||||||
}
|
|
||||||
|
|
||||||
ConnectListener connectListener = new ConnectListener(this, core.getRateLimiter(), floodgateVersion);
|
|
||||||
|
|
||||||
pluginManager.registerListener(this, connectListener);
|
pluginManager.registerListener(this, connectListener);
|
||||||
pluginManager.registerListener(this, new PluginMessageListener(this));
|
pluginManager.registerListener(this, new PluginMessageListener(this));
|
||||||
|
@ -1,9 +0,0 @@
|
|||||||
package com.github.games647.fastlogin.bungee.hook.floodgate;
|
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
public interface FloodgateHook {
|
|
||||||
|
|
||||||
boolean isBedrockPlayer(UUID uuid);
|
|
||||||
|
|
||||||
}
|
|
@ -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);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -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);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -28,9 +28,6 @@ package com.github.games647.fastlogin.bungee.listener;
|
|||||||
import com.github.games647.craftapi.UUIDAdapter;
|
import com.github.games647.craftapi.UUIDAdapter;
|
||||||
import com.github.games647.fastlogin.bungee.BungeeLoginSession;
|
import com.github.games647.fastlogin.bungee.BungeeLoginSession;
|
||||||
import com.github.games647.fastlogin.bungee.FastLoginBungee;
|
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.AsyncPremiumCheck;
|
||||||
import com.github.games647.fastlogin.bungee.task.ForceLoginTask;
|
import com.github.games647.fastlogin.bungee.task.ForceLoginTask;
|
||||||
import com.github.games647.fastlogin.core.RateLimiter;
|
import com.github.games647.fastlogin.core.RateLimiter;
|
||||||
@ -96,26 +93,16 @@ public class ConnectListener implements Listener {
|
|||||||
private final FastLoginBungee plugin;
|
private final FastLoginBungee plugin;
|
||||||
private final RateLimiter rateLimiter;
|
private final RateLimiter rateLimiter;
|
||||||
private final Property[] emptyProperties = {};
|
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.plugin = plugin;
|
||||||
this.rateLimiter = rateLimiter;
|
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
|
@EventHandler
|
||||||
public void onPreLogin(PreLoginEvent preLoginEvent) {
|
public void onPreLogin(PreLoginEvent preLoginEvent) {
|
||||||
PendingConnection connection = preLoginEvent.getConnection();
|
PendingConnection connection = preLoginEvent.getConnection();
|
||||||
if (preLoginEvent.isCancelled() || isBedrockPlayer(connection.getUniqueId())) {
|
if (preLoginEvent.isCancelled()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -212,16 +199,4 @@ 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
|
|
||||||
if (floodgateHook == null || correctedUUID == null) {
|
|
||||||
// Also ignore if not set by floodgate or any other plugin
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return this.floodgateHook.isBedrockPlayer(correctedUUID);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user