-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Expand file tree
/
Copy pathEquippable.java
More file actions
220 lines (195 loc) · 6.36 KB
/
Equippable.java
File metadata and controls
220 lines (195 loc) · 6.36 KB
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
package io.papermc.paper.datacomponent.item;
import io.papermc.paper.datacomponent.BuildableDataComponent;
import io.papermc.paper.datacomponent.DataComponentBuilder;
import io.papermc.paper.registry.set.RegistryKeySet;
import net.kyori.adventure.key.Key;
import org.bukkit.entity.EntityType;
import org.bukkit.inventory.EquipmentSlot;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Contract;
import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.Nullable;
/**
* Holds the equippable properties of an item.
* @see io.papermc.paper.datacomponent.DataComponentTypes#EQUIPPABLE
*/
@NullMarked
@ApiStatus.Experimental
@ApiStatus.NonExtendable
public interface Equippable extends BuildableDataComponent<Equippable, Equippable.Builder> {
/**
* Creates a new {@link Equippable.Builder} instance.
*
* @param slot The slot for the new equippable to be equippable in.
* @return a new builder
*/
@Contract(value = "_ -> new", pure = true)
static Equippable.Builder equippable(final EquipmentSlot slot) {
return ItemComponentTypesBridge.bridge().equippable(slot);
}
/**
* Gets the equipment slot this item can be equipped in.
*
* @return the equipment slot
*/
@Contract(pure = true)
EquipmentSlot slot();
/**
* Gets the equip sound key.
*
* @return the equip sound key
*/
@Contract(pure = true)
Key equipSound();
/**
* Gets the asset id if present.
*
* @return the asset id or null
*/
@Contract(pure = true)
@Nullable Key assetId();
/**
* Gets the camera overlay key if present.
*
* @return the camera overlay key or null
*/
@Contract(pure = true)
@Nullable Key cameraOverlay();
/**
* Gets the set of allowed entities that can equip this item.
* May be null if all entities are allowed.
*
* @return the set of allowed entities
*/
@Contract(pure = true)
@Nullable RegistryKeySet<EntityType<?>> allowedEntities();
/**
* Checks if the item is dispensable.
*
* @return true if dispensable, false otherwise
*/
@Contract(pure = true)
boolean dispensable();
/**
* Checks if the item is swappable.
*
* @return true if swappable, false otherwise
*/
@Contract(pure = true)
boolean swappable();
/**
* Checks if the item takes damage when the wearer is hurt.
*
* @return true if it damages on hurt, false otherwise
*/
@Contract(pure = true)
boolean damageOnHurt();
/**
* Checks if the item should be equipped when interacting with an entity.
*
* @return true if it equips on interact, false otherwise
*/
@Contract(pure = true)
boolean equipOnInteract();
/**
* Checks if the item can be sheared off an entity.
*
* @return true if can be sheared off an entity, false otherwise
*/
@Contract(pure = true)
boolean canBeSheared();
/**
* Returns the sound that is played when shearing this equipment off an entity.
*
* @return shear sound
*/
@Contract(pure = true)
Key shearSound();
/**
* Builder for {@link Equippable}.
*/
@ApiStatus.Experimental
@ApiStatus.NonExtendable
interface Builder extends DataComponentBuilder<Equippable> {
/**
* Sets the equip sound key for this item.
*
* @param sound the equip sound key
* @return the builder for chaining
*/
@Contract(value = "_ -> this", mutates = "this")
Builder equipSound(Key sound);
/**
* Sets the asset id for this item.
*
* @param assetId the asset id, nullable
* @return the builder for chaining
*/
@Contract(value = "_ -> this", mutates = "this")
Builder assetId(@Nullable Key assetId);
/**
* Sets the camera overlay key for this item.
*
* @param cameraOverlay the camera overlay key, nullable
* @return the builder for chaining
*/
@Contract(value = "_ -> this", mutates = "this")
Builder cameraOverlay(@Nullable Key cameraOverlay);
/**
* Sets the allowed entities that can equip this item.
*
* @param allowedEntities the set of allowed entity types, or null if any
* @return the builder for chaining
*/
@Contract(value = "_ -> this", mutates = "this")
Builder allowedEntities(@Nullable RegistryKeySet<EntityType<?>> allowedEntities);
/**
* Sets whether the item is dispensable.
*
* @param dispensable true if dispensable
* @return the builder for chaining
*/
@Contract(value = "_ -> this", mutates = "this")
Builder dispensable(boolean dispensable);
/**
* Sets whether the item is swappable.
*
* @param swappable true if swappable
* @return the builder for chaining
*/
@Contract(value = "_ -> this", mutates = "this")
Builder swappable(boolean swappable);
/**
* Sets whether the item takes damage when the wearer is hurt.
*
* @param damageOnHurt true if it damages on hurt
* @return the builder for chaining
*/
@Contract(value = "_ -> this", mutates = "this")
Builder damageOnHurt(boolean damageOnHurt);
/**
* Sets whether the item should be equipped when interacting with an entity.
*
* @param equipOnInteract true if it equips on interact
* @return the builder for chaining
*/
@Contract(value = "_ -> this", mutates = "this")
Builder equipOnInteract(boolean equipOnInteract);
/**
* Sets whether the item can be sheared off an entity.
*
* @param canBeSheared true if can be sheared off an entity
* @return the builder for chaining
*/
@Contract(value = "_ -> this", mutates = "this")
Builder canBeSheared(boolean canBeSheared);
/**
* Sets the sound that is played when shearing this equipment off an entity.
*
* @param shearSound the shear sound key
* @return the builder for chaining
*/
@Contract(value = "_ -> this", mutates = "this")
Builder shearSound(Key shearSound);
}
}