Spigot Plugin

FrostSpawnPlugin

Context: I need a custom Minecraft plugin for a Paper 1.21.1 server. Goal: Teleport players to a specific location based on their primary LuckPerms group, but ONLY on their very first join. Requirements: API Integration: Use the LuckPerms API to check the player's primary group. Logic: > - Listen for the PlayerJoinEvent. Check if the player has NOT played before (!player.hasPlayedBefore()). If it's their first join, wait 5 ticks (to ensure the player is fully loaded) and then teleport them based on their LuckPerms group.

Read the full description

Configurable: Create a config.yml where I can set the World, X, Y, Z, Yaw, and Pitch for 4 groups: noord, zuid, west, and oost. Commands: > - Add a command /frostspawn reload to reload the config (permission: frost.admin). Add a command /frostspawn set <group> to set the location for a group at my current position (permission: frost.admin). Deliverables: Provide the complete Main.java class code, the plugin.yml (including the LuckPerms dependency), and a default config.yml.

src/main/java/eu/codexe/frostspawnplugin/FrostSpawnPlugin.java
package eu.codexe.frostspawnplugin;

import eu.codexe.frostspawnplugin.command.FrostSpawnCommand;
import eu.codexe.frostspawnplugin.config.PluginConfig;
import eu.codexe.frostspawnplugin.listener.FirstJoinTeleportListener;
import eu.codexe.frostspawnplugin.service.TeleportService;
import org.bukkit.Bukkit;
import org.bukkit.command.PluginCommand;
import org.bukkit.plugin.java.JavaPlugin;

public final class FrostSpawnPlugin extends JavaPlugin {

    private PluginConfig pluginConfig;
    private TeleportService teleportService;

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

        this.pluginConfig = new PluginConfig(this);
        this.pluginConfig.reload();

        this.teleportService = new TeleportService(this, pluginConfig);

        Bukkit.getPluginManager().registerEvents(new FirstJoinTeleportListener(teleportService), this);

        FrostSpawnCommand command = new FrostSpawnCommand(this, pluginConfig, teleportService);
        PluginCommand pluginCommand = getCommand("frostspawn");
        if (pluginCommand != null) {
            pluginCommand.setExecutor(command);
            pluginCommand.setTabCompleter(command);
        } else {
            getLogger().severe("Command 'frostspawn' is missing from plugin.yml");
        }
    }

    @Override
    public void onDisable() {
        // no persistent resources to close
    }

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

    public PluginConfig getPluginConfigWrapper() {
        return pluginConfig;
    }
}