Skip to content

Commit fa9aa58

Browse files
committed
Differentiate Floodgate players during login
1 parent eff9e8e commit fa9aa58

File tree

2 files changed

+59
-6
lines changed

2 files changed

+59
-6
lines changed

core/src/main/java/com/github/games647/fastlogin/core/shared/FloodgateManagement.java

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,38 @@ public void run() {
8181
}
8282

8383
profile = core.getStorage().loadProfile(username);
84+
85+
if (profile.isSaved()) {
86+
if (!profile.isFloodgateMigrated()) {
87+
if (isLinked) {
88+
profile.setFloodgate(FloodgateState.LINKED);
89+
core.getPlugin().getLog().info(
90+
"Player {} will be migrated to the v2 database schema as a linked Floodgate user",
91+
username);
92+
} else {
93+
profile.setFloodgate(FloodgateState.TRUE);
94+
core.getPlugin().getLog().info(
95+
"Player {} will be migrated to the v2 database schema as a Floodgate user", username);
96+
}
97+
} else if (profile.getFloodgate() == FloodgateState.TRUE && isLinked) {
98+
core.getPlugin().getLog()
99+
.info("Player {} is already stored by FastLogin as a non-linked Bedrock Edition player",
100+
username);
101+
return;
102+
} else if (profile.getFloodgate() == FloodgateState.FALSE && isLinked) {
103+
profile.setFloodgate(FloodgateState.LINKED);
104+
core.getPlugin().getLog().info(
105+
"Player {} will be changed from a Java player to a linked Floodgate player",
106+
username);
107+
}
108+
} else {
109+
if (isLinked) {
110+
profile.setFloodgate(FloodgateState.LINKED);
111+
} else {
112+
profile.setFloodgate(FloodgateState.TRUE);
113+
}
114+
}
115+
84116
AuthPlugin<P> authPlugin = core.getAuthPluginHook();
85117

86118
try {
@@ -126,7 +158,8 @@ public void run() {
126158

127159
//logging in from bedrock for a second time threw an error with UUID
128160
if (profile == null) {
129-
profile = new StoredProfile(getUUID(player), username, true, getAddress(player).toString());
161+
profile = new StoredProfile(getUUID(player), username, true, FloodgateState.TRUE,
162+
getAddress(player).toString());
130163
}
131164

132165
//start Bukkit/Bungee specific tasks

core/src/main/java/com/github/games647/fastlogin/core/shared/JoinManagement.java

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,19 +50,33 @@ public JoinManagement(FastLoginCore<P, C, ?> core, AuthPlugin<P> authHook, Bedro
5050

5151
public void onLogin(String username, S source) {
5252
core.getPlugin().getLog().info("Handling player {}", username);
53-
StoredProfile profile = core.getStorage().loadProfile(username);
54-
if (profile == null) {
55-
return;
56-
}
5753

5854
//check if the player is connecting through Bedrock Edition
5955
if (bedrockService != null && bedrockService.isBedrockConnection(username)) {
60-
//perform Bedrock specific checks and skip Java checks, if they are not needed
56+
//perform Bedrock specific checks
6157
if (bedrockService.performChecks(username, source)) {
58+
//skip Java checks, since they are not needed
6259
return;
6360
}
6461
}
6562

63+
StoredProfile profile = core.getStorage().loadProfile(username);
64+
65+
//can't be a premium Java player, if it's not saved in the database
66+
if (profile == null) {
67+
return;
68+
}
69+
70+
if (!profile.isFloodgateMigrated()) {
71+
profile.setFloodgate(FloodgateState.FALSE);
72+
core.getPlugin().getLog().info(
73+
"Player {} will be migrated to the v2 database schema as a JAVA user", username);
74+
} else if (profile.getFloodgate() == FloodgateState.TRUE) {
75+
core.getPlugin().getLog().info("Player {} is already stored by FastLogin as a Bedrock Edition player",
76+
username);
77+
return;
78+
}
79+
6680
callFastLoginPreLoginEvent(username, source, profile);
6781

6882
Configuration config = core.getConfig();
@@ -140,6 +154,12 @@ private boolean checkNameChange(S source, String username, Profile profile) {
140154
if (core.getConfig().get("nameChangeCheck", false)) {
141155
StoredProfile storedProfile = core.getStorage().loadProfile(profile.getId());
142156
if (storedProfile != null) {
157+
if (storedProfile.getFloodgate() == FloodgateState.TRUE) {
158+
core.getPlugin().getLog()
159+
.info("Player {} is already stored by FastLogin as a Bedrock Edition player.", username);
160+
return false;
161+
}
162+
143163
//uuid exists in the database
144164
core.getPlugin().getLog().info("GameProfile {} changed it's username", profile);
145165

0 commit comments

Comments
 (0)