mirror of
https://github.com/TuxCoding/FastLogin.git
synced 2025-07-30 10:47:33 +02:00
Merge pull request #527 from TechnicallyCoded/feature/floodgate-v2.0
Implement floodgate api version 2.0
This commit is contained in:
@ -0,0 +1,9 @@
|
|||||||
|
package com.github.games647.fastlogin.bungee.hook.floodgate;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public interface FloodgateHook {
|
||||||
|
|
||||||
|
boolean isBedrockPlayer(UUID uuid);
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,14 @@
|
|||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,21 @@
|
|||||||
|
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,6 +28,9 @@ 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;
|
||||||
@ -99,11 +102,21 @@ public class ConnectListener implements Listener {
|
|||||||
private final RateLimiter rateLimiter;
|
private final RateLimiter rateLimiter;
|
||||||
private final Property[] emptyProperties = {};
|
private final Property[] emptyProperties = {};
|
||||||
private final String floodgateVersion;
|
private final String floodgateVersion;
|
||||||
|
private final FloodgateHook floodgateHook;
|
||||||
|
|
||||||
public ConnectListener(FastLoginBungee plugin, RateLimiter rateLimiter, String floodgateVersion) {
|
public ConnectListener(FastLoginBungee plugin, RateLimiter rateLimiter, String floodgateVersion) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
this.rateLimiter = rateLimiter;
|
this.rateLimiter = rateLimiter;
|
||||||
this.floodgateVersion = floodgateVersion;
|
this.floodgateVersion = floodgateVersion;
|
||||||
|
|
||||||
|
// 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
|
||||||
@ -211,12 +224,9 @@ public class ConnectListener implements Listener {
|
|||||||
// Floodgate will set a correct UUID at the beginning of the PreLoginEvent
|
// Floodgate will set a correct UUID at the beginning of the PreLoginEvent
|
||||||
// and will cancel the online mode login for those players
|
// and will cancel the online mode login for those players
|
||||||
// Therefore we just ignore those
|
// Therefore we just ignore those
|
||||||
if (floodgateVersion.startsWith("1")) {
|
if (floodgateHook == null) {
|
||||||
return FloodgateAPI.isBedrockPlayer(correctedUUID);
|
return false;
|
||||||
} else if (floodgateVersion.startsWith("2")) {
|
|
||||||
return FloodgateAPI.isBedrockPlayer(correctedUUID);
|
|
||||||
}
|
}
|
||||||
|
return this.floodgateHook.isBedrockPlayer(correctedUUID);
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user