A powerful and easy-to-use NPC (Non-Player Character) API for Minecraft Spigot plugins that allows you to create, manage, and customize NPCs with advanced features.
- π Create custom NPCs with ease
- π¨ Customize NPC appearance (skins, glowing effects, etc.)
- π Handle click events and interactions
- π¬ Play animations and control NPC behavior
- πΎ Save and load NPCs persistently
- π₯ Show/hide NPCs for specific players
- π Comprehensive NPC management system
Choose your preferred installation method based on your project needs:
This method requires NpcPlugin-Paper to be installed as a separate plugin on the server.
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<dependency>
<groupId>com.github.Eisi05</groupId>
<artifactId>NpcApi-Paper</artifactId>
<version>1.21.x-14</version>
<scope>provided</scope>
</dependency>dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
}
}
dependencies {
compileOnly 'com.github.Eisi05:NpcApi-Paper:1.21.x-14'
}Add NpcPlugin-Paper as a dependency in your plugin.yml:
# Required dependency (hard dependency)
dependencies:
server:
- name: NpcPlugin-Paper
required: true
# Or optional dependency (soft dependency)
dependencies:
server:
- name: NpcPlugin-Paper
required: falseThis method bundles NpcApi directly into your plugin JAR file.
Add the repository and dependency to your pom.xml:
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.github.Eisi05</groupId>
<artifactId>NpcApi-Paper</artifactId>
<version>1.21.x-14</version>
</dependency>
</dependencies>Add the following to your build.gradle:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
}
}
dependencies {
implementation 'com.github.Eisi05:NpcApi-Paper:1.21.x-14'
}To enabled/disable the NpcApi add this to your Plugin Main class:
@Override
public void onEnable()
{
// Initialize NpcAPI with default configuration
NpcApi.createInstance(this, new NpcConfig());
}
@Override
public void onDisable()
{
// Properly disable NpcAPI
NpcApi.disable();
}// Create a location where the NPC should spawn
Location location = new Location(world, x, y, z);
// Create a new NPC with a name
NPC npc = new NPC(location, Component.text("Test"));
// Enable the NPC to make it visible to all players
npc.setEnabled(true);// Make the NPC glow with a red color
npc.setOption(NpcOption.GLOWING, ChatFormat.RED);
// Set a custom skin from a player
npc.setOption(NpcOption.SKIN, NpcSkin.of(Skin.fromPlayer(player)));// Set up a click event handler
npc.setClickEvent(event -> {
Player player = event.getPlayer();
NPC clickedNpc = event.getNpc();
player.sendMessage(Component.text("You clicked ").append(clickedNpc.getName()));
});npc.save();
npc.setName(Component.text("New Name"));
npc.setLocation(newLocation);
npc.reload();npc.playAnimation(/* animation parameters */);
npc.showNPCToPlayer(player);
npc.hideNpcFromPlayer(player);
npc.lookAtPlayer(player);
npc.delete();// Get a list of all available NPCs
List<NPC> allNpcs = NpcManager.getList();// Get a specific NPC by its UUID
UUID npcUuid = /* your NPC's UUID */;
NPC npc = NpcManager.fromUUID(npcUuid);| Method | Description |
|---|---|
setOption(NpcOption, Object) |
Set NPC options like glowing, skin, etc. |
setClickEvent(Consumer<ClickEvent>) |
Set the click event handler |
setEnabled(boolean) |
Enable/disable NPC visibility |
save() |
Save NPC to persistent storage |
reload() |
Reload NPC data |
setName(Component) |
Update NPC display name |
setLocation(Location) |
Move NPC to new location |
playAnimation(...) |
Play NPC animation |
showNPCToPlayer(Player) |
Show NPC to specific player |
hideNpcFromPlayer(Player) |
Hide NPC from specific player |
lookAtPlayer(Player) |
Make NPC look at player |
delete() |
Remove NPC permanently |
walkTo(Path, double, boolean, Consumer<Result>, players) |
Let the NPC walk along a path (can be created with PathfindingUtils class) |
- Java 21+
- Paper 1.21 - 1.21.10
- Minecraft server with NPC support