Izz Darwisy Bin Iskandar

i want you to make a plugin that like an ai assistant for the server i named it Cookie AI i use Groq api key. this plugin can make the ai interact with the game like /cookieai {prompt}. Example /cookieai build a modern house infront of me. and it will automatically build what comes out of the ai minds another example/cookieai give me a green shulker of full Golden apple stack 64 each of them. Then it will make and will give to the player. The prompt can be more interesting because it can interact with ingame can control animals ai mobs ai and more. but if prompt /cookieai setup. it will open a developer prompt meaning what i enter for the prompt will be saved, like a kid that the teacher teach him whats his name and it will remember it forever. To turn off developer prompt type /cookieai developer but make sure dont put anything for the tab complete just put Prompt this ai is so powerful that it can like make a npc named anything or anyone who ever joined the server online by making it like a bot and can move it through choice. I want you to link to server. properties, usercache. json and plugins folder and more, but more easily the ai can have access all the server directory only player with op can interact with the ai if none op player uses the /cookieai it will say Can't Execute Command. also Player named Frizz and izzzfr has all the access of the ai and can blacklist any player from using the ai using their prompt. remember the server can execute command can interact with Minecraft world, Minecraft server, players, mob, and the entire game or should i say the entire Minecraft server. make a config file so that i can put the groq api key and make some more config that you can think of

Kodari AI
KodariNov 6 at 7:22 am 3
CookieAI
A powerful AI assistant plugin for Minecraft servers that integrates with Groq's API. Players with OP permissions can use /cookieai commands to interact with the AI, which can build structures, spawn items, control mobs, create NPCs, and execute server commands. Features include a developer mode for customizing AI behavior, player blacklisting system, and full server directory access. The plugin automatically parses AI responses to execute in-game actions like building, item spawning, and command execution. Includes configurable API key settings, permission system, and special access for designated players. The AI can create interactive NPCs, manage entities, and respond to complex natural language prompts that translate into concrete Minecraft actions.

Created Cookie AI with Groq prompts, persistent developer instructions, owner-managed blacklisting, and console-command execution.

Set your Groq key in plugins/CookieAI/config.yml, then restart the server. Use /cookieai setup to save instructions and /cookieai developer to exit setup mode.

Important: AI-generated commands run as the server console and can change or damage the server. Limit operator access and keep backups. Direct server-directory access and player-like NPC bots are not implemented; world and mob interactions are limited to commands available on your server.

Izz Darwisy Bin Iskandar

i want the ai to access my server directory its not your choice

Kodari AI
KodariNov 6 at 7:24 am 4
  • Add server-directory list, read, write, create-directory and delete actions.

  • Keep file operations inside the server directory and report their results back to Groq.

  • Log file changes and retain the existing player access checks.

Cookie AI can now list, read, write and delete files, and create directories within the server directory. File operations are logged; symbolic links are not followed.

Important: File contents the AI reads are sent to Groq and may include API keys or other secrets. Changes to configuration files may require a plugin reload or server restart.

Izz Darwisy Bin Iskandar

the plugin is for paper 26.2 make this ai can interact world and mon interactions this is my server its my responsibility add it now

Kodari AI
KodariNov 6 at 7:26 am 4
  • Add native world and mob actions, including nearby-entity inspection.

  • Run game actions on the server thread and return results to the AI.

  • Keep the existing console-command support for actions outside those tools.

Added native world and mob actions for Cookie AI on Paper: placing and filling blocks, spawning and finding entities, teleporting, naming, removing, toggling mob AI, and setting targets. The AI receives action results so it can continue the request.

Console commands remain available for other interactions. NPC bots are still not implemented.

Izz Darwisy Bin Iskandar

implant the npc bots now. for security reasons the ai cant touch its config because put some on/off switch to shut down ai. so the ai can access the server all of the directory but it can touch its own config file

Kodari AI
KodariNov 6 at 7:30 am 5
  1. Add AI-controlled NPC bots with spawning, movement and removal.

  2. Protect Cookie AI’s own config from its file tools and add an AI shutdown switch.

  • Added NPC spawning, skins, pathfinding, following, stopping and removal. Install a Paper 26.2-compatible Citizens build to use them.

  • Added enabled: false to shut off AI requests. After editing plugins/CookieAI/config.yml, run cookieai reload from the server console.

  • Blocked the AI’s file tools from accessing its config.

Security limitation: This does not fully protect the config while the AI can execute unrestricted console commands and modify other server files. Those capabilities may provide indirect ways to change it.

Izz Darwisy Bin Iskandar

i dont want to use citizens plugin just use fancynpc

Kodari AI
KodariNov 6 at 7:31 am 3
  • Replace Citizens with FancyNpcs for spawning, skins, listing, moving and removing NPCs.

  • Keep movement honest: FancyNpcs provides packet movement, not Citizens-style pathfinding or follow AI.

Replaced Citizens with FancyNpcs for NPC spawning, skins, listing, movement and removal. Install a Paper 26.2-compatible FancyNpcs build on your server.

NPC movement changes position directly; pathfinding and following are not supported.

Izz Darwisy Bin Iskandar

i have uploaded the cookieai. zip file make ot to

Kodari AI
KodariNov 8 at 4:32 am 1

What would you like me to do with the uploaded CookieAI.zip—import its contents into this project, or use it to update the plugin?

[Generation stopped]

Izz Darwisy Bin Iskandar

use it to update the plugin that. zip file i have some talk with claude now i want you to update the plugin using that . zip file

Kodari AI
KodariNov 8 at 4:34 am 1

I found CookieAI-1.2.zip, but it isn’t readable as a valid ZIP archive, so I can’t compare or import its changes yet. Please re-upload the ZIP, or upload the extracted project files.

Izz Darwisy Bin Iskandar

try again

Kodari AI
KodariNov 8 at 4:38 am 1

I tried again, but the ZIP isn’t currently available in the project workspace. Please re-upload CookieAI-1.2.zip or upload the extracted files, and I can use them to update the plugin.

Izz Darwisy Bin Iskandar

i have replace it

Kodari AI
KodariNov 8 at 4:42 am 1

I still can’t see a ZIP in the project workspace. Please upload it again, or place the extracted files in the cookie folder so I can compare them with the current plugin.

Izz Darwisy Bin Iskandar

i have replaced all check

Kodari AI
KodariNov 8 at 4:43 am 1

I can now see the replaced plugin files. The project includes Groq integration, server and web tools, and FancyNpcs support.

The config still contains placeholder API keys, so you’ll need to enter your Groq key before using the AI. I haven’t compiled or tested the replacement on a server yet.

Izz Darwisy Bin Iskandar

just make it a plugin

Kodari AI
KodariNov 8 at 4:45 am 1

CookieAI is already structured as a Paper-compatible plugin. To get the JAR:

  1. Click Compile in the top bar. On mobile, tap ⋮ → Compile Project.

  2. Click Compile in the window.

  3. When it succeeds, click Download on the build.

If compilation fails, click Auto-fix in the chat or Fix in the build window.

Kodari can make mistakes. Review important code before using.
Files
cookie
src
build.gradle
settings.gradle
Code
10 1,735
src/main/java/com/kodari/cookieai/CookieAI.java
package com.kodari.cookieai;

import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Mob;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;

import java.io.File;
import java.io.IOException;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.LinkOption;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;
import java.nio.file.StandardOpenOption;
import java.time.Duration;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.logging.Level;
import java.util.stream.Stream;

public final class CookieAI extends JavaPlugin implements TabExecutor {
    private final Set<UUID> developerMode = new HashSet<>();
    private final Set<UUID> pending = new HashSet<>();
    private final Set<String> blacklist = new HashSet<>();
    private final List<String> memory = new ArrayList<>();
    private File dataFile;
    private YamlConfiguration data;
    private HttpClient http;
    private WebTools web;
    private static final int CONFIG_VERSION = 2;
    private volatile String knowledge = "";
    private final Map<UUID, List<String[]>> history = new HashMap<>();
    private final Map<UUID, Pending> awaiting = new HashMap<>();

    private static final class Pending {
        final String response;
        final List<WebTools.Download> downloads;
        final long created = System.currentTimeMillis();

        Pending(String response, List<WebTools.Download> downloads) {
            this.response = response;
            this.downloads = downloads;
        }
    }

    @Override
    public void onEnable() {
        saveDefaultConfig();
        migrateConfig();
        dataFile = new File(getDataFolder(), "memory.yml");
        data = YamlConfiguration.loadConfiguration(dataFile);
        memory.addAll(data.getStringList("developer-memory"));
        for (String name : data.getStringList("blacklist")) {
            blacklist.add(name.toLowerCase(Locale.ROOT));
        }
        http = HttpClient.newBuilder().connectTimeout(Duration.ofSeconds(10)).build();
        web = new WebTools(this);
        loadKnowledge();
        getCommand("cookieai").setExecutor(this);
        getCommand("cookieai").setTabCompleter(this);
    }

    private boolean owner(String name) {
        return name.equalsIgnoreCase("Frizz") || name.equalsIgnoreCase("izzzfr");
    }

    private boolean allowed(Player player) {
        return owner(player.getName()) || (player.isOp() && !blacklist.contains(player.getName().toLowerCase(Locale.ROOT)));
    }

    private void saveData() {
        data.set("developer-memory", memory);
        data.set("blacklist", new ArrayList<>(blacklist));
        try {
            data.save(dataFile);
        } catch (IOException e) {
            getLogger().log(Level.SEVERE, "Could not save Cookie AI memory", e);
        }
    }

    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        if (args.length == 1 && args[0].equalsIgnoreCase("reload") && !(sender instanceof Player)) {
            reloadConfig();
            loadKnowledge();
            sender.sendMessage("Cookie AI configuration reloaded. AI enabled: " + getConfig().getBoolean("enabled", true));
            return true;
        }
        if (!(sender instanceof Player)) {
            sender.sendMessage("Only players can use Cookie AI.");
            return true;
        }
        Player player = (Player) sender;
        if (!allowed(player)) {
            player.sendMessage("Can't Execute Command.");
            return true;
        }
        if (!getConfig().getBoolean("enabled", true)) {
            player.sendMessage(ChatColor.RED + "Cookie AI is disabled in its configuration.");
            return true;
        }
        if (args.length == 0) {
            player.sendMessage(ChatColor.YELLOW + "Usage: /cookieai <prompt>");
            return true;
        }
        String prompt = String.join(" ", args);
        if (prompt.equalsIgnoreCase("reset")) {
            synchronized (history) {
                history.remove(player.getUniqueId());
            }
            awaiting.remove(player.getUniqueId());
            player.sendMessage(ChatColor.YELLOW + "Cookie AI conversation memory cleared.");
            return true;
        }
        if (prompt.equalsIgnoreCase("confirm") || prompt.equalsIgnoreCase("cancel")) {
            Pending waiting = awaiting.remove(player.getUniqueId());
            if (waiting == null || System.currentTimeMillis() - waiting.created > 300_000L) {
                player.sendMessage(ChatColor.YELLOW + "Nothing is waiting for confirmation.");
            } else if (prompt.equalsIgnoreCase("cancel")) {
                player.sendMessage(ChatColor.YELLOW + "Cancelled. Nothing was run.");
            } else {
                executeResponse(player, waiting.response, Math.max(1, Math.min(100, getConfig().getInt("limits.max-commands", 30))), waiting.downloads);
            }
            return true;
        }
        if (prompt.equalsIgnoreCase("setup")) {
            developerMode.add(player.getUniqueId());
            player.sendMessage(ChatColor.GREEN + "Developer mode enabled. Your /cookieai prompts will be saved as persistent instructions. Use /cookieai developer to exit.");
            return true;
        }
        if (prompt.equalsIgnoreCase("developer")) {
            developerMode.remove(player.getUniqueId());
            player.sendMessage(ChatColor.YELLOW + "Developer mode disabled.");
            return true;
        }
        if (developerMode.contains(player.getUniqueId())) {
            if (prompt.length() > Math.max(1, getConfig().getInt("limits.max-memory-entry-length", 1000)) || memory.size() >= Math.max(1, getConfig().getInt("limits.max-memory-entries", 100))) {
                player.sendMessage(ChatColor.RED + "Memory limit reached or instruction is too long. Edit memory.yml to remove instructions.");
                return true;
            }
            memory.add(prompt);
            saveData();
            player.sendMessage(ChatColor.GREEN + "Developer instruction saved.");
            return true;
        }
        if (prompt.length() > Math.max(1, getConfig().getInt("limits.max-prompt-length", 3000))) {
            player.sendMessage(ChatColor.RED + "Prompt is too long.");
            return true;
        }
        String key = getConfig().getString("groq.api-key", "").trim();
        if (key.isEmpty() || key.equals("PUT_YOUR_GROQ_API_KEY_HERE")) {
            player.sendMessage(ChatColor.RED + "Set your Groq API key in plugins/CookieAI/config.yml and restart the server.");
            return true;
        }
        if (!pending.add(player.getUniqueId())) {
            player.sendMessage(ChatColor.YELLOW + "Cookie AI is still processing your previous request.");
            return true;
        }
        awaiting.remove(player.getUniqueId());
        Location location = player.getLocation();
        String context = "Player: " + player.getName() + "; world: " + location.getWorld().getName()
                + "; position: " + location.getBlockX() + " " + location.getBlockY() + " " + location.getBlockZ()
                + "; facing: " + player.getFacing().name() + "; Minecraft version: " + Bukkit.getBukkitVersion()
                + "; privileged blacklist owner: " + owner(player.getName())
                + "; worlds: " + worldNames() + "; online players: " + onlineNames();
        String instructions = String.join("\n", memory);
        String model = getConfig().getString("groq.model", "llama-3.3-70b-versatile");
        int timeout = Math.max(5, Math.min(120, getConfig().getInt("groq.timeout-seconds", 45)));
        int tokens = Math.max(256, Math.min(8192, getConfig().getInt("groq.max-output-tokens", 4096)));
        int maxCommands = Math.max(1, Math.min(100, getConfig().getInt("limits.max-commands", 30)));
        UUID id = player.getUniqueId();