Skip to content

Commit d7ccb58

Browse files
Update fancyworlds docs
1 parent 0222fa3 commit d7ccb58

4 files changed

Lines changed: 120 additions & 97 deletions

File tree

content/docs/minecraft-plugins/fancyworlds/api/getting-started.mdx

Lines changed: 10 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ description: How to get started with the FancyWorlds API
99

1010
To include the FancyNPCs API in your project, you need to add the following dependency to your `build.gradle.kts` or `pom.xml` file.
1111

12-
**Latest version**: <LatestVersion project="FancyNpcs" showDevBuilds />
12+
**Latest version**: <LatestVersion project="FancyWorlds" showDevBuilds />
1313

1414
**Gradle:**
1515
```kotlin
@@ -20,7 +20,7 @@ repositories {
2020

2121
```kotlin
2222
dependencies {
23-
compileOnly("de.oliver:FancyNpcs:2.9.2")
23+
compileOnly("com.fancyinnovations:FancyWorlds:${VERSION}")
2424
}
2525
```
2626

@@ -35,108 +35,21 @@ dependencies {
3535

3636
```xml
3737
<dependency>
38-
<groupId>de.oliver</groupId>
39-
<artifactId>FancyNpcs</artifactId>
40-
<version>2.9.2</version>
38+
<groupId>com.fancyinnovations</groupId>
39+
<artifactId>FancyWorlds</artifactId>
40+
<version>${VERSION}</version>
4141
<scope>provided</scope>
4242
</dependency>
4343
```
4444

45-
Replace `2.9.2` with the version of the API you want to use. You can find the latest version on the download pages or in the GitHub releases.
45+
Replace `${VERSION}` with the version of the API you want to use. You can find the latest version on the download pages or in the GitHub releases.
4646

47-
## Create a new NPC
47+
## Create and manage worlds
4848

49-
### 1. Create the NPC data
50-
51-
The `NpcData` class is used to store all the information about an NPC. You can create a new instance of `NpcData` by providing a name, the UUID of the creator, and the location where the NPC should be spawned.
52-
53-
```java
54-
NpcData data = new NpcData("myNpc", creatorUUID, location);
55-
data.setSkin("OliverHD"); // use skin of the player OliverHD
56-
data.setDisplayName("<red>cool displayname</red>");
57-
```
58-
59-
### 2. Create the NPC
60-
61-
You can use the NpcData object to create a new NPC. Because the implementation of the NPC is different for every Minecraft version, FancyNpcs provides a factory to create the NPC.
62-
63-
```java
64-
Npc npc = FancyNpcsPlugin.get().getNpcAdapter().apply(data);
65-
```
66-
67-
### 3. Register the NPC
68-
69-
To let FancyNpcs handle the NPC, you need to register it. FancyNpcs will take care of spawning, despawning, saving the NPC, and more.
70-
71-
```java
72-
FancyNpcsPlugin.get().getNpcManager().registerNpc(npc);
73-
```
74-
75-
<Callout type="warn">
76-
Do not register npcs in the first few seconds after the server has started. You need to wait at least 10 seconds before registering npcs. Otherwise, the npcs will not get registered correctly.
77-
You can also listen to the `NpcsLoadedEvent` to know when you can register npcs.
78-
</Callout>
79-
80-
<Callout>
81-
If you don't want to persist the npc, you can do the following: `npc.setSaveToFile(false);`
82-
</Callout>
83-
84-
### 4. Initially spawn the NPC for all players
85-
86-
To spawn the NPC for all players, you can use the following methods.
87-
88-
```java
89-
npc.create();
90-
npc.spawnForAll();
91-
```
92-
93-
## Modify an existing NPC
94-
95-
### 1. Get the NPC object by name
96-
97-
You can get an NPC object by its name. The name is unique for every NPC (unless the `player-npcs` feature flag is enabled). Alternatively, you can get an NPC by its ID.
98-
99-
```java
100-
Npc npc = FancyNpcsPlugin.get().getNpcManager().getNpc("myNpc");
101-
NpcData data = npc.getData();
102-
```
103-
104-
### 2. Modify the NPC data
105-
106-
You can modify the NPC data object to change the NPC's properties.
107-
108-
```java
109-
data.setDisplayName("<green>new displayname</green>");
110-
data.setSkin("https://url-to-skin.com/skin.png");
111-
```
112-
113-
### 3. Update the NPC
114-
115-
After you have modified the NPC data, you need to update the NPC for all players.
116-
117-
```java
118-
npc.updateForAll();
119-
```
120-
121-
<Callout>
122-
Some changes require the NPC to be respawned. You can respawn the NPC for all players by doing the following:
123-
```java
124-
npc.removeForAll();
125-
npc.spawnForAll();
126-
```
127-
</Callout>
128-
129-
## Remove an NPC
130-
131-
To remove an NPC, you can use the following method.
132-
133-
```java
134-
FancyNpcsPlugin.get().getNpcManager().removeNpc(npc);
135-
npc.removeForAll();
136-
```
49+
TODO
13750

13851
## JavaDocs and help
13952

140-
You can find the JavaDocs for the FancyNpcs API [here](https://repo.fancyinnovations.com/javadoc/releases/de/oliver/FancyNpcs/latest).
53+
You can find the JavaDocs for the FancyWorlds API [here](https://repo.fancyinnovations.com/javadoc/releases/com/fancyinnovations/FancyWorlds/latest).
14154

142-
Join the [FancyInnovations Discord](https://discord.gg/ZUgYCEJUEx) for help and support. There is a dedicated channel for help about the api (`#npcs-api`).
55+
Join the [FancyInnovations Discord](https://discord.gg/ZUgYCEJUEx) for help and support. There is a dedicated channel for help about the api (`#worlds-api`).

content/docs/minecraft-plugins/fancyworlds/commands/world.mdx

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,104 @@ description: Usage of the /world command
66

77
The `/world` command is the main command for managing worlds with FancyWorlds.
88

9+
## World lifecycle
10+
11+
### Link world
12+
13+
Links an existing world to FancyWorlds, allowing you to manage it with the plugin.
14+
15+
- **Permissions**: `fancyworlds.commands.world.link`
16+
- **Syntax**: `/world link <world>`
17+
18+
### Unlink world
19+
20+
Unlinks a world from FancyWorlds, removing it from the plugin's management.
21+
The world will not be deleted and will still exist on the server, but it will no longer be managed by FancyWorlds.
22+
23+
- **Permissions**: `fancyworlds.commands.world.unlink`
24+
- **Syntax**: `/unworld unlink <world>`
25+
26+
### Load world
27+
28+
Loads an existing world from disk and registers it to FancyWorlds.
29+
30+
- **Permissions**: `fancyworlds.commands.world.load`
31+
- **Syntax**: `/unworld load <world_name> [--seed=<seed>] [--environment=<environment>] [--generator=<generator>] [--structures]`
32+
33+
*You only need to the optional flags, if you want to change the world settings.
34+
If you don't specify any flags, the world will be loaded with its existing settings.*
35+
36+
### Unload world
37+
38+
Unloads a world. There must be no players in the world for it to be unloaded, otherwise the command will fail unless you use the `--force` flag, which will teleport away players from the world before unloading it.
39+
40+
- **Permissions**: `fancyworlds.commands.world.unload`
41+
- **Syntax**: `/unworld unload <world> [--force]`
42+
43+
44+
### Create new world
45+
46+
Creates a new world and registers it to FancyWorlds.
47+
48+
- **Permissions**: `fancyworlds.commands.world.create`
49+
- **Syntax**: `/unworld create <world_name> [--seed=<seed>] [--environment=<environment>] [--generator=<generator>] [--structures]`
50+
51+
## General commands
52+
53+
### World list
54+
55+
Shows a list of all loaded worlds.
56+
57+
- **Permissions**: `fancyworlds.commands.world.list`
58+
- **Syntax**: `/world list` or `/worlds`
59+
60+
### Teleport to world
61+
62+
Teleports you or someone else to the specified world.
63+
64+
- **Permissions**: `fancyworlds.commands.world.teleport`
65+
- **Syntax**: `/world teleport <world> [--target=<target>] [--destination=<destination>]` or `/world tp <world> [--target=<target>] [--destination=<destination>]`
66+
67+
### Show seed
68+
69+
Shows the seed of the world.
70+
If no world is specified, the command will show the seed of the world the player is currently in.
71+
72+
- **Permissions**: `fancyworlds.commands.world.seed`
73+
- **Syntax**: `/world seed [--world=<world>]` or `/seed [--world=<world>]`
74+
75+
## World settings
76+
77+
### Set world time
78+
79+
Sets the time of the world. You can use 'day', 'noon', 'night', 'midnight' or a specific time value.
80+
If no world is specified, the command will set the time of the world the player is currently in.
81+
82+
- **Permissions**: `fancyworlds.commands.world.time.set`
83+
- **Syntax**: `/world time set <time> [--world=<world>]` or `/time set <time> [--world=<world>]`
84+
85+
You can also use `/day`, `/noon`, `/night` and `/midnight` commands as shortcuts for setting the time to day, noon, night and midnight respectively.
86+
87+
### Get current world time
88+
89+
Shows the current time of the world.
90+
If no world is specified, the command will get the time of the world the player is currently in.
91+
92+
- **Permissions**: `fancyworlds.commands.world.time.current`
93+
- **Syntax**: `/world time current [--world=<world>]` or `/time current [--world=<world>]`
94+
95+
### List gamerules
96+
97+
Shows all gamerules of the world.
98+
If no world is specified, the command will get the gamerules of the world the player is currently in.
99+
100+
- **Permissions**: `fancyworlds.commands.world.gamerules.list`
101+
- **Syntax**: `/world gamerules list [--world=<world>] [--changed_only]` or `/gamerule list [--world=<world>] [--changed_only]`
102+
103+
### Set gamerule
104+
105+
Sets a gamerule of the world.
106+
If no world is specified, the command will set the gamerule to the world the player is currently in.
107+
108+
- **Permissions**: `fancyworlds.commands.world.gamerules.set`
109+
- **Syntax**: `/world gamerules set <gamerule> <value> [--world=<world>]` or `/gamerule set <gamerule> <value> [--world=<world>]`

scripts/generate-docs.mjs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ const PROJECT_IDS = {
1010
'FancyHolograms': '5QNgOj66',
1111
'FancyNpcs': 'EeyAn23L',
1212
'FancyDialogs': 'Sx6YwpnK',
13+
'FancyWorlds': 'pQjoA91u',
1314
};
1415

1516
async function fetchLatestVersion(projectId, projectName) {
@@ -53,6 +54,7 @@ async function main() {
5354
FancyHolograms: await fetchLatestVersion(PROJECT_IDS.FancyHolograms, 'FancyHolograms'),
5455
FancyNpcs: await fetchLatestVersion(PROJECT_IDS.FancyNpcs, 'FancyNpcs'),
5556
FancyDialogs: await fetchLatestVersion(PROJECT_IDS.FancyDialogs, 'FancyDialogs'),
57+
FancyWorlds: await fetchLatestVersion(PROJECT_IDS.FancyWorlds, 'FancyWorlds'),
5658
};
5759

5860
const failedFetches = Object.entries(versions).filter(([_, version]) => version === null);
@@ -86,6 +88,12 @@ async function main() {
8688
{ '\\$\\{VERSION\\}': versions.FancyHolograms }
8789
);
8890

91+
await processTemplate(
92+
join(rootDir, 'templates/minecraft-plugins/fancyworlds/api/getting-started.mdx'),
93+
join(rootDir, 'content/docs/minecraft-plugins/fancyworlds/api/getting-started.mdx'),
94+
{ '\\$\\{VERSION\\}': versions.FancyHolograms }
95+
);
96+
8997
console.log('\n✓ All documentation files generated successfully!');
9098
} catch (error) {
9199
console.error('\n✗ Error generating docs:', error);

templates/minecraft-plugins/fancyworlds/api/getting-started.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ Replace `${VERSION}` with the version of the API you want to use. You can find t
4646

4747
## Create and manage worlds
4848

49+
TODO
4950

5051
## JavaDocs and help
5152

0 commit comments

Comments
 (0)