Skip to content

EcholightMC/MSNPCs

Repository files navigation

MSNPCs

Simple and small NPC library for Minestom. One of its key features is that it automatically removes npcs from chat completions and the player report menu. MSNameTags support is built-in by setting the username string tag for the npc, helping it recognize if it's a Player NPC or not.

Usage

Without MSNameTags

GlobalEventHandler eventHandler = MinecraftServer.getGlobalEventHandler();
NPCManager npcManager = new NPCManager(eventHandler);
NPC npc = npcManager.createNPC(EntityType.PLAYER, "Bill", null, null); // if name is null npc id will be used instead
npc.setInstance(instance, position);
MiniMessage miniMessage = MiniMessage.miniMessage();
GlobalEventHandler eventHandler = MinecraftServer.getGlobalEventHandler();
NameTagManager nameTagManager = new NameTagManager(eventHandler);
NPCManager npcManager = new NPCManager(eventHandler);
NPC npc = npcManager.createNPC(EntityType.PLAYER, null, null, null); // if name is null npc id will be used instead
npc.setInstance(instance, position);
NameTag nameTag = nameTagManager.createNameTag(npc);
nameTag.setText(miniMessage.deserialize("<red><b>Billy"));

Add as Dependency

Gradle

repositories {
  ..
  maven {
    url = "https://maven.hapily.me/releases"
  }
}
dependencies {
  ..
  implementation("com.github.echolightmc:MSNPCs:1.4-SNAPSHOT") {
    exclude group: "net.minestom", module: "minestom-snapshots"
  }
}