Skip to content

API Skins

Eisi05 edited this page Jan 21, 2026 · 1 revision

NpcAPI supports static and dynamic skins.

Static skin from an online player

import de.eisi05.npc.api.objects.NpcOption;
import de.eisi05.npc.api.objects.NpcSkin;
import de.eisi05.npc.api.objects.Skin;

Skin skin = Skin.fromPlayer(player);
if (skin != null) {
  npc.setOption(NpcOption.SKIN, NpcSkin.of(skin));
  npc.reload();
}

Fetch skin from Mojang (by name or UUID)

These calls may return Optional.empty() on failure.

Skin.fetchSkin("Notch").ifPresent(skin -> {
  npc.setOption(NpcOption.SKIN, NpcSkin.of(skin));
  npc.reload();
});

Async:

Skin.fetchSkinAsync("Notch").thenAccept(opt -> opt.ifPresent(skin -> {
  npc.setOption(NpcOption.SKIN, NpcSkin.of(skin));
  npc.reload();
}));

Use the viewing player’s skin

npc.setOption(NpcOption.USE_PLAYER_SKIN, true);
npc.reload();

Placeholder-based dynamic skins

NpcAPI has placeholder update logic (it checks if the PlaceholderAPI plugin is enabled). If you want per-viewer dynamic skins, you can use a dynamic NpcSkin:

npc.setOption(NpcOption.SKIN, NpcSkin.of((viewer, npc, placeholder) -> {
  // return a Skin based on viewer + npc + placeholder
  Skin computed = null;
  return computed;
}, "%player_name%", Skin.fromPlayer(player)));

If your function returns null, the fallback skin is used.

PlaceholderAPI helper

If you want PlaceholderAPI-based resolution without writing your own function:

npc.setOption(NpcOption.SKIN, NpcSkin.ofPlaceholderAPI("%player_name%", Skin.fromPlayer(player)));

Clone this wiki locally