NPC
NPC is a fake player with which you can interact, change something, set skin to it, cape, detect clicks on npc, changing location, etc.
How to create?
import com.hakan.core.HCore;
import com.hakan.core.item.HItemBuilder;
import com.hakan.core.npc.HNPC;
import com.hakan.core.npc.skin.HNpcSkin;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import java.util.Arrays;
public class CustomNPC {
public HNPC buildNPC() {
return HCore.npcBuilder("npc id")
.showEveryone(true) // you can show npc to everyone, or:
.showEveryone(false)
.viewers(/* List of specified players UUIDs and NPC will show to them*/)
.location(new Location(Bukkit.getWorld("world"), 0, 0, 0, 0.0f, 0.0f)) // Npc will be spawned in x: 0 y: 0 z: 0 with yaw: 0 and pitch: 0 in world: world
.lines(Arrays.asList(
"This is first line of hologram over the npc!",
"this is the second line."
)) // Will create the holo over the npc
.skin(HNpcSkin.from("Steve")) // Npc will have skin from player steve
.equipment(HNPC.EquipmentType.HEAD, new HItemBuilder(Material.DIAMOND_HELMET).build()) // Npc will have diamond helmet on head
.equipment(HNPC.EquipmentType.CHEST, new HItemBuilder(Material.DIAMOND_CHESTPLATE).build()) // Npc will have diamond chestplate
.equipment(HNPC.EquipmentType.LEGS, new HItemBuilder(Material.DIAMOND_LEGGINGS).build()) // Npc will have diamond leggings
.equipment(HNPC.EquipmentType.FEET, new HItemBuilder(Material.DIAMOND_BOOTS).build()) // Npc will have diamond boots
.equipment(HNPC.EquipmentType.MAINHAND, new HItemBuilder(Material.DIAMOND_SWORD).build()) // Npc will have diamond sword in hand
.whenClicked((player, action) -> {
}) // Will called when player will click. you can check if player is right clicked on npc or left clicked, and what player
.whenDeleted(npc -> {
}) // Will called when npc is deleted
.whenSpawned(npc -> {
}) // Will called when npc is spawned
.forceBuild(); // Use forceBuild if you want to delete existing npc with provided id (if it exists)
}
}HNPC#showEveryone(boolean)
HNPC#addViewer(List<Player>)
HNPC#removeViewer(List<Player>)
HNPC#delete()
HNPC#expire(int ticks)
HNPC#canEveryoneSee()
HNPC#getEntity()
HNPC#getID()
HNPC#getLocation()
HNPC#setLocation(Location loc)
HNPC#getSkin()
HNPC#setSkin(String skin)
HNPC#whenClicked(BiConsumer<Player, Action>)
HNPC#whenDeleted(Consumer<HNPC>)
HNPC#whenSpawned(Consumer<HNPC>)
HNPC#walk(Location loc, double speed)
HNPC#isDead()
HNPC#isWalking()
HNPC#setEquipment(EquipmentType type, ItemStack item)
Ending
Last updated