iamnotcrazymc.

Build a professional Minecraft server plugin called NeoFlag using Java 21 and Maven, targeting the Paper API (latest stable, e.g. 1.21.x). Zero manual setup required โ€” no database files, no API keys, no config editing needed to work out of the box. Real flag icons, not emoji or text, must appear correctly โ€” this has failed in prior builds, so debug logging is mandatory (see bottom section).

Flag placement

A flag icon must appear directly before the player's name, no gap, in:

Tab list Chat messages Join messages Leave messages

Use Paper's TabList API for tab, and AsyncChatEvent / PlayerJoinEvent / PlayerQuitEvent for the rest, so the flag is a real prefix component.

Country lookup On join, get the player's IP and send an async request (never blocks main thread) to http://ip-api.com/json/{ip}?fields=status,countryCode,country, 3-second timeout.

Cache the resolved country by UUID for the session โ€” one lookup per join, not per message.

If the lookup fails, times out, or the IP is private/local, use the configured fallback.

Auto-detect proxy setups (Velocity/BungeeCord) and use the real forwarded client IP, not the proxy's IP.

Resource pack โ€” real flag icons Bundle a resource pack (pack.zip) inside the plugin's resources at build time:

Custom font at assets/neoflag/font/flags.json 16ร—16 flag PNGs for the top ~50 country codes Each mapped to an unused private-use Unicode codepoint (\uE000 onward) On startup, auto-host the pack via a built-in HTTP server on a configurable port (default 8642). Immediately after binding, self-test it with an internal HTTP GET request and log the result ("resource pack server reachable" / "resource pack server FAILED self-test: <reason>"). If resource-pack.url is set in config, use that instead.

If the self-test fails, do not attempt to send the resource pack to players at all โ€” log a clear one-time warning explaining port 8642 likely needs to be forwarded/opened on the host, or resource-pack.url should be set manually โ€” and skip straight to fallback rendering for everyone.

If the self-test passes, send the pack on join via Player#setResourcePack(...) / ResourcePackRequest, required = config value (default false), with the configured prompt message.

Track each player's status via PlayerResourcePackStatusEvent and log it per player (e.g. "NeoFlag: PlayerName resource pack status = SUCCESSFULLY_LOADED" / DECLINED / FAILED_DOWNLOAD).

Strict rendering rule: <flag> must resolve to the private-use icon character only after that player's status is confirmed SUCCESSFULLY_LOADED/ACCEPTED. For every other state (pending, declined, failed, or pack disabled/unreachable), <flag> must resolve to the plain configured fallback (๐Ÿณ๏ธ or [XX] text) โ€” never a raw emoji pair, never a private-use character with no font loaded, never a blank/broken glyph.

Per-player rendering: each player sees icon or fallback based on their own personal acceptance status, applied consistently across chat, tab, and join/leave.

Commands /country [player] โ€” shows detected country (self or target) /neoflag reload โ€” reloads config live Permissions: neoflag.use, neoflag.others, neoflag.admin Config file โ€” generate exactly this as default yaml

NeoFlag works immediately after it is installed. These settings are optional.

Country lookups use the player's address exposed by Paper. For proxy networks,

configure Paper/Velocity/Bungee forwarding correctly; no NeoFlag toggle is needed.

lookup: enabled: true endpoint: 'http://ip-api.com/json/{ip}?fields=status,countryCode,country' timeout-seconds: 3

resource-pack: enabled: true url: '' sha1: '' required: false host-port: 8642 prompt-message: '<yellow>Accept the resource pack to see real flag icons in chat!' decline-fallback: true

fallback: flag: '๐Ÿณ๏ธ' country-name: 'Unknown'

features: chat: true tab-list: true join-message: true leave-message: true

formats: chat: '<flag><player> <dark_gray>ยป <message>' tab-list: '<flag><player>' join: '<green>+ <flag><player> joined the server.' leave: '<red>- <flag><player> left the server.' country-self: '<gray>Your detected country: <flag> <country>.' country-other: '<gray><player>''s detected country: <flag> <country>.' no-permission: '<red>You do not have permission to do that.' player-not-found: '<red>That player is not online.' usage-country: '<yellow>Usage: /country [player]' usage-neoflag: '<yellow>Usage: /neoflag reload' reload-success: '<green>NeoFlag configuration reloaded.' Naming (apply throughout) plugin.yml name: NeoFlag, package e.g. com.yourname.neoflag Jar output: NeoFlag-1.0.0.jar All classes, commands, permissions use neoflag/NeoFlag, not flagtag Mandatory debug logging (this is required, not optional)

On every player join, print a single console line summarizing the full pipeline result, e.g.: [NeoFlag] PlayerName -> country: IN (India) | pack: SUCCESSFULLY_LOADED | flag render: ICON or [NeoFlag] PlayerName -> country: IN (India) | pack: server unreachable | flag render: FALLBACK

This line alone must make it possible to tell, from server console, exactly why a player is or isn't seeing a real icon โ€” without needing to read code.

Deliverable

Full buildable Maven project (mvn clean package) producing NeoFlag-1.0.0.jar, with the resource pack embedded, self-tested on startup, and the join-log line described above. Never crash the server regardless of API, lookup, or resource-pack failures.

Kodari AI
KodariAug 18 at 3:06 pm 3
NeoFlag
NeoFlag is a Minecraft Paper plugin that displays real flag icons before player names in chat, tab list, and join/leave messages. It performs async country lookups via ip-api.com with caching, auto-detects proxy setups, and bundles a resource pack with custom font-mapped flag icons. The plugin auto-hosts the pack via an embedded HTTP server with self-testing, tracks per-player resource pack acceptance, and falls back to text flags when needed. Includes /country and /neoflag reload commands with configurable formats and permissions.
  1. Create the Maven/Paper project and exact default configuration.

  2. Add asynchronous country lookup with private-IP fallback and session caching.

  3. Add the embedded/generated flag resource pack, HTTP hosting, self-test, and per-player pack tracking.

  4. Add per-viewer rendering, tab/chat/join/leave integration, commands, permissions, and mandatory diagnostics.

  1. Created the complete Maven/Paper Java 21 project for NeoFlag, producing NeoFlag-1.0.0.jar.

  2. Added asynchronous IP country lookup with private/local fallback, session caching, proxy-compatible Paper address handling, and /country.

  3. Added build-time generation of pack.zip containing 16ร—16 PNG flag textures and private-use font mappings.

  4. Added built-in HTTP hosting on port 8642, startup self-test, configurable external URL support, SHA-1 handling, resource-pack status tracking, and mandatory join diagnostics.

  5. Added per-viewer flag rendering for chat, tab list, join/leave messages, live /neoflag reload, configuration, permissions, and fallback rendering.

Kodari can make mistakes. Review important code before using.
Files
src
pom.xml
Code
15 1,119
src/main/java/com/yourname/neoflag/NeoFlag.java
package com.yourname.neoflag;

import com.yourname.neoflag.command.CountryCommand;
import com.yourname.neoflag.command.NeoFlagCommand;
import com.yourname.neoflag.config.NeoFlagConfig;
import com.yourname.neoflag.country.CountryService;
import com.yourname.neoflag.listener.NeoFlagListener;
import com.yourname.neoflag.pack.FlagPackManager;
import com.yourname.neoflag.render.FlagRenderer;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;

public final class NeoFlag extends JavaPlugin {
    private NeoFlagConfig configuration;
    private CountryService countryService;
    private FlagPackManager packManager;
    private FlagRenderer renderer;

    @Override
    public void onEnable() {
        saveDefaultConfig();
        configuration = new NeoFlagConfig(this);
        packManager = new FlagPackManager(this, configuration);
        packManager.start();
        countryService = new CountryService(this, configuration);
        renderer = new FlagRenderer(configuration, countryService, packManager);

        Bukkit.getPluginManager().registerEvents(
                new NeoFlagListener(this, configuration, countryService, packManager, renderer), this);

        CountryCommand countryCommand = new CountryCommand(this, configuration, countryService, renderer);
        if (getCommand("country") != null) {
            getCommand("country").setExecutor(countryCommand);
            getCommand("country").setTabCompleter(countryCommand);
        }
        if (getCommand("neoflag") != null) {
            getCommand("neoflag").setExecutor(new NeoFlagCommand(this, configuration));
        }
    }

    @Override
    public void onDisable() {
        if (countryService != null) {
            countryService.shutdown();
        }
        if (packManager != null) {
            packManager.stop();
        }
    }

    public void reloadNeoFlag() {
        reloadConfig();
        packManager.reloadConfiguration();
        renderer.refreshTabLists();
    }

    public NeoFlagConfig configuration() {
        return configuration;
    }

    public CountryService countryService() {
        return countryService;
    }

    public FlagPackManager packManager() {
        return packManager;
    }

    public FlagRenderer renderer() {
        return renderer;
    }
}