-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from Foxikle/1.7
1.7
- Loading branch information
Showing
14 changed files
with
512 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
<buildprofiles xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="https://resources.jetbrains.com/writerside/1.0/build-profiles.xsd"> | ||
<variables> | ||
<primary-color>emerald</primary-color> | ||
<primary-color>aqua</primary-color> | ||
<product-web-url>https://foxikle.dev</product-web-url> | ||
<download-title>Download CustomNPCs</download-title> | ||
<download-page>https://modrinth.com/plugin/customnpcs</download-page> | ||
|
@@ -15,7 +15,8 @@ | |
<footer> | ||
<copyright>Foxikle 2024</copyright> | ||
<social type="youtube" href="https://youtube.com/@foxikle">Youtube</social> | ||
<social type="email" href="mailto:[email protected]">Email</social> | ||
<social type="email" href="[email protected]">Email</social> | ||
<social type="blog" href="https://foxikle.dev">Website</social> | ||
<link href="discord.gg/4uThsAfJ8g">Discord</link> | ||
<link href="https://github.com/foxikle/customnpcs">GitHub</link> | ||
<link href="https://patreon.com/foxikle">Patreon</link> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
# API Documentation | ||
|
||
## Coming Soon ;) | ||
For now, look [here](https://github.com/Foxikle/CustomNPCs/wiki). | ||
The API is the best way to utilize the true potential of CustomNPCS. With the API, you can customize nearly every aspect | ||
of any NPC. The API is written in Java, and requires the CustomNPCs plugin to be installed on the same server as the | ||
plugin utilizing the API. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# API Roadmap | ||
|
||
Here is the current roadmap for features that I would *like* to implement. This doesn't mean these features are | ||
guaranteed to be implemented in the given version, or at all. If you would like to request a feature, join my Discord | ||
server and create a feature request ticket. Alternatively, you could create an issue with the feature request template. | ||
|
||
## 1.8 | ||
- Walking paths (A list of locations to "teleport" the NPC to) | ||
- Multiple data storage options, (Databases, file, etc.) | ||
- Along with this, NPC data will likely shift from YAML to json | ||
- A pose editor | ||
- A bunch of qol and small tweaks to make using the plugin better | ||
|
||
## 1.9 | ||
- Goal based AI | ||
- Generic pathfinding | ||
- "Keyframed" walking. | ||
- The idea here is to have a set of points or "keyframes" for the NPC to navigate in between, using its own pathfinding | ||
to fill in the gaps. | ||
- Adding the ability to damage the NPCs (and knock back) would probably fit in well with the theme of this update. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,167 @@ | ||
# Creating an NPC with the API | ||
|
||
|
||
> You can visit the JavaDocs at `https://repo.foxikle.dev/javadoc/public/dev/foxikle/customnpcs/<VERSION>` | ||
> [Here](https://repo.foxikle.dev/javadoc/public/dev/foxikle/customnpcs/1.7) are the latest javadocs! | ||
## Creating the NPC object | ||
To start, you need an NPC object. You can create one by calling `NPC::new` (The constructor) | ||
Here is an example: | ||
|
||
```java | ||
World world = Bukkit.getWorld("world"); // the default world name | ||
// But you should do a null check, as | ||
// an error will be thrown if the world is null | ||
NPC npc = new NPC(world); | ||
``` | ||
|
||
## General Customization | ||
### Position | ||
|
||
From there, you have to do a few things in order for the NPC to be useful. For starters, you should set the | ||
spawn location. If you don't the NPC will spawn at (0, 0, 0). | ||
```java | ||
// arbitrary numbers for the sake of example | ||
npc.setPosition(new Location(world, 100, 100, 100)); | ||
``` | ||
|
||
### Rotation | ||
|
||
If you want to customize the yaw and pitch of the NPC's head, you should do so using the Location object. | ||
```java | ||
// arbitrary numbers for the sake of example | ||
Location loc = new Location(world, 100, 100, 100, 45, 0); | ||
npc.setPosition(loc); | ||
``` | ||
|
||
|
||
### Skin Data | ||
If you want to specify a skin for the NPC, you should do so using the `setSkinData` method. To get the signature and | ||
value, you can use InventiveTalent's [Mineskin](https://mineskin.org). | ||
```java | ||
String value = ...; // assume an actual value | ||
String signature = ...; // assume an actual signature | ||
String skinName = ...; // shown when a user tries to edit the NPC | ||
npc.setSkinData(skinName, signature, value) | ||
``` | ||
|
||
## The Settings Object | ||
> It is imperative that you call `NPC#reloadSettings()` if you edit the Settings or Equipment objects **after** creating | ||
> the NPC {style=warning} | ||
|
||
### Interactability | ||
Interactability defines if the NPC will have the clickable hologram. (More info Later) If this is set to false, even if | ||
you give the NPC actions, they will be ignored. (Defaults to **false**) | ||
To change it, simply call | ||
```java | ||
npc.getSettings().setInteractable(true); | ||
``` | ||
|
||
### Tunnel Vision | ||
Tunnel vision defines if the NPC will look at nearby players. (Defaults to **false**) | ||
To change it, simply call | ||
```java | ||
npc.getSettings().setTunnelVision(true); | ||
``` | ||
|
||
### Resilient | ||
Resiliency, or being resilient, defines if the NPC should persist on server restarts or running `/npc reload`. This | ||
defaults to **false**, unlike creating NPCs using the plugin's UI. Setting this to true may fill up your `npcs.yml` file | ||
if you are not careful. | ||
To change it, simply call | ||
```java | ||
npc.getSettings.setResilient(true); | ||
``` | ||
|
||
### ~~Direction~~ (Deprecated -- To be removed in 1.8) | ||
Lets you set the yaw of the NPC's head. Just set the Yaw in the NPC's location :) | ||
|
||
### Skin Data (But settings) | ||
The method on the NPC is just a wrapper around the settings object, it is functionally the same. You can view the docs | ||
on it [here](#skin-data). | ||
|
||
### Hide Clickable Hologram | ||
This option hides the Clickable hologram, making the NPC appear as if I wasn't interactable, yet still being | ||
interactable. (Defaults to **false**) | ||
To change it, simply call | ||
```java | ||
npc.getSettings().setHideClickableHologram(true); | ||
``` | ||
|
||
### Custom Interactable Hologram | ||
This option allows you to override the global Clickable Hologram value. The string value can contain MiniMessage tags | ||
and PlaceholderAPI placeholders. | ||
To change it, simply call | ||
```java | ||
npc.getSettings().setCustomInteractableHologram("<Your hologram>"); | ||
``` | ||
|
||
## The Equipment Object | ||
> It is imperative that you call `NPC#reloadSettings()` if you edit the Settings or Equipment objects **after** creating | ||
> the NPC {style=warning} | ||
I am not going to go through every method, because their names are self-explanatory. The point is, you can set/get the | ||
itemstack object the NPC uses. | ||
|
||
If you would like to import that equipment from a player, for example, you can use the `importFromEntityEquipment()` | ||
method. | ||
|
||
Here is an example: | ||
```java | ||
Player player = ...; // pretend its valid | ||
npc.getEquipment().importFromEntityEquipment(player.getEquipment()); | ||
``` | ||
|
||
## Using Actions | ||
In 1.7, the Action system got a complete rewrite. This makes it way easier to use over its predecessors. Instead of | ||
using a string array and an enum, each action has its own class. If you want to add an action, you can just call | ||
`NPC#addAction(Action)`. [Here](Using-the-Action-System.md) is a list of available actions. For example, sending a message: | ||
```java | ||
npc.addAction(new SendMessage("Text Here", 0, ONE, List.of())); | ||
``` | ||
All actions follow the same general constructor parameter layout: | ||
|
||
First, are the action specific parameters, in our case, the message to send. | ||
|
||
Then, there is an integer, specifying the number of ticks of delay to run the action after the initial interaction. | ||
|
||
Then, there is a `Condition.SelectionMode` enum constant, signifying if one, or all of the following conditions must be | ||
met in order for the action to execute. | ||
|
||
Finally, the list of conditions the player must fulfil for the Action to be executed. | ||
|
||
If you would like to write your own actions, check out [this](Writing-Custom-Actions.md) page. | ||
|
||
If you would like to create your own Conditions, check out the [Roadmap](API-Roadmap.md), as that is a planned feature. | ||
|
||
## Moving the NPC | ||
You can move the NPC by calling the `moveTo(Location)` method. Please note that it takes the pitch and yaw into account. | ||
The movements are only temporary, as reloading the npcs will put the NPC back to its spawn location. | ||
|
||
## Looking at things | ||
You can make the NPC look at things in two ways. First, you can use the `lookAt(Location)` to look at the specified | ||
location. | ||
```java | ||
npc.lookAt(new Location(world, 0, 0, 0); | ||
``` | ||
Additionally, you can look at an entity instead. | ||
```java | ||
npc.lookAt(entity, true); | ||
``` | ||
The first argument is the entity to look at. It cannot be null. | ||
|
||
The second argument is true of the npc should look at the entity's head, or false for their feet | ||
## Swinging the NPC's arm | ||
You can swing the NPC's arm by calling `npc.swingArm()`. | ||
## Manual Injection (Not recommended) | ||
Even though the plugin handles injection, or making the NPCs actually appear, it is possible to handle it yourself. | ||
This could be useful, for example, if you are creating per-player NPCs. (But even then, there are better ways of doing | ||
it) In order to inject NPCs yourself, you can call | ||
```java | ||
npc.injectPlayer(player); | ||
``` | ||
Please note, if you want to do conditional injection, you should cancel the NpcInjectEvent instead :) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
# Getting Started With The API | ||
|
||
To start, you need to add CustomNPCs as a dependency in your dependency manager. | ||
|
||
<tabs> | ||
<tab title="Maven"> | ||
Add the repository to the `repositories` section in your `pom.xml` | ||
<code-block lang="XML"> | ||
<repository> | ||
<id>customnpcs</id> | ||
<name>Foxikle's Repository</name> | ||
<url>https://repo.foxikle.dev/public</url> | ||
</repository> | ||
</code-block> | ||
|
||
|
||
Then, add the dependency to your dependencies section | ||
<code-block lang="xml"> | ||
<dependency> | ||
<groupId>dev.foxikle</groupId> | ||
<artifactId>customnpcs</artifactId> | ||
<version>1.7</version> | ||
</dependency> | ||
</code-block> | ||
</tab> | ||
<tab title="Gradle (kotlin)"> | ||
|
||
Add the CustomNPCs Maven Repository | ||
|
||
<code-block lang="kotlin"> | ||
maven { | ||
name = "foxiklePublic" | ||
url = uri("https://repo.foxikle.dev/public") | ||
} | ||
</code-block> | ||
OR | ||
<code-block lang="kotlin"> | ||
maven ("https://repo.foxikle.dev/public") | ||
</code-block> | ||
|
||
|
||
<br> | ||
|
||
Then, add the dependency to your `build.gradle.kts` | ||
<code-block lang="KOTLIN"> | ||
compileOnly("dev.foxikle:customnpcs:1.7") | ||
|
||
</code-block> | ||
|
||
</tab> | ||
<tab title="Gradle (Groovy)"> | ||
|
||
Add the CustomNPCs Maven Repository | ||
|
||
<code-block lang="groovy"> | ||
maven { | ||
name "customnpcs" | ||
url "https://repo.foxikle.dev/public" | ||
} | ||
|
||
</code-block> | ||
|
||
Add the dependency to your `build.gradle` | ||
<code-block lang="groovy"> | ||
compileOnly "dev.foxikle:customnpcs:1.7" | ||
|
||
</code-block> | ||
</tab> | ||
</tabs> | ||
|
||
|
||
Then, you can reload your project and get ready to use the API! | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Gimmicks | ||
|
||
The API has a few gimmicks with it, as it is still under active development. Here are a few. | ||
|
||
NPC Rotation | ||
: In order to set the yaw of the NPC's head, you can use two methods. You can either call `Settings#setDirection` or | ||
you can modify the NPC's SpawnLocation property. |
Oops, something went wrong.