cjcool3003

cjcool3003 Can you please make me a minecraft 1.21.11 paper plugin that when a player joins the server for the first commands can be issued, to add a command plese add the command /jc add [id] [command]. [id] is a custom id you can give to the command and [command is the command] please use placeholders for players names ect. please also add a /jc list command that lets staff list all the commands avalible as well as a /jc delete [id] command that lets staff delete the command using the id from when creating it for all commandsthat are /jc please make it require the permission "jc.admin" please add a /jc reload command to reload the plugin. if the player joins back for their second time or so on do not issue the commands. please call this plugin joincommand+

Kodari AI
KodariJul 7 at 12:16 am 1
JoinCommandPlus
A first-join command execution plugin for Paper 1.21.1. Executes configured commands when a player joins the server for the first time. Features include /jc add, /jc delete, /jc list, and /jc reload commands with jc.admin permission required. Supports placeholders for player name, UUID, display name, and world. Tracks joined players via persistent storage to prevent re-execution on subsequent joins.

Plugin structure created:

  • build.gradle — Paper 1.21.1 API, Java 21

  • plugin.yml — registers /jc with jc.admin permission (OP by default)

  • config.yml — stores commands by ID with placeholders %player%, %uuid%, %displayname%, %world%

  • JoinCommandPlus.java — main class: loads commands from config, tracks joined players via players.yml, handles add/remove/save

  • JoinListener.java — fires only on first join per UUID, executes each configured command via console

  • JoinCommandExecutor.java — /jc add <id> <command> (remaining args joined as command), /jc delete <id>, /jc list, /jc reload

cjcool3003

can i add player commands?

Kodari AI
KodariOct 17 at 9:52 pm 1
  • Add an optional player or console executor to /jc add; existing commands remain console-run by default.

  • Run player-selected commands as the first-joining player, with the existing placeholders.

  • Update /jc usage/list output and the config example.

Yes. /jc add <id> player <command> now runs that command as the first-joining player—for example: /jc add starter player spawn.

Commands without player still run as console. Player-run commands use the joining player’s permissions, and both modes support the existing placeholders. /jc list shows whether each command runs as player or console.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
Code
6 328
src/main/java/com/joincommandplus/JoinCommandPlus.java
package com.joincommandplus;

import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;

import java.io.File;
import java.io.IOException;
import java.util.*;

public class JoinCommandPlus extends JavaPlugin {

    private final Map<String, String> commands = new LinkedHashMap<>();
    private final Set<UUID> joinedPlayers = new HashSet<>();
    private File playersFile;
    private FileConfiguration playersConfig;

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

        getServer().getPluginManager().registerEvents(new JoinListener(this), this);

        Objects.requireNonNull(getCommand("jc")).setExecutor(new JoinCommandExecutor(this));

        getLogger().info("JoinCommandPlus enabled!");
    }

    @Override
    public void onDisable() {
        savePlayers();
        getLogger().info("JoinCommandPlus disabled!");
    }

    public void loadCommands() {
        commands.clear();
        reloadConfig();
        FileConfiguration config = getConfig();
        if (config.contains("commands")) {
            for (String id : Objects.requireNonNull(config.getConfigurationSection("commands")).getKeys(false)) {
                String cmd = config.getString("commands." + id);
                if (cmd != null) {
                    commands.put(id, cmd);
                }
            }
        }
    }

    public void loadPlayers() {
        joinedPlayers.clear();
        playersFile = new File(getDataFolder(), "players.yml");
        if (!playersFile.exists()) {
            try {
                playersFile.createNewFile();
            } catch (IOException e) {
                getLogger().severe("Could not create players.yml: " + e.getMessage());
            }
        }
        playersConfig = YamlConfiguration.loadConfiguration(playersFile);
        if (playersConfig.contains("joined")) {
            for (String uuidStr : playersConfig.getStringList("joined")) {
                try {
                    joinedPlayers.add(UUID.fromString(uuidStr));
                } catch (IllegalArgumentException ignored) {
                }
            }
        }
    }

    public void savePlayers() {
        if (playersConfig == null || playersFile == null) return;
        List<String> uuidList = new ArrayList<>();
        for (UUID uuid : joinedPlayers) {
            uuidList.add(uuid.toString());
        }
        playersConfig.set("joined", uuidList);
        try {
            playersConfig.save(playersFile);
        } catch (IOException e) {
            getLogger().severe("Could not save players.yml: " + e.getMessage());
        }
    }

    public boolean hasJoinedBefore(UUID uuid) {
        return joinedPlayers.contains(uuid);
    }

    public void markJoined(UUID uuid) {
        joinedPlayers.add(uuid);
        savePlayers();
    }

    public Map<String, String> getCommands() {
        return commands;
    }

    public void addCommand(String id, String command) {
        commands.put(id, command);
        getConfig().set("commands." + id, command);
        saveConfig();
    }

    public boolean removeCommand(String id) {
        if (!commands.containsKey(id)) return false;
        commands.remove(id);
        getConfig().set("commands." + id, null);
        saveConfig();
        return true;
    }
}