Skip to content

Join message plugin

Anoop Singh edited this page Oct 31, 2025 · 1 revision

Join Message Plugin System

The BetterLib Join Message Plugin System allows any mod developer to easily add custom player join messages — links, colors, changelogs, or community invites — that display when a player joins a server.

Each mod can provide its own welcome messages without editing BetterLib.
Just implement an interface


Features

  • Per-mod join messages
  • Clickable URLs and colored text
  • Multiple message sets (e.g., welcome + changelog)
  • One-time display per player
  • Optional per-plugin enable/disable
  • Works with Forge / NeoForge / Fabric

⚙️ Library Setup (for BetterLib maintainers)

Main API Components

Class Description
JoinMessageSet Used to define a group of join messages (with colors, links, etc.).
JoinMessagePlugin The main interface mods implement to add messages.
JoinMessagePlugins Internal registry of all loaded plugins.
JoinMessageLib Event subscriber that displays messages when players join.

Basic Mod Integration

to register your mod’s messages:


Create a class implementing JoinMessagePlugin, then register it manually in your mod’s setup.

Example:

package com.reggarf.mods.demo;

import com.reggarf.mods.better_lib.Better_lib;
import com.reggarf.mods.better_lib.message.event.JoinMessageSet;
import com.reggarf.mods.better_lib.message.util.JoinMessagePlugin;
import com.reggarf.mods.better_lib.message.util.JoinMessagePlugins;

import java.util.List;

public class DemoPlugin implements JoinMessagePlugin {

    @Override
    public String getModId() {
        return Better_lib.MODID; // Your mod ID
    }

    @Override
    public boolean enabled() {
        return true; // Set false to disable messages
    }

    @Override
    public List<JoinMessageSet> getMessageSets() {
        return List.of(
            new JoinMessageSet()
                .addText("Welcome to Magic Crystals!", "FFD700")
                .addBlankLine()
                .addLink("Discord", "https://discord.gg/bettermods", "00AAFF", "(Community)")
                .addLink("GitHub", "https://github.com/reggarf/better_lib", "AAAAAA", "(Source / Issues)"),

            new JoinMessageSet()
                .addBlankLine()
                .addText("New 2.0 Update — New message Added!", "00FF66")
                .addLink("Read Changelog", "https://betterlib.com/changelog", "00FFFF", "")
        );
    }

    public static void register() {
        JoinMessagePlugins.register(new DemoPlugin());
    }
}

Then, in your mod’s main class

        DemoPlugin.register();

🧰 Example Output (in-game)

When a player joins for the first time:

Welcome to Demo!
- Discord (community)
- GitHub (source / issues)

New 2.0 Update — New Spells Added!
- Read Changelog

All messages are automatically formatted with colors and clickable links.


JoinMessageSet — Message Formatting API

JoinMessageSet lets you chain together messages, links, and formatting easily.

Method Description Example
addText(String text, String colorHex) Adds colored text .addText("Welcome!", "#FFD700")
addLink(String label, String url, String colorHex, String desc) Adds a clickable link .addLink("Discord", "https://discord.gg/abc", "#00AAFF", "(community)")
addBlankLine() Adds a new line .addBlankLine()
sendTo(ServerPlayer player) Sends all messages to a player (handled automatically)

Internal Behavior

  • Messages only show the first time a player joins a world.
  • The player’s join status is saved in persistent NBT using:
    joinmsglib_<modid>_hasJoinedBefore
    
  • If you want messages to show every time, simply remove that tag manually in your world data or config.

⚠️ Common Issues

Error Cause Fix
Messages not showing Plugin not registered Call .register() or ensure ServiceLoader file exists
No clickable links Chat settings disabled in client Enable “Chat: Shown” in Minecraft settings

Example: Multi-Mod Compatibility

If 5 mods implement JoinMessagePlugin, all will display their join messages independently.

  • BetterLib handles registration and display
  • Each mod has its own message list

🧾 License

The better is free for all mod developers to integrate into their mods.
Credit to BetterLib is appreciated but not required.

Clone this wiki locally