Other game Narula

FINAL UPDATE โ€” COUNTRY SPAWN PLUGIN

Update the existing Country Spawn Plugin using the original full plugin requirements. Keep ALL original features, commands, configuration, permissions, spawn systems, and functionality.

Do not remove or break any existing feature.

  1. ONLY TWO COUNTRIES

The country selection GUI must contain ONLY:

๐Ÿ‡ฎ๐Ÿ‡ณ INDIA ๐Ÿ‡ต๐Ÿ‡ฐ PAKISTAN

Remove all other countries and regions from the GUI.

Keep the existing country spawn system and "/setcountryspawn <country>" command.

  1. IMPORTANT โ€” WORK AFTER LOGIN PLUGIN

The server uses a Login/Register authentication plugin.

The Country Spawn Plugin MUST NOT open the country selection GUI, teleport players, or force country selection before the player has successfully authenticated.

Required Login Flow:

  1. A new player joins the server.
  2. The Login/Register plugin handles authentication.
  3. The player enters "/register <password> <password>" if they are new, or "/login <password>" if already registered.
  4. Wait until the authentication plugin confirms that the player has successfully logged in.
  5. ONLY AFTER SUCCESSFUL LOGIN, check whether the player has selected a country.
  6. If the player has NOT selected a country, open the Country Selection GUI.
  7. If the player has already selected a country, do not open the GUI again.
  8. Do not teleport or apply country spawn logic before successful authentication.

Authentication Compatibility:

  • Support common login plugins such as AuthMe Reloaded where possible.
  • Use the authentication plugin's proper login event or API.
  • Do not assume that PlayerJoinEvent means the player is authenticated.
  • If the authentication plugin is not available, provide a configurable integration or clearly document the supported authentication method.
  • Ensure the plugin works reliably after "/login" and "/register" authentication.
  • Avoid duplicate GUI openings.
  • Handle reconnects and server restarts correctly.
  1. ONE CHANCE ONLY

Display this warning prominently inside the GUI:

ONE CHANCE ONLY โ€” SELECT YOUR COUNTRY CAREFULLY!

Warning style:

  • Bold
  • Red or dark red
  • Clearly visible

After selecting India or Pakistan:

  • Save the country permanently.
  • Prevent the player from changing their country.
  • Do not reopen the GUI for that player.
  • Keep the country saved after server restarts.

The admin reset command must remain available to authorized administrators.

  1. GUI DESIGN

Create a professional and attractive Minecraft inventory GUI.

Theme:

  • Black background
  • Bold text
  • Red and bold warning
  • Clean and organized layout
  • Attractive country items
  • Decorative black stained glass panes where appropriate
  • Prevent item theft and accidental movement

Make sure all text is readable in Minecraft. Use suitable contrasting colors where black text would not be visible.

Country items:

  • ๐Ÿ‡ฎ๐Ÿ‡ณ INDIA
  • ๐Ÿ‡ต๐Ÿ‡ฐ PAKISTAN
  1. KEEP ALL ORIGINAL COMMANDS

Keep all commands from the original plugin:

/setcountryspawn <country> /countryspawn reload /countryspawn info <player> /countryspawn reset <player>

Keep:

  • Admin permissions
  • Persistent player data
  • Country spawn points
  • Respawn and join spawn behavior
  • Tab completion
  • Configuration file
  • Error handling
  • GUI protection
  1. FINAL DEVELOPMENT REQUIREMENT

Provide the complete updated plugin source code, including all required classes, plugin.yml, configuration, and installation instructions.

Make sure the plugin is functional and tested for the target Minecraft server version.

The most important requirement is:

THE COUNTRY SELECTION GUI MUST WORK ONLY AFTER THE PLAYER HAS SUCCESSFULLY LOGGED IN THROUGH THE LOGIN/REGISTER PLUGIN.

Do not provide an incomplete demonstration or remove existing features.

Kodari AI
KodariSep 22 at 5:18 pm 2
CountrySpawnAuth
A Bukkit/Spigot plugin that provides a country selection system with India and Pakistan options, integrated with authentication plugins like AuthMe. It features a professional black-themed inventory GUI with bold red warning text, permanent country selection, country-specific spawn points, and admin commands for setting spawns, reloading config, viewing player info, and resetting selections. The plugin waits for successful login before opening the selection GUI, preventing premature teleportation or selection. It includes persistent player data storage, respawn and join spawn behavior, tab completion, configuration file, and GUI protection against item theft.
  1. Create the Gradle project, plugin metadata, configuration, persistence, and installation documentation.

  2. Implement country models, permanent player country data, country spawn storage, and admin commands with tab completion.

  3. Implement the protected two-country GUI and event handling for clicks, closing, joins, quits, respawns, and teleport behavior.

  4. Implement AuthMe-compatible post-login detection with a configurable no-auth mode, then wire and register everything in the main plugin.

Created the complete CountrySpawn plugin source with:

  • Only India and Pakistan in the selection GUI.

  • Permanent one-time country selection.

  • Prominent red โ€œONE CHANCE ONLYโ€ warning.

  • Protected inventory GUI with decorative black panes.

  • AuthMe Reloaded integration using both login events and authenticated-state polling.

  • No GUI, teleport, or spawn logic before successful authentication.

  • Configurable AUTO, AUTHME, and NONE authentication modes.

  • Persistent player country data and country spawn locations.

  • Join, respawn, and post-selection teleport handling.

  • Commands:

    • /setcountryspawn <india|pakistan>

    • /countryspawn reload

    • /countryspawn info <player>

    • /countryspawn reset <player>

  • Permissions and tab completion.

  • Gradle build files, plugin.yml, config.yml, and installation documentation.

The project targets Java 17 and Spigot/Paper 1.20.x.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
README.md
settings.gradle
Code
15 960
src/main/java/com/kodari/countryspawn/CountrySpawnPlugin.java
package com.kodari.countryspawn;

import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;

import java.util.HashSet;
import java.util.Set;
import java.util.UUID;

public class CountrySpawnPlugin extends JavaPlugin {
    private CountryManager countryManager;
    private AuthIntegration authIntegration;
    private final Set<UUID> authenticatedPlayers = new HashSet<>();
    private final Set<UUID> openSelectionMenus = new HashSet<>();

    @Override
    public void onEnable() {
        saveDefaultConfig();
        countryManager = new CountryManager(this);
        authIntegration = new AuthIntegration(this);

        CountryListener listener = new CountryListener(this);
        Bukkit.getPluginManager().registerEvents(listener, this);
        getCommand("setcountryspawn").setExecutor(new SetCountrySpawnCommand(this));
        getCommand("setcountryspawn").setTabCompleter(new SetCountrySpawnCommand(this));
        CountrySpawnCommand command = new CountrySpawnCommand(this);
        getCommand("countryspawn").setExecutor(command);
        getCommand("countryspawn").setTabCompleter(command);

        authIntegration.start();
    }

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

    public CountryManager getCountryManager() {
        return countryManager;
    }

    public AuthIntegration getAuthIntegration() {
        return authIntegration;
    }

    public Set<UUID> getAuthenticatedPlayers() {
        return authenticatedPlayers;
    }

    public void handleAuthenticated(Player player) {
        if (!player.isOnline() || !authenticatedPlayers.add(player.getUniqueId())) {
            return;
        }
        Country country = countryManager.getCountry(player.getUniqueId());
        if (country == null) {
            openSelectionMenu(player);
            send(player, "messages.selection-required");
            return;
        }
        if (getConfig().getBoolean("teleport.on-join", true)) {
            teleportToCountrySpawn(player, country);
        }
    }

    public void openSelectionMenu(Player player) {
        if (!player.isOnline() || countryManager.getCountry(player.getUniqueId()) != null || !openSelectionMenus.add(player.getUniqueId())) {
            return;
        }
        player.openInventory(CountrySelectionGUI.create(this, player));
    }

    public void handleSelectionClose(Player player) {
        UUID uuid = player.getUniqueId();
        openSelectionMenus.remove(uuid);
        if (player.isOnline() && authenticatedPlayers.contains(uuid) && countryManager.getCountry(uuid) == null) {
            Bukkit.getScheduler().runTaskLater(this, () -> openSelectionMenu(player), 20L);
        }
    }

    public void selectCountry(Player player, Country country) {
        if (countryManager.selectCountry(player.getUniqueId(), player.getName(), country)) {
            openSelectionMenus.remove(player.getUniqueId());
            player.closeInventory();
            send(player, "messages.country-selected", "%country%", country.displayName());
            if (getConfig().getBoolean("teleport.after-selection", true)) {
                teleportToCountrySpawn(player, country);
            }
            return;
        }
        Country existing = countryManager.getCountry(player.getUniqueId());
        send(player, "messages.country-already-selected", "%country%", existing == null ? "unknown" : existing.displayName());
        player.closeInventory();
    }

    public void resetPlayer(Player target) {
        countryManager.resetCountry(target.getUniqueId());
        openSelectionMenus.remove(target.getUniqueId());
        target.closeInventory();
        if (authenticatedPlayers.contains(target.getUniqueId())) {
            Bukkit.getScheduler().runTask(this, () -> openSelectionMenu(target));
        }
    }

    public void teleportToCountrySpawn(Player player, Country country) {
        Location spawn = countryManager.getSpawn(country);
        if (spawn == null) {
            send(player, "messages.spawn-not-set", "%country%", country.displayName());
            return;
        }
        player.teleport(spawn);
    }

    public void reloadPlugin() {
        reloadConfig();
        countryManager.reload();
    }

    public void send(Player player, String path, String... replacements) {
        String message = getConfig().getString(path, "");
        for (int index = 0; index + 1 < replacements.length; index += 2) {
            message = message.replace(replacements[index], replacements[index + 1]);
        }
        player.sendMessage(color(message));
    }

    public void send(org.bukkit.command.CommandSender sender, String path, String... replacements) {
        String message = getConfig().getString(path, "");
        for (int index = 0; index + 1 < replacements.length; index += 2) {
            message = message.replace(replacements[index], replacements[index + 1]);
        }
        sender.sendMessage(color(message));
    }

    public String color(String text) {
        return ChatColor.translateAlternateColorCodes('&', text == null ? "" : text);
    }
}