API & extension docs & Geyser system property docs (#159)

* initial start on api docs

* oops

* oops #2

* oops #3

* move global api info to global-api.md page, fix typo

* Initial setup page

* the extensions template and list is now in the geysermc org

* add fabric event subscribe example

* fix outdated naming

* the extensions template and list is now in the geysermc org, and therefore official

* spigot/paper plugin geyser-api docs

* minor tweaks

* the setup guide should be in a separate PR, oops

* Updated docs for resource packs PR

* document system properties

* Apply suggestions from code review

Co-authored-by: Redned <redned235@gmail.com>

* move and shuffle pages, address review

* -DGeyser.BedrockNetworkThreads exists too, apparently

* turn notes into banners

* be more specific to indicate this to be advanced stuff

* adjust texts & address camotoy's review

* nms good dont disable

* add chapter on event priorities

* remove whitespace

* main instead of maven-snapshots; floodgate-api 2.2.2

* Move around pages in toc.yml, no need to fully copy event priorities

* Apply suggestions from code review

Co-authored-by: Tim203 <mctim203@gmail.com>

* apply command suggestion

Co-authored-by: Tim203 <mctim203@gmail.com>

* reduce command comments

* specify that this is the Geyser API

* Apply suggestions from code review

Co-authored-by: Redned <redned235@gmail.com>

* dont repeat that the bulk of code would go into a post init event; we already say that

* adress review

* extensions currently target Base API version

---------

Co-authored-by: JensC <jenscollaertyprive@hotmail.com>
Co-authored-by: Redned <redned235@gmail.com>
Co-authored-by: Tim203 <mctim203@gmail.com>
This commit is contained in:
authored and GitHub committed 2023-07-09 10:49:13 -05:00
1 parent fd8b563efa
commit 2f8c69185f
13 files changed
+516 -95

No files matched your search

+7 -17
View File
@@ -2,27 +2,13 @@
title: Floodgate API
---
### Floodgate has an API to extend what is possible and allow servers to get information about the Bedrock client. It also allows other plugins access to [Cumulus](/floodgate/forms/)
### Floodgate has an API to extend what is possible and allow servers to get information about the Bedrock client. It also allows other plugins access to [Cumulus](/geyser/forms/)
This page will contain information about class FloodgateApi.<br>
See the sidebar for more information about other parts of the API.
### Accessing the Floodgate API
Floodgate uses the open collaboration repo. The following example is for Maven, but the same concept applies for Gradle etc.
```xml
<repository>
<id>opencollab-snapshot</id>
<url>https://repo.opencollab.dev/maven-snapshots/</url>
</repository>
<dependency>
<groupId>org.geysermc.floodgate</groupId>
<artifactId>api</artifactId>
<version>2.2.0-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
```
See [here](/geyser/getting-started-with-the-api) for how to include the Floodgate API in your project.
The Floodgate API has changed in Floodgate 2.0. The most important change is that the API methods are no longer static and instead instance-based, as shown below.
---
@@ -37,6 +23,10 @@ After you got the instance, you have access to all the methods.<br>
Use the documentation in the API module to see (and get info about) every single method available.
Most [API methods have a simple explanation](https://github.com/GeyserMC/Floodgate/tree/master/api/src/main/java/org/geysermc/floodgate/api).
<div class="alert alert-info" role="alert">
Note: To see full, detailed documentation, see the <a href="https://repo.opencollab.dev/javadoc/maven-snapshots/org/geysermc/floodgate/api/2.2.2-SNAPSHOT">javadocs</a>.
</div>
#### We'll highlight a few to get you started quickly:
`FloodgateApi#isFloodgatePlayer(UUID)`<br>
Used to check if the given UUID of an **online** player is a Bedrock player.
@@ -54,7 +44,7 @@ Click [here](/floodgate/linking/) to get more information about the PlayerLink c
`FloodgateApi#sendForm(UUID, Form(Builder))`<br>
Used to send a form to the Bedrock player with the given UUID.<br>
Click [here](/floodgate/forms/) to get more information about Forms.
Click [here](/geyser/forms/) to get more information about Forms.
### Using the API on backend servers
In order to successfully use the API on backend Spigot servers when using a proxy, `send-floodgate-data` must be set to `true` on the proxy Floodgate's config, and the `key.pem` file must be identical between all Floodgate instances.
-5
View File
@@ -12,11 +12,6 @@ You can also specify a UUID: `fwhitelist add 00000000-0000-0000-0009-01f64f65c7c
The permission node is `floodgate.command.fwhitelist`.
## What is the Global Api?
The Global Api is an API that is available for every server. It currently includes: [Global Linking](#what-is-global-linking), [skin uploading](#what-is-skin-uploading), getting a xuid by gamertag, and getting a gamertag by xuid.
We don't store anything else than you can access by the Global Api, except for some non-identifiable metrics. The source code of the Global Api is available [here](https://github.com/GeyserMC/global_api) and the source code of the Global Linking server is available [here](https://github.com/GeyserMC/GlobalLinkServer).
## What is skin uploading?
Skins of Bedrock player should be visible to Java players on servers with Floodgate 2.0 installed.
If they aren't, it's most likely that the skin uploading queue has grown too large and can take a while to upload your skin.
-146
View File
@@ -1,146 +0,0 @@
---
title: Forms and Cumulus
---
# What is Cumulus?
Bedrock Edition has a cool exclusive feature called Forms.<br>
Cumulus is the Forms API that we use in Geyser and Floodgate.<br>
The source code is available [here](https://github.com/GeyserMC/Cumulus). You can access the Cumulus API through the [Floodgate API](/floodgate/api/).
Bedrock knows three types of Forms:
* ModalForm
* SimpleForm
* CustomForm
We'll discuss them one by one starting with the easiest and ending with the least easy form type.<br>
After that, you get an overview of every single component.<br>
Then we'll talk about sending the form, receiving a response and doing advanced stuff.<br>
## ModalForm
While this is the easiest form type it's also the least customisable.<br>
You have a title, description (content) and two buttons.
![Example of a ModalForm](https://i.imgur.com/kMpMgOh.png)
Code used in the image:
```java
ModalForm.builder()
.title("Title")
.content("Content")
.button1("Button 1")
.button2("Button 2")
```
## SimpleForm
While this one is less easy then ModalForm is, it also has more customizability.<br>
It's still limited to title, content and buttons, but these buttons can also have images and do not have a minimum and maximum of two.
![Example of a SimpleForm](https://i.imgur.com/3rj2OQ2.png)
Code used in the image:
```java
SimpleForm.builder()
.title("Title")
.content("Content")
.button("Button without an image")
.button("Button with URL image", FormImage.Type.URL, "https://github.com/GeyserMC.png?size=200")
.button("Button with path image", FormImage.Type.PATH, "textures/i/glyph_world_template.png")
```
## CustomForm
While the CustomForm is the last one on our list (and thus the least easy one), it also has the greatest customizability.<br>
This form exists of a title, content and a list of different components e.g. label, slider and input.<br>
See [Components](#components) for more information about every component you can use and in which form type.
![Example of a CustomForm](https://i.imgur.com/zHgxELm.png)
Code used in the image:
```java
CustomForm.builder()
.title("Title")
.dropdown("Text", "Option 1", "Option 2")
.input("Input", "placeholder")
.toggle("Toggle")
.slider("Text", 0, 10, 1, 5)
```
## Sending a form
After you decided which form type you want to use and finished filling in the actual content, it's time to send the Form to the Bedrock player.<br>
You can do that by calling the API and send a form to the player's UUID and the form:
```java
FloodgateApi.getInstance().sendForm(uuid, form); // or #sendForm(uuid, formBuilder)
```
Or you can do it by using the Player's FloodgatePlayer instance:
```java
FloodgatePlayer player = FloodgateApi.getInstance().getPlayer(uuid);
player.sendForm(form); // or #sendForm(formBuilder)
```
So you can make and send forms in a pretty compact way by doing something like this:
```java
FloodgatePlayer player = FloodgateApi.getInstance().getPlayer(uuid);
...
player.sendForm(
CustomForm.builder()
.title("My cool title")
.label("10/10 content")
);
```
## Receiving a response from the client
It's nice and all that we can send forms to a client, but we also want to be able to get a response from a client and being able to handle them.<br>
We can do that using one (or multiple) result handers. The most used result handlers are: `validResultHandler(BiConsumer<Form, ValidFormResponseResult> | Consumer<ValidFormResponseResult>)`, `invalidResultHandler`, `closedResultHandler` and `closedOrInvalidResultHandler`.<br>
Here follows an example that uses result handlers:
```java
CustomForm.builder()
.title("geyser.auth.login.form.details.title")
.label("geyser.auth.login.form.details.desc")
.input("geyser.auth.login.form.details.email", "account@geysermc.org", "")
.input("geyser.auth.login.form.details.pass", "123456", "")
.closedOrInvalidResultHandler(() -> buildAndShowLoginDetailsWindow(session))
.validResultHandler(response -> session.authenticate(response.next(), response.next())));
```
## Advanced stuff
The FormBuilder also has support for translating the data used in the builder.<br>
To add a translator, you can use the `translator(BiFunction<String, String, String>)` or the `translator(BiFunction<String, String, String>, String)` method:
```java
ModalForm form = ModalForm.builder()
.translator(this::translate, userLanguage)
.title("Title")
.content("Content")
.button1("translate.button1")
.button2("translate.button2")
.build();
public String translate(String key, String locale) {
// this method will be called for every string, in this case, 4 times:
// Title, Content, translate.button1, translate.button2
// your own translate logic here
// return the value that replaces the key
}
```
Or you can have the translate method directly in the FormBuilder instead of a separate method:
```java
ModalForm form = ModalForm.builder()
.translator((key, unused) -> {
// this method will be called for every string, in this case, 4 times:
// Title, Content, translate.button1, translate.button2
// since this isn't a separate method, you don't need the locale argument, so it's unused.
// your own translate logic here
// return the value that replaces the key
})
.title("Title")
.content("Content")
.button1("translate.button1")
.button2("translate.button2")
.build();
```
+1 -1
View File
@@ -10,5 +10,5 @@ This is something you install in addition to Geyser. Unlike Geyser, Floodgate ca
## What has Floodgate 2.0 to offer?
Floodgate 2.0 is a rewrite of Floodgate 1.0, with various bugfixes and improvements. It also introduces new features: being able to [see Bedrock player skins on Java edition](/floodgate/features/#what-is-skin-uploading),
being able to [use Bedrock forms](/floodgate/forms/), link your account once and login on every server that has [Global Linking](/floodgate/features/#what-is-global-linking) enabled,
being able to [use Bedrock forms](/geyser/forms/), link your account once and login on every server that has [Global Linking](/floodgate/features/#what-is-global-linking) enabled,
and the [Global Api](/floodgate/features/#what-is-the-global-api).