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 NpcApi 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</artifactId>
<version>1.1</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:1.1'
}
Add NpcApi as a dependency in your plugin.yml
:
# Required dependency (hard dependency)
depend: [NpcApi]
# Or optional dependency (soft dependency)
soft-depend: [NpcApi]
This 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</artifactId>
<version>1.1</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:1.1'
}
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, WrappedComponent.create("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, ChatColor.RED);
// Set a custom skin from a player
npc.setOption(NpcOption.SKIN, Skin.fromPlayer(player));
// Set up a click event handler
npc.setClickEvent(event -> {
Player player = event.getPlayer();
NPC clickedNpc = event.getNpc();
player.sendMessage("You clicked " + clickedNpc.getName().toLegacy());
});
npc.save();
npc.setName(WrappedComponent.create("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(WrappedComponent) |
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 |
- Java 17+
- Spigot 1.17+ (compatible with newer versions)
- Minecraft server with NPC support