tatwanshop
📎 1 file 3,567 chars
📄
pasted-code-1786997063585.txt
txt 163 lines
▶
Create a Minecraft **Paper/Spigot Java plugin** called **AutoMine**.

## `/automine`

Add the command:

`/automine`

When a player runs `/automine`, toggle AutoMine ON/OFF.

When AutoMine is ON, the plugin automatically mines the block the player is looking at.

## ALL TOOLS

AutoMine must work with **every Minecraft tool**, including:

* Wooden tools
* Stone tools
* Iron tools
* Golden tools
* Diamond tools
* Netherite tools
* Pickaxes
* Axes
* Shovels
* Hoes
* Shears
* Any other current or future tool supported by the Minecraft/Paper API

The plugin must use the **item currently held in the player's main hand**.

It must respect:

* Tool durability
* Mining speed
* Efficiency
* Fortune
* Silk Touch
* Unbreaking
* Correct tool requirements
* Normal Minecraft block-breaking behavior

## ALL BLOCKS

Allow AutoMine to mine **ALL blocks that the player can normally break**.

There must be **NO block whitelist** and **NO block blacklist**.

Do not create an `allowed-blocks` section.

The plugin should automatically check whether the targeted block can normally be broken.

Examples include:

* Stone
* Cobblestone
* Deepslate
* Ores
* Dirt
* Grass
* Sand
* Gravel
* Wood/logs
* Leaves
* Glass
* Nether blocks
* End blocks
* Crops
* Concrete
* Terracotta
* Any other normally breakable Minecraft block

Do not allow AutoMine to bypass blocks that Minecraft normally prevents the player from breaking.

## NORMAL MINECRAFT MECHANICS

AutoMine must:

* Give normal block drops.
* Apply Fortune and Silk Touch correctly.
* Damage the player's tool normally.
* Break blocks according to the player's tool and mining rules.
* Trigger the normal Bukkit/Paper `BlockBreakEvent`.
* Respect WorldGuard and other protection plugins.
* Stop if another plugin cancels the block-break event.
* Respect the player's game mode and permissions.
* Never bypass protected regions.
* Never mine through walls.
* Never mine blocks outside the configured reach distance.
* Only mine the block the player is actually targeting.

## CONFIG

Use:

```yaml
mine-delay-ticks: 5
max-distance: 5
require-tool: True

messages:
  enabled: "&aAutoMine enabled!"
  disabled: "&cAutoMine disabled!"
  no-permission: "&cYou don't have permission to use AutoMine."
```

Do NOT add an `allowed-blocks` list.

## COMMANDS

`/automine` — Toggle AutoMine.

`/automine reload` — Reload the configuration.

## PERMISSIONS

`automine.use` — Use `/automine`.

`automine.admin` — Use `/automine reload`.

## AUTO-DISABLE

Disable AutoMine when:

* The player logs out.
* The player dies.
* The player changes worlds.
* The player changes to an inappropriate game mode.
* The player manually runs `/automine` again.

## PERFORMANCE

Make the plugin optimized for a multiplayer BoxPvP server.

* Do not create excessive tasks.
* Do not cause server lag.
* Use scheduled tasks efficiently.
* Do not instantly destroy huge numbers of blocks.
* Use the configurable `mine-delay-ticks`.
* Properly cancel tasks when AutoMine is disabled.

## PROJECT REQUIREMENTS

Use:

* Java 21
* Latest stable Paper API
* Maven

Provide:

1. Complete `pom.xml`
2. Complete `plugin.yml`
3. Complete `config.yml`
4. All Java source files
5. Complete folder structure
6. Installation instructions
7. Build instructions using Maven

Make the code clean, optimized, and ready to compile and install on a Paper server.

Do not use NMS unless absolutely necessary.
Kodari AI
KodariAug 17 at 8:06 pm 2
AutoMine
AutoMine is a Paper/Spigot plugin that toggles automatic mining of the block a player is looking at. It supports every Minecraft tool and respects all normal block-breaking mechanics including durability, mining speed, Fortune, Silk Touch, Unbreaking, and correct tool requirements. The plugin has no block whitelist or blacklist, automatically checking breakability through normal Bukkit events. It triggers BlockBreakEvent, respects protection plugins, and stops if events are cancelled. Features configurable mine delay and distance, auto-disable on death, logout, world change, or game mode change, and includes /automine and /automine reload commands with permission checks.
  1. Create the Maven project and Paper plugin metadata.

  2. Implement the toggle command, configuration, and permissions.

  3. Implement a single efficient mining scheduler with ray-traced targeting and normal Player#breakBlock mechanics.

  4. Add lifecycle listeners and provide build/install instructions.

Implemented the AutoMine Paper plugin.

Project structure

Plain Text
AutoMine/
├── pom.xml
└── src/
    └── main/
        ├── java/
        │   └── com/kodari/automine/
        │       ├── AutoMineCommand.java
        │       ├── AutoMineListener.java
        │       ├── AutoMineManager.java
        │       └── AutoMinePlugin.java
        └── resources/
            ├── config.yml
            └── plugin.yml

Features

  • /automine toggles AutoMine.

  • /automine reload reloads configuration.

  • Uses the player’s main-hand item.

  • Supports all tools without material whitelists.

  • Uses ray tracing to prevent mining through walls or beyond reach.

  • Uses Player#breakBlock for normal block-breaking behavior, drops, enchantments, durability, and protection-plugin events.

  • Uses one shared repeating task for multiplayer efficiency.

  • Stops for logout, death, world changes, Creative, and Spectator mode.

  • Supports automine.use and automine.admin.

  • No allowed-blocks configuration section.

Build

Shell
mvn clean package

The compiled plugin will be located at:

Plain Text
target/automine-1.0.0.jar

Installation

  1. Build the project with Maven.

  2. Copy target/automine-1.0.0.jar into the server’s plugins directory.

  3. Start or restart the Paper server.

  4. Grant permissions as needed:

Plain Text
automine.use
automine.admin

Configuration is stored in:

Plain Text
plugins/AutoMine/config.yml
Kodari can make mistakes. Review important code before using.
Files
src
pom.xml
Code
7 347
src/main/java/com/kodari/automine/AutoMinePlugin.java
package com.kodari.automine;

import org.bukkit.Bukkit;
import org.bukkit.command.PluginCommand;
import org.bukkit.plugin.java.JavaPlugin;

public final class AutoMinePlugin extends JavaPlugin {

    private AutoMineManager autoMineManager;

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

        this.autoMineManager = new AutoMineManager(this);
        this.autoMineManager.start();

        Bukkit.getPluginManager().registerEvents(new AutoMineListener(autoMineManager), this);

        PluginCommand command = getCommand("automine");
        if (command != null) {
            AutoMineCommand autoMineCommand = new AutoMineCommand(this, autoMineManager);
            command.setExecutor(autoMineCommand);
            command.setTabCompleter(autoMineCommand);
        }
    }

    @Override
    public void onDisable() {
        if (autoMineManager != null) {
            autoMineManager.stop();
        }
    }

    public String message(String path) {
        String message = getConfig().getString(path, "");
        return org.bukkit.ChatColor.translateAlternateColorCodes('&', message);
    }
}