forked from TuxCoding/FastLogin
Merge bedrock packet checks into a single function
Floodgate and Geyser specific checks can now be modified without changing JoinManagement. Added the ability to resume Java specific checks for Bedrock players. This will be neccessary for Geyser `auth-type=online` players
This commit is contained in:
@ -48,6 +48,15 @@ public abstract class BedrockService<B> {
|
||||
this.allowConflict = core.getConfig().get("allowFloodgateNameConflict").toString().toLowerCase();
|
||||
}
|
||||
|
||||
/**
|
||||
* Perfrom every packet level check needed on a Bedrock player.
|
||||
*
|
||||
* @param username the name of the player
|
||||
* @param source an instance of LoginSource
|
||||
* @return true if Java specific checks can be skipped
|
||||
*/
|
||||
public abstract boolean performChecks(String username, LoginSource source);
|
||||
|
||||
/**
|
||||
* Check if the player's name conflicts an existing Java player's name, and kick
|
||||
* them if it does
|
||||
@ -55,7 +64,7 @@ public abstract class BedrockService<B> {
|
||||
* @param username the name of the player
|
||||
* @param source an instance of LoginSource
|
||||
*/
|
||||
public void checkNameConflict(String username, LoginSource source) {
|
||||
protected void checkNameConflict(String username, LoginSource source) {
|
||||
// check for conflicting Premium Java name
|
||||
Optional<Profile> premiumUUID = Optional.empty();
|
||||
try {
|
||||
@ -81,7 +90,6 @@ public abstract class BedrockService<B> {
|
||||
core.getPlugin().getLog().error("Could not kick Player {}", username, ex);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -76,7 +76,7 @@ public class FloodgateService extends BedrockService<FloodgatePlayer> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkNameConflict(String username, LoginSource source) {
|
||||
public boolean performChecks(String username, LoginSource source) {
|
||||
// check if the Bedrock player is linked to a Java account
|
||||
FloodgatePlayer floodgatePlayer = getBedrockPlayer(username);
|
||||
boolean isLinked = floodgatePlayer.getLinkedPlayer() != null;
|
||||
@ -87,6 +87,9 @@ public class FloodgateService extends BedrockService<FloodgatePlayer> {
|
||||
} else {
|
||||
core.getPlugin().getLog().info("Skipping name conflict checking for player {}", username);
|
||||
}
|
||||
|
||||
//Floodgate users don't need Java specific checks
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -45,13 +45,14 @@ public class GeyserService extends BedrockService<GeyserSession> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkNameConflict(String username, LoginSource source) {
|
||||
//TODO: Replace stub with Geyser specific code
|
||||
public boolean performChecks(String username, LoginSource source) {
|
||||
//TODO: Replace stub with Geyser specific code
|
||||
if ("false".equals(allowConflict)) {
|
||||
super.checkNameConflict(username, source);
|
||||
} else {
|
||||
core.getPlugin().getLog().info("Skipping name conflict checking for player {}", username);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -56,10 +56,9 @@ public abstract class JoinManagement<P extends C, C, S extends LoginSource> {
|
||||
}
|
||||
|
||||
//check if the player is connecting through Bedrock Edition
|
||||
if (bedrockService != null) {
|
||||
if (bedrockService.isBedrockConnection(username)) {
|
||||
bedrockService.checkNameConflict(username, source);
|
||||
// skip flow for any Bedrock player
|
||||
if (bedrockService != null && bedrockService.isBedrockConnection(username)) {
|
||||
//perform Bedrock specific checks and skip Java checks, if they are not needed
|
||||
if (bedrockService.performChecks(username, source)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user