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
502 stars 121 forks source link

Compatibility with other plugins than login ones #436

Open arthurfiorette opened 3 years ago

arthurfiorette commented 3 years ago

Knowledge about a player who is logged in as a pirate or original can be very useful for many other plug-ins. There's many other threads asking for it too (and none works because when in offline mode, the uuid from original players are changed too):

I am an example of this. I just look for information on whether the player who logged in actually paid for his minecraft or not. I know there is a way to check if the nick is paid, but there are many failures to circumvent this.

Is your feature request related to a problem? Please describe.

No, this is more of a feature request than a bug fix feature request.

Describe the solution you'd like

I know you don't have much to do with it, but apparently you were the only one who coded such an efficient solution. In case you are interested in helping, I thought in some way.

Like a modification in the fast login itself making other plugins able to call and check if it is original or not:

// False if the nick is not registered with mojang or if he is logged in with a premium nick he does not own.
FastLoginAPI.isCracked(Player); 

Maybe a separation of the plugin (very unlikely, I saw that your code is well organized like that), like FastAPI that detects and makes the necessary connections with Mojang and etc. and FastLogin that only contacts the api and if it is 'true' (The API detected that this user is premium) he contacts the auth plugins and he does his job to bypass.

*EDIT: I saw that most mojang is done by CraftAPI, so maybe it’s not that difficult or it already exists and I i'm blind

Or even if you really don't want to, I would love your help to do something like this, I know enough about java for, but I found it confusing how the connection logic is made and organized with mojang, client and the server. If you could help me to code this it would also be a great help, as I am searching all over the internet to do this.

Anyway, any help from someone would be very useful.

Thanks for the time.

WalrusSlayer commented 3 years ago

Great idea!

arthurfiorette commented 3 years ago

Hey @games647 do you have plans for this?

Kamilkime commented 3 years ago

Maybe you could use this event? https://github.com/games647/FastLogin/blob/main/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/event/BukkitFastLoginPreLoginEvent.java

You should be able to get the premium status from the stored profile

games647 commented 3 years ago

Well there is this:

https://github.com/games647/FastLogin/blob/ff2e5c043538b4502a41d5435d05b8d5963b509e/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/FastLoginBukkit.java#L168

However the result is very depended on the plugin configuration. By default the plugin uses opt-in for requesting the online mode authentication. The reason for this is that, requesting an onlinemode connection from a cracked client, will result in a disconnect by the client (vanilla behavior). However, with the above mentioned event or changed plugin configuration, you could enforce that all players connecting with paid usernames to be premium.

If you need some overview about the login process, you can take a look at the FAQ. I did a simplified communication protocol.

games647 commented 3 years ago

To be clear, we can only check if a player is premium if both is true: we were requesting an online mode connection and the player passed through it. A cracked status could mean, the player is cracked or we didn't tested it in the first place. Maybe because we were unsure and afraid of losing the player, because of the mentioned disconnect behavior.

arthurfiorette commented 3 years ago

yeah, as time went by, i took a good look at the premium verification and encryption protocol... i could replace the login process with mine, as you also did on yours, but to a plugin that doesn't have anything with login and just wanna know the player status. replacing all the login steps will be dangerous... The only solution that i can think is the plugin separation that i said before, but anyways, i don't think fast login have to do that for himself.

arthurfiorette commented 3 years ago

i could also make the "api" that just replace the login and save the information for others plugins... but i'm unfocused on coding minecraft plugins anymore even if the only "barrier" that is in my mind is that if i do this i will create an incompatibility or bugs with all other plugins that have something in the login process. Do you have a solution or idea for that?

games647 commented 3 years ago

but to a plugin that doesn't have anything with login and just wanna know the player status. replacing all the login steps will be dangerous... The only solution that i can think is the plugin separation that i said before, but anyways, i don't think fast login have to do that for himself.

I wonder how you think this separation should work.

i could also make the "api" that just replace the login and save the information for others plugins...

If you are just doing everything the same like the original Spigot implementation, you could also just read the online mode of the server. Even in BungeeCord settings the onlinemode should (AFAIK) represent the premium status of all players, because otherwise they couldn't join.

What FastLogin effectively does is that it creates a mixed online mode where you have most players in offline mode, but others could join as premium players with their premium UUID, skin and optionally skip auth plugin authentication. The later option requires the request for online mode. Either by the player itself or based heuristics specified in the configuration. This means plugins can no longer rely on the online mode setting. This is where an API makes sense, but otherwise it's just reading the online mode.