Skip to content
Rapha149 edited this page Jan 25, 2024 · 5 revisions

Usage

In order to be able to use the api, you have to call DisplayUtils#init in your Plugin#onEnable method:

public class MyPlugin extends JavaPlugin {

    @Override
    public void onEnable() {
        // some code

        DisplayUtils.init(this);

        // some more code
    }
}

After you have done that, you can use the individual utils as described below.

NPCs

To create an NPC, you first have to adjust it's settings via the NPCBuilder and then add it using NPCUtil#addNPC:

// Create the NPC's skin
NPCSkin skin = new NPCSkin(
    "ewogICJ0a...", // texture
    "vP7de1V4M...", // signature
    NPCSkinPart.getDefaultParts() // list of skin parts to dispaly
);

// Create the builder
NPCBuilder builder = new NPCBuilder(
    "mynpc", // unique identifier to easily remove the NPC if needed
    "§aJohn", // name of the NPC, can contain color codes
    skin, // the NPC's skin (see above)
    new Location(Bukkit.getWorld("world"), 0, 70, 0, 90F, 0F), // location of the NPC, can contain yaw and pitch
    player -> { // npc use listener
        player.sendMessage("That tickled!");
    }
);

// here you can call optional methods of the builder to further adjust the settings for your npcs
// see the javadoc for explanation of the methods

// add the npc
NPCUtil.addNPC(builder.build());

Clone this wiki locally