Add floodgate service to Bungee

This commit is contained in:
games647
2021-10-05 15:42:40 +02:00
parent a3bf875976
commit 28480a0f01
9 changed files with 30 additions and 11 deletions
@@ -41,9 +41,11 @@ import org.geysermc.floodgate.api.player.FloodgatePlayer;
public class FloodgateService {
private final FloodgateApi floodgate;
private final FastLoginCore<?, ?, ?> core;
public FloodgateService(FastLoginCore<?, ?, ?> core) {
public FloodgateService(FloodgateApi floodgate, FastLoginCore<?, ?, ?> core) {
this.floodgate = floodgate;
this.core = core;
}
@@ -84,10 +86,11 @@ public class FloodgateService {
* @param username the name of the player
* @param source an instance of LoginSource
*/
public void checkFloodgateNameConflict(String username, LoginSource source, FloodgatePlayer floodgatePlayer) {
public void checkNameConflict(String username, LoginSource source) {
String allowConflict = core.getConfig().get("allowFloodgateNameConflict").toString().toLowerCase();
// check if the Bedrock player is linked to a Java account
FloodgatePlayer floodgatePlayer = getFloodgatePlayer(username);
boolean isLinked = floodgatePlayer.getLinkedPlayer() != null;
if ("false".equals(allowConflict)
@@ -151,6 +154,5 @@ public class FloodgateService {
public boolean isFloodgateConnection(String username) {
return getFloodgatePlayer(username) != null;
}
}
@@ -36,8 +36,6 @@ import java.util.Optional;
import net.md_5.bungee.config.Configuration;
import org.geysermc.floodgate.api.player.FloodgatePlayer;
public abstract class JoinManagement<P extends C, C, S extends LoginSource> {
protected final FastLoginCore<P, C, ?> core;
@@ -60,7 +58,7 @@ public abstract class JoinManagement<P extends C, C, S extends LoginSource> {
//check if the player is connecting through Floodgate
if (floodgateService != null) {
if (floodgateService.isFloodgateConnection(username)) {
floodgateService.checkFloodgateNameConflict(username, source, floodgatePlayer);
floodgateService.checkNameConflict(username, source);
// skip flow for any floodgate player
return;
}