cjcool3003

Can you please make me a minecraft 1.21.11 plugin that adds generators, generators can be created by an admin with the permission generators.admin and to create a generator they select the two positions of the generator with /ag pos1 and /ag pos2 when those two points are selected the staff member can type /ag create [block] [name] the [block] lets the staff member set what block will be filled in that area, and name lets the staff member set what that generator will be. when that generator has been created it will fill that block in there for the player to mine. (it would act like a repeating command block constantly filling that area with the block, don't actually add a command block) please add a /ag reload command to reload the plugin as well as a /ag delete [name] to delete that generator to not make it work. please also add a /ag list command that will list all of the generators by thir /ag pos1 command location all of the commands i have listed will need the generators.admin permission please. the name of the plugin is Generators+ and please make things like the prefix customisable in the config file. when a user mines a ore from a genrator please give them one XP point

Kodari AI
KodariJul 5 at 11:06 pm 1
GeneratorsPlus
A Minecraft 1.21.1 plugin that creates persistent block generators. Admins define two corner positions with /ag pos1 and /ag pos2, then create a generator with /ag create [block] [name]. The generator continuously refills the defined area with the specified block. Players mining from generators earn 1 XP per block. Features /ag delete, /ag list, and /ag reload commands. All commands require the generators.admin permission. Configurable prefix and fill interval.

Creating the Generators+ plugin with 10 files

Creating the Generators+ plugin — 9 files total.

GeneratorsPlus
A Minecraft 1.21.1 plugin that creates persistent block generators. Admins define two corner positions with /ag pos1 and /ag pos2, then create a generator with /ag create [block] [name]. The generator continuously refills the defined area with the specified block. Players mining from generator blocks earn 1 XP per break. Features /ag delete, /ag list, and /ag reload commands. All commands require the generators.admin permission. Customizable prefix and fill interval in config.yml.
cjcool3003

can you please edit this plugin to instead of having /ag pos1 and /ag pos2 can you please add a /ag wand command which requires the generators.admin permission and when that command is typed the user gets a stone axe with custom model data of 1003, when the user left clicks on a block whilest holding the tool it selects the first position, when that block is broken please regenerate it. when the user right clicks whilest holding the want it sets the second position, just like world edit! when both positions are selected you can create a generator.

Kodari AI
KodariJul 5 at 11:20 pm 1

Now I’ll update the AdminCommand.java to replace pos1/pos2 with the wand command, update help, and create a WandListener.java.

Now creating the WandListener to handle left-click/right-click with the wand tool.

Now register it in the main class.

All done. Here’s what changed:

  • GeneratorsPlus.java — Added selections map (UUID→Selection) and Selection inner class with getters/setters. Registered WandListener.

  • AdminCommand.java — Replaced /ag pos1 and /ag pos2 with /ag wand (gives stone axe with custom model data 1003). /ag create now reads selections from the plugin’s map.

  • WandListener.java (new) — Left-click on a block with the wand → sets pos1 + regenerates the broken block. Right-click → sets pos2. Captain’s messages show position coordinates.

cjcool3003

can you please speed up how long it takes for a block to regenerate to be instantly as well as when a player mines a block the sound entity.player.levelup plays and the item that the block drops (eg dirt from dirt) goes straight into the players inventory instead of dropping on the ground. when the players inventory is full please do not put the items into the players inventory and just let them drop on the ground like normal

Kodari AI
KodariJul 5 at 11:35 pm 2

Now update BlockListener — instant regen, sound, item-to-inventory, and change config default fill-interval to 1

All changes applied. Here’s what was done:

GeneratorManager.java — Added getGeneratorAt(Location) returning the Generator directly (used by BlockListener). Removed the chunk-load check from fillAll() so blocks fill regardless of loaded chunks.

BlockListener.java — Complete rewrite:

  • Instantly replaces the block in the same event (setType right after break)

  • Sets setDropItems(false) and setExpToDrop(0) to handle drops manually

  • Gives 1 XP to the player

  • Plays ENTITY_PLAYER_LEVELUP sound

  • Gets block drops with the player’s held item, inserts into inventory if there’s room, otherwise drops on ground

GeneratorsPlus.java — Fill task runs every 1 tick (safety net, block is already replaced in the break event)

config.yml — fill-interval default changed to 1

Result: mining a generator block immediately refills it, gives 1 XP, plays the levelup sound, and puts the drop into your inventory (or drops it on the ground if your inventory is full).

cjcool3003

can you please add to the plugin so when a player increases an xp level (eg 1-2) a random command is peformed, commands can be managed through the config file or through /ag command [add/remove] [percentage] [command] please calculate the overall percentage so if it is over 100 minus however much from all the command rarities to make it be 100, when the command is peformed please send a message to the player saying "You just received a crate key [percent-chance" the [percent-chance] is the percentage that you could have gotten it, this message is customisable in the config. please make the commands be executed as console commands

Kodari AI
KodariJul 5 at 11:46 pm 2

Let me read the remaining files I haven’t seen yet, then implement the feature

Now I have full context. Let me implement the level-up command system

cjcool3003

can you please add to the plugin a command reward system so when a playermines 10 blocks a random command is peformed, after that command is peformed the player needs to mine an additional 10 blocks and then another 10 (so it goes like 10, 20, 30, 40, 50, 60 blocks they need to mine) commands can be managed through the config file or through /block-reward command [add/remove] [percentage] [command] please calculate the overall percentage so if it is over 100 minus however much from all the command rarities to make it be 100. each command is given an ID starting at 1 and going up, this is used for further customisation. when the command is peformed please send a message based on the reward to the player saying "You just received a crate key [percent-chance]" the [percent-chance] is the percentage that you could have gotten it, this message is customisable in the config as well as with /block-reward message [id] [name]. please make the commands be executed as console commands, all commands need the blockreward.admin permission to be used but recieving the rewards doesnt need a permission. please also use placeholder API for placeholder formatting for names ect. please also add a reset command which resets the players bloks mined to 0 so they only have to mine 10 and so on. please make it be /block-reward resetplayer [player]. when a player receives a command reward please play the sound entity.firework_rocket.launch to the player (all commands are to be console commands)

Kodari AI
KodariJul 6 at 12:33 am 2

I have full context. Let me implement the block-reward system — 5 new/modified files.

Now let me create the new files and update the existing ones. I’ll batch all the modifications.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
settings.gradle
Code
12 682
src/main/java/com/generatorsplus/GeneratorsPlus.java
package com.generatorsplus;

import com.generatorsplus.commands.AdminCommand;
import com.generatorsplus.listeners.BlockListener;
import com.generatorsplus.listeners.LevelUpListener;
import com.generatorsplus.listeners.WandListener;
import lombok.Getter;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.plugin.java.JavaPlugin;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;

public final class GeneratorsPlus extends JavaPlugin {

    @Getter
    private GeneratorManager generatorManager;
    @Getter
    private String prefix;
    @Getter
    private final Map<UUID, Selection> selections = new HashMap<>();
    @Getter
    private List<LevelUpEntry> levelUpEntries = new ArrayList<>();
    private int fillTaskId = -1;

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

        this.generatorManager = new GeneratorManager(this);
        generatorManager.loadGenerators();

        getCommand("ag").setExecutor(new AdminCommand(this));
        Bukkit.getPluginManager().registerEvents(new BlockListener(this), this);
        Bukkit.getPluginManager().registerEvents(new WandListener(this), this);
        Bukkit.getPluginManager().registerEvents(new LevelUpListener(this), this);

        startFillTask();

        getLogger().info("Generators+ enabled!");
    }

    @Override
    public void onDisable() {
        if (fillTaskId != -1) {
            Bukkit.getScheduler().cancelTask(fillTaskId);
        }
        if (generatorManager != null) {
            generatorManager.saveGenerators();
        }
        getLogger().info("Generators+ disabled!");
    }

    public void reloadConfigValues() {
        reloadConfig();
        prefix = getConfig().getString("prefix", "&8[&aGenerators+&8] &r");
        loadLevelUpEntries();
    }

    private void loadLevelUpEntries() {
        levelUpEntries.clear();
        List<String> list = getConfig().getStringList("level-up-commands");
        for (String entry : list) {
            String[] parts = entry.split(" ", 2);
            if (parts.length == 2) {
                try {
                    int chance = Integer.parseInt(parts[0]);
                    levelUpEntries.add(new LevelUpEntry(chance, parts[1]));
                } catch (NumberFormatException ignored) {
                }
            }
        }
    }

    public void saveLevelUpEntries() {
        List<String> lines = new ArrayList<>();
        for (LevelUpEntry entry : levelUpEntries) {
            lines.add(entry.getChance() + " " + entry.getCommand());
        }
        getConfig().set("level-up-commands", lines);
        saveConfig();
    }

    public void startFillTask() {
        if (fillTaskId != -1) {
            Bukkit.getScheduler().cancelTask(fillTaskId);
        }
        fillTaskId = Bukkit.getScheduler().scheduleSyncRepeatingTask(this,
                () -> generatorManager.fillAll(), 1L, 1L);
    }

    public String color(String message) {
        return ChatColor.translateAlternateColorCodes('&', message);
    }

    public static class Selection {
        private Location pos1;
        private Location pos2;

        public Location getPos1() { return pos1; }
        public void setPos1(Location pos1) { this.pos1 = pos1; }
        public Location getPos2() { return pos2; }
        public void setPos2(Location pos2) { this.pos2 = pos2; }
    }
}