This spigot plugin is a easy to use NPC API called NPC-Factory.
Creating non-player-characters was never so easy!
- Download the latest release.
- Put the .jar file in your plugins folder.
- Restart the server.
Add the dependency to your project:
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
<dependency>
<groupId>com.github.qrowned</groupId>
<artifactId>NPC-Factory</artifactId>
<version>1.0.0-RELEASE</version>
</dependency>
maven {
name 'jitpack.io'
url 'https://jitpack.io'
}
implementation only: 'com.github.qrowned:NPC-Factory:1.0.0-RELEASE'
public class NPCExample {
private final NPCFactoryPlugin npcFactoryPlugin;
public NPCExample(NPCFactoryPlugin npcFactoryPlugin) {
this.npcFactoryPlugin = npcFactoryPlugin;
}
/**
* Spawn sample npc
*
* @param location location the npc should spawn
* @param excludedPlayers list of players which should not see the npc
*/
public void spawnNPC(Location location, List<Player> excludedPlayers) {
final NPC npc = NPC.builder()
.data(this.createNPCData())
.location(location)
.lookAtPlayers(false)
.imitatePlayers(false)
.build(this.npcFactoryPlugin.getNpcHandler());
excludedPlayers.forEach(npc::exclude);
}
/**
* Create a sample npc data
*
* @return created npc data
*/
private NPCData createNPCData() {
// Creating data and fetching data from mojang
final NPCData npcData = NPCData.create(UUID.fromString("a7f2ffe9-cf32-46be-8453-9c73eb3be00b"));
npcData.complete();
// Change UUID & Name
npcData.setUniqueId(UUID.randomUUID());
npcData.setName("NPC-Factory");
return npcData;
}
}