[SPIGOT-7953] UseCooldownComponent - Crash client or delete item Created: 11/Nov/24  Updated: 25/Dec/24  Resolved: 12/Nov/24

Status: Resolved
Project: Spigot
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: Ssomar Assignee: Unassigned
Resolution: Fixed Votes: 0
Labels: None

Attachments: File Minecraft 1.21.3 - Multiplayer (3rd-party Server) 2024-11-11 13-30-39.mp4    
Version: This server is running CraftBukkit version 4378-Spigot-e65d67a-8ef9079 (MC: 1.21.3)
Guidelines Read: Yes

 Description   

Hello !

When I try to only modify the cooldonwGroup of UseCooldownComponent.

In survival : The item is deleted after a quit/join.

In creative : the client return an error and the item is deleted.

Short video of the test attached.

It seems not appearing when I initialize the cooldownSeconds setting with a value superior to 0

The code to reproduce the issue:

public class TESTEVENT implements Listener {


    @EventHandler(priority = EventPriority.HIGH)
    public void onPlayerToggleSneakEvent(PlayerToggleSneakEvent e) {
        if(!e.isSneaking()) return;

        Player p = e.getPlayer();

        ItemStack item = new ItemStack(Material.BEACON);
        ItemMeta meta = item.getItemMeta();
        UseCooldownComponent useCooldownComponent = meta.getUseCooldown();
        useCooldownComponent.setCooldownGroup(NamespacedKey.fromString("its_a_test"));
        // REQUIRED TO NOT HAVE THE ISSUE useCooldownComponent.setCooldownSeconds(1);
        meta.setUseCooldown(useCooldownComponent);
        item.setItemMeta(meta);

        p.getInventory().addItem(item);
    }


}

Generated at Sat Dec 13 19:00:06 UTC 2025 using Jira 10.3.13#10030013-sha1:56dd970ae30ebfeda3a697d25be1f6388b68a422.