francikblancik

make a plugin that when someone joins or leaves types a configurable custom message in chat depending on their rank from luckperms

Kodari AI
KodariJan 29 at 4:26 pm 4,523 (v2)

I’ll create a plugin that displays custom join/leave messages based on LuckPerms ranks.

RankedMessages
A lightweight plugin that displays customizable join and leave messages based on player ranks from LuckPerms. Server owners can define unique messages for each rank with color codes and placeholders. Messages are globally broadcast to all online players when someone joins or leaves. Supports unlimited ranks and includes a default message fallback for players without a specific rank configuration.

Plugin created! Here’s what I’ve built:

Features:

  • Custom join/leave messages based on LuckPerms primary group

  • Configurable messages for each rank in config.yml

  • Multiple messages per rank (randomly selected)

  • {player} placeholder for player name

  • Color codes using & symbol

  • Hides vanilla join/leave messages (optional)

  • /rankedmessages reload command to reload config

Configuration: The config.yml includes example ranks (owner, admin, moderator, vip, default). Server owners can add/remove ranks as needed. Each rank can have multiple message variants - the plugin will randomly choose one.

How it works:

  1. Player joins/leaves server

  2. Plugin fetches their primary group from LuckPerms

  3. Looks up the message for that group in config

  4. Replaces {player} with their name

  5. Broadcasts the colored message to all players

Simply add more ranks to the config following the same format!

francikblancik

add in game commands to confiugure it from there

Kodari AI
KodariJan 29 at 4:29 pm 6,698 (v2)

I’ll add in-game commands to configure the plugin. Let me first read the existing files to understand the current structure.

I’ll create a comprehensive command system to configure the plugin in-game.

francikblancik

make commanmd that actually work

Kodari AI
KodariJan 29 at 4:42 pm 6,114 (v2)

I’ll read the existing files to see what’s wrong with the current command implementation.

I found the issue! The RankedMessagesCommand class exists with all the features but it’s never registered. The main class uses a simple lambda that only handles reload. I’ll fix this by properly registering the command handler.

Fixed! The command now properly registers the full RankedMessagesCommand with all subcommands (addjoin, addleave, removejoin, removeleave, listjoin, listleave, clearjoin, clearleave, toggle, list, reload) and tab completion support.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
Code
6 471
src/main/java/com/rankedmessages/RankedMessages.java
package com.rankedmessages;

import com.rankedmessages.command.RankedMessagesCommand;
import com.rankedmessages.listener.JoinQuitListener;
import lombok.Getter;
import net.luckperms.api.LuckPerms;
import org.bukkit.command.PluginCommand;
import org.bukkit.plugin.RegisteredServiceProvider;
import org.bukkit.plugin.java.JavaPlugin;

@Getter
public class RankedMessages extends JavaPlugin {

    private LuckPerms luckPerms;

    @Override
    public void onEnable() {
        saveDefaultConfig();

        if (!setupLuckPerms()) {
            getLogger().severe("Nie znaleziono LuckPerms! Wylacznie pluginu...");
            getServer().getPluginManager().disablePlugin(this);
            return;
        }

        getServer().getPluginManager().registerEvents(new JoinQuitListener(this), this);

        RankedMessagesCommand commandHandler = new RankedMessagesCommand(this);
        PluginCommand command = getCommand("rankedmessages");
        command.setExecutor(commandHandler);
        command.setTabCompleter(commandHandler);

        getLogger().info("RankedMessages zostalo wylaczone!");
    }

    @Override
    public void onDisable() {
        getLogger().info("RankedMessages zostalo wylaczone!");
    }

    private boolean setupLuckPerms() {
        RegisteredServiceProvider<LuckPerms> provider = getServer().getServicesManager().getRegistration(LuckPerms.class);
        if (provider != null) {
            luckPerms = provider.getProvider();
            return true;
        }
        return false;
    }
}