Skip to content

Commit

Permalink
Merge pull request #1 from Foxikle/1.7
Browse files Browse the repository at this point in the history
1.7
  • Loading branch information
Foxikle authored Dec 21, 2024
2 parents 9da0777 + 637f580 commit bc40a7c
Show file tree
Hide file tree
Showing 14 changed files with 512 additions and 20 deletions.
5 changes: 3 additions & 2 deletions Writerside/cfg/buildprofiles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand All @@ -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>
Expand Down
29 changes: 16 additions & 13 deletions Writerside/customnpcs.tree
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,24 @@
<!DOCTYPE instance-profile
SYSTEM "https://resources.jetbrains.com/writerside/1.0/product-profile.dtd">

<instance-profile id="customnpcs"
name="CustomNPCs"
start-page="Wiki.md">

<toc-element topic="Wiki.md">
<toc-element topic="getting-started.md"/>
<toc-element topic="configuring-customnpcs.md"/>
<toc-element topic="Creating-Your-First-NPC.md"/>
<toc-element topic="Commands.md"/>
<toc-element topic="Using-the-Action-System.md">
<toc-element topic="Using-Conditions-Within-Actions.md"/>
</toc-element>
<instance-profile id="customnpcs" name="CustomNPCS" start-page="Wiki.md">
<toc-element topic="Wiki.md"/>
<toc-element topic="getting-started.md"/>
<toc-element topic="configuring-customnpcs.md"/>
<toc-element topic="Creating-Your-First-NPC.md"/>
<toc-element topic="Commands.md"/>
<toc-element topic="Using-the-Action-System.md">
<toc-element topic="Using-Conditions-Within-Actions.md"/>
</toc-element>
<toc-element topic="API-Documentation.md">
<toc-element topic="Getting-Started-With-The-API.md"/>
<toc-element topic="Creating-an-NPC-with-the-API.md"/>
<toc-element topic="Writing-Custom-Actions.md"/>
<toc-element topic="Using-Events.md"/>
<toc-element topic="Gimmicks.md"/>
<toc-element topic="API-Roadmap.md"/>
</toc-element>
<toc-element topic="Support.md"/>
<toc-element topic="Contributing.md"/>
<toc-element topic="Acknowledgments.md"/>
<toc-element topic="API-Documentation.md"/>
</instance-profile>
4 changes: 4 additions & 0 deletions Writerside/redirection-rules.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,8 @@
<description>Created after removal of "Creating an NPC" from Help Instance</description>
<accepts>Creating-an-NPC.html</accepts>
</rule>
<rule id="98a84b6">
<description>Created after removal of "v2" from CustomNPCs</description>
<accepts>v2.html</accepts>
</rule>
</rules>
5 changes: 3 additions & 2 deletions Writerside/topics/API-Documentation.md
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.
20 changes: 20 additions & 0 deletions Writerside/topics/API-Roadmap.md
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.
2 changes: 1 addition & 1 deletion Writerside/topics/Acknowledgments.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ day knowing that you chose my plugin to use. I appreciate everyone who reaches o

If you would like to support me, you can do so on [Patreon](https://patreon.com/foxikle).

\~ Foxikle <3
Foxikle <3
167 changes: 167 additions & 0 deletions Writerside/topics/Creating-an-NPC-with-the-API.md
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 :)
73 changes: 73 additions & 0 deletions Writerside/topics/Getting-Started-With-The-API.md
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">
&lt;repository&gt;
&lt;id&gt;customnpcs&lt;/id&gt;
&lt;name&gt;Foxikle's Repository&lt;/name&gt;
&lt;url&gt;https://repo.foxikle.dev/public&lt;/url&gt;
&lt;/repository&gt;
</code-block>


Then, add the dependency to your dependencies section
<code-block lang="xml">
&lt;dependency&gt;
&lt;groupId&gt;dev.foxikle&lt;/groupId&gt;
&lt;artifactId&gt;customnpcs&lt;/artifactId&gt;
&lt;version&gt;1.7&lt;/version&gt;
&lt;/dependency&gt;
</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!

7 changes: 7 additions & 0 deletions Writerside/topics/Gimmicks.md
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.
Loading

0 comments on commit bc40a7c

Please sign in to comment.