-
Notifications
You must be signed in to change notification settings - Fork 0
Online Messages System
Introduced in Better Lib v1.0.102+
The Online Messages System allows mod developers to display dynamic messages and clickable links to players when they join a world or server. Messages are fetched from a remote text file (e.g., GitHub, Pastebin, or your website) and can be updated anytime without requiring users to download a new mod version.
This system can also be used to push update notifications, letting players know when a new mod version or important announcement is available instantly, and without any manual updates.
| Feature | Description |
|---|---|
| Multi-line text | Display multiple lines of messages with custom colors |
| Clickable links | Add clickable links with custom labels and colors |
| Auto-refresh | Players only see new messages when content changes |
| Refetchable | Mods can manually refresh messages in-game |
| Color support | Supports #RRGGBB hex colors for each line or link |
| Modular | Works per mod — each mod registers its own message set |
| Built into Better Lib | No extra setup needed beyond registration |
Each participating mod must define two remote text files (they can be hosted anywhere publicly):
| File | Purpose |
|---|---|
message.txt |
Contains multi-line plain text messages. |
links.txt |
Contains clickable link entries (label + URL + color + optional description). |
Welcome to Create: Better lib!
Thank you for supporting the project ❤️
Follow us for updates and sneak peeks!
# Lines starting with '#' are ignored
CurseForge|https://curseforge.com/minecraft/mc-mods/create-better-villager|#00AAFF|View mod page
Modrinth|https://modrinth.com/mod/create-better-villager|#00FF88|Download now
Discord|https://discord.gg/example|#7289DA|Join our community
Patreon|https://patreon.com/example|#FFD700|Support development
Format (per line):
Label|URL|ColorHex|Description
- Label → Text shown to the player
- URL → Clickable destination
-
ColorHex → Optional color in
#RRGGBB - Description → Optional text shown after the link
Each mod must implement this interface to define message sources.
package com.example.mycoolmod;
import com.reggarf.mods.better_lib.message.api.OnlineMessagePlugin;
public class MyModOnlineMessages implements OnlineMessagePlugin {
@Override
public String getModId() {
return "mycoolmod";
}
@Override
public String getMessageUrl() {
return "https://raw.githubusercontent.com/Reggarfgod/World_First_Join_Message/refs/heads/CC/1.21.1/forge/messages.txt";
}
@Override
public String getClickableUrl() {
return "https://raw.githubusercontent.com/Reggarfgod/World_First_Join_Message/refs/heads/CC/1.21.1/forge/FETCH_URL.txt";
}
@Override
public boolean isOnlineMessageEnabled() {
return true; // Can be toggled via config
}
}Register your plugin in your mod.
OnlineMessageLib.registerPlugin(new MyModOnlinePlugin());| Step | Description |
|---|---|
| 🪶 Initialization | Your mod registers an OnlineMessagePlugin during setup. |
| 🌐 Fetch | Better Lib downloads both message.txt and links.txt. |
| 💾 Cache | Data is cached in memory and saved to player NBT to prevent spam. |
| 👋 Join Event | On player join, the system checks if message hash changed. |
| 💬 Display | Messages and links are shown once when new or updated. |
You can use hex color codes for text and links:
-
#FF0000→ Red -
#00FF00→ Green -
#00AAFF→ Cyan -
#FFD700→ Gold
If omitted, defaults to white (#FFFFFF for text, #00FF00 for links).
In future versions, you’ll be able to define hover tooltips in the links.txt format, e.g.:
Label|URL|ColorHex|Description|Hover:Click to open this link
Better Lib will automatically show “Click to open this link” when hovering over the label.
Welcome to Create: Better Villager!
Thank you for supporting the project ❤️
- CurseForge [Clickable in blue]
- Modrinth [Clickable in green]
- Discord [Clickable in purple]
Each link opens in the player’s web browser.
- The system only fetches text; no JSON or HTML parsing is required.
- Player data is stored in persistent NBT (
lastSeenMessage_modid). - Supports Forge and NeoForge 1.20+.
- HTTP errors are safely logged but won’t crash the game.
- Remote text files can be hosted on GitHub, Pastebin (raw), or any static file host.
| Hosting | Example Raw URL |
|---|---|
| GitHub | https://raw.githubusercontent.com/YourName/messages/main/message.txt |
| Pastebin | https://pastebin.com/raw/abc123 |
| GitLab | https://gitlab.com/YourName/messages/-/raw/main/message.txt |
| Class | Purpose |
|---|---|
WFJMOnlineMessageHandler |
Core handler for message registration and display. |
WFJMOnlineMessageFetcher |
Fetches text from remote URLs. |
OnlineMessageSet |
Holds messages and clickable components. |
OnlineMessagePlugin |
Interface implemented by mods to define sources. |
- Create: Better Villager → [CurseForge Page](https://www.curseforge.com/minecraft/mc-mods/create-better-villager)
- Underground Villages, Stoneholm → [Modrinth Page](https://modrinth.com/mod/underground-villages-stoneholm)
| Action | Method |
|---|---|
| Register plugin | WFJMOnlineMessageHandler.initializeFor(modId, plugin) |
| Refetch messages | WFJMOnlineMessageHandler.refreshMessages(modId, plugin) |
| Add message line | OnlineMessageSet.addText(text, colorHex) |
| Add clickable link | OnlineMessageSet.addLink(label, url, colorHex, description) |
| Send to player | set.sendTo(player) |