D

add the the staff sword which is a sword that when put in a crafting table with it will merge with that block and it will gain a special ability depending on what block to put it in with on the crafting table. and to use the ability you right click the sword

Kodari AI
KodariJan 11 at 8:56 am 8,932 (v2)

I’ll create a staff sword plugin that allows players to merge swords with blocks to gain special abilities.

StaffSword
A unique weapon system featuring a customizable staff sword that can be combined with different blocks in a crafting table. Each block type grants the sword a unique special ability. Players activate abilities by right-clicking the sword. Features include customizable ability cooldowns, particle effects, sound effects, and a wide variety of block-based abilities such as fire resistance from magma blocks, flight from feathers, and explosive attacks from TNT.

Plugin created! Here’s what I’ve built:

Features:

  • Base staff sword obtained via /staffsword give

  • Combine sword with blocks in crafting table (2 items only)

  • Right-click to activate abilities

  • 10 pre-configured abilities (Diamond, Gold, Emerald, Netherite, Iron, TNT, Obsidian, Magma, Glowstone, Slime)

  • Customizable cooldowns, effects, particles, and sounds

  • Permission-based usage

Abilities included:

  • Diamond Block - Resistance + Absorption

  • Gold Block - Luck + Speed

  • Emerald Block - Healing + Regeneration

  • Netherite Block - Fire resist + Resistance + Strength

  • TNT - Creates explosion at target location

  • Magma Block - Fire aura that damages nearby enemies

  • Glowstone - Night vision + Glowing

  • Slime Block - Jump boost

Commands:

  • /staffsword give - Get a base staff sword

  • /staffsword reload - Reload config

All abilities and cooldowns are fully customizable in the config!

D

add it so that when they merge the staff sword with a command block you can use any command besides gamemode and effect and fill commands

Kodari AI
KodariJan 11 at 9:00 am 12,949 (v2)

I’ll add a command block merging system for the staff sword. Let me first read the existing files to understand the current implementation.

Now I’ll implement the command block merging system. I need to:

  • Create a listener for command block merging in crafting

  • Store the command in the staff sword’s persistent data

  • Execute the command when right-clicking

  • Filter out gamemode, effect, and fill commands

Done! I’ve added the command block merging system with the following features:

What was added:

  • New CommandBlockMergeListener that handles crafting a staff sword with a command block

  • Command extraction from command blocks (works with all 3 types: normal, repeating, chain)

  • Command filtering that blocks: gamemode, gm, effect, and fill commands

  • Command execution when right-clicking the command staff sword

  • Support for {player} placeholder in commands

  • Separate cooldown system for command swords

  • New permissions: staffsword.craft.command and staffsword.use.command

How it works:

  1. Place a base staff sword + command block (with a command set) in a crafting table

  2. The command is extracted and validated (blocked commands are rejected)

  3. Creates a purple “Command Staff Sword” with the command in the lore

  4. Right-click to execute the command as console

  5. Commands are executed with a configurable cooldown (default 10s)

Config additions:

  • command-sword.name - Display name

  • command-sword.lore - Lore with {command} and {cooldown} placeholders

  • command-sword.cooldown - Cooldown in seconds

  • New messages for permissions and execution feedback

D

make it so you put the command block and the staff sword in the crafting table and get the command sword you set the command after its done being crafted. when you right click the sword you then right a command and it exicutes it

Kodari AI
KodariJan 11 at 9:10 am 14,289 (v2)

I’ll read the existing files to understand the current implementation, then modify the plugin to support command sword crafting and execution.

Now I’ll modify the system to allow players to set the command after crafting. I need to:

  1. Update CommandBlockMergeListener to create a command sword without a command when crafted with command block + staff sword

  2. Create a new listener to handle chat input for setting the command

  3. Create a manager to track players who are setting commands

  4. Update the config with new messages

Done! Here’s what I’ve implemented:

New System:

  1. Craft command block + staff sword = command sword (without command set)

  2. Right-click the command sword to enter “command input mode”

  3. Type the command in chat (without the /)

  4. The command is saved to the sword and can be executed on future right-clicks

Features:

  • Command input expires after 60 seconds

  • Type “cancel” to cancel command input

  • Blocked commands list in config (stop, restart, reload, op, deop by default)

  • {player} placeholder in commands gets replaced with the player’s name

  • Different lore for swords with/without commands set

  • Prevents setting command on swords that already have one

  • Requires staffsword.craft.command permission to craft

  • Requires staffsword.use.command permission to use

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
Code
13 1,105
src/main/java/com/staffsword/StaffSwordPlugin.java
package com.staffsword;

import com.staffsword.commands.StaffSwordCommand;
import com.staffsword.listeners.CommandBlockMergeListener;
import com.staffsword.listeners.CommandInputListener;
import com.staffsword.listeners.CraftListener;
import com.staffsword.listeners.UseAbilityListener;
import com.staffsword.managers.AbilityManager;
import com.staffsword.managers.CommandInputManager;
import com.staffsword.managers.CooldownManager;
import com.staffsword.managers.StaffSwordManager;
import lombok.Getter;
import org.bukkit.plugin.java.JavaPlugin;

@Getter
public class StaffSwordPlugin extends JavaPlugin {
    
    private StaffSwordManager staffSwordManager;
    private AbilityManager abilityManager;
    private CooldownManager cooldownManager;
    private CommandInputManager commandInputManager;
    
    @Override
    public void onEnable() {
        saveDefaultConfig();
        
        this.staffSwordManager = new StaffSwordManager(this);
        this.cooldownManager = new CooldownManager();
        this.abilityManager = new AbilityManager(this);
        this.commandInputManager = new CommandInputManager();
        
        getCommand("staffsword").setExecutor(new StaffSwordCommand(this));
        
        getServer().getPluginManager().registerEvents(new CraftListener(this), this);
        getServer().getPluginManager().registerEvents(new UseAbilityListener(this), this);
        getServer().getPluginManager().registerEvents(new CommandBlockMergeListener(this), this);
        getServer().getPluginManager().registerEvents(new CommandInputListener(this), this);
        
        getServer().getScheduler().runTaskTimer(this, () -> {
            commandInputManager.clearExpired();
        }, 1200L, 1200L);
        
        getLogger().info("StaffSword has been enabled!");
    }
    
    @Override
    public void onDisable() {
        getLogger().info("StaffSword has been disabled!");
    }
    
    public void reload() {
        reloadConfig();
        this.staffSwordManager = new StaffSwordManager(this);
        this.abilityManager = new AbilityManager(this);
    }
}