sigmatest 123

continue

Kodari AI
KodariNov 8 at 6:43 pm 1
ShopKeeper
ShopKeeper is a Minecraft plugin that allows players to create and manage their own personal shops. Players can set up shop signs or chests to sell items for set prices, browse other players' shops, and purchase items directly. The plugin features a GUI-based shop management system, configurable pricing, transaction logging, and economy integration for seamless currency handling. It supports multiple shop types, item stock management, and automatic restocking options, providing a robust and user-friendly marketplace experience for server communities.

What should the plugin do? Tell me its name and the features you want, and I’ll build it from scratch.

sigmatest 123

continue

Kodari AI
KodariNov 8 at 6:46 pm 1

What plugin should I build? Share its name and the features you want.

sigmatest 123

/zrob [zone_name] [type] [options]

Available zone types:

"safe" (PvP strictly prohibited, no damage, no "elixirs/buffs") "limited" (restricted PvP; combat carries consequences/penalties) "full" (unrestricted, free-for-all PvP; no rules apply)

Available options (you may use multiple at once):

entry: "text" (message displayed upon entering the zone) exit: "text" (message displayed upon leaving the zone) effect: [effect_name] (e.g., healing, poison, slow, speed, no_magic) range: [radius or coordinates]

When I enter a command, your task is to generate:

Ready-to-use, clean configuration code (in JSON structure format).

A brief, bulleted summary of how the zone functions.

Kodari AI
KodariNov 8 at 6:47 pm 1
  • Create a Java server plugin with the /zrob command and tab completion.

  • Validate zone types/options, then print a formatted JSON configuration and behavior summary.

  • Add only the Gradle and plugin manifest files needed to build and register it.

Added /zrob to generate a JSON zone configuration and a brief summary in chat. It accepts safe, limited, or full, plus optional entry/exit messages, effects, and radius or coordinate-bound ranges.

Example: /zrob spawn safe entry:"Welcome to spawn" range:20

This generates configuration; it does not enforce zone rules in-game.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
settings.gradle
Code
4 312
src/main/java/com/kodari/zoneconfig/ZoneConfigPlugin.java
package com.kodari.zoneconfig;

import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter;
import org.bukkit.plugin.java.JavaPlugin;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;

public final class ZoneConfigPlugin extends JavaPlugin implements CommandExecutor, TabCompleter {
    private static final Set<String> ZONE_TYPES = Set.of("safe", "limited", "full");
    private static final Set<String> OPTION_NAMES = Set.of("entry", "exit", "effect", "range");

    @Override
    public void onEnable() {
        getCommand("zrob").setExecutor(this);
        getCommand("zrob").setTabCompleter(this);
    }

    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        if (args.length < 2) {
            sendUsage(sender, label);
            return true;
        }

        String zoneName = args[0];
        String type = args[1].toLowerCase(Locale.ROOT);
        if (!zoneName.matches("[A-Za-z0-9_-]+")) {
            sender.sendMessage("§cZone name may contain only letters, numbers, underscores, and hyphens.");
            return true;
        }
        if (!ZONE_TYPES.contains(type)) {
            sender.sendMessage("§cUnknown zone type. Choose safe, limited, or full.");
            return true;
        }

        Map<String, String> options;
        try {
            options = parseOptions(String.join(" ", Arrays.copyOfRange(args, 2, args.length)));
            if (options.containsKey("range")) {
                validateRange(options.get("range"));
            }
        } catch (IllegalArgumentException exception) {
            sender.sendMessage("§c" + exception.getMessage());
            sendUsage(sender, label);
            return true;
        }

        sendJson(sender, createJson(zoneName, type, options));
        sendSummary(sender, type, options);
        return true;
    }

    @Override
    public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
        if (args.length == 2) {
            return matching(List.of("safe", "limited", "full"), args[1]);
        }
        if (args.length >= 3) {
            return matching(List.of("entry:\"\"", "exit:\"\"", "effect:", "range:"), args[args.length - 1]);
        }
        return List.of();
    }

    private Map<String, String> parseOptions(String input) {
        Map<String, String> options = new LinkedHashMap<>();
        int cursor = 0;
        while (cursor < input.length()) {
            while (cursor < input.length() && Character.isWhitespace(input.charAt(cursor))) {
                cursor++;
            }
            if (cursor == input.length()) {
                break;
            }

            int keyStart = cursor;
            while (cursor < input.length() && Character.isLetter(input.charAt(cursor))) {
                cursor++;
            }
            if (keyStart == cursor || cursor == input.length() || input.charAt(cursor) != ':') {
                throw new IllegalArgumentException("Options must use key:value syntax.");
            }
            String key = input.substring(keyStart, cursor).toLowerCase(Locale.ROOT);
            cursor++;
            if (!OPTION_NAMES.contains(key)) {
                throw new IllegalArgumentException("Unknown option: " + key + ".");
            }
            if (options.containsKey(key)) {
                throw new IllegalArgumentException("Option provided more than once: " + key + ".");
            }
            if (cursor == input.length() || Character.isWhitespace(input.charAt(cursor))) {
                throw new IllegalArgumentException("Option " + key + " needs a value.");
            }

            String value;
            char first = input.charAt(cursor);
            if (first == '"' || first == '\'') {
                char quote = first;
                cursor++;
                StringBuilder parsed = new StringBuilder();
                boolean closed = false;
                while (cursor < input.length()) {
                    char current = input.charAt(cursor++);
                    if (current == '\\' && cursor < input.length()) {
                        char escaped = input.charAt(cursor++);
                        if (escaped != quote && escaped != '\\') {
                            parsed.append('\\');
                        }
                        parsed.append(escaped);
                    } else if (current == quote) {
                        closed = true;
                        break;
                    } else {
                        parsed.append(current);
                    }
                }
                if (!closed || (cursor < input.length() && !Character.isWhitespace(input.charAt(cursor)))) {
                    throw new IllegalArgumentException("Quoted option values must be closed and separated by a space.");
                }
                value = parsed.toString();
            } else {
                int valueStart = cursor;
                while (cursor < input.length() && !Character.isWhitespace(input.charAt(cursor))) {
                    cursor++;
                }
                value = input.substring(valueStart, cursor);
            }

            if (value.isBlank()) {
                throw new IllegalArgumentException("Option " + key + " cannot be empty.");
            }
            options.put(key, value);
        }
        return options;
    }

    private void validateRange(String range) {
        if (range.matches("(?:\\d+(?:\\.\\d+)?|\\.\\d+)")) {
            if (Double.parseDouble(range) <= 0) {
                throw new IllegalArgumentException("Radius must be greater than zero.");
            }
            return;
        }

        String[] bounds = range.split(":", -1);
        if (bounds.length != 2 || !isCoordinate(bounds[0]) || !isCoordinate(bounds[1])) {
            throw new IllegalArgumentException("Range must be a positive radius or two coordinate triples: x1,y1,z1:x2,y2,z2.");
        }
    }

    private boolean isCoordinate(String value) {
        String[] coordinates = value.split(",", -1);
        if (coordinates.length != 3) {
            return false;
        }
        try {
            for (String coordinate : coordinates) {
                if (!Double.isFinite(Double.parseDouble(coordinate))) {
                    return false;
                }
            }
            return true;
        } catch (NumberFormatException exception) {
            return false;
        }
    }

    private String createJson(String name, String type, Map<String, String> options) {
        List<String> fields = new ArrayList<>();
        fields.add("      \"name\": \"" + escapeJson(name) + "\"");
        fields.add("      \"type\": \"" + escapeJson(type) + "\"");
        for (String key : List.of("entry", "exit", "effect")) {
            if (options.containsKey(key)) {
                fields.add("      \"" + key + "\": \"" + escapeJson(options.get(key)) + "\"");
            }
        }
        if (options.containsKey("range")) {
            fields.add("      \"range\": " + rangeJson(options.get("range")));
        }

        StringBuilder json = new StringBuilder("{\n  \"zones\": [\n    {\n");
        for (int i = 0; i < fields.size(); i++) {
            json.append(fields.get(i));
            if (i < fields.size() - 1) {
                json.append(',');
            }
            json.append('\n');
        }
        return json.append("    }\n  ]\n}").toString();
    }

    private String rangeJson(String range) {