macekeeperr
📎 1 file 3,567 chars
📄
pasted-code-1782233911113.txt
txt 264 lines
▶
Create a complete Minecraft Paper 1.21.4 plugin called **OpTools**.

Purpose:
A utility plugin designed exclusively for OP players. Every feature only affects OP players who choose to use it. This is intended for staff, content creators, recording, testing, and administration.

Requirements:

* Java 21
* Maven
* Paper 1.21.4
* Fully compilable
* Generate all files
* Generate plugin.yml
* Generate pom.xml
* Generate config.yml
* No TODOs
* No placeholders

Command:

* /optools

Permission:

* optools.admin
* default: op

INVENTORY GUI:

* 27 slots
* Title: §bOP Tools

Features:

Slot 10:
Recording Mode Toggle

When enabled:

* Hide all chat messages.
* Hide command feedback.
* Hide join messages.
* Hide quit messages.
* Hide advancement messages.
* Hide broadcast messages.
* Hide private messages.
* Hide plugin messages.
* ONLY show death messages.
* Persist until toggled off.

Slot 11:
Nick OP

Opens an anvil INVENTORY GUI.

Player enters nickname.

Changes:

* Chat name
* Tab list name
* Name above head

Supports colors.

Persists until removed.

Slot 12:
Remove Nick

Restores original name.

Slot 13:
Build Lock Toggle

When enabled:

* Player cannot break blocks.
* Player cannot place blocks.
* Inventory still works.
* Commands still work.
* Movement still works.
* NOT Adventure Mode.
* Custom event-based protection.

Slot 14:
Vanish Toggle

When enabled:

* Hidden from non-op players.
* Hidden from tab list.
* Hidden from player count.
* Join/quit silently.

Slot 15:
Staff Fly Toggle

* Unlimited flight.
* No fall damage while active.

Slot 16:
God Mode Toggle

* No damage.
* No fire.
* No fall damage.
* No drowning.

Slot 17:
Night Vision Toggle

Permanent night vision until disabled.

Slot 18:
Speed Toggle

Gives Speed II until disabled.

Slot 19:
Instant Heal

Fully heal.
Remove fire.
Fill hunger.

Slot 20:
Teleport To Random OP

Randomly teleports to another online OP.

Slot 21:
Staff Compass

Compass tracks nearest OP.

Updates every second.

Slot 22:
Silent Chest Mode

Allows opening containers without sounds.

Slot 23:
Entity Cleanup

Removes:

* Dropped items
* Arrows
* XP orbs

Only executable by OP.

Slot 24:
OP Chat Toggle

Creates private OP-only chat.

Messages start with:
!

Example:
!hello

Only OPs receive message.

Slot 25:
AFK Mode

Adds:
[AFK]

to nickname.

Disables join/quit notifications.

Slot 26:
Player Inspector

Opens INVENTORY GUI showing:

* Health
* Food
* XP
* Gamemode
* Coordinates
* Ping

Additional Systems:

Nickname System:

* Store nicknames in data.yml.
* Restore on rejoin.

Recording Mode:

* Save state.
* Restore after reconnect.

Build Lock:

* Prevent:

  * Block break
  * Block place
  * Bucket use

Vanish:

* Works with reconnects.
* Reapply automatically.

Configurable:

config.yml

Messages:

* Prefix
* Nick messages
* Vanish messages
* Recording messages

INVENTORY GUI:

* Title
* Item names

Sounds:

* Success
* Error
* Toggle

Architecture:

Main:
OpTools

Managers:
NickManager
RecordingManager
VanishManager
BuildLockManager
StaffChatManager

Listeners:
ChatListener
GUIListener
PlayerListener
ProtectionListener

Utilities:
ItemBuilder
ConfigUtil
MessageUtil

Generate complete source code for all files.
Generate full Maven project tree.
Generate code that compiles immediately.
Output every file.
Kodari AI
KodariJun 23 at 5:15 pm 86
OpTools
A utility plugin for OP players featuring a 27-slot GUI with 17 tools: Recording Mode (filters chat/join/quit), Nickname with anvil input, Build Lock, Vanish, Staff Fly, God Mode, Night Vision, Speed, Instant Heal, Random OP Teleport, Staff Compass, Silent Chest, Entity Cleanup, OP Chat, AFK Mode, and Player Inspector. Nicknames, vanish, and recording state persist across reconnects via data.yml. Built for Paper 1.21.4 with full Adventure API.

24 files generated. Here’s a summary of every system:

Slot
Feature
Notes
10
Recording Mode
Removes player from
AsyncChatEvent
viewers; filters join/quit messages per-player
11
Nick OP
Opens virtual anvil;
PrepareAnvilEvent
captures typed text; click slot 2 to confirm
12
Remove Nick
Clears data.yml nick, restores original name + scoreboard team
13
Build Lock
BlockBreak/Place/BucketEmpty/Fill
events cancelled via
ProtectionListener
14
Vanish
hidePlayer
for all non-OPs; silent join/quit; restored on reconnect
15
Staff Fly
setAllowFlight(true)
+ fall damage cancelled in
EntityDamageEvent
16
God Mode
All
EntityDamageEvent
cancelled while active
17
Night Vision
PotionEffectType.NIGHT_VISION
with
-1
(infinite) duration
18
Speed II
PotionEffectType.SPEED
amplifier 1 with infinite duration
19
Instant Heal
Full heal, saturation, fire ticks cleared
20
Random OP TP
Picks from online OPs excluding self
21
Staff Compass
StaffCompassTask
updates
setCompassTarget
every 20 ticks
22
Silent Chest
Cancels
PlayerInteractEvent
on containers → manual
openInventory
23
Entity Cleanup
Removes
Item
,
Arrow
,
ExperienceOrb
across all worlds
24
OP Chat
!
prefix in
AsyncChatEvent
→ broadcast only to online OPs
25
AFK Mode
Prepends
[AFK]
to display/tab name; suppresses join/quit
26
Player Inspector
54-slot GUI with player skulls + health/food/XP/gamemode/coords/ping in lore

Persistence (data.yml): nick, vanish state, recording state — all restored on rejoin. All other states (god mode, fly, night vision, etc.) are in-memory and reset on disconnect.

Kodari can make mistakes. Review important code before using.
Files
src
pom.xml
Code
24 1,716
src/main/java/com/optools/OpTools.java
package com.optools;

import com.optools.inventory.gui.GUIListener;
import com.optools.inventory.gui.GUIManager;
import com.optools.inventory.impl.OpToolsGUI;
import com.optools.listeners.ChatListener;
import com.optools.listeners.PlayerListener;
import com.optools.listeners.ProtectionListener;
import com.optools.managers.BuildLockManager;
import com.optools.managers.NickManager;
import com.optools.managers.PlayerStateManager;
import com.optools.managers.RecordingManager;
import com.optools.managers.StaffChatManager;
import com.optools.managers.VanishManager;
import com.optools.tasks.StaffCompassTask;
import com.optools.util.ConfigUtil;
import com.optools.util.MessageUtil;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;

import java.io.File;
import java.io.IOException;

public class OpTools extends JavaPlugin {

    private static OpTools instance;

    private GUIManager guiManager;
    private NickManager nickManager;
    private RecordingManager recordingManager;
    private VanishManager vanishManager;
    private BuildLockManager buildLockManager;
    private StaffChatManager staffChatManager;
    private PlayerStateManager playerStateManager;
    private ConfigUtil configUtil;

    private File dataFile;
    private FileConfiguration dataConfig;

    @Override
    public void onEnable() {
        instance = this;
        saveDefaultConfig();

        dataFile = new File(getDataFolder(), "data.yml");
        if (!dataFile.exists()) {
            try {
                getDataFolder().mkdirs();
                dataFile.createNewFile();
            } catch (IOException e) {
                getLogger().severe("Could not create data.yml: " + e.getMessage());
            }
        }
        dataConfig = YamlConfiguration.loadConfiguration(dataFile);

        configUtil = new ConfigUtil(this);
        guiManager = new GUIManager();
        nickManager = new NickManager(this);
        recordingManager = new RecordingManager(this);
        vanishManager = new VanishManager(this);
        buildLockManager = new BuildLockManager();
        staffChatManager = new StaffChatManager();
        playerStateManager = new PlayerStateManager();

        getServer().getPluginManager().registerEvents(new GUIListener(guiManager), this);
        getServer().getPluginManager().registerEvents(new ChatListener(this), this);
        getServer().getPluginManager().registerEvents(new PlayerListener(this), this);
        getServer().getPluginManager().registerEvents(new ProtectionListener(this), this);

        getCommand("optools").setExecutor((sender, cmd, label, args) -> {
            if (!(sender instanceof Player player)) {
                sender.sendMessage("Only players can use this command.");
                return true;
            }
            if (!player.isOp()) {
                MessageUtil.sendRaw(player, configUtil.getPrefix() + "&cYou must be OP to use OpTools.");
                return true;
            }
            OpToolsGUI gui = new OpToolsGUI(this, player);
            guiManager.openGUI(gui, player);
            return true;
        });

        new StaffCompassTask(this).runTaskTimer(this, 0L, 20L);

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

    @Override
    public void onDisable() {
        saveDataConfig();
        getLogger().info("OpTools disabled.");
    }

    public void saveDataConfig() {
        try {
            dataConfig.save(dataFile);
        } catch (IOException e) {
            getLogger().severe("Could not save data.yml: " + e.getMessage());
        }
    }

    public FileConfiguration getDataConfig() {
        return dataConfig;
    }

    public static OpTools getInstance() {
        return instance;
    }

    public GUIManager getGuiManager() { return guiManager; }
    public NickManager getNickManager() { return nickManager; }
    public RecordingManager getRecordingManager() { return recordingManager; }
    public VanishManager getVanishManager() { return vanishManager; }
    public BuildLockManager getBuildLockManager() { return buildLockManager; }
    public StaffChatManager getStaffChatManager() { return staffChatManager; }
    public PlayerStateManager getPlayerStateManager() { return playerStateManager; }
    public ConfigUtil getConfigUtil() { return configUtil; }
}