Skip to content

Commit

Permalink
Add Server API documentation (#17)
Browse files Browse the repository at this point in the history
* add structure of server api, write setup

* add instructions for input prompt, server switch prompt, permissions, labymod version, interaction menu, gamemode, emotes, discord rpc & server banner

* add instructions for economy display, introduce packet creating and protocol usage

* fix copyright

* move contributors to index

* add TabListFlags, Addon Recommendations & Marker

* add voicechat integration

* add integrations

* improve index

* move cache disclaimer to infobox

* improve wording

* dev.labymod.net
  • Loading branch information
jumpingpxl authored Jul 3, 2024
1 parent 14b8624 commit e1472f2
Show file tree
Hide file tree
Showing 35 changed files with 1,885 additions and 63 deletions.
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

This is the official wiki for the LabyMod 4 API.

At the moment, we've only got a wiki for the Addon API but there will be more to come.

Have you found something missing from this wiki that you think is important, or are you unhappy with something?
Please fork this repository, add/improve it and create a pull request.

The live build can be found <a href="https://wiki.labymod.net" target="_blank">here</a>.
The live build can be found <a href="https://dev.labymod.net" target="_blank">here</a>.
Binary file added docs/assets/files/serverapi/economy_display.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/files/serverapi/game-mode.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/files/serverapi/input-prompt.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/files/serverapi/interaction-menu.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/files/serverapi/tablist-banner.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
31 changes: 0 additions & 31 deletions docs/assets/theme/js/script.js

This file was deleted.

2 changes: 1 addition & 1 deletion docs/pages/addon/contributors.md → docs/contributors.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Due to the sheer complexity and scope of LabyMod 4 and its addon API, we cannot maintain this wiki alone. <br>
Due to the sheer complexity and scope of LabyMod 4 and its Addon & Server API, we cannot maintain this wiki alone. <br>
Therefore, we rely on the help of the community to keep this wiki complete and up to date.

If you want to help us, feel free to fork the repository of this wiki, make your desired changes and create a pull request <a href="https://github.com/LabyMod/labymod4-api-wiki" target="_blank">here</a>.
Expand Down
13 changes: 9 additions & 4 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
# LabyMod4 API Wiki
# LabyMod 4 Developer Portal

Click <a href="/pages/addon/">here</a> to get to the wiki of our new addon API.
Welcome to the Developer Portal of LabyMod 4. <br/>
This website serves as a hub for everything related to the LabyMod 4, directed at developers. Whether you're looking for
information on how to create addons or utilize our server API, you'll find it here.

Have you found something missing from this wiki that you think is important, or are you unhappy with something?
Please fork our wiki repository, add/improve it and create a pull request
<a href="https://github.com/LabyMod/labymod4-api-wiki" target="_blank">here</a>.
Please fork our wiki repository, add/improve it and create a pull request
<a href="https://github.com/LabyMod/labymod4-api-wiki" target="_blank">here</a>.

If you have any questions or need help, feel free to join
our [Discord server for Developers](https://discord.gg/labymod).
38 changes: 38 additions & 0 deletions docs/pages/server/addons/voicechat/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
The VoiceChat integration provides a way to manage the voice chat server-side.

## Adding the Dependency

The VoiceChat integration is shipped with all official [server platform integration artifacts](http://localhost:8080/pages/server/#adding-the-labymod-4-server-api-as-a-dependency). If you are using the `core` artifact, you can add the following dependency to your project:

???+ danger "Important Note"

For the examples below, `VERSION` with the version you want to use. The latest version can be found here: <a href="https://github.com/LabyMod/labymod4-server-api-integrations/releases" target="_blank" style="display: inline-flex;-ms-transform: translateY(25%);transform: translateY(25%);">![GitHub Release](https://img.shields.io/github/v/release/LabyMod/labymod4-server-api-integrations?label=%20)</a>

=== ":octicons-file-code-16: Gradle (Kotlin DSL)"

```kotlin
dependencies {
compileOnly("net.labymod.serverapi.integration:voicechat:VERSION")
}
```

=== ":octicons-file-code-16: Gradle (Groovy)"

```groovy
dependencies {
compileOnly "net.labymod.serverapi.integration:voicechat:VERSION"
}
```

=== ":octicons-file-code-16: Maven"

```xml
<dependencies>
<dependency>
<groupId>net.labymod.serverapi.integration</groupId>
<artifactId>voicechat</artifactId>
<version>VERSION</version>
</dependency>
</dependencies>
```

88 changes: 88 additions & 0 deletions docs/pages/server/addons/voicechat/mute.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
The `VoiceChatMutePacket` is a client-bound packet provided by the VoiceChat integration, that allows servers to mute any player in the voice chat on their server.

## Creating the Mute Model

The packet uses the `VoiceChatMute` model, which can be created with `VoiceChatMute.create`.

```java
// Create the mute model
// For a permanent mute, remove the timestamp parameter
VoiceChatMute voiceChatMute = VoiceChatMute.create(
uniqueId, // The UUID of the player to mute
"Example Mute Reason", // The reason for the mute. Can be null
System.currentTimeMillis() + 60000 // The timestamp until the mute expires.
);
```

## Sending the Packet

The packet can either be sent via the `VoiceChatPlayer` or the `AddonProtocol` of the `VoiceChatIntegration`

If you are using the `VoiceChatPlayer` to mute a player, the mute will automatically be sent to every LabyMod player on
the server. LabyMod players connecting to the server will also be sent every mute that is currently active automatically.

### Via VoiceChatPlayer (Recommended)

```java
// Get the LabyModPlayer
LabyModPlayer labyModPlayer = LabyModProtocolService.get().getPlayer(uniqueId);

// Get the VoiceChatPlayer
VoiceChatPlayer voiceChatPlayer = labyModPlayer.getIntegrationPlayer(VoiceChatPlayer.class);

// Mute the player
voiceChatPlayer.mute(voiceChatMute);
```

### Via the AddonProtocol

While not recommended, it is also possible to send the mutes directly via the `AddonProtocol` of the `VoiceChatIntegration`.

???+ danger "Important Note"

When sending mutes directly via the `AddonProtocol` of the `VoiceChatIntegration`, you will have to store all mutes yourself and send them to every player manually.

```java
// Create or get a List of mutes (array is also possible)
List<VoiceChatMute> mutes = new ArrayList<>();

// Add all mutes that you want to send to the player
mutes.add(voiceChatMute);

// Get the VoiceChatIntegration
// #getOrRegisterIntegration is a fail-safe method to get the integration, even
// if the integration has not been registered. Alternatively, you can use
// #getIntegration, which will return null if the integration has not been registered.
VoiceChatIntegration voiceChatIntegration = LabyModProtocolService.get().getOrRegisterIntegration(
VoiceChatIntegration.class,
VoiceChatIntegration::new
);

// Get the AddonProtocol
AddonProtocol addonProtocol = voiceChatIntegration.voiceChatProtocol();

// Send the packet
addonProtocol.sendPacket(uniqueId, new VoiceChatMutePacket(mutes));
```

### Via the LabyMod Player

While not recommended, it is also possible to send the packet directly via the `LabyModPlayer`. This will basically skip the "protocol-getting" process, as it will search for the protocol automatically.

???+ danger "Important Note"

When sending mutes directly via the `LabyModPlayer`, you will have to store all mutes yourself and send them to every player manually.

```java
// Create or get a List of mutes (array is also possible)
List<VoiceChatMute> mutes = new ArrayList<>();

// Add all mutes that you want to send to the player
mutes.add(voiceChatMute);

// Get the LabyModPlayer
LabyModPlayer labyModPlayer = LabyModProtocolService.get().getPlayer(uniqueId);

// Send the packet
labyModPlayer.sendPacket(new VoiceChatMutePacket(mutes));
```
49 changes: 49 additions & 0 deletions docs/pages/server/addons/voicechat/open-channels.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
The `VoiceChatOpenChannelsPacket` is a client-bound packet provided by the VoiceChat integration, that allows servers to open the voice channels popup.

## Sending the Packet

The packet can either be sent via the `VoiceChatPlayer` or the `AddonProtocol` of the `VoiceChatIntegration`

### Via VoiceChatPlayer

```java
// Get the LabyModPlayer
LabyModPlayer labyModPlayer = LabyModProtocolService.get().getPlayer(uniqueId);

// Get the VoiceChatPlayer
VoiceChatPlayer voiceChatPlayer = labyModPlayer.getIntegrationPlayer(VoiceChatPlayer.class);

// Mute the player
voiceChatPlayer.openVoiceChatChannels();
```

### Via the AddonProtocol

```java
// Get the VoiceChatIntegration
// #getOrRegisterIntegration is a fail-safe method to get the integration, even
// if the integration has not been registered. Alternatively, you can use
// #getIntegration, which will return null if the integration has not been registered.
VoiceChatIntegration voiceChatIntegration = LabyModProtocolService.get().getOrRegisterIntegration(
VoiceChatIntegration.class,
VoiceChatIntegration::new
);

// Get the AddonProtocol
AddonProtocol addonProtocol = voiceChatIntegration.voiceChatProtocol();

// Send the packet
addonProtocol.sendPacket(uniqueId, new VoiceChatOpenChannelsPacket());
```

### Via the LabyMod Player

While not recommended, it is also possible to send the packet directly via the `LabyModPlayer`. This will basically skip the "protocol-getting" process, as it will search for the protocol automatically. <br/>

```java
// Get the LabyModPlayer
LabyModPlayer labyModPlayer = LabyModProtocolService.get().getPlayer(uniqueId);

// Send the packet
labyModPlayer.sendPacket(new VoiceChatOpenChannelsPacket());
```
62 changes: 62 additions & 0 deletions docs/pages/server/addons/voicechat/unmute.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
The `VoiceChatUnmutePacket` is a client-bound packet provided by the VoiceChat integration, that allows servers to remove the server-bound mute from a player in the voice chat.

## Sending the Packet

The packet can either be sent via the `VoiceChatPlayer` or the `AddonProtocol` of the `VoiceChatIntegration`

If you are using the `VoiceChatPlayer` to unmute a player, the unmute will automatically be sent to every LabyMod player on
the server.

### Via VoiceChatPlayer (Recommended)

```java
// Get the LabyModPlayer
LabyModPlayer labyModPlayer = LabyModProtocolService.get().getPlayer(uniqueId);

// Get the VoiceChatPlayer
VoiceChatPlayer voiceChatPlayer = labyModPlayer.getIntegrationPlayer(VoiceChatPlayer.class);

// Mute the player
voiceChatPlayer.unmute();
```

### Via the AddonProtocol

While not recommended, it is also possible to send the unmutes directly via the `AddonProtocol` of the `VoiceChatIntegration`.

???+ danger "Important Note"

When sending (un)mutes directly via the `AddonProtocol` of the `VoiceChatIntegration`, you will have to store all mutes yourself and send them to every player manually.

```java
// Get the VoiceChatIntegration
// #getOrRegisterIntegration is a fail-safe method to get the integration, even
// if the integration has not been registered. Alternatively, you can use
// #getIntegration, which will return null if the integration has not been registered.
VoiceChatIntegration voiceChatIntegration = LabyModProtocolService.get().getOrRegisterIntegration(
VoiceChatIntegration.class,
VoiceChatIntegration::new
);

// Get the AddonProtocol
AddonProtocol addonProtocol = voiceChatIntegration.voiceChatProtocol();

// Send the packet
addonProtocol.sendPacket(uniqueId, new VoiceChatUnmutePacket(uniqueId));
```

### Via the LabyMod Player

While not recommended, it is also possible to send the packet directly via the `LabyModPlayer`. This will basically skip the "protocol-getting" process, as it will search for the protocol automatically.

???+ danger "Important Note"

When sending (un)mutes directly via the `LabyModPlayer`, you will have to store all mutes yourself and send them to every player manually.

```java
// Get the LabyModPlayer
LabyModPlayer labyModPlayer = LabyModProtocolService.get().getPlayer(uniqueId);

// Send the packet
labyModPlayer.sendPacket(new VoiceChatUnmutePacket(uniqueId));
```
Loading

0 comments on commit e1472f2

Please sign in to comment.