-
-
Notifications
You must be signed in to change notification settings - Fork 0
API Skins
Eisi05 edited this page Jan 21, 2026
·
1 revision
NpcAPI supports static and dynamic skins.
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();
}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();
}));npc.setOption(NpcOption.USE_PLAYER_SKIN, true);
npc.reload();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.
If you want PlaceholderAPI-based resolution without writing your own function:
npc.setOption(NpcOption.SKIN, NpcSkin.ofPlaceholderAPI("%player_name%", Skin.fromPlayer(player)));