NachoSpigot icon indicating copy to clipboard operation
NachoSpigot copied to clipboard

SkullMeta setOwner

Open andreasdc opened this issue 4 years ago • 26 comments

Will calling setOwner to the same name spam mojang api or will it cache in ItemStack SkullMeta?

andreasdc avatar Jul 23 '21 01:07 andreasdc

  • bug calling setOwner changes skin to alex, then to skin, when doing it again it's again alex, skin.

andreasdc avatar Jul 23 '21 01:07 andreasdc

@Outfluencer ?

Sculas avatar Jul 23 '21 08:07 Sculas

This issue seems stale, it should be closed

CyberFlameGO avatar Oct 18 '21 00:10 CyberFlameGO

I can confirm that using setOwner changes the skin of the head to an alex, then to the correct skin. The alex stays around for 1-2 seconds before updating.

Rqver avatar Oct 18 '21 19:10 Rqver

I'll work on that.

sadcenter avatar Nov 13 '21 21:11 sadcenter

Okay, actually it isn't a bug, it's just minecraft fault... It takes around 450ms to download skin texture. So slow

sadcenter avatar Nov 13 '21 21:11 sadcenter

Is the skin texture cached?

Sculas avatar Nov 13 '21 21:11 Sculas

Yea it is, but sometimes there is no player in cache and the server has to download texture. When the skin is alex the server is downloading actual skin. I was thinking about changing GameProfileRepository in MinecraftServer due it's responsible for this stuff. I believe this change would also bring better performance. https://github.com/CobbleSword/NachoSpigot/blob/ebf0841bee5ccf847d0b2dd8d18ec10be6afced8/NachoSpigot-Server/src/main/java/net/minecraft/server/MinecraftServer.java#L133 https://github.com/Electroid/mojang-api - I've heard this api is great, I'm also using this in my auth plugins.

sadcenter avatar Nov 13 '21 21:11 sadcenter

Spammed that API and Mojang's API a couple of times and it seems that Electroid's API is faster.

Sculas avatar Nov 13 '21 21:11 Sculas

So if you want, feel free to PR that. But keep in mind to keep the old logic for Minecraft's session server in case Electroid's API breaks. We need a fallback in the case that such a thing happens.

Sculas avatar Nov 13 '21 21:11 Sculas

So just do a try-catch, and if that fails send a request to Mojang's API and continue from there. Make sure to log an error for that in the console so we can check what's wrong.

Sculas avatar Nov 13 '21 21:11 Sculas

You have maybe mojang api from different ips to bypass mojang's limit?

andreasdc avatar Nov 13 '21 21:11 andreasdc

Definetly faster, and also Electroid's api has no ratelimit.

sadcenter avatar Nov 13 '21 21:11 sadcenter

It uses normal mojang urls, so it has 600 connections per 10 minutes, but I see it has its own url.

andreasdc avatar Nov 13 '21 21:11 andreasdc

There is a way to bypass rate limit. https://github.com/Electroid/mojang-api#purpose

sadcenter avatar Nov 13 '21 21:11 sadcenter

I think I've done that. It's nearly(or fully?) impossible to make heads load instantly, we would have to make heads sync what would make this even worse, imagine for example 200 heads loading at once and a player has to wait while heads are loading. I made an async implementation of authlib which uses file caching that speeds up the process. (preview https://github.com/sadcenter/NachoSpigot/tree/auth/NachoSpigot-Server/src/main/java/com/github/sadcenter/auth) I'm currently using ashcon api to read textures, the only downside is providing too much data (more data -> it takes more time to deserialize JSON by GSON -> late response). @andreasdc already has suggested to the owner a function to exclude parameters that are not wanted (Electroid/mojang-api#48). I'm almost sure I'll post PR tomorrow. BTW: It's not a bug

sadcenter avatar Nov 19 '21 21:11 sadcenter

@sadcenter Since there's not a lot of data, you could also just go through each line and find the right one and parse it yourself.

Sculas avatar Nov 19 '21 21:11 Sculas

  • bug calling setOwner changes skin to alex, then to skin, when doing it again it's again alex, skin.

This was the bug @sadcenter I think

andreasdc avatar Nov 19 '21 21:11 andreasdc

Okay, NVM after some tests I've concluded that parsing doesn't make a real difference here

sadcenter avatar Nov 19 '21 23:11 sadcenter

Also, if possible, make sure to cache it. And check if the player is online, if so grab their skin since when they're online it should be held in memory so you don't need to send a unnecessary http request.

Sculas avatar Nov 19 '21 23:11 Sculas

It's already in the code BTW: What do you guys think about making accessibility to turn online/offline mode per player, like in bungeecord? This will allow developers to make premium authentication plugins like FastLogin, JPremium, mineLogin on Spigot, currently, this is only available on proxies, etc. IMO Nice feature

sadcenter avatar Nov 19 '21 23:11 sadcenter

It's already in the code BTW: What do you guys think about making accessibility to turn online/offline mode per player, like in bungeecord? This will allow developers to make premium authentication plugins like FastLogin, JPremium, mineLogin on Spigot, currently, this is only available on proxies, etc. IMO Nice feature

IMO there are cooler things and optimizations that should be created in Nacho first.

andreasdc avatar Nov 20 '21 13:11 andreasdc

It's already in the code

BTW: What do you guys think about making accessibility to turn online/offline mode per player, like in bungeecord? This will allow developers to make premium authentication plugins like FastLogin, JPremium, mineLogin on Spigot, currently, this is only available on proxies, etc.

IMO Nice feature

I always thought it was like servers in the sense that servers can only be offline or online, unless you mean separate proxies (or unless I'm just oblivious to that knowledge). Cool idea, but as @andreasdc said there's other stuff the project is focusing on. If you wanna contribute something like that I'd love to see that on this project, though!

CyberFlameGO avatar Nov 20 '21 14:11 CyberFlameGO

It's already in the code BTW: What do you guys think about making accessibility to turn online/offline mode per player, like in bungeecord? This will allow developers to make premium authentication plugins like FastLogin, JPremium, mineLogin on Spigot, currently, this is only available on proxies, etc. IMO Nice feature

I always thought it was like servers in the sense that servers can only be offline or online, unless you mean separate proxies (or unless I'm just oblivious to that knowledge). Cool idea, but as @andreasdc said there's other stuff the project is focusing on. If you wanna contribute something like that I'd love to see that on this project, though!

I think @sadcenter wants to do auth plugin to check premium users on spigot, but I think it's better to look into getCubes, movement, double interactions, packet sending and many other cool optimizations that can be done in Nacho, we are fork of Taco, good fork of Paper, right?

andreasdc avatar Nov 20 '21 23:11 andreasdc

I want to add accessibility to set online mode per player in PreLoginEvent which shouldn't be difficult

sadcenter avatar Nov 20 '21 23:11 sadcenter

@sadcenter Any updates? Might wanna PR this soon if possible so this issue can be closed :)

Sculas avatar Dec 17 '21 19:12 Sculas