From d0c55b9112aa2894e867447e4b375fde09ca04b4 Mon Sep 17 00:00:00 2001
From: AlexDev_ <56083016+alexdev03@users.noreply.github.com>
Date: Thu, 19 Oct 2023 16:07:50 +0200
Subject: [PATCH] docs: New API documentation corrections (#107)
* Updated docs
* Improved grammar
* Added more information about vanishing a player.
---
docs/API-Examples.md | 21 ++++++++++++---------
1 file changed, 12 insertions(+), 9 deletions(-)
diff --git a/docs/API-Examples.md b/docs/API-Examples.md
index b252b31..961d279 100644
--- a/docs/API-Examples.md
+++ b/docs/API-Examples.md
@@ -1,25 +1,27 @@
Velocitab provides an API for vanishing (hiding) and modifying the names of players as they appear in the TAB list for other players.
-This page assumes you have read the general [[API]] introduction and that you have both imported Velocitab into your project and added it as a dependency.
+This page assumes you have read the general [[API]] introduction and that you have both imported Velocitab into your project, added it as a dependency and having an instance of `VelocitabAPI` available. For the following examples, an instance called `velocitabAPI` was used.
## 1. Vanishing/Un-vanishing a player
### 1.1 Vanishing a player
Use `VelocitabAPI#vanishPlayer` to vanish a player. This method takes a Velocity `Player` as a parameter.
-This will hide a user from all TAB lists (they will not be shown). Note this will not remove them at a packet level; Vanish plugins should use this API feature as a utility that forms part of their Vanish implementation.
+This will hide a user from all TAB lists (they will not be shown). Note this will remove them at a packet level; Vanish plugins should use this API feature as a utility that forms part of their Vanish implementation.
+Be sure to not remove the entry from TabList with Velocity API or direct packet as the packet would be sent twice and could cause a client-side bug.
+This won't send an EntityRemovePacket so your vanish plugin should send it. On a backend server you can just use Player#hidePlayer and Player#showPlayer.
Example — Vanishing a player
```java
// Vanishing a proxy Player
-VelocitabAPI.vanishPlayer(player);
+velocitabAPI.vanishPlayer(player);
```
### 1.2 Un-vanishing a player
-Use `VelocitabAPI#unvanishPlayer` to un-vanish a player. This method takes a Velocity `Player` as a parameter.
+Use `VelocitabAPI#unVanishPlayer` to un-vanish a player. This method takes a Velocity `Player` as a parameter.
This will allow the user to be shown in all TAB lists again.
@@ -28,7 +30,7 @@ This will allow the user to be shown in all TAB lists again.
```java
// Un-vanishing a proxy Player
-VelocitabAPI.unvanishPlayer(player);
+velocitabAPI.unVanishPlayer(player);
```
@@ -36,24 +38,25 @@ VelocitabAPI.unvanishPlayer(player);
You can provide a Vanish integration to provide a managed class to Vanish/Unvanish a player through the `VelocitabAPI#setVanishIntegration` instance.
## 2. Modifying a player's name
-You can set a custom name for a player that will be displayed in `%name%` placeholders in the TAB list. This can be used to display a player's nickname, for example. This is done through `VelocitabAPI#setCustomPlayerName()`, which accepts a Velocity `Player` and a `String` custom name
+You can set a custom name for a player that will be displayed in `%name%` placeholders in the TAB list. This can be used to display a player's nickname, for example. This is done through `VelocitabAPI#setCustomPlayerName`, which accepts a Velocity `Player` and a `String` custom name.
+This won't change the player's name in nametags and name list when you press T (key to open chat) and then press tab.
Example — Setting a custom name for a player
```java
// Setting a custom name for a proxy Player
-VelocitabAPI.setCustomPlayerName(player, "CustomName");
+velocitabAPI.setCustomPlayerName(player, "CustomName");
```
-You can also use `VelocitabAPI#getCustomPlayerName(Player)` to get a player's custom name, wrapped in an `Optional` that will return with the String of the player's custom name if one has been set (otherwise `Optional#empty`)
+You can also use `VelocitabAPI#getCustomPlayerName` which accepts a Velocity `Player`, to get player's custom name, wrapped in an `Optional` that will return the String of the player's custom name if one has been set (otherwise `Optional#empty`)
Example — Getting a player's custom name
```java
// Getting a player's custom name
-Optional customName = VelocitabAPI.getCustomPlayerName(player);
+Optional customName = velocitabAPI.getCustomPlayerName(player);
```
\ No newline at end of file