docs: fix errors in API (#268)

* Update API.md

There's a little mistake and I found it and fixed. :)

* Update API.md

Fixed the wrong index
feat/data-edit-commands
SnowCutieOwO 8 months ago committed by GitHub
parent 73de0ff392
commit 8f13a3955c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -31,11 +31,12 @@ The HuskSync API is available for the following platforms:
1. [API Introduction](#api-introduction) 1. [API Introduction](#api-introduction)
1. [Setup with Maven](#11-setup-with-maven) 1. [Setup with Maven](#11-setup-with-maven)
2. [Setup with Gradle](#12-setup-with-gradle) 2. [Setup with Gradle](#12-setup-with-gradle)
2. [Creating a class to interface with the API](#3-creating-a-class-to-interface-with-the-api) 2. [Adding HuskSync as a dependency](#2-adding-husksync-as-a-dependency)
3. [Checking if HuskSync is present and creating the hook](#4-checking-if-husksync-is-present-and-creating-the-hook) 3. [Creating a class to interface with the API](#3-creating-a-class-to-interface-with-the-api)
4. [Getting an instance of the API](#5-getting-an-instance-of-the-api) 4. [Checking if HuskSync is present and creating the hook](#4-checking-if-husksync-is-present-and-creating-the-hook)
5. [CompletableFuture and Optional basics](#6-completablefuture-and-optional-basics) 5. [Getting an instance of the API](#5-getting-an-instance-of-the-api)
6. [Next steps](#7-next-steps) 6. [CompletableFuture and Optional basics](#6-completablefuture-and-optional-basics)
7. [Next steps](#7-next-steps)
## API Introduction ## API Introduction
### 1.1 Setup with Maven ### 1.1 Setup with Maven
@ -83,7 +84,7 @@ dependencies {
``` ```
</details> </details>
### 2. Adding HuskSync as a dependency ## 2. Adding HuskSync as a dependency
- Add HuskSync to your `softdepend` (if you want to optionally use HuskSync) or `depend` (if your plugin relies on HuskSync) section in `plugin.yml` of your project. - Add HuskSync to your `softdepend` (if you want to optionally use HuskSync) or `depend` (if your plugin relies on HuskSync) section in `plugin.yml` of your project.
```yaml ```yaml
@ -146,7 +147,7 @@ public class HuskSyncAPIHook {
## 6. CompletableFuture and Optional basics ## 6. CompletableFuture and Optional basics
- HuskSync's API methods often deal with `CompletableFuture`s and `Optional`s. - HuskSync's API methods often deal with `CompletableFuture`s and `Optional`s.
- A `CompletableFuture` is an asynchronous callback mechanism. The method will be processed asynchronously and the data returned when it has been retrieved. Then, use `CompletableFuture#thenAccept(data -> {})` to do what you want to do with the `data` you requested after it has asynchronously been retrieved, to prevent lag. - A `CompletableFuture` is an asynchronous callback mechanism. The method will be processed asynchronously and the data returned when it has been retrieved. Then, use `CompletableFuture#thenAccept(data -> {})` to do what you want to do with the `data` you requested after it has asynchronously been retrieved, to prevent lag.
- An `Optional` is a null-safe representation of data, or no data. You can check if the Optional is empty via `Optional#isEmpty()` (which will be returned by the API if no data could be found for the call you made). If the optional does contain data, you can get it via `Optional#get(). - An `Optional` is a null-safe representation of data, or no data. You can check if the Optional is empty via `Optional#isEmpty()` (which will be returned by the API if no data could be found for the call you made). If the optional does contain data, you can get it via `Optional#get()`.
> **Warning:** You should never call `#join()` on futures returned from the HuskSyncAPI as futures are processed on server asynchronous tasks, which could lead to thread deadlock and crash your server if you attempt to lock the main thread to process them. > **Warning:** You should never call `#join()` on futures returned from the HuskSyncAPI as futures are processed on server asynchronous tasks, which could lead to thread deadlock and crash your server if you attempt to lock the main thread to process them.
@ -154,4 +155,4 @@ public class HuskSyncAPIHook {
Now that you've got everything ready, you can start doing stuff with the HuskSync API! Now that you've got everything ready, you can start doing stuff with the HuskSync API!
- [[Data Snapshot API]] &mdash; Get, edit, create & delete data snapshots and update players - [[Data Snapshot API]] &mdash; Get, edit, create & delete data snapshots and update players
- [[Custom Data API]] &mdash; Register custom data types to sync your plugin's data with HuskSync - [[Custom Data API]] &mdash; Register custom data types to sync your plugin's data with HuskSync
- [[API Events]] &mdash; Listen to, cancel and modify the result of data synchronization events - [[API Events]] &mdash; Listen to, cancel and modify the result of data synchronization events

Loading…
Cancel
Save