ScriptsLab
WikiDownloadsSourcesSupport
ScriptsLab
DocumentationDownloadsGitHubDiscord

© 2026 ScriptsLab

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

CustomItem.java

Java · 123 lines · 2.6 KB

src/main/java/com/scriptslab/api/item/CustomItem.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
package com.scriptslab.api.item;

import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;

import java.util.List;
import java.util.Map;

/**
 * Represents a custom item with unique properties and abilities.
 * Immutable.
 */
public interface CustomItem {
    
    /**
     * Gets the unique identifier of this item.
     * 
     * @return item ID
     */
    String getId();
    
    /**
     * Gets the base material of this item.
     * 
     * @return material
     */
    Material getMaterial();
    
    /**
     * Gets the display name of this item.
     * 
     * @return display name with color codes
     */
    String getDisplayName();
    
    /**
     * Gets the lore (description) of this item.
     * 
     * @return list of lore lines
     */
    List<String> getLore();
    
    /**
     * Gets the custom model data for resource packs.
     * 
     * @return custom model data, or 0 if none
     */
    int getCustomModelData();
    
    /**
     * Gets custom NBT data for this item.
     * 
     * @return map of NBT key-value pairs
     */
    Map<String, Object> getNbtData();
    
    /**
     * Gets the abilities attached to this item.
     * 
     * @return list of abilities
     */
    List<ItemAbility> getAbilities();
    
    /**
     * Checks if this item is unbreakable.
     * 
     * @return true if unbreakable
     */
    boolean isUnbreakable();
    
    /**
     * Gets the rarity of this item.
     * 
     * @return rarity level
     */
    Rarity getRarity();
    
    /**
     * Creates an ItemStack from this custom item.
     * 
     * @param amount stack size
     * @return ItemStack instance
     */
    ItemStack toItemStack(int amount);
    
    /**
     * Creates an ItemStack with amount 1.
     * 
     * @return ItemStack instance
     */
    default ItemStack toItemStack() {
        return toItemStack(1);
    }
    
    /**
     * Item rarity levels.
     */
    enum Rarity {
        COMMON("§f", "Обычный"),
        UNCOMMON("§a", "Необычный"),
        RARE("§9", "Редкий"),
        EPIC("§5", "Эпический"),
        LEGENDARY("§6", "Легендарный"),
        MYTHIC("§c", "Мифический");
        
        private final String color;
        private final String displayName;
        
        Rarity(String color, String displayName) {
            this.color = color;
            this.displayName = displayName;
        }
        
        public String getColor() {
            return color;
        }
        
        public String getDisplayName() {
            return displayName;
        }
    }
}