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.