Skip to content

Commit 7a5d068

Browse files
committed
smol refactor: prefix components with Java / Geyser, prefix DataComponent / DataComponentMap
1 parent 789abab commit 7a5d068

File tree

61 files changed

+551
-542
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+551
-542
lines changed

api/src/main/java/org/geysermc/geyser/api/item/custom/v2/CustomItemDefinition.java

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@
2828
import org.checkerframework.checker.nullness.qual.NonNull;
2929
import org.checkerframework.common.returnsreceiver.qual.This;
3030
import org.geysermc.geyser.api.GeyserApi;
31-
import org.geysermc.geyser.api.item.custom.v2.component.DataComponent;
32-
import org.geysermc.geyser.api.item.custom.v2.component.DataComponentMap;
33-
import org.geysermc.geyser.api.item.custom.v2.component.java.ItemDataComponents;
31+
import org.geysermc.geyser.api.item.custom.v2.component.ItemDataComponent;
32+
import org.geysermc.geyser.api.item.custom.v2.component.ItemDataComponentMap;
33+
import org.geysermc.geyser.api.item.custom.v2.component.java.JavaItemDataComponents;
3434
import org.geysermc.geyser.api.predicate.MatchPredicate;
3535
import org.geysermc.geyser.api.predicate.MinecraftPredicate;
3636
import org.geysermc.geyser.api.predicate.PredicateStrategy;
@@ -137,26 +137,27 @@ public interface CustomItemDefinition {
137137
* <p>Currently, the following components are (somewhat) supported:</p>
138138
*
139139
* <ul>
140-
* <li>{@code minecraft:consumable} ({@link ItemDataComponents#CONSUMABLE})</li>
141-
* <li>{@code minecraft:equippable} ({@link ItemDataComponents#EQUIPPABLE})</li>
142-
* <li>{@code minecraft:food} ({@link ItemDataComponents#FOOD})</li>
143-
* <li>{@code minecraft:max_damage} ({@link ItemDataComponents#MAX_DAMAGE})</li>
144-
* <li>{@code minecraft:max_stack_size} ({@link ItemDataComponents#MAX_STACK_SIZE})</li>
145-
* <li>{@code minecraft:use_cooldown} ({@link ItemDataComponents#USE_COOLDOWN})</li>
146-
* <li>{@code minecraft:enchantable} ({@link ItemDataComponents#ENCHANTABLE})</li>
147-
* <li>{@code minecraft:tool} ({@link ItemDataComponents#TOOL})</li>
148-
* <li>{@code minecraft:repairable} ({@link ItemDataComponents#REPAIRABLE})</li>
149-
* <li>{@code minecraft:enchantment_glint_override} ({@link ItemDataComponents#ENCHANTMENT_GLINT_OVERRIDE})</li>
140+
* <li>{@code minecraft:consumable} ({@link JavaItemDataComponents#CONSUMABLE})</li>
141+
* <li>{@code minecraft:equippable} ({@link JavaItemDataComponents#EQUIPPABLE})</li>
142+
* <li>{@code minecraft:food} ({@link JavaItemDataComponents#FOOD})</li>
143+
* <li>{@code minecraft:max_damage} ({@link JavaItemDataComponents#MAX_DAMAGE})</li>
144+
* <li>{@code minecraft:max_stack_size} ({@link JavaItemDataComponents#MAX_STACK_SIZE})</li>
145+
* <li>{@code minecraft:use_cooldown} ({@link JavaItemDataComponents#USE_COOLDOWN})</li>
146+
* <li>{@code minecraft:enchantable} ({@link JavaItemDataComponents#ENCHANTABLE})</li>
147+
* <li>{@code minecraft:tool} ({@link JavaItemDataComponents#TOOL})</li>
148+
* <li>{@code minecraft:repairable} ({@link JavaItemDataComponents#REPAIRABLE})</li>
149+
* <li>{@code minecraft:enchantment_glint_override} ({@link JavaItemDataComponents#ENCHANTMENT_GLINT_OVERRIDE})</li>
150150
* </ul>
151151
*
152152
* <p>Note: some components, for example {@code minecraft:rarity} and {@code minecraft:attribute_modifiers}, are translated automatically, and do not have to be specified here.
153153
* Components that are added here cannot be removed in {@link CustomItemDefinition#removedComponents()}.</p>
154154
*
155-
* @see ItemDataComponents
155+
* @see JavaItemDataComponents
156156
* @see CustomItemDefinition#removedComponents()
157157
* @return the item's data component patch
158158
*/
159-
@NonNull DataComponentMap components();
159+
@NonNull
160+
ItemDataComponentMap components();
160161

161162
/**
162163
* A list of removed default item data components. These are components that are present on the vanilla base item, but not on the custom item. Like with custom added
@@ -244,27 +245,27 @@ interface Builder extends GenericBuilder<CustomItemDefinition> {
244245
* <p>Added data components cannot be removed using {@link CustomItemDefinition.Builder#removeComponent(Identifier)},
245246
* and this method will throw when a component is added that was removed using the aforementioned method.</p>
246247
*
247-
* @param component the type of the component, found in {@link ItemDataComponents}
248+
* @param component the type of the component, found in {@link JavaItemDataComponents}
248249
* @param value the value of the component
249250
* @param <T> the value held by the component
250251
* @throws IllegalArgumentException when the added component was removed using {@link CustomItemDefinition.Builder#removeComponent(Identifier)}
251252
* @return this builder
252253
*/
253254
@This
254-
<T> Builder component(@NonNull DataComponent<T> component, @NonNull T value);
255+
<T> Builder component(@NonNull ItemDataComponent<T> component, @NonNull T value);
255256

256257
/**
257-
* Convenience method for {@link CustomItemDefinition.Builder#component(DataComponent, Object)}
258+
* Convenience method for {@link CustomItemDefinition.Builder#component(ItemDataComponent, Object)}
258259
*
259-
* @param component the type of the component - found in {@link ItemDataComponents}
260+
* @param component the type of the component - found in {@link JavaItemDataComponents}
260261
* @param builder the builder of the component
261262
* @param <T> the value held by the component
262263
* @throws IllegalArgumentException when the added component was removed using {@link CustomItemDefinition.Builder#removeComponent(Identifier)}
263-
* @see CustomItemDefinition.Builder#component(DataComponent, Object)
264+
* @see CustomItemDefinition.Builder#component(ItemDataComponent, Object)
264265
* @return this builder
265266
*/
266267
@This
267-
default <T> Builder component(@NonNull DataComponent<T> component, @NonNull GenericBuilder<T> builder) {
268+
default <T> Builder component(@NonNull ItemDataComponent<T> component, @NonNull GenericBuilder<T> builder) {
268269
return component(component, builder.build());
269270
}
270271

@@ -273,11 +274,11 @@ default <T> Builder component(@NonNull DataComponent<T> component, @NonNull Gene
273274
* existing on the vanilla item. This must match server-side behavior, otherwise, issues
274275
* will occur. See {@link CustomItemDefinition#removedComponents()} for more information.
275276
*
276-
* <p>Removed data components cannot be added again using {@link CustomItemDefinition.Builder#component(DataComponent, Object)},
277+
* <p>Removed data components cannot be added again using {@link CustomItemDefinition.Builder#component(ItemDataComponent, Object)},
277278
* and this method will throw when a component is removed that was added using the aforementioned method.</p>
278279
*
279280
* @param component the identifier of the vanilla base component to remove
280-
* @throws IllegalArgumentException when the removed component was added using {@link CustomItemDefinition.Builder#component(DataComponent, Object)}
281+
* @throws IllegalArgumentException when the removed component was added using {@link CustomItemDefinition.Builder#component(ItemDataComponent, Object)}
281282
* @return this builder
282283
*/
283284
@This
@@ -287,11 +288,11 @@ default <T> Builder component(@NonNull DataComponent<T> component, @NonNull Gene
287288
* Convenience method for {@link CustomItemDefinition.Builder#removeComponent(Identifier)}.
288289
*
289290
* @param component the component type to remove
290-
* @throws IllegalArgumentException when the removed component was added using {@link CustomItemDefinition.Builder#component(DataComponent, Object)}
291+
* @throws IllegalArgumentException when the removed component was added using {@link CustomItemDefinition.Builder#component(ItemDataComponent, Object)}
291292
* @return this builder
292293
*/
293294
@This
294-
default Builder removeComponent(@NonNull DataComponent<?> component) {
295+
default Builder removeComponent(@NonNull ItemDataComponent<?> component) {
295296
Objects.requireNonNull(component);
296297
if (!component.vanilla()) {
297298
throw new IllegalArgumentException("Cannot remove non-vanilla component");

api/src/main/java/org/geysermc/geyser/api/item/custom/v2/NonVanillaCustomItemDefinition.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@
3030
import org.checkerframework.checker.nullness.qual.Nullable;
3131
import org.checkerframework.common.returnsreceiver.qual.This;
3232
import org.geysermc.geyser.api.GeyserApi;
33-
import org.geysermc.geyser.api.item.custom.v2.component.geyser.GeyserDataComponent;
34-
import org.geysermc.geyser.api.item.custom.v2.component.DataComponent;
35-
import org.geysermc.geyser.api.item.custom.v2.component.DataComponentMap;
33+
import org.geysermc.geyser.api.item.custom.v2.component.geyser.GeyserItemDataComponent;
34+
import org.geysermc.geyser.api.item.custom.v2.component.ItemDataComponent;
35+
import org.geysermc.geyser.api.item.custom.v2.component.ItemDataComponentMap;
3636
import org.geysermc.geyser.api.predicate.MinecraftPredicate;
3737
import org.geysermc.geyser.api.predicate.PredicateStrategy;
3838
import org.geysermc.geyser.api.predicate.context.item.ItemPredicateContext;
@@ -48,7 +48,7 @@
4848
* right now with vanilla custom item definitions, is currently not implemented, so only one definition can be created for each
4949
* Java non-vanilla item.</p>
5050
*
51-
* <p>Non-vanilla item definitions can be configured with additional components defined in {@link GeyserDataComponent}.</p>
51+
* <p>Non-vanilla item definitions can be configured with additional components defined in {@link GeyserItemDataComponent}.</p>
5252
*/
5353
@ApiStatus.NonExtendable
5454
public interface NonVanillaCustomItemDefinition extends CustomItemDefinition {
@@ -115,18 +115,19 @@ default int priority() {
115115
}
116116

117117
/**
118-
* On top of vanilla Minecraft's item components, custom ones defined by Geyser in {@link GeyserDataComponent} can
118+
* On top of vanilla Minecraft's item components, custom ones defined by Geyser in {@link GeyserItemDataComponent} can
119119
* also be used. Like with vanilla data components, it is still expected that the item <em>always</em> has the behaviour defined by its components.
120120
*
121121
* <p>Default component removals are not supported for non-vanilla items, since here the data component map defines default components, instead of
122122
* a patch on top of a vanilla base item.</p>
123123
*
124124
* @see CustomItemDefinition#components()
125-
* @see GeyserDataComponent
125+
* @see GeyserItemDataComponent
126126
* @return the item's default data components
127127
*/
128128
@Override
129-
@NonNull DataComponentMap components();
129+
@NonNull
130+
ItemDataComponentMap components();
130131

131132
/**
132133
* Creates a builder for a non-vanilla custom item definition, using the {@code javaIdentifier} as {@code bedrockIdentifier}.
@@ -187,7 +188,7 @@ interface Builder extends CustomItemDefinition.Builder {
187188
*/
188189
@Override
189190
@This
190-
<T> Builder component(@NonNull DataComponent<T> component, @NonNull T value);
191+
<T> Builder component(@NonNull ItemDataComponent<T> component, @NonNull T value);
191192

192193
/**
193194
* Sets the Java translation string of the item.

api/src/main/java/org/geysermc/geyser/api/item/custom/v2/component/DataComponent.java renamed to api/src/main/java/org/geysermc/geyser/api/item/custom/v2/component/ItemDataComponent.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,24 +27,24 @@
2727

2828
import org.checkerframework.checker.nullness.qual.NonNull;
2929
import org.geysermc.geyser.api.item.custom.v2.CustomItemDefinition;
30-
import org.geysermc.geyser.api.item.custom.v2.component.geyser.GeyserDataComponent;
31-
import org.geysermc.geyser.api.item.custom.v2.component.java.ItemDataComponents;
30+
import org.geysermc.geyser.api.item.custom.v2.component.geyser.GeyserItemDataComponent;
31+
import org.geysermc.geyser.api.item.custom.v2.component.java.JavaItemDataComponents;
3232
import org.geysermc.geyser.api.util.GeyserProvided;
3333
import org.geysermc.geyser.api.util.Identifier;
3434
import org.jetbrains.annotations.ApiStatus;
3535

3636
import java.util.function.Predicate;
3737

3838
/**
39-
* Data components are used to indicate item behaviour of custom items.
39+
* Data components are used to indicate item behaviour.
4040
* It is expected that any components set on a {@link CustomItemDefinition} are always present on the item server-side.
4141
*
42-
* @see ItemDataComponents
43-
* @see GeyserDataComponent
42+
* @see JavaItemDataComponents
43+
* @see GeyserItemDataComponent
4444
* @see CustomItemDefinition#components()
4545
*/
4646
@ApiStatus.NonExtendable
47-
public interface DataComponent<T> extends GeyserProvided {
47+
public interface ItemDataComponent<T> extends GeyserProvided {
4848

4949
/**
5050
* The identifier of the data component.

api/src/main/java/org/geysermc/geyser/api/item/custom/v2/component/DataComponentMap.java renamed to api/src/main/java/org/geysermc/geyser/api/item/custom/v2/component/ItemDataComponentMap.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,23 +30,23 @@
3030
/**
3131
* A map of data components to their values. Mainly used internally when mapping custom items.
3232
*/
33-
public interface DataComponentMap {
33+
public interface ItemDataComponentMap {
3434

3535
/**
3636
* @return the value of the given component, or null if it is not in the map.
3737
*/
38-
<T> T get(DataComponent<T> type);
38+
<T> T get(ItemDataComponent<T> type);
3939

4040
/**
4141
* @return the value of the given component, or {@code fallback} if it is null.
4242
*/
43-
default <T> T getOrDefault(DataComponent<T> type, T fallback) {
43+
default <T> T getOrDefault(ItemDataComponent<T> type, T fallback) {
4444
T value = get(type);
4545
return value == null ? fallback : value;
4646
}
4747

4848
/**
4949
* @return all data components in this map.
5050
*/
51-
Set<DataComponent<?>> keySet();
51+
Set<ItemDataComponent<?>> keySet();
5252
}

api/src/main/java/org/geysermc/geyser/api/item/custom/v2/component/geyser/BlockPlacer.java renamed to api/src/main/java/org/geysermc/geyser/api/item/custom/v2/component/geyser/GeyserBlockPlacer.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
* Allows modifying items so these can place blocks or take on the
3636
* icon of the block they place.
3737
*/
38-
public interface BlockPlacer {
38+
public interface GeyserBlockPlacer {
3939

4040
/**
4141
* The block placed by the item, used by the
@@ -60,8 +60,8 @@ public interface BlockPlacer {
6060
*
6161
* @return a new builder
6262
*/
63-
static Builder builder() {
64-
return GeyserApi.api().provider(BlockPlacer.Builder.class);
63+
static @NonNull Builder builder() {
64+
return GeyserApi.api().provider(GeyserBlockPlacer.Builder.class);
6565
}
6666

6767
/**
@@ -71,22 +71,22 @@ static Builder builder() {
7171
* @param useBlockIcon whether to use the 3d block rendering for the item icon
7272
* @return the block placer component
7373
*/
74-
static BlockPlacer of(Identifier block, boolean useBlockIcon) {
75-
return BlockPlacer.builder().block(block).useBlockIcon(useBlockIcon).build();
74+
static @NonNull GeyserBlockPlacer of(@NonNull Identifier block, boolean useBlockIcon) {
75+
return GeyserBlockPlacer.builder().block(block).useBlockIcon(useBlockIcon).build();
7676
}
7777

7878
/**
7979
* Builder for the block placer component.
8080
*/
81-
interface Builder extends GenericBuilder<BlockPlacer> {
81+
interface Builder extends GenericBuilder<GeyserBlockPlacer> {
8282

8383
/**
8484
* The identifier of the block to place.
8585
* This should be the block identifier as it is
8686
* known to the Bedrock client.
8787
*
8888
* @param block the identifier of the block
89-
* @see BlockPlacer#block()
89+
* @see GeyserBlockPlacer#block()
9090
* @return this builder
9191
*/
9292
@This
@@ -97,7 +97,7 @@ interface Builder extends GenericBuilder<BlockPlacer> {
9797
* Block items have a 3d-generated block icon.
9898
*
9999
* @param useBlockIcon whether to use the block icon
100-
* @see BlockPlacer#useBlockIcon()
100+
* @see GeyserBlockPlacer#useBlockIcon()
101101
* @return this builder
102102
*/
103103
@This
@@ -109,6 +109,6 @@ interface Builder extends GenericBuilder<BlockPlacer> {
109109
* @return the new component
110110
*/
111111
@Override
112-
BlockPlacer build();
112+
GeyserBlockPlacer build();
113113
}
114114
}

api/src/main/java/org/geysermc/geyser/api/item/custom/v2/component/geyser/Chargeable.java renamed to api/src/main/java/org/geysermc/geyser/api/item/custom/v2/component/geyser/GeyserChargeable.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
* charges on being drawn, and the ammunition that can be
4141
* used by the item.
4242
*/
43-
public interface Chargeable {
43+
public interface GeyserChargeable {
4444

4545
/**
4646
* The maximum draw duration determines how long the weapon
@@ -63,7 +63,7 @@ public interface Chargeable {
6363
* For example, this can contain {@code minecraft:arrow} to allow arrows to be shot.
6464
*
6565
* <p>Items listed <em>must</em> have a {@code minecraft:projectile} component on bedrock to work.
66-
* Non-vanilla custom items can mark an item as a projectile and add this component by specifying the {@link GeyserDataComponent#PROJECTILE} component.</p>
66+
* Non-vanilla custom items can mark an item as a projectile and add this component by specifying the {@link GeyserItemDataComponent#PROJECTILE} component.</p>
6767
*
6868
* @return all valid ammunition items
6969
*/
@@ -74,20 +74,20 @@ public interface Chargeable {
7474
*
7575
* @return a new builder
7676
*/
77-
static Builder builder() {
78-
return GeyserApi.api().provider(Chargeable.Builder.class);
77+
static @NonNull Builder builder() {
78+
return GeyserApi.api().provider(GeyserChargeable.Builder.class);
7979
}
8080

8181
/**
8282
* Builder for the chargeable component.
8383
*/
84-
interface Builder extends GenericBuilder<Chargeable> {
84+
interface Builder extends GenericBuilder<GeyserChargeable> {
8585

8686
/**
8787
* Sets the maximum draw duration before the item is released.
8888
*
8989
* @param maxDrawDuration the non-negative maximum charging duration
90-
* @see Chargeable#maxDrawDuration()
90+
* @see GeyserChargeable#maxDrawDuration()
9191
* @return this builder
9292
*/
9393
@This
@@ -97,7 +97,7 @@ interface Builder extends GenericBuilder<Chargeable> {
9797
* Sets whether the item is charged when drawing.
9898
*
9999
* @param chargeOnDraw whether drawing charges the item
100-
* @see Chargeable#chargeOnDraw()
100+
* @see GeyserChargeable#chargeOnDraw()
101101
* @return this builder
102102
*/
103103
@This
@@ -108,7 +108,7 @@ interface Builder extends GenericBuilder<Chargeable> {
108108
* This will throw when trying to add an item that was already added.
109109
*
110110
* @param ammunition the Bedrock item identifier of possible ammunition
111-
* @see Chargeable#ammunition()
111+
* @see GeyserChargeable#ammunition()
112112
* @return this builder
113113
*/
114114
@This
@@ -120,6 +120,6 @@ interface Builder extends GenericBuilder<Chargeable> {
120120
* @return the new component
121121
*/
122122
@Override
123-
Chargeable build();
123+
GeyserChargeable build();
124124
}
125125
}

0 commit comments

Comments
 (0)