Skip to content

Commit 355edf0

Browse files
authored
Merge pull request #242 from Zoltus/feature/tinymessage-documentation
GH-241 add guide for 3rd party coloring api tinymessage
2 parents 5603ee0 + 10745d6 commit 355edf0

2 files changed

Lines changed: 140 additions & 1 deletion

File tree

content/docs/en/guides/plugin/chat-formatting.mdx

Lines changed: 140 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: "Formatting the chat"
3-
description: "Learn how to format the chat using the PlayerChatEvent"
3+
description: "Learn how to format the chat using the PlayerChatEvent and rich text with TinyMessage"
44
authors:
55
- name: "oskarscot"
66
link: "https://oskar.scot"
@@ -11,6 +11,8 @@ authors:
1111
The chat uses the PlayerChatEvent, it contains the formatter, the PlayerRef for the sender, the content as well as a list of targets (it's safe to assume the targets is the list of players who can see the chat message)
1212
You can cancel this event as well as modify the content and the formatter.
1313

14+
## Manual Formatting (Standard Approach)
15+
1416
```java
1517
public class ChatFormatter {
1618

@@ -45,3 +47,140 @@ The formatter is the following interface:
4547
}
4648
}
4749
```
50+
51+
---
52+
53+
## TinyMessage - Rich Text Formatting (Easy Alternative)
54+
55+
![chat format example](/assets/guides/chat-tinymessage-example.png)
56+
57+
**TinyMessage** is a lightweight, powerful rich text parser for Hytale servers that allows you to use simple tags to create gradients, hex colors, clickable links, and nested styles in chat messages. Similar to minecraft MiniMessage
58+
59+
### Features
60+
* **Gradients:** `<gradient:red:blue>Hello</gradient>` or multi-color `<gradient:gold:red:black>...`
61+
* **Hex Colors:** `<color:#FF55FF>Custom Colors</color>` or `<color:red>Named Colors</color>`
62+
* **Standard Styles:** `<b>Bold</b>`, `<i>Italic</i>`, `<u>Underline</u>`, `<mono>Monospace</mono>`
63+
* **Clickable Links:** `<link:https://google.com>Click me!</link>`
64+
* **Nested Styling:** Tags can be nested indefinitely
65+
66+
### Usage Examples
67+
68+
```java
69+
import fi.sulku.hytale.TinyMsg;
70+
import com.hypixel.hytale.server.core.Message;
71+
72+
// Parse a formatted string into a Message
73+
Message message = TinyMsg.parse("<gradient:red:blue>Hello World!</gradient>");
74+
player.sendMessage(message);
75+
76+
// Multiple styles
77+
TinyMsg.parse("<b><color:gold>Bold Gold Text</color></b>");
78+
79+
// Clickable gradient link
80+
TinyMsg.parse("<link:https://example.com><gradient:aqua:blue>Click me!</gradient></link>");
81+
82+
// Complex nested styling
83+
TinyMsg.parse("<b>Bold <i>and italic <color:red>and red</color></i></b>");
84+
85+
// Reset styles mid-text
86+
TinyMsg.parse("<b>Bold <reset>normal text");
87+
```
88+
89+
```java
90+
public class ChatFormatter {
91+
92+
private void onPlayerChat(PlayerChatEvent event) {
93+
PlayerRef sender = event.getSender();
94+
if (event.getContent().equalsIgnoreCase("poo")) {
95+
event.setCancelled(true);
96+
sender.sendMessage(TinyMsg.parse("<red>Hey, you cannot say that!</red>"));
97+
}
98+
99+
if (event.getContent().equalsIgnoreCase("you stink")) {
100+
event.setContent("i stink");
101+
}
102+
103+
event.setFormatter((playerRed, message) ->
104+
TinyMsg.parse("<red>[COOL] </red><yellow>" + sender.getUsername() + "</yellow><pink> : " + message + "</pink>"));
105+
}
106+
}
107+
```
108+
### Installation
109+
110+
Links:
111+
<a href="https://github.com/Zoltus/TinyMessage/" target="_blank" rel="noopener noreferrer">
112+
Github Repository
113+
</a>
114+
<a href="https://github.com/Zoltus/TinyMessage/releases" target="_blank" rel="noopener noreferrer">
115+
Github Releases
116+
</a>
117+
Curseforge (coming soon)
118+
119+
## Installation for server owners:
120+
121+
### Download the TinyMessage.jar
122+
Download the latest TinyMessage.jar from the releases page and place it in your server's `mods` folder.
123+
124+
## Installation for developers:
125+
126+
Temporary until hytale plugin repository is available.
127+
Create libs folder in your plugin directory and place the TinyMsg jar file there.
128+
project/libs/TinyMessage-2.0.0-SNAPSHOT.jar
129+
130+
### manifest.json
131+
```json
132+
"Dependencies": {
133+
"Zoltus:TinyMessage": "*"
134+
},
135+
```
136+
137+
### For Gradle
138+
```kotlin
139+
dependencies {
140+
compileOnly(files("libs/tinymessage-2.0.0-SNAPSHOT.jar"))
141+
}
142+
```
143+
144+
### For Maven
145+
```xml
146+
<dependency>
147+
<groupId>fi.sulku.hytale</groupId>
148+
<artifactId>tinymessage</artifactId>
149+
<version>2.0.0</version>
150+
<scope>provided</scope>
151+
<systemPath>${project.basedir}/libs/tinymessage-2.0.0-SNAPSHOT.jar</systemPath>
152+
</dependency>
153+
```
154+
155+
---
156+
157+
### API Reference
158+
159+
#### `TinyMsg.parse(String text)`
160+
Parses a string with TinyMsg tags and returns a `Message` object.
161+
162+
**Parameters:**
163+
- `text` - The string to parse
164+
165+
**Returns:**
166+
- `Message` - A Hytale `Message` object ready to be sent to players
167+
168+
### Supported Tags
169+
170+
| Tag | Aliases | Example | Description |
171+
|-----|---------|---------|-------------|
172+
| `<color:X>` | `<c:X>`, `<colour:X>` | `<color:red>text</color>` | Sets text color (named or hex) |
173+
| `<gradient:X:Y:Z>` | `<grnt:X:Y:Z>` | `<gradient:red:blue>text</gradient>` | Creates a color gradient |
174+
| `<bold>` | `<b>` | `<b>text</b>` | Makes text bold |
175+
| `<italic>` | `<i>`, `<em>` | `<i>text</i>` | Makes text italic |
176+
| `<underline>` | `<u>` | `<u>text</u>` | Underlines text |
177+
| `<monospace>` | `<mono>` | `<mono>text</mono>` | Uses monospace font |
178+
| `<link:URL>` | `<url:link>` | `<link:https://google.com>click</link>` | Creates clickable link |
179+
| `<reset>` | `<r>` | `<b>bold<reset>normal` | Resets all formatting |
180+
181+
### Named Colors
182+
`black`, `dark_blue`, `dark_green`, `dark_aqua`, `dark_red`, `dark_purple`, `gold`, `gray`, `dark_gray`, `blue`, `green`, `aqua`, `red`, `light_purple`, `yellow`, `white`
183+
184+
### License
185+
TinyMsg is available under the MIT License - feel free to use in your projects!
186+
28.8 KB
Loading

0 commit comments

Comments
 (0)