ScriptsLab
WikiDownloadsSourcesSupport
ScriptsLab
DocumentationDownloadsGitHubDiscord

© 2026 ScriptsLab

Back to src/main/java/com/scriptslab/api/item
J

ItemManager.java

Java · 132 lines · 3.4 KB

src/main/java/com/scriptslab/api/item/ItemManager.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
package com.scriptslab.api.item;

import org.bukkit.inventory.ItemStack;

import java.util.Collection;
import java.util.Optional;
import java.util.concurrent.CompletableFuture;

/**
 * Manager for custom items.
 * Thread-safe.
 */
public interface ItemManager {
    
    /**
     * Registers a custom item.
     * 
     * @param item custom item to register
     * @return future that completes when registered
     */
    CompletableFuture<Void> registerItem(CustomItem item);
    
    /**
     * Unregisters a custom item.
     * 
     * @param itemId item identifier
     * @return future that completes when unregistered
     */
    CompletableFuture<Void> unregisterItem(String itemId);
    
    /**
     * Gets a custom item by ID.
     * 
     * @param itemId item identifier
     * @return optional containing item if found
     */
    Optional<CustomItem> getItem(String itemId);
    
    /**
     * Gets all registered custom items.
     * 
     * @return collection of all items
     */
    Collection<CustomItem> getAllItems();
    
    /**
     * Checks if an ItemStack is a custom item.
     * 
     * @param itemStack item to check
     * @return true if custom item
     */
    boolean isCustomItem(ItemStack itemStack);
    
    /**
     * Gets the custom item ID from an ItemStack.
     * 
     * @param itemStack item to check
     * @return optional containing ID if custom item
     */
    Optional<String> getCustomItemId(ItemStack itemStack);
    
    /**
     * Gets the custom item from an ItemStack.
     * 
     * @param itemStack item to check
     * @return optional containing custom item if found
     */
    Optional<CustomItem> getCustomItem(ItemStack itemStack);
    
    /**
     * Creates an ItemStack from a custom item ID.
     * 
     * @param itemId item identifier
     * @param amount stack size
     * @return optional containing ItemStack if item found
     */
    Optional<ItemStack> createItemStack(String itemId, int amount);
    
    /**
     * Creates an ItemStack with amount 1.
     * 
     * @param itemId item identifier
     * @return optional containing ItemStack if item found
     */
    default Optional<ItemStack> createItemStack(String itemId) {
        return createItemStack(itemId, 1);
    }
    
    /**
     * Registers an item ability.
     * 
     * @param ability ability to register
     * @return future that completes when registered
     */
    CompletableFuture<Void> registerAbility(ItemAbility ability);
    
    /**
     * Gets an ability by ID.
     * 
     * @param abilityId ability identifier
     * @return optional containing ability if found
     */
    Optional<ItemAbility> getAbility(String abilityId);
    
    /**
     * Checks if a player can use an ability (cooldown check).
     * 
     * @param playerId player UUID
     * @param abilityId ability identifier
     * @return true if can use
     */
    boolean canUseAbility(java.util.UUID playerId, String abilityId);
    
    /**
     * Sets an ability on cooldown for a player.
     * 
     * @param playerId player UUID
     * @param abilityId ability identifier
     * @param cooldownTicks cooldown in ticks
     */
    void setCooldown(java.util.UUID playerId, String abilityId, long cooldownTicks);
    
    /**
     * Gets remaining cooldown for an ability.
     * 
     * @param playerId player UUID
     * @param abilityId ability identifier
     * @return remaining ticks, or 0 if no cooldown
     */
    long getRemainingCooldown(java.util.UUID playerId, String abilityId);
}