Alex

Okay so basicly i need for minecrafts blaze rods item to be remade basicly the new name of it will be "revolver" and what it will do is on left click on a player it will shuffle their hotbar and offhand and the version will be paper 1.21.11 java

Kodari AI
KodariOct 26 at 10:59 pm 1
RevolverHotbarShuffle
This Minecraft Paper plugin transforms blaze rods into a "Revolver" item. When a player left-clicks another player while holding the Revolver, it instantly shuffles the target's hotbar slots and offhand inventory. The plugin renames the blaze rod item to "Revolver" and implements a custom interaction listener that detects left-click attacks on players, triggering a random permutation of the victim's nine hotbar slots and offhand slot. The plugin targets Paper 1.21.11 and Java, providing a fun PvP or minigame mechanic that disorients opponents by scrambling their quick-access inventory.
  1. Scaffold a Paper 1.21.11 plugin project.

  2. Add /revolver to give a blaze rod renamed Revolver.

  3. On a hit against a player with it, randomly shuffle the victim’s hotbar and offhand.

Created the Paper 1.21.11 plugin. Players can use /revolver to get a blaze rod named Revolver; hitting another player with it shuffles their hotbar and offhand. The hit still deals normal damage.

Alex

Are u making it?

Kodari AI
KodariOct 26 at 11:04 pm 1

Yes — it’s made. /revolver gives you the renamed blaze rod, and hitting a player with it shuffles their hotbar and offhand.

Alex

Where do i download it

Kodari AI
KodariOct 26 at 11:04 pm 1

Click Compile in the top bar (on phone, tap ⋮ → Compile Project). Then click Compile in the window. Once it succeeds, download it from the build’s Download button, or the Download {name}.jar button in chat.

Alex

Okay but u sure it works?

Kodari AI
KodariOct 26 at 11:06 pm 1

I checked the code: the Revolver shuffles all 9 hotbar slots plus the offhand when you hit another player with it, and the hit still deals normal damage. I haven’t confirmed it with a successful build yet, so click Compile to verify the jar; if it fails, use Auto-fix.

Alex

I clicked compile and it downloaded

Kodari AI
KodariOct 26 at 11:06 pm 1

Great—the plugin compiled successfully, and you’ve downloaded the jar. Put it in your server’s plugins folder and restart the server. Then use /revolver and hit another player with it to test the shuffle.

Alex

okay it works but can u add like a little sound that alerts u your it got shuffled?

Kodari AI
KodariOct 27 at 1:44 am 1
  • Add a brief alert sound for the player whose hotbar/offhand gets shuffled.

Added a level-up sound for the player whose hotbar and offhand are shuffled. Compile again and download the updated jar to use the change.

Alex

okay how do i downlload it

Kodari AI
KodariOct 27 at 1:45 am 1

Compile the updated project again: click Compile in the top bar (on phone, tap ⋮ → Compile Project), then click Compile in the window. When it succeeds, click Download on the new build to get the updated jar with the sound.

Alex

okay can u make it not infinite now when u use it once its gone and make it stack also change the sound to a more allert sound

Kodari AI
KodariOct 27 at 1:50 am 1
  1. Make Revolvers stackable and consume one on a successful shuffle.

  2. Replace the sound with a sharper alert cue.

Each successful shuffle now consumes one Revolver; multiple Revolvers can stack like normal blaze rods. The shuffled player hears a bell alert instead of the level-up sound. Compile again and download the updated jar.

Alex

okay can u also add a alert on screen like the text saying "Your Inventory has been shuffled!"

Kodari AI
KodariOct 27 at 8:19 pm 1
  • Send the shuffled player the exact alert message after the shuffle.

  • Keep the existing sound and item consumption unchanged.

Added the on-screen message “Your Inventory has been shuffled!” for the player who gets shuffled. Compile again and download the updated jar.

Alex

okay one last change make it so only ppl that are /op can do that command

Kodari AI
KodariOct 27 at 8:54 pm 1
  1. Restrict /revolver to operators via its command permission.

/revolver is now restricted to operators. Compile again and download the updated jar.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
Code
3 133
src/main/java/com/kodari/revolver/RevolverPlugin.java
package com.kodari.revolver;

import com.cryptomorin.xseries.XSound;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.plugin.java.JavaPlugin;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;

public final class RevolverPlugin extends JavaPlugin implements Listener, CommandExecutor {
    @Override
    public void onEnable() {
        getServer().getPluginManager().registerEvents(this, this);
        getCommand("revolver").setExecutor(this);
    }

    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        if (!(sender instanceof Player player)) {
            sender.sendMessage("Only players can receive a Revolver.");
            return true;
        }

        Map<Integer, ItemStack> overflow = player.getInventory().addItem(createRevolver());
        overflow.values().forEach(item -> player.getWorld().dropItemNaturally(player.getLocation(), item));
        player.sendMessage(ChatColor.GREEN + "You received a Revolver.");
        return true;
    }

    @EventHandler(ignoreCancelled = true)
    public void onPlayerHit(EntityDamageByEntityEvent event) {
        if (!(event.getDamager() instanceof Player attacker)
                || !(event.getEntity() instanceof Player target)
                || !isRevolver(attacker.getInventory().getItemInMainHand())) {
            return;
        }

        shuffleHotbarAndOffhand(target.getInventory());
        XSound.matchXSound("BLOCK_NOTE_BLOCK_BELL").ifPresent(sound -> sound.play(target));
        target.sendMessage(ChatColor.YELLOW + "Your Inventory has been shuffled!");
        ItemStack revolver = attacker.getInventory().getItemInMainHand();
        if (revolver.getAmount() > 1) {
            revolver.setAmount(revolver.getAmount() - 1);
            attacker.getInventory().setItemInMainHand(revolver);
        } else {
            attacker.getInventory().setItemInMainHand(null);
        }
    }

    private ItemStack createRevolver() {
        ItemStack revolver = new ItemStack(Material.matchMaterial("BLAZE_ROD"));
        ItemMeta meta = revolver.getItemMeta();
        meta.setDisplayName(ChatColor.GOLD + "Revolver");
        revolver.setItemMeta(meta);
        return revolver;
    }

    private boolean isRevolver(ItemStack item) {
        if (item == null || !item.getType().name().equals("BLAZE_ROD") || !item.hasItemMeta()) {
            return false;
        }

        ItemMeta meta = item.getItemMeta();
        return meta.hasDisplayName() && ChatColor.stripColor(meta.getDisplayName()).equals("Revolver");
    }

    private void shuffleHotbarAndOffhand(PlayerInventory inventory) {
        List<ItemStack> items = new ArrayList<>(10);
        for (int slot = 0; slot < 9; slot++) {
            ItemStack item = inventory.getItem(slot);
            items.add(item == null ? null : item.clone());
        }
        ItemStack offhand = inventory.getItemInOffHand();
        items.add(offhand == null ? null : offhand.clone());

        Collections.shuffle(items);

        for (int slot = 0; slot < 9; slot++) {
            inventory.setItem(slot, items.get(slot));
        }
        inventory.setItemInOffHand(items.get(9));
    }
}