dexfvv
📎 1 file 3,480 chars
📄
pasted-code-1790265092126.txt
txt 89 lines
▶
Make me a Minecraft Paper 1.21.11 plugin for Java 21 that adds a custom Netherite Axe with a protective Pink Bubble ability.

When a player holds the custom Netherite Axe and presses SHIFT + RIGHT CLICK, create a full 360-degree protective bubble around the player.

The bubble should:

* Extend 8 blocks North, South, East and West from the player.
* Fully surround the player in every direction, including above and below, creating a completely enclosed sphere/bubble.
* Be made from Pink Stained Glass.
* Be completely unbreakable while active.
* Automatically disappear after 15 seconds.
* Restore everything correctly when it disappears. Do NOT permanently destroy or replace existing blocks.

ENDER PEARL PROTECTION IS VERY IMPORTANT:

Players must NOT be able to Ender Pearl through the bubble under any circumstances.

* Players OUTSIDE the bubble CANNOT pearl INTO the bubble.
* Players INSIDE the bubble CANNOT pearl OUTSIDE the bubble.
* Players cannot throw a pearl through the Pink Stained Glass.
* Cancel any Ender Pearl teleport if the pearl's starting position and destination are on opposite sides of the bubble.
* Do not rely only on the Pink Stained Glass physically blocking the pearl. The plugin itself must detect and cancel attempted pearl teleports across the bubble boundary.
* This protection must work across the ENTIRE 360-degree bubble, including the sides, top and bottom.
* Make sure common pearl clipping/pearl glitching methods cannot be used to bypass the bubble.
* A player outside the bubble should still be able to pearl somewhere else outside the bubble.
* A player inside the bubble can pearl to another valid position inside the same bubble, but NEVER through or outside its boundary.

IMPORTANT ACTIVATION:

The ability must ONLY activate when the player is SNEAKING/SHIFTING AND RIGHT CLICKS with the custom axe.

Normal right clicking without SHIFT must NOT activate the ability. This is important so players can still use shields normally while holding the axe.

COOLDOWN:

The ability has a 45-second cooldown per player.

While holding the custom axe, continuously display the ability status in the action bar.

When ready:

&dʀᴇᴀᴅʏ

When on cooldown, show the remaining cooldown in pink, for example:

&d𝟦𝟢ꜱ

Update it every second until the ability is ready again.

CUSTOM AXE:

The ability must ONLY work with the special custom Netherite Axe. Normal Netherite Axes must never activate it.

Add:

/givebubbleaxe 

ONLY server operators (OPs) can use this command.

CONFIG.YML:

Make these configurable:

* Cooldown: 45 seconds
* Bubble duration: 15 seconds
* Bubble radius/range: 8 blocks
* Bubble material: PINK_STAINED_GLASS
* Ready action bar message
* Cooldown action bar format
* Activation messages
* Cooldown messages
* Other player-facing messages

Support Minecraft colour codes such as &d in configurable messages.

IMPORTANT:

Optimize the plugin so the bubble does not cause server lag.

Multiple players must be able to activate separate bubbles at the same time.

If bubbles overlap, one bubble expiring must NOT destroy blocks belonging to another active bubble.

Only remove/restore blocks belonging to the bubble that expired.

The bubble must never permanently damage the world.

Provide the COMPLETE working plugin source code, plugin.yml, config.yml, pom.xml and instructions for compiling it into a working JAR.
Kodari AI
KodariSep 24 at 3:56 pm 16
PinkBubbleAxe
A Paper 1.21 plugin adding a custom Netherite Axe with a protective Pink Stained Glass bubble ability. Sneak-right-click activates a 360-degree bubble (8 blocks radius) that fully encloses the player for 15 seconds. The bubble blocks all Ender Pearl teleportation across its boundary via plugin-level detection, preventing pearl glitching. Features a 45-second per-player cooldown with live action bar status, operator-only /givebubbleaxe command, and fully configurable cooldown, duration, radius, material, and messages via config.yml. Optimized block tracking ensures overlapping bubbles never interfere and expired bubbles restore the world perfectly without permanent damage.

I’ll build the axe ability, shared bubble protection and restoration, then add the configuration, Maven build, and compile instructions.

Created the complete Paper 1.21.11 plugin source, plugin.yml, config.yml, pom.xml, and build instructions.

Build with JDK 21 using mvn clean package, then install target/pinkbubble-1.0.0-jar-with-dependencies.jar. An operator can give the custom axe with /givebubbleaxe <player>. Sneak and right-click to activate the bubble; normal right-clicking does not activate it.

dexfvv

fix it because it never makes the bubble and showes nothing in the chat and make it so it says theres not enough space here in the action bar instead of the chat and make it make a villager no noise when it doesnt work

Kodari AI
KodariSep 24 at 4:08 pm 4
  1. Trace why activation isn’t creating a bubble.

  2. Put the no-space warning in the action bar and play the villager “no” sound when activation fails.

Two things are blocking the feedback: the interaction listener skips some right-click-air events, and the bubble refuses to form when its lower shell meets ordinary ground. I’ll fix both without replacing terrain blocks, then move the no-space warning to the action bar.

Fixed the activation path so sneak-right-click is handled even when Paper marks the interaction as cancelled. The bubble can now form at ground level without replacing solid terrain; it still refuses to overwrite passable blocks such as plants.

When there isn’t enough space, the warning appears in the action bar instead of chat and plays the villager “no” sound. Failed cooldown, already-active, and storage attempts also play that sound. Action-bar colour codes now render correctly.

Rebuild the JAR and restart the server.

dexfvv

fix it because i told you to add the messages to the action bar it should not be in the chat make it like you can use this in seconds in the action bar that message should not even be a thing since theres already a cooldown in the action bar and make it so messages are in action bar not in chat and make sure we can customize the messages

Kodari AI
KodariSep 24 at 4:13 pm 3

I found the remaining chat messages in the shared message method. I’ll route player messages to the action bar, keep console feedback in text, and remove the duplicate cooldown message so it uses the existing countdown.

Player-facing messages now appear in the action bar, not chat. Clicking during cooldown shows the existing configurable countdown instead of a separate “wait” message. The no-space warning and other feedback use the configurable messages entries; console command feedback remains in text.

Rebuild and restart the server to use the changes.

dexfvv

make the bubble a little bit smaller like 1 block smaller and make sure people cant break the glass double check that

Kodari AI
KodariSep 24 at 4:15 pm 3
  1. Reduce the default bubble radius by one block.

  2. Check and enforce protection against breaking active bubble glass.

The default bubble radius is now 7 blocks, down from 8. I also checked the glass protection: breaking active bubble blocks was already cancelled, and damage to those blocks is now cancelled too.

If your server already has a config.yml, set bubble-radius: 7 there—the new default won’t overwrite an existing config. Then rebuild the JAR and restart the server.

dexfvv

add a reload command too

Kodari AI
KodariSep 24 at 4:20 pm 4

The bubble manager keeps its block material in memory, so a reload must not switch materials while a bubble is active. I’ll add an OP-only /bubbleaxe reload command that refreshes settings and messages, with a configurable action-bar warning if a material change has to wait.

Added the OP-only /bubbleaxe reload command. It reloads the cooldown, duration, radius, material, and customizable messages without restarting the server.

Feedback appears in the action bar for players. If you change the bubble material while bubbles are active, the command asks you to wait until they expire so restoration stays safe. Rebuild and install the updated JAR to use the new command.

dexfvv

fix it cause custom prefixes like for messaages and stuff dont work

Kodari AI
KodariSep 24 at 4:24 pm 2

The action-bar messages currently read each message directly, so a configured prefix is never applied. I’ll add a configurable messages.prefix, apply it to player messages, and support {prefix} in the action-bar status formats.

Fixed configurable prefixes. Set messages.prefix in config.yml; it now appears before player-facing messages in the action bar. You can also place {prefix} in an individual message, the ready or cooldown status, or the axe name and lore to control its position.

Rebuild the JAR and run /bubbleaxe reload after editing the config.

dexfvv

its still doesnt show the colours its just #FF54A7

Kodari AI
KodariSep 24 at 4:29 pm 2

The colour formatter handles &d but treats #FF54A7 as plain text. I’ll make it parse hex colours in prefixes, action-bar messages, and the axe name and lore.

Fixed hex colours: #FF54A7 now renders as a colour instead of appearing as text. This applies to configurable prefixes, action-bar messages, and the axe name and lore; &d codes still work.

Rebuild and replace the JAR, restart the server, then use /bubbleaxe reload after changing colours in config.yml.

dexfvv

make it not work in the world named spawn

Kodari AI
KodariSep 24 at 4:50 pm 2

The bubble ability now won’t activate in the world named spawn. Attempting it there shows a customizable action-bar message and plays the villager “no” sound; the ready/cooldown status is also hidden there.

Rebuild and replace the JAR, then restart the server. You can customize messages.disabled-world in config.yml.

dexfvv

make it so when in dimension spawn the axe shouldnt work and it should say in the action bar this ability disabled prefix also make it so i dont need to delete the old config for this to apply since i made the best settings for it this is the prefix for disabled &#E43A96&lᴀ&#E6479D&lʙ&#E854A4&lɪ&#E961AB&lʟ&#EB6FB2&lɪ&#ED7CB9&lᴛ&#EF89C0&lʏ &#F2A3CE&lᴅ&#F4B0D5&lɪ&#F6BDDC&ls&#F8CAE3&lᴀ&#FAD8EA&lʙ&#FBE5F1&lʟ&#FDF2F8&lᴇ&#FFFFFF&lᴅ

Kodari AI
KodariSep 26 at 12:06 pm 4
  1. Check the current spawn restriction and make its feedback use your disabled-ability prefix.

  2. Add the new defaults without overwriting your existing config settings.

The bubble axe now refuses to activate in the spawn world and shows ABILITY DISABLED in your supplied gradient, followed by “This ability is disabled here.” The feedback stays in the action bar, and the villager “no” sound still plays.

Your existing config does not need to be deleted. The new messages.disabled-world-prefix and messages.disabled-world-action-bar defaults work even when those keys are missing from your saved config. Add them only if you want to customize them, then run /bubbleaxe reload.

Kodari can make mistakes. Review important code before using.
Files
src
pom.xml
README.md
Code
7 750
src/main/java/com/kodari/pinkbubble/PinkBubblePlugin.java
package com.kodari.pinkbubble;

import com.cryptomorin.xseries.XMaterial;
import com.cryptomorin.xseries.XSound;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.NamespacedKey;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.persistence.PersistentDataType;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.configuration.file.YamlConfiguration;

import java.io.File;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public final class PinkBubblePlugin extends JavaPlugin {
    private static final Pattern HEX_COLOR = Pattern.compile("(?i)&?#([0-9a-f]{6})");
    private final Map<UUID, Long> cooldowns = new HashMap<>();
    private final Map<UUID, Long> actionBarWarnings = new HashMap<>();
    private NamespacedKey axeKey;
    private BubbleManager bubbles;
    private Material axeMaterial;
    private int cooldownSeconds;
    private int durationSeconds;
    private int radius;

    @Override
    public void onEnable() {
        saveDefaultConfig();
        axeKey = new NamespacedKey(this, "bubble_axe");
        axeMaterial = XMaterial.matchXMaterial("NETHERITE_AXE").map(XMaterial::parseMaterial).orElseThrow();
        Material bubbleMaterial = resolveBubbleMaterial(getConfig().getString("bubble-material", "PINK_STAINED_GLASS"));
        if (bubbleMaterial == null) {
            getLogger().severe("bubble-material must be a solid, non-falling block.");
            getServer().getPluginManager().disablePlugin(this);
            return;
        }
        cooldownSeconds = Math.max(1, getConfig().getInt("cooldown-seconds", 45));
        durationSeconds = Math.max(1, getConfig().getInt("bubble-duration-seconds", 15));
        radius = Math.max(2, Math.min(16, getConfig().getInt("bubble-radius", 7)));
        try {
            bubbles = new BubbleManager(this, bubbleMaterial);
        } catch (IOException | RuntimeException ex) {
            getLogger().severe("Could not recover bubble journal; refusing to start to protect world blocks: " + ex.getMessage());
            getServer().getPluginManager().disablePlugin(this);
            return;
        }
        getServer().getPluginManager().registerEvents(new BubbleListener(this, bubbles), this);
        Bukkit.getScheduler().runTaskTimer(this, () -> {
            long now = System.currentTimeMillis();
            for (Player player : Bukkit.getOnlinePlayers()) {
                if (!isAxe(player.getInventory().getItemInMainHand())) continue;
                if (actionBarWarnings.getOrDefault(player.getUniqueId(), 0L) > now) continue;
                if (player.getWorld().getName().equals("spawn")) continue;
                showStatus(player, now);
            }
            cooldowns.entrySet().removeIf(entry -> entry.getValue() <= now);
            actionBarWarnings.entrySet().removeIf(entry -> entry.getValue() <= now);
        }, 0L, 20L);
    }

    @Override
    public void onDisable() {
        if (bubbles != null) bubbles.shutdown();
    }

    private Material resolveBubbleMaterial(String name) {
        Material material = XMaterial.matchXMaterial(name).map(XMaterial::parseMaterial)
                .filter(Material::isBlock).orElse(null);
        return material != null && material.isSolid() && !material.hasGravity() ? material : null;
    }

    boolean isAxe(ItemStack item) {
        if (item == null || item.getType() != axeMaterial || !item.hasItemMeta()) return false;
        Byte tag = item.getItemMeta().getPersistentDataContainer().get(axeKey, PersistentDataType.BYTE);
        return tag != null && tag == (byte) 1;
    }

    void activate(Player player) {
        if (player.getWorld().getName().equals("spawn")) {
            String text = getConfig().getString("messages.disabled-world-prefix", "")
                    + getConfig().getString("messages.disabled-world-action-bar", " &8» &cThis ability is disabled here.");
            player.sendActionBar(LegacyComponentSerializer.legacySection().deserialize(color(text)));
            actionBarWarnings.put(player.getUniqueId(), System.currentTimeMillis() + 2000L);
            failed(player);
            return;
        }
        long now = System.currentTimeMillis();
        long remaining = Math.max(0, (cooldowns.getOrDefault(player.getUniqueId(), 0L) - now + 999) / 1000);
        if (remaining > 0) {
            actionBarWarnings.remove(player.getUniqueId());
            showStatus(player, now);
            failed(player);
            return;
        }
        BubbleManager.Result result = bubbles.activate(player, radius, durationSeconds);
        switch (result) {
            case CREATED -> {
                cooldowns.put(player.getUniqueId(), now + cooldownSeconds * 1000L);
                message(player, "activated", "&dYour protective bubble is active!");
            }
            case ALREADY_ACTIVE -> {
                message(player, "already-active", "&dYou already have an active bubble.");
                failed(player);
            }
            case OBSTRUCTED -> {
                message(player, "obstructed", "&dThere is not enough space here.");
                failed(player);
            }
            case STORAGE_ERROR -> {
                message(player, "storage-error", "&cCould not safely save bubble blocks. Try again later.");
                failed(player);
            }
        }
    }

    private void failed(Player player) {
        XSound.matchXSound("ENTITY_VILLAGER_NO").ifPresent(sound -> sound.play(player));
    }

    void expired(UUID owner) {
        Player player = Bukkit.getPlayer(owner);
        if (player != null) message(player, "expired", "&dYour protective bubble has disappeared.");
    }

    void message(CommandSender sender, String key, String fallback, String... replacements) {
        String text = getConfig().getString("messages." + key, fallback);
        for (int i = 0; i < replacements.length; i += 2) text = text.replace(replacements[i], replacements[i + 1]);
        text = withPrefix(text, true);
        if (sender instanceof Player player) {
            player.sendActionBar(LegacyComponentSerializer.legacySection().deserialize(color(text)));
            actionBarWarnings.put(player.getUniqueId(), System.currentTimeMillis() + 2000L);
        } else {
            sender.sendMessage(color(text));
        }
    }

    private void showStatus(Player player, long now) {
        long remaining = Math.max(0, (cooldowns.getOrDefault(player.getUniqueId(), 0L) - now + 999) / 1000);
        String text = remaining == 0 ? getConfig().getString("ready-action-bar", "&dʀᴇᴀᴅʏ")
                : getConfig().getString("cooldown-action-bar", "&d{seconds}ꜱ")
                .replace("{seconds}", String.valueOf(remaining));
        player.sendActionBar(LegacyComponentSerializer.legacySection().deserialize(color(withPrefix(text, false))));
    }

    private String withPrefix(String text, boolean prepend) {
        String prefix = getConfig().getString("messages.prefix", "");
        if (text.contains("{prefix}")) return text.replace("{prefix}", prefix);
        return prepend ? prefix + text : text;
    }

    private String color(String text) {
        Matcher matcher = HEX_COLOR.matcher(text);
        StringBuffer result = new StringBuffer();
        while (matcher.find()) {
            StringBuilder code = new StringBuilder("&x");
            for (char digit : matcher.group(1).toCharArray()) code.append('&').append(digit);
            matcher.appendReplacement(result, code.toString());
        }
        matcher.appendTail(result);
        return ChatColor.translateAlternateColorCodes('&', result.toString());
    }

    private ItemStack makeAxe() {
        ItemStack axe = new ItemStack(axeMaterial);
        ItemMeta meta = axe.getItemMeta();
        meta.setDisplayName(color(withPrefix(getConfig().getString("axe-name", "&d&lPink Bubble Axe"), false)));
        List<String> lore = getConfig().getStringList("axe-lore");
        meta.setLore(lore.stream().map(line -> color(withPrefix(line, false))).toList());
        meta.getPersistentDataContainer().set(axeKey, PersistentDataType.BYTE, (byte) 1);
        axe.setItemMeta(meta);
        return axe;
    }

    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        if (command.getName().equalsIgnoreCase("bubbleaxe")) {
            if (!sender.isOp()) {
                message(sender, "no-permission", "&cOnly server operators can use this command.");
                return true;
            }
            if (args.length != 1 || !args[0].equalsIgnoreCase("reload")) {
                message(sender, "reload-usage", "&dUsage: /bubbleaxe reload");
                return true;
            }
            Material newMaterial = resolveBubbleMaterial(YamlConfiguration.loadConfiguration(