Skip to content

Commit 685b795

Browse files
authored
Merge pull request #32 from EinsJustinn/master
Add User Badge and User Indicator Server API pages
2 parents 1f83eb6 + 8c0eb02 commit 685b795

File tree

5 files changed

+123
-0
lines changed

5 files changed

+123
-0
lines changed
219 KB
Loading
87.8 KB
Loading
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
The `UpdateLabyModUserIndicatorVisibilityPacket` is a client-bound packet that allows servers to hide the indicator of a player.
2+
3+
## Sending the Packet
4+
5+
The packet can either be sent via the `LabyModPlayer` object of the player, or directly via the `LabyModProtocol`.
6+
7+
### Via the LabyModPlayer (Recommended)
8+
9+
```java
10+
// Get the LabyModPlayer
11+
LabyModPlayer player = LabyModProtocolService.get().getPlayer(uniqueId);
12+
13+
// Update the Indicator Visibility
14+
player.updateLabyModUserIndicatorVisibility(false);
15+
```
16+
17+
### Via the LabyModProtocol
18+
19+
```java
20+
// Get the LabyModProtocol
21+
LabyModProtocol labyModProtocol = LabyModProtocolService.get().labyModProtocol();
22+
23+
// Send the packet
24+
labyModProtocol.sendPacket(uniqueId, new UpdateLabyModUserIndicatorVisibilityPacket(false));
25+
```
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
The `ServerBadgePacket` is a client-bound packet that allows servers to display a badge in the tab list next to the player's name and in the nametag.
2+
3+
![Tablist Badge](../../../../assets/files/serverapi/user-badge-tablist.png)
4+
![Tablist Nametag](../../../../assets/files/serverapi/user-badge-nametag.png)
5+
6+
## Set the Badge Infos
7+
8+
???+ danger "Important Note"
9+
10+
You must first send the Badge Infos before the badges can be displayed next to the players.
11+
12+
The packet can either be sent via the `LabyModPlayer` object of the player, or directly via the `LabyModProtocol`.
13+
14+
You can send one or more server badge info to the player.
15+
16+
### Via the LabyModPlayer (Recommended)
17+
18+
```java
19+
// Get the LabyModPlayer
20+
LabyModPlayer player = LabyModProtocolService.get().getPlayer(uniqueId);
21+
22+
// Create a new ServerBadge
23+
ServerBadge owner = ServerBadge.create(
24+
1, // The ID of the badge
25+
new Color(255, 0, 0), // The color of the badge
26+
"https://example.com/image_owner.png" // The URL of the badge image
27+
);
28+
ServerBadge developer = ServerBadge.create(
29+
2, // The ID of the badge
30+
new Color(0, 0, 255), // The color of the badge
31+
"https://example.com/image_developer.png" // The URL of the badge image
32+
);
33+
34+
// Register the badges
35+
player.registerBadges(List.of(owner, developer));
36+
```
37+
38+
### Via the LabyModProtocol
39+
40+
```java
41+
// Get the LabyModProtocol
42+
LabyModProtocol labyModProtocol = LabyModProtocolService.get().labyModProtocol();
43+
44+
// Create a new ServerBadge
45+
ServerBadge owner = ServerBadge.create(
46+
1, // The ID of the badge
47+
new Color(255, 0, 0), // The color of the badge
48+
"https://example.com/image_owner.png" // The URL of the badge image
49+
);
50+
ServerBadge developer = ServerBadge.create(
51+
2, // The ID of the badge
52+
new Color(0, 0, 255), // The color of the badge
53+
"https://example.com/image_developer.png" // The URL of the badge image
54+
);
55+
56+
// Send the packet
57+
labyModProtocol.sendPacket(uniqueId, new ServerBadgePacket(owner, developer));
58+
```
59+
60+
## Set the badges for the players.
61+
62+
The packet can either be sent via the `LabyModPlayer` object of the player, or directly via the `LabyModProtocol`.
63+
64+
### Via the LabyModPlayer (Recommended)
65+
66+
```java
67+
// Get the LabyModPlayer
68+
LabyModPlayer player = LabyModProtocolService.get().getPlayer(uniqueId);
69+
70+
// Create a new ServerUserBadge
71+
ServerUserBadge serverUserBadge = ServerUserBadge.create(
72+
uniqueId, // The UUID of the user who has the badge
73+
1 // The ID of the badge
74+
);
75+
76+
// Bind the badges
77+
player.bindBadges(List.of(serverUserBadge));
78+
```
79+
80+
### Via the LabyModProtocol
81+
82+
Now you can assign the badge to a player, which will then be displayed.
83+
84+
```java
85+
// Get the LabyModProtocol
86+
LabyModProtocol labyModProtocol = LabyModProtocolService.get().labyModProtocol();
87+
88+
// Create a new ServerUserBadge
89+
ServerUserBadge serverUserBadge = ServerUserBadge.create(
90+
uniqueId, // The UUID of the user who has the badge
91+
1 // The ID of the badge
92+
);
93+
94+
// Send the packets
95+
labyModProtocol.sendPacket(uniqueId, new ServerUserBadgePacket(serverUserBadge));
96+
```

mkdocs.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ nav:
3030
- Gamemode: pages/server/labymod/features/gamemode.md
3131
- Interaction Menu: pages/server/labymod/features/interaction-menu.md
3232
- Markers: pages/server/labymod/features/markers.md
33+
- User Badge: pages/server/labymod/features/user-badge.md
34+
- Indicator Visibility: pages/server/labymod/features/indicator-visibility.md
3335
- Moderation:
3436
- Addon Recommendations: pages/server/labymod/moderation/addon-recommendation.md
3537
- Get Installed Addons: pages/server/labymod/moderation/installed-addons.md

0 commit comments

Comments
 (0)