NPC skins load on online servers, but not on offline servers

I give skins to npcs (HUMAN entities) with the following code

npc.offer(npc.getOrCreate(SkinData.class).get().set(Keys.SKIN_UNIQUE_ID, UUID.fromString("8667ba71-b85a-4004-af54-457a9734eed7")));

but skin doesn’t load in an offline server.

Is there a way to resolve that?

Switch to online mode?

Short answer, no.

Long answer. The offline mode is the setting to change if you wish for your server to do the checks at mojangs servers. This includes checking the uuid of the player is valid, as well as getting the skin data for that uuid. If you disable this setting then the getting of the skin data will not apply.

Sponge respects this setting, meaning all sponge code will not do a work around to get the data for you. I.E if you disable this setting you must suffer with all effects it has.

While you maybe able to go directly into NMS and apply skin data yourself by getting it from mojang servers yourself, this would mean that you would be limited to sponge common based implementations of the sponge api, not only that but all the issues of NMS come to attack you. And it wont work on none mojang servers such as Lantern.

I also know that deliberately making features that are only to support offline servers would mean your plugin was not approved on dev.bukkit. can not remember of the top of my head if sponge ore is that strict.

I’m answering to both of you.

Thanks for the reply, but the problem is that if I’m using bungeecord, I don’t have skins on NPCs.
Servers must be in offline mode for bungeecord to work!

Then you will be forced to use my suggestion in the long answer. Or to swap your server proxy to one that supports online mode … If there is one.

Oh, the server proxy is an interesting idea… Or maybe I could find a skin-setting API for sponge… :stuck_out_tongue:

The second option may not exists as sponge has its own skin api as you have found (it would be reinventing the wheel to fix a small issue) hence my insistence on creating it yourself

But what about the plugin/mod called “SkinRestorer”?
It’s said that it fixes skins on offline sponge servers.

By all means try it. Not going to stop you at all. Just never heard of it. But to be honest, not looked into it

Thanks, will do!

Just to clarify this point - in order for a proxy setup to work, offline-mode MUST be enabled as the proxy doesn’t have the credentials to validate a user against Mojang’s servers. It’s one of the more legitimate uses. Bungee and Velocity (I really recommend the latter, but I digress) have an extra set of steps during login that the proxy and server go through to confirm login validity and then the server should see this as if it was in “online mode”. At the very least, the player data is available on the server as if it’s in online mode (such as player UUIDs etc.)

It feels to me that if we have the BungeeCord module enabled and we modify the handshake so we emulate online mode, we should consider treating the server as online where possible - including for skins. I’m not really speaking for us all in the project, there may be a different view from elsewhere, but it might be worth looking into that when time permits.

I don’t know if an issue exists for this behaviour on SpongeCommon - but you could always create one explicity stating this is a Bungee/Velocity thing. I don’t guarantee that it’ll be accepted (as I said, there might be a range of views about this and we may not really have time for it) but putting this issue on Github at least puts it on the radar.

I would not want to do this for a purely offline server where no proxy exists though.

2 Likes