nacho_ninja1
📎 1 file 4,167 chars
📄
pasted-code-1791716611305.txt
txt 111 lines
▶
# WAFFLE MSG — PREMIUM PRIVATE MESSAGING PLUGIN

Build a fully working, production-ready Minecraft plugin called **WaffleMsg** for WAFFLE SMP.

## Technical requirements
- Paper 1.21.11
- Java 21
- Maven
- Modern Paper APIs; avoid deprecated APIs.
- No Vault dependency.
- Deliver the complete Maven source project AND a compiled `WaffleMsg-1.21.11.jar`.
- Must compile successfully with `mvn clean package`.

## 1. Premium private message design

Make `/msg` look like a professionally designed Minecraft network feature.

**Sender format:**

`[✉] YOU  ➜  PlayerName`

`    Your message appears here.`

**Receiver format:**

`[✉] PlayerName  ➜  YOU`

`    Your message appears here.`

Use MiniMessage gradients and elegant symbols, with a polished WAFFLE theme:
- Rich toasted gold: `#D89B45`
- Bright amber: `#F2C46D`
- Warm cream: `#FFF1C7`
- Soft white: `#FFFFFF`
- Dark gold accents where appropriate.

Style the message header separately from the actual message. Keep the message text readable and avoid huge, spammy banners.

## 2. Commands — ONLY these commands

- `/msg  ` — send a private message.
- `/msg toggle` — enable or disable incoming private messages.

Do NOT register aliases such as `/tell`, `/w`, `/whisper`, `/reply`, `/r`, `/ignore`, `/spy`, `/socialspy`, `/message`, or any extra commands.

## 3. Make the experience feel premium

- Use clean MiniMessage formatting and a consistent WAFFLE identity.
- Highlight sender and receiver names elegantly.
- Add hover text to player names, such as `Private message with PlayerName`.
- Add clickable player names where useful, without requiring extra commands.
- Use subtle separators and spacing, but don't spam the chat.
- Show attractive, configurable feedback when `/msg toggle` is used.
- Use sound feedback when receiving a private message, configurable in `config.yml`.
- Allow players to disable incoming messages without leaving the server.
- Never broadcast private messages to other players.

## 4. Smart functionality

- Correctly parse `/msg toggle` instead of treating `toggle` as a player name.
- Support messages containing spaces and normal Unicode characters.
- Prevent sending messages to yourself.
- Handle offline players and players who disabled incoming messages.
- Check permissions before executing commands.
- Persist toggle preferences across reconnects and server restarts.
- Do not let user-supplied formatting codes spoof the WAFFLE prefix or change other players' messages.
- Avoid errors when players disconnect while a message is being sent.

## 5. Configuration

Create a complete, well-commented `config.yml` that lets me customize:
- All message formats and MiniMessage colors
- Prefix, symbols, and separators
- Toggle enabled/disabled messages
- Error messages
- Receive-message sound and volume
- Permissions
- Persistence settings

I must be able to change the appearance without recompiling the plugin.

## 6. Permissions

- `wafflemsg.use` — use `/msg`.
- `wafflemsg.toggle` — use `/msg toggle`.
- `wafflemsg.admin` — administrative permission if genuinely needed.

Use sensible defaults and document them.

## 7. Compatibility

- Paper 1.21.11, Java 21.
- Correct `plugin.yml` command registration.
- Detect and explain conflicts if EssentialsX or another plugin already owns `/msg`.
- Do not silently claim success when another plugin intercepts the command.
- No unnecessary dependencies or expensive repeating tasks.

## 8. Deliverables and testing

Provide:
- Complete Java source files.
- `pom.xml`.
- `plugin.yml`.
- Default `config.yml`.
- Persistent storage implementation.
- README with installation, permissions, configuration, and build instructions.
- A compiled, ready-to-install `WaffleMsg-1.21.11.jar`.

Test with two players to confirm private delivery, message formatting, toggle behavior, reconnect persistence, permissions, offline players, and command conflicts.

Do not provide pseudocode, incomplete classes, or a fake JAR. Ensure the source builds and the plugin's actual behavior matches the documentation.
Kodari AI
KodariOct 11 at 11:08 am 1
WaffleMsg
A premium private messaging plugin for Paper 1.21.11 servers. Features elegant MiniMessage formatting with a WAFFLE gold theme, gradient headers, hoverable and clickable player names, and configurable sound notifications. Includes /msg and /msg toggle commands with permission checks, persistent toggle preferences across reconnects, and comprehensive config.yml customization. Handles offline players, self-messaging prevention, and command conflicts gracefully. Built with Java 21 and Maven, using modern Paper APIs without deprecated methods or unnecessary dependencies.
  1. Create the Paper 1.21.11 / Java 21 Maven project and plugin resources.

  2. Implement /msg and /msg toggle with safe MiniMessage formatting, permissions, configurable feedback, and receive sound.

  3. Persist toggle preferences and report declared /msg command conflicts; include installation and configuration documentation.

Created the WaffleMsg Maven source project with /msg and /msg toggle, configurable MiniMessage styling and sound, persistent toggle preferences, permission checks, and startup warnings for declared /msg conflicts. I haven’t run a live two-player server test, so I can’t claim that test passed.

To get the requested JAR, compile the project in Kodari: on desktop click Compile in the top bar (on phone, tap ⋮ → Compile Project), then click Compile in the window. When it succeeds, download the build there or use the Download WaffleMsg-1.21.11.jar button in chat. If the build fails, use Auto-fix in the chat or Fix in the build window.

nacho_ninja1

fix

Kodari AI
KodariOct 11 at 11:14 am 1

I need the build error to make a targeted fix. Paste the Maven output starting at the first [ERROR] (or the Auto-fix diagnostic); the project files alone don’t show what failed.

Kodari can make mistakes. Review important code before using.
Files
src
pom.xml
README.md
Code
5 392
src/main/java/com/wafflesmp/wafflemsg/WaffleMsgPlugin.java
package com.wafflesmp.wafflemsg;

import java.io.File;
import java.io.IOException;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.UUID;
import java.util.stream.Collectors;

import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.event.ClickEvent;
import net.kyori.adventure.text.event.HoverEvent;
import net.kyori.adventure.text.minimessage.MiniMessage;
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.PluginCommand;
import org.bukkit.command.TabExecutor;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.configuration.file.YamlConfiguration;

public final class WaffleMsgPlugin extends JavaPlugin implements TabExecutor {
    private static final MiniMessage MINI_MESSAGE = MiniMessage.miniMessage();

    private final Map<UUID, Boolean> incomingEnabled = new HashMap<>();
    private File preferencesFile;

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

        PluginCommand msgCommand = getCommand("msg");
        if (msgCommand == null) {
            getLogger().severe("The /msg command is missing from plugin.yml; disabling WaffleMsg.");
            Bukkit.getPluginManager().disablePlugin(this);
            return;
        }
        msgCommand.setExecutor(this);
        msgCommand.setTabCompleter(this);

        if (getConfig().getBoolean("persistence.enabled", true)) {
            preferencesFile = new File(getDataFolder(), getConfig().getString("persistence.file", "preferences.yml"));
            loadPreferences();
        }

        warnAboutCommandConflicts();
    }

    @Override
    public void onDisable() {
        savePreferences();
    }

    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        if (!(sender instanceof Player player)) {
            sendConfigured(sender, "messages.player-only", prefixResolver());
            return true;
        }

        if (args.length > 0 && args[0].equalsIgnoreCase("toggle")) {
            if (args.length != 1) {
                sendConfigured(player, "messages.usage", prefixResolver());
                return true;
            }
            toggleIncoming(player);
            return true;
        }

        if (!player.hasPermission(getConfig().getString("permissions.use", "wafflemsg.use"))) {
            sendConfigured(player, "messages.no-permission", prefixResolver());
            return true;
        }
        if (args.length < 2) {
            sendConfigured(player, "messages.usage", prefixResolver());
            return true;
        }

        Player target = findOnlinePlayer(args[0]);
        if (target == null) {
            sendConfigured(player, "messages.player-not-found", prefixResolver(), Placeholder.unparsed("name", args[0]));
            return true;
        }
        if (player.getUniqueId().equals(target.getUniqueId())) {
            sendConfigured(player, "messages.self-message", prefixResolver());
            return true;
        }
        if (!incomingEnabled.getOrDefault(target.getUniqueId(), true)) {
            sendConfigured(player, "messages.incoming-disabled", prefixResolver(),
                    Placeholder.unparsed("name", target.getName()));
            return true;
        }

        String text = String.join(" ", Arrays.copyOfRange(args, 1, args.length));
        if (text.isBlank()) {
            sendConfigured(player, "messages.empty-message", prefixResolver());
            return true;
        }
        if (!player.isOnline() || !target.isOnline()) {
            sendConfigured(player, "messages.player-not-found", prefixResolver(),
                    Placeholder.unparsed("name", target.getName()));
            return true;
        }

        player.sendMessage(renderPrivateMessage(true, player, target, text));
        if (target.isOnline()) {
            target.sendMessage(renderPrivateMessage(false, target, player, text));
            playReceiveSound(target);
        }
        return true;
    }

    @Override
    public java.util.List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
        if (!(sender instanceof Player player) || args.length != 1) {
            return java.util.List.of();
        }
        String partial = args[0].toLowerCase(Locale.ROOT);
        java.util.List<String> suggestions = Bukkit.getOnlinePlayers().stream()
                .filter(target -> !target.getUniqueId().equals(player.getUniqueId()))
                .map(Player::getName)
                .filter(name -> name.toLowerCase(Locale.ROOT).startsWith(partial))
                .collect(Collectors.toCollection(java.util.ArrayList::new));
        if ("toggle".startsWith(partial) && player.hasPermission(getConfig().getString("permissions.toggle", "wafflemsg.toggle"))) {
            suggestions.add("toggle");
        }
        return suggestions;
    }

    private void toggleIncoming(Player player) {
        if (!player.hasPermission(getConfig().getString("permissions.toggle", "wafflemsg.toggle"))) {
            sendConfigured(player, "messages.no-permission", prefixResolver());
            return;
        }

        UUID playerId = player.getUniqueId();
        boolean enabled = !incomingEnabled.getOrDefault(playerId, true);
        incomingEnabled.put(playerId, enabled);
        savePreferences();
        sendConfigured(player, enabled ? "messages.toggle-enabled" : "messages.toggle-disabled", prefixResolver());
    }

    private Component renderPrivateMessage(boolean senderView, Player viewer, Player other, String text) {
        String side = senderView ? "sender" : "receiver";
        Component header = MINI_MESSAGE.deserialize(
                getConfig().getString("format." + side + ".header", ""),
                prefixResolver(),
                Placeholder.component("separator", configuredComponent("format.separator", "➜")),
                Placeholder.component(senderView ? "target" : "from", playerName(other)));
        Component body = MINI_MESSAGE.deserialize(
                getConfig().getString("format." + side + ".body", "<message>"),
                Placeholder.unparsed("message", text));
        return header.append(Component.newline()).append(body);
    }

    private Component playerName(Player player) {
        Component hover = MINI_MESSAGE.deserialize(
                getConfig().getString("format.hover", "Private message with <name>"),
                Placeholder.unparsed("name", player.getName()));
        return Component.text(player.getName())
                .hoverEvent(HoverEvent.showText(hover))
                .clickEvent(ClickEvent.suggestCommand("/msg " + player.getName() + " "));
    }

    private Component configuredComponent(String path, String fallback) {
        return MINI_MESSAGE.deserialize(getConfig().getString(path, fallback));
    }

    private TagResolver prefixResolver() {
        return Placeholder.component("prefix", configuredComponent("format.prefix", "[✉]"));
    }

    private void sendConfigured(CommandSender recipient, String path, TagResolver... resolvers) {
        recipient.sendMessage(MINI_MESSAGE.deserialize(getConfig().getString(path, ""), resolvers));
    }

    private Player findOnlinePlayer(String name) {
        return Bukkit.getOnlinePlayers().stream()
                .filter(player -> player.getName().equalsIgnoreCase(name))
                .findFirst()
                .orElse(null);
    }

    private void playReceiveSound(Player recipient) {
        if (!getConfig().getBoolean("sound.enabled", true)) {
            return;
        }
        String sound = getConfig().getString("sound.name", "minecraft:entity.experience_orb.pickup");
        float volume = (float) getConfig().getDouble("sound.volume", 0.65);
        float pitch = (float) getConfig().getDouble("sound.pitch", 1.2);
        try {
            recipient.playSound(recipient.getLocation(), sound, volume, pitch);
        } catch (IllegalArgumentException exception) {
            getLogger().warning("Could not play configured receive sound '" + sound + "'. Check sound.name in config.yml.");