12345bartek

Generate a plugin for a special item that, when right-clicked, generates a command via the console and disappears from the player's inventory. The configuration should include the item type, item name, and description, and three such items should be included in the configuration.

Kodari AI
KodariJan 3 at 11:55 pm 3,800 (v2)

I’ll create a plugin that executes console commands when special items are right-clicked.

SpecialItems
A plugin that allows creation of special consumable items which execute console commands when right-clicked. Items are fully configurable including material type, display name, lore, and command to execute. Upon use, the item is consumed and removed from the player's inventory. Perfect for reward systems, event items, or custom consumables.

Now I’ll create the complete plugin structure:

Plugin complete! Here’s what was created:

Features:

  • Right-click special items to execute console commands

  • Items are consumed after use (single-use consumables)

  • Full item matching: material, name, and lore must match

  • %player% placeholder in commands replaced with player name

  • Color code support for item names and lore

Configuration includes 3 example items:

  1. Vote Reward (Diamond) - Gives 100 coins

  2. Spawn Teleporter (Ender Pearl) - Teleports to spawn

  3. Mystery Crate (Chest) - Gives random crate

Usage: Players simply right-click the item and it executes the configured command then disappears.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
Code
5 197
src/main/java/com/specialitems/plugin/SpecialItems.java
package com.specialitems.plugin;

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

public class SpecialItems extends JavaPlugin {
    
    @Override
    public void onEnable() {
        saveDefaultConfig();
        
        Bukkit.getPluginManager().registerEvents(new ItemInteractListener(this), this);
        
        getLogger().info("SpecialItems has been enabled!");
    }
    
    @Override
    public void onDisable() {
        getLogger().info("SpecialItems has been disabled!");
    }
}