Reset Skin for GameProfile

Discussion in 'Spigot Plugin Development' started by nathanthesnooper, May 26, 2018.

  1. I basically want a player's name and skin to be the same. This is my code for changing their skin:
    Code (Java):
    OfflinePlayer newPlayer = Bukkit.getOfflinePlayer(name);
    WrappedGameProfile newProfile = new WrappedGameProfile(newPlayer.getUniqueId(), name);
    newProfile.getProperties().putAll(WrappedGameProfile.fromOfflinePlayer(newPlayer).getProperties());
    Of course, I send them a PlayerInfoData packet later, but I already know that works (Because their name is changed)
    However, this gives everyone either the Steve or the Alex skin, which isn't what I want.
    I've also tried clearing the properties, but that also gives it Steve/Alex.
    I want to be able to nick as people that are offline, so I cannot make it an online player.

    ALSO: I have considered Mojang's session servers, but these are highly rate limited and I am sure that there is a better way since many large servers have thousands of people on with their own skin
     
  2. MiniDigger

    Supporter

    if you create a game profile from an offline player, you will not have a skin. to get the skin, you would need to fill in the skin properties yourself, either via mojangs servers or via your own cache for some 3rd party service.

    this is my cache (implemented using papers fantastic playerprofile api which provides events to catch the lookups)
    https://github.com/VoxelGamesLib/Vo...eslib/voxelgameslib/texture/TextureCache.java
    it basically caches all lookups and redirects them to my cache, if the cache doesn't contain that uuid or name, it tries to hit mojang. I also persist my cache to disk using gson to further reduce lookups to mojang.

    so yeah, you need to fill in properties, to be not rate limited you need to cache stuff, to do that easily use the paper api
     
    • Agree Agree x 1
    • Optimistic Optimistic x 1
  3. @MiniDigger If you read all of my question, you will see that I don't want to use Mojang's servers. If I cache user's skins then they won't be updated (It keeps using the old skin) and even then if 2 new people join within a minute than there will be problems. My main question was about how vanilla servers do it without being rate limited
     
  4. MiniDigger

    Supporter

    They use the vanilla server and a cache?
    If two different players join within a minute you don't get rate limited. You can request the same profile once per minute, however you can send as many unique requests as you like.

    The only reason I have that cache is to be prepared if a user decides to join twice in a minute. You also need to make sure to not request a profile when the internal server just requested one. That's why I use papers profile events to redirect the internal calls to my cache, that way I can make sure that only one request per profile goes off to mojang.

    Also, you can just set the cache timeout to smth like 5 minutes and their skin will be updated properly if you fear players complaining over outdated skins.

    If don't use mojangs servers, how are you gonna get the skin? Lol. You could use a 3rd party service but you then would 100% rely on them which is a bad idea. You could also setup your own caching server (smth like https://github.com/dotStart/Stockpile) but you only really need that if your server is large enough that you hit rate limits even after the caching I just explained.

    Instead of getting agressive towards ppl who try to help, I would consider actually listen and thinking about the points presented.
     
    • Like Like x 1
  5. Sorry for mishearing you, I did not know that mojang only rate limits similar requests. I was able to fix my issue by saving the player's skin when they join the server, allowing me to reset it later