-
-
Notifications
You must be signed in to change notification settings - Fork 142
Differentiate Floodgate players in database #709
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
@games647 I've got some questions. As of now, (on branch which forbids registering two players with the same name. While I am strongly against registering multiple players with the same name, because it can cause confusion with some plugins (especially auth plugins), but there are folks out there already using this approach. For example, see #696. I have came up with the following possibilities as a solution:
|
b8a6d44 to
1da0d90
Compare
|
To be honest name changing is difficult topic. I made the Correct me if I'm wrong, but the referenced ticket is about the login with the same player name, that is the same account owner? The best option would be to allow both, because Floodgate authentication is identical to onlinemode verification. It only differs that FastLogin doesn't perform the validation. However, I noticed, this should only apply to linked profiles. Otherwise it should be forbidden for the second platform. Although it would be possible to have two accounts with the same player name, because as far as I know Floodgate uses different UUID. Nevertheless it could cause conflicts like you mentioned. |
1da0d90 to
74197a3
Compare
|
I've decided to drop support for conflicting names alltogether. If a player is registered in Java, and logs in via Bedrock, they won't have access to auto login/register (they won't be kicked, so if they have the password, they can still log in). My reasons for dropping this "feature":
Also, sorry for being inactive lately, I will try to contribute more in the future. |
f0b0a64 to
9a1ebe7
Compare
2bc8394 to
87b21fd
Compare
2eba9d0 to
e846f77
Compare
|
This pull request is more or less ready for review. Commits 1c63e70, 25e71e8, ae9772c, 24d552d, eab6ef9 could have been a separate pull request (I can still open a new one, if you'd like me to), but I thought that they fix an important issue (the floodgate prefix bug with ProtocolLib) that it should be fixed before the new database columns get added. I might replace the getBedrockPlayer() function with the channel extraction method from 1c63e70 and ae9772c, but that could be done in a future PR. It'd also require me to figure out how to extract the player's channel in Bungee and in ProtocolSupport (and Velocity in the future), which would take some time. For migrating legacy databases I came up with the idea to add a new integer column called Do you have any idea on how to make this line shorter? This didn't help: https://stackoverflow.com/questions/41056517/breaking-a-long-url-to-several-line-in-javadoc |
Well there also the approach of doing migrations. This what I heard is normally used when doing schema changes. However I don't know if they fit here, because we are doing a decision during the login process and not on the data itself.
Well you can split the <a href="">
lorem ipsum
</a>Attribute |
The pluign you provided uses PHP, and I don't think that it'd fit for a java project. However, Flyway could be used, which has a Java API.
There are three approaches I could think of:
Which one should I go with? I'd actually prefer the second one. Regardless, I could use Flyway to add the missing column(s) to the database. Would that plugin/library be okay? EDIT: It might be a bit overkill for adding a single column. And most of the examples migrate the database via maven commands, so I think that the plugin is oriented towards codebases where the developer also maintains the database themselves. Also, is there any way I could properly integrate migrations into a Java project? |
|
I rather was talking about the concept of having change based migrations. So one table which is used to keep track of the applied migrations and then seperate files for each migration. The implementation can be very simple, because the files can fully be read and then applied. So we then have something like: migrations/01_base_table.sql (the current table for existing setups) I don't think we need a library for that. We check the number of applied migrations and then apply the sql file(s) of which are missing. What do you think about that? This might be a bit overkill, because it's often used in combinations with many contributors (then also with timestamps) and frequent scheme changes.
I guess that's the best option to migrate the old data while using the new structure for new players. We could later drop the backwards compatibility by migrating all nullable values to false. |
TuxCoding
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good so far
Then I misunderstood you, I thought you were talking about the library.
Me neither.
It'd make code cleaner, and it'd also make potential future migrations easier, so I think it's fine.
This will be the way then. |
core/src/main/java/com/github/games647/fastlogin/core/storage/SQLStorage.java
Outdated
Show resolved
Hide resolved
...main/java/com/github/games647/fastlogin/bukkit/listener/protocollib/ProtocolLibListener.java
Outdated
Show resolved
Hide resolved
|
I've moved the ProtocolLib fix to #876 so I won't have to rebase ProtocolLib related commits when working on the database. As long as the fix gets merged before the database modifications, things should be fine. I'll remove the commits from this branch in a moment. I'll just have dinner beforehand. 🙃 |
dfe3698 to
e846f77
Compare
TuxCoding
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks very good so far.
core/src/main/java/com/github/games647/fastlogin/core/storage/AuthStorage.java
Show resolved
Hide resolved
core/src/main/java/com/github/games647/fastlogin/core/storage/MigrationManager.java
Outdated
Show resolved
Hide resolved
core/src/main/java/com/github/games647/fastlogin/core/shared/JoinManagement.java
Outdated
Show resolved
Hide resolved
core/src/main/java/com/github/games647/fastlogin/core/shared/JoinManagement.java
Outdated
Show resolved
Hide resolved
core/src/main/java/com/github/games647/fastlogin/core/shared/FloodgateManagement.java
Outdated
Show resolved
Hide resolved
core/src/main/java/com/github/games647/fastlogin/core/shared/FloodgateManagement.java
Outdated
Show resolved
Hide resolved
core/src/main/java/com/github/games647/fastlogin/core/shared/FloodgateManagement.java
Outdated
Show resolved
Hide resolved
core/src/main/java/com/github/games647/fastlogin/core/storage/MigratableStorage.java
Outdated
Show resolved
Hide resolved
core/src/main/java/com/github/games647/fastlogin/core/storage/MigrationManager.java
Outdated
Show resolved
Hide resolved
core/src/main/java/com/github/games647/fastlogin/core/storage/MigrationManager.java
Outdated
Show resolved
Hide resolved
The Floodgate field is null in the database, if the player has not been migrated to the new database format. It's a bit cleaner this way than storing the isFloodgateMigrated in a separate field in StoredProfile. One less variable in the already crowded constructor. While this is not memory efficient, this is only temporary, as per TuxCoding#709 (comment) (last sentence).
cebc530 to
0e8e07f
Compare
The Floodgate field is null in the database, if the player has not been migrated to the new database format. It's a bit cleaner this way than storing the isFloodgateMigrated in a separate field in StoredProfile. One less variable in the already crowded constructor. While this is not memory efficient, this is only temporary, as per TuxCoding#709 (comment) (last sentence).
1d0e089 to
c764812
Compare
|
@games647 The code is ready for review (and merge?), when you have some spare time. No need to rush. I think I've fixed everything I've noticed in my previous tests. |
The Floodgate field is null in the database, if the player has not been migrated to the new database format. It's a bit cleaner this way than storing the isFloodgateMigrated in a separate field in StoredProfile. One less variable in the already crowded constructor. While this is not memory efficient, this is only temporary, as per TuxCoding#709 (comment) (last sentence).
9b146a7 to
d075bc6
Compare
|
Hi, I know it's been a long time, but I kind of want to rewrite some parts. While I remember that we had discussions about the Migrations table, and wether or not it's neccesarry. I've looked at the code of AuthMe, and they don't use a Migrations table. Here's what they use: https://github.com/AuthMe/AuthMeReloaded/blob/master/src/main/java/fr/xephi/authme/datasource/MySQL.java#L191-L301 Do you think something similar would be sufficient here? edit: it'd simplify the code a lot The commit history could also take some squashing here and there. (for example 2c515e6) And I'll also sign the commits you've pushed. I saw that there's an integration-test-containers branch. Either that should be completed, or at least some JUnit tests should be added to make sure that database migrations won't break anytime soon. edit: and there are some parts that I just generally don't like how I've approached them. |
Warning I lost some commits during rebase. Maybe you could restore your version or I'll try to dig into my reflog. EDIT: I think I found it.
To be honest: This migration concept could be a little too much for a single database change (atm). The idea of migrations comes from my experience with web projects where I saw it quite often with big benefits for multiple contributors (separating logical changes to different files) and being able to rollback. In the end, I'm fine with the AuthMe system too.
Yeah the idea was to test core functionality against a full Minecraft server. However, this is very hard to setup and optimize. Nevertheless, it could be very helpful for verifying aspects like login support. Regarding the database system, this could be a lot easier and a good idea. By separating the encapsulating the database implementation from the Bukkit API we could be fine with only running a MySQL/MariaDB image. |
d075bc6 to
9b146a7
Compare
|
Aside from the migrations part, I've changed only this: diff --git a/core/src/main/java/com/github/games647/fastlogin/core/shared/FloodgateManagement.java b/core/src/main/java/com/github/games647/fastlogin/core/shared/FloodgateManagement.java
index 2f2922f5..c01c1478 100644
--- a/core/src/main/java/com/github/games647/fastlogin/core/shared/FloodgateManagement.java
+++ b/core/src/main/java/com/github/games647/fastlogin/core/shared/FloodgateManagement.java
@@ -152,16 +152,12 @@ public abstract class FloodgateManagement<P extends C, C, L extends LoginSession
}
}
- if (!isRegistered && !isAutoAuthAllowed(autoRegisterFloodgate)) {
+ if ((!isRegistered && !isAutoAuthAllowed(autoRegisterFloodgate))
+ || (profile.getFloodgate() == FloodgateState.LINKED && !isLinked)
+ || (profile.getFloodgate() == FloodgateState.TRUE && isLinked)) {
return;
}
- //logging in from bedrock for a second time threw an error with UUID
- if (profile == null) {
- profile = new StoredProfile(getUUID(player), username, true, FloodgateState.TRUE,
- getAddress(player).toString());
- }
-
//start Bukkit/Bungee specific tasks
startLogin();Review it whenever you have time for it. No need to hurry. :) |
fa9aa58 to
bf3c5fe
Compare
|
Let's not forget to check this on Velocity since #1071 got merged. This PR only changes code in core, so it's possible, that it'll work without any modifications, but who knows? I'll be pretty busy nowdays, I'll report back once I have some time. |
9141f8e to
14a9a80
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Finally I have some free time so I looked over the code. I would like to merge it now and revive some work on the project. I only inverted some ifs, because for me personally reading the non-inverted-case is easier to read than having shorter code.
In the end, I only have trouble to understand the if-cases in FloodgateManagement that would like to have resolved before merging it. Thank you in advance for the help.
core/src/main/java/com/github/games647/fastlogin/core/shared/FloodgateManagement.java
Outdated
Show resolved
Hide resolved
14a9a80 to
e141ca5
Compare
Those if statements got really complicated, that's for sure. Some months ago I tried looking into it to simplify the code, but I couldn't really do anything about it. I have force pushed those changes as a fixup of Differentiate Floodgate players during login & rebased the branch on main, so you may have to re-sign your commits. EDIT: There were some merge conflicts in the pom.xml versions, duh... It's nice to hear from you after all this time! Thanks for remembering, and looking into my code after so long Hope you are alright! |
It's safer to rely on names instead of indexes. It's also easier to add new columns at the end of the table.
e141ca5 to
434a276
Compare
Summary of your change
Please read #700.
Added a new column to the database called
Floodgate.This will make the life of Bedrock and Java players with the same name a lot easier.
Why Draft
I've just started working on this, and I wanted to share the code while I'm progressing with it.
At this stage you have to delete the old database, or the server will crash when someone tries to join it.
Todo
Floodgatefield in the databaseMigrate*activateplugin messageMigrate*/crackedand/premiumcommands (self)floodgatePrefixWorkaroundto true gives "Your username contains illegal characters" to Bedrock Clients #689)Migrate*/crackedand/premiumcommands (others)Premiumfield in the db does for Floodgate players (so check for leftover code)uuidandlastIparenullfor Floodgate players in the database (code)*No longer needed, becuase usernames are now unique (#709 (comment)).
To Test
just notes for myself, so that I won't forget it
Result: only works on the platform where premium login was enabled
Floodgate detection
#689 needs to be fixed. (I'm not linking that issue to his PR on purpose, as it's not fixed yet.)
In short, if ProtocolLib prefix workaround is enabled, the following code wont work, after the prefix is added:
https://github.com/games647/FastLogin/blob/9b04ea5c89e0b99bc273d28a1d9b0483c0a1b903/core/src/main/java/com/github/games647/fastlogin/core/hooks/bedrock/FloodgateService.java#L105-L114
Related issue
Fixes #700
Fixes #696
Fixes #633