Update DOCUMENTATION.md
This commit is contained in:
+11
-11
@@ -2,9 +2,9 @@
|
|||||||
NPCLib – Basic non-player character library.<br>
|
NPCLib – Basic non-player character library.<br>
|
||||||
=
|
=
|
||||||
|
|
||||||
This is an API made specifically for spigot servers (Minecraft). Current supported versions: **1.7.10\* - 1.13.2**. Lightweight replacement for Citizens. NPCLib only uses packets instead of registering the entity in the actual Minecraft server.
|
This is an API made specifically for spigot servers (Minecraft). Current supported versions: **1.7.10\* - 1.14.4**. Lightweight replacement for Citizens. NPCLib only uses packets instead of registering the entity in the actual Minecraft server.
|
||||||
|
|
||||||
\*NPCLib has basic support for 1.7.10, as it not currently support multi-line text for this version (yet).
|
\*NPCLib has basic support for 1.7.10 and is not actively maintained.
|
||||||
|
|
||||||
## Documentation
|
## Documentation
|
||||||
|
|
||||||
@@ -37,15 +37,15 @@ Now you have an instance of the library, it is time to create your first NPC! Yo
|
|||||||
If you want your NPC to have a custom skin, either [create your own Skin object](#create-skin-object) or fetch the data from [mineskin.org](https://mineskin.org) using the [SkinFetcher](#skin-fetcher) class.
|
If you want your NPC to have a custom skin, either [create your own Skin object](#create-skin-object) or fetch the data from [mineskin.org](https://mineskin.org) using the [SkinFetcher](#skin-fetcher) class.
|
||||||
|
|
||||||
```Java
|
```Java
|
||||||
// Skin parameter: The skin you would like the NPC to have (may be null).
|
// Lines parameter: The text you would like to display above the NPC's head (optional).
|
||||||
// AutoHideDistance parameter: The distance NPCLib will use to automatically hide the NPC (default = 50).
|
NPC npc = library.createNPC(List<String> lines);
|
||||||
// Lines parameter: The text you would like to display above the NPC's head (may be null).
|
|
||||||
NPC npc = library.createNPC(Skin skin, double autoHideDistance, List<String> lines);
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Even though you have created the NPC object now, you will not be able to see it just yet. We first need to show it to the player. The NPC does not show up to players automatically because NPCLib relies on packets rather than registering the actual entity in the Minecraft server.
|
Even though you have created the NPC object now, you will not be able to see it just yet. We first need to need to do some other things. The NPC does not show up to players automatically because NPCLib relies on packets rather than registering the actual entity in the Minecraft server.
|
||||||
|
|
||||||
```Java
|
```Java
|
||||||
|
npc.setLocation(Location location);
|
||||||
|
npc.create(); // Generates the packets.
|
||||||
npc.show(Player player);
|
npc.show(Player player);
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -61,15 +61,15 @@ When you are done using the NPC, you will have to destroy all NPCs accordingly:
|
|||||||
npc.destroy();
|
npc.destroy();
|
||||||
```
|
```
|
||||||
|
|
||||||
If you're destroying NPCs, because you are reloading your plugin. I recommend using the following method (as it does not use any schedulers):
|
When you are done with the NPC, you can destroy it accordingly. This will remove the NPC from the internal registry and hide it from all players that can (still) see it:
|
||||||
|
|
||||||
```Java
|
```Java
|
||||||
npc.destroy(true);
|
npc.destroy();
|
||||||
```
|
```
|
||||||
|
|
||||||
#### NPC handling
|
#### NPC handling
|
||||||
|
|
||||||
Every NPC is given a unique identifier (`NPC#getEntityId`)that should be used throughout your plugin to identify which NPC has been interacted with.
|
Every NPC is given a unique identifier (`NPC#getId`)that should be used throughout your plugin to identify which NPC has been interacted with.
|
||||||
|
|
||||||
#### Create skin object
|
#### Create skin object
|
||||||
|
|
||||||
@@ -94,4 +94,4 @@ The ID in this method is the ID that is in the URL of your MineSkin skin (e.g. h
|
|||||||
|
|
||||||
### Useful events
|
### Useful events
|
||||||
|
|
||||||
Events you may want to use are `NPCSpawnEvent`, `NPCDestroyEvent` and `NPCInteractEvent`.
|
Events you may want to use are `NPCShowEvent`, `NPCHideEvent` and `NPCInteractEvent`.
|
||||||
|
|||||||
Reference in New Issue
Block a user