Invert if and document migration flow for better readability

This commit is contained in:
games647
2023-12-11 15:05:50 +01:00
committed by Smart123s
parent 485af5e044
commit 434a276d30
2 changed files with 21 additions and 18 deletions

View File

@ -82,7 +82,19 @@ public abstract class FloodgateManagement<P extends C, C, L extends LoginSession
profile = core.getStorage().loadProfile(username);
if (profile.isSaved()) {
if (!profile.isFloodgateMigrated()) {
if (profile.isFloodgateMigrated()) {
if (profile.getFloodgate() == FloodgateState.TRUE && isLinked) {
core.getPlugin().getLog()
.info("Player {} is already stored by FastLogin as a non-linked Bedrock Edition player",
username);
return;
} else if (profile.getFloodgate() == FloodgateState.FALSE && isLinked) {
profile.setFloodgate(FloodgateState.LINKED);
core.getPlugin().getLog().info(
"Player {} will be changed from a Java player to a linked Floodgate player",
username);
}
} else {
if (isLinked) {
profile.setFloodgate(FloodgateState.LINKED);
core.getPlugin().getLog().info(
@ -93,16 +105,6 @@ public abstract class FloodgateManagement<P extends C, C, L extends LoginSession
core.getPlugin().getLog().info(
"Player {} will be migrated to the v2 database schema as a Floodgate user", username);
}
} else if (profile.getFloodgate() == FloodgateState.TRUE && isLinked) {
core.getPlugin().getLog()
.info("Player {} is already stored by FastLogin as a non-linked Bedrock Edition player",
username);
return;
} else if (profile.getFloodgate() == FloodgateState.FALSE && isLinked) {
profile.setFloodgate(FloodgateState.LINKED);
core.getPlugin().getLog().info(
"Player {} will be changed from a Java player to a linked Floodgate player",
username);
}
} else {
if (isLinked) {

View File

@ -52,9 +52,8 @@ public abstract class JoinManagement<P extends C, C, S extends LoginSource> {
//check if the player is connecting through Bedrock Edition
if (bedrockService != null && bedrockService.isBedrockConnection(username)) {
//perform Bedrock specific checks
//perform Bedrock specific checks and skip Java checks if no longer needed
if (bedrockService.performChecks(username, source)) {
//skip Java checks, since they are not needed
return;
}
}
@ -66,14 +65,16 @@ public abstract class JoinManagement<P extends C, C, S extends LoginSource> {
return;
}
if (!profile.isFloodgateMigrated()) {
if (profile.isFloodgateMigrated()) {
if (profile.getFloodgate() == FloodgateState.TRUE) {
// migrated and enabled floodgate player, however the above bedrocks fails, so the current connection
// isn't premium
return;
}
} else {
profile.setFloodgate(FloodgateState.FALSE);
core.getPlugin().getLog().info(
"Player {} will be migrated to the v2 database schema as a JAVA user", username);
} else if (profile.getFloodgate() == FloodgateState.TRUE) {
core.getPlugin().getLog().info("Player {} is already stored by FastLogin as a Bedrock Edition player",
username);
return;
}
callFastLoginPreLoginEvent(username, source, profile);