Skip to content

Commit c51ae0f

Browse files
committed
Merge remote-tracking branch 'origin/main' into feature/new-menus
2 parents b29c6b6 + 86bf6b2 commit c51ae0f

2 files changed

Lines changed: 13 additions & 6 deletions

File tree

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
<plugin>
4848
<groupId>org.apache.maven.plugins</groupId>
4949
<artifactId>maven-javadoc-plugin</artifactId>
50-
<version>3.11.1</version>
50+
<version>3.11.2</version>
5151
<configuration>
5252
<doclint>all,-missing</doclint>
5353
</configuration>
@@ -101,7 +101,7 @@
101101
<dependency>
102102
<groupId>org.junit.jupiter</groupId>
103103
<artifactId>junit-jupiter-engine</artifactId>
104-
<version>5.11.3</version>
104+
<version>5.11.4</version>
105105
<scope>test</scope>
106106
</dependency>
107107
<dependency>

src/main/java/com/cosimo/utilities/item/ItemBuilder.java

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,14 @@
2424
* A proxy class (rather than a true builder) that wraps around an {@link ItemStack}, allowing easier, more fluent and
2525
* chained modifications of the item.
2626
*/
27+
@SuppressWarnings("unused")
2728
public class ItemBuilder implements Cloneable {
2829

2930
/**
3031
* Mutable {@link ItemStack}.
3132
*/
3233
private final ItemStack itemStack;
34+
private ItemMeta itemMeta;
3335

3436
/**
3537
* Creates a new {@link ItemBuilder} from an item stored in a given configuration file's path or a default provided
@@ -132,6 +134,7 @@ public ItemBuilder(@NonNull Material material) {
132134
*/
133135
public ItemBuilder(@NonNull ItemStack itemStack) {
134136
this.itemStack = itemStack;
137+
this.itemMeta = itemStack.getItemMeta();
135138
}
136139

137140
/**
@@ -246,7 +249,9 @@ public ItemBuilder loreAt(@Nullable String line, final int @NonNull ... indices)
246249
*/
247250
@NonNull
248251
public ItemBuilder with(@NonNull Consumer<ItemStack> itemConsumer) {
249-
itemConsumer.accept(this.itemStack);
252+
itemConsumer.accept(this.build());
253+
this.itemMeta = this.itemStack.getItemMeta();
254+
250255
return this;
251256
}
252257

@@ -474,7 +479,7 @@ public ItemBuilder clearLore() {
474479
*/
475480
@NonNull
476481
public Optional<ItemMeta> getItemMeta() {
477-
return Optional.ofNullable(this.itemStack.getItemMeta());
482+
return Optional.ofNullable(this.itemMeta);
478483
}
479484

480485
/**
@@ -503,6 +508,7 @@ public boolean isBreakable() {
503508
*/
504509
@NonNull
505510
public ItemStack build() {
511+
this.itemStack.setItemMeta(this.itemMeta);
506512
return this.itemStack;
507513
}
508514

@@ -514,7 +520,7 @@ public ItemStack build() {
514520
*/
515521
@NonNull
516522
public <E> Button<E> asButton() {
517-
return Button.of(this.itemStack);
523+
return Button.of(this.build());
518524
}
519525

520526
/**
@@ -525,9 +531,10 @@ public <E> Button<E> asButton() {
525531
*/
526532
@NonNull
527533
public <E> Button<E> asButton(E property) {
528-
return Button.of(this.itemStack, property);
534+
return Button.of(this.build(), property);
529535
}
530536

537+
@SuppressWarnings("MethodDoesntCallSuperMethod")
531538
@Override
532539
public ItemBuilder clone() {
533540
return new ItemBuilder(this.itemStack.clone());

0 commit comments

Comments
 (0)