✅ [API] Player NPC ✅ [1.17 - 1.20.1]
2023.6Player NPC Lib via packets API for 1.17, 1.18, 1.19 & 1.20
PlayerNPC is a simple NPC API for Spigot, that allows you to create your own NPC per player.
This plugin was developed by SergiFerry
/npclib - Let you customize the NPCLib.
Permission: playernpc.command
/npcglobal - Let you customize the Global NPCs.
Permission: playernpc.command
- All changes made to Persistent NPC will be saved when the server restarts.
/npcpersonal - Let you customize the Personal NPCs.
Permission: playernpc.command
- This is an experimental command, and it's only for developer testing purposes.
- Changes will not be saved when the server restarts.
Plugins using PlayerNPC API
- Corpses - Developed by SergiFerry
- RandomTeleport - Developed by SergiFerry
- Graves - Developed by Ranull
If you want to show your plugin here, contact me throught twitter @SergiFerry
All JavaDocs are available at:
https://sergiferry.github.io/PlayerNPC/
Put the PlayerNPC.jar on your server's /plugins and add the jar to the llibary of your Java Project.
Maven:
<repository>
<id>ranull-repo-external</id>
<url>https://repo.ranull.com/maven/external/</url>
</repository>
<dependency>
<groupId>dev.sergiferry</groupId>
<artifactId>playernpc</artifactId>
<version>2023.4</version>
<scope>provided</scope>
</dependency>
First of all, register your Plugin to the NPCLib
NPCLib.getInstance().registerPlugin(plugin);
Step 1, generate the NPC instance
NPC.Global npc = NPCLib.getInstance().generateGlobalNPC(plugin, id, location);
//or
NPC.Personal npc = NPCLib.getInstance().generatePersonalNPC(player, plugin, id, location);
Step 2, modify the NPC attributes
npc.setSkin(texture, signature); //Use https://mineskin.org/
npc.setItem(NPC.Slot, ItemStack);
npc.setText(String...);
npc.setGlowing(boolean, ChatColor);
npc.setCollidable(boolean);
npc.setGazeTrackingType(NPC.GazeTrackingType);
npc.setCustomTabListName(String, boolean);
npc.setHideDistance(double);
npc.setShowOnTabList(boolean);
npc.setInteractCooldown(long);
npc.setLineSpacing(double);
npc.setTextOpacity(NPC.Hologram.Opacity);
npc.setTextAlignment(Vector);
npc.setPose(NPC.Pose);
npc.addCustomClickAction(NPC.Interact.ClickType, CustomAction);
Step 3, if you are using Personal NPCs, you need to create and show it to the player.
npc.create();
npc.show();
You can listen for player interact with the NPC, but it's better to use ClickActions
@EventHandler
public void onNPCInteract(NPC.Events.Interact event){
Player player = event.getPlayer();
NPC npc = event.getNPC();
NPC.Interact.ClickType clickType = event.getClickType();
}
You can hide it temporally or destroy it permanent.
npc.hide();
npc.destroy();
You can change the NPC skin, even when if it's created and shown.
npc.setSkin(NPC.Skin);
npc.forceUpdate();
You can change where the NPC looks at
npc.lookAt(location);
npc.update();
You can change the NPC location
npc.teleport(location);
You can change the Text above the NPC
npc.setText(String...);
npc.setLineOpacity(Integer, NPC.Hologram.Opacity);
npc.updateText(); //if the text have the same amount of lines
npc.forceUpdateText(); //if the text have different amount of lines
npc.setHideText(boolean); //you can also hide the text and then show it later
Remember that some changes at the NPC instance will not have effect on the player client until you update the npc.
npc.update();
npc.forceUpdate();
Similar projects
Plugin →Let Me Despawn
Improves performance by tweaking mob despawn rules. Say bye to pesky unintentional persistent mobs.
26.2MSueta
JourneyMap
Real-time map used for mapping in-game or your browser as you explore.
14.7MSueta
Emotecraft
Create your own emotes in Minecraft.
7.9MSueta
Simple Tpa
A simple tpa plugin which sends requests
5.4MSueta
Common Network
Forge and Fabric Unified Networking Solution
4.7MSueta
Set Home
A lightweight plugin for players to set their homes.
3.8MSueta
