games647 / FastLogin

Checks if a minecraft player has a valid paid account. If so, they can skip offline authentication automatically. (premium auto login)
https://www.spigotmc.org/resources/fastlogin.14153
MIT License
498 stars 121 forks source link

Floodgate Velocity fixes #1223

Closed Smart123s closed 2 months ago

Smart123s commented 3 months ago

Summary of your change

First of all, I'm sorry for this awful reflection heavy code. I didn't want to add too many dependencies, so there are some type safety related warnings.

Two commits in this PR, but the second one is a one liner, and I'm lazy.

9a40cf0afb1d59d77892b098ca8fdbc13d33b4b9: After running the LOGIN event, it didn't get marked as run due to an early return. In Velocity, this caused all proxy commands to have no effect.

2d177e3df563fe30b4f8ab4ec42c07a8761fda07: Most of the Floodgate checks are run at the PreLoginEvent, which requires precise usernames. However, Floodgate only sets the correct username in GameProfileRequestEvent (see here). If username prefixes are used, this made FastLogin unable to detect Floodgate players at this stage of the login process.

Related issue

Should fix pretty much every Floodgate & Velocity related issue. Fixes https://github.com/games647/FastLogin/issues/1222 Fixes https://github.com/games647/FastLogin/issues/1176 Fixes https://github.com/games647/FastLogin/issues/1070 Fixes https://github.com/games647/FastLogin/issues/991 Fixes https://github.com/games647/FastLogin/issues/935 Fixes https://github.com/games647/FastLogin/issues/729

Clyde6790pGIT commented 3 months ago

Hi, I am testing this and it worked almost instantly, it did tell me to register a few times but then it registered automatically and logged me in, this also worked with authmevelocity.

games647 commented 2 months ago

Oh wow, that's really nasty reflection. Sadly we cannot use the other ProfileEvent, because the decision needs to made earlier. I guess we cannot use the API at that instant?

Nevertheless, thank you very much for the research.

Smart123s commented 2 months ago

I guess we cannot use the API at that instant?

Both the name and the UUID are set at the GameProfile stage.

The only thing we have access to at this step is the username, and an offline UUID. The purpose of username prefixes is that a Floodgate user and a Java user can be online at the same time, so that's not really useful if we don't know which platform the player is on. As for offline UUID, AFAIK, Minecraft generates them based on usernames, so same problem there.

Sadly we cannot use the other ProfileEvent, because the decision needs to made earlier.

Yeah, I know. The Minecraft login procedure is pretty strict.

A prettier solution would be to change Floodgates code to directly expose that cache variable, but they have previously stated that they don't want to support offline-mode servers.