Skip to content

Commit

Permalink
don't need to unnecessary item meta edits for setting the max stack size
Browse files Browse the repository at this point in the history
I was fixing the issue in the wrong place.
  • Loading branch information
ryderbelserion committed Jul 12, 2024
1 parent 044d071 commit c9242ba
Showing 1 changed file with 6 additions and 44 deletions.
50 changes: 6 additions & 44 deletions src/main/java/com/badbones69/crazycrates/api/objects/Crate.java
Original file line number Diff line number Diff line change
Expand Up @@ -530,28 +530,15 @@ public final CrateType getCrateType() {
* @return the key as an item stack.
*/
public @NotNull final ItemStack getKey(Player player) {
final ItemStack itemStack = this.userManager.addPlaceholders(this.keyBuilder.setPlayer(player), this).getStack();

if (itemStack.hasItemMeta()) {
itemStack.editMeta(itemMeta -> itemMeta.setMaxStackSize(64));
}

return itemStack;
return this.userManager.addPlaceholders(this.keyBuilder.setPlayer(player), this).getStack();
}

/**
* @param amount The amount of keys you want.
* @return the key as an item stack.
*/
public @NotNull final ItemStack getKey(int amount) {
final ItemStack itemStack = this.keyBuilder.getStack();
itemStack.setAmount(amount);

if (itemStack.hasItemMeta()) {
itemStack.editMeta(itemMeta -> itemMeta.setMaxStackSize(64));
}

return itemStack;
return this.keyBuilder.setAmount(amount).getStack();
}

/**
Expand All @@ -560,14 +547,7 @@ public final CrateType getCrateType() {
* @return the key as an item stack.
*/
public @NotNull final ItemStack getKey(int amount, Player player) {
final ItemStack itemStack = this.userManager.addPlaceholders(this.keyBuilder.setPlayer(player), this).getStack();
itemStack.setAmount(amount);

if (itemStack.hasItemMeta()) {
itemStack.editMeta(itemMeta -> itemMeta.setMaxStackSize(64));
}

return itemStack;
return this.userManager.addPlaceholders(this.keyBuilder.setPlayer(player), this).setAmount(amount).getStack();
}

/**
Expand Down Expand Up @@ -831,13 +811,7 @@ public final int getAbsolutePreviewItemPosition(final int baseSlot) {
ArrayList<ItemStack> items = new ArrayList<>();

for (final Prize prize : getPrizes()) {
ItemStack stack = prize.getDisplayItem();

if (stack.hasItemMeta()) {
stack.editMeta(itemMeta -> itemMeta.setMaxStackSize(64));
}

items.add(stack);
items.add(prize.getDisplayItem());
}

return items;
Expand All @@ -852,13 +826,7 @@ public final int getAbsolutePreviewItemPosition(final int baseSlot) {
List<ItemStack> items = new ArrayList<>();

for (final Prize prize : getPrizes()) {
ItemStack stack = prize.getDisplayItem(player);

if (stack.hasItemMeta()) {
stack.editMeta(itemMeta -> itemMeta.setMaxStackSize(64));
}

items.add(stack);
items.add(prize.getDisplayItem(player));
}

return items;
Expand All @@ -875,13 +843,7 @@ public final int getAbsolutePreviewItemPosition(final int baseSlot) {

for (final Prize prize : getPrizes()) {
if (prize.getTiers().contains(tier)) {
ItemStack stack = prize.getDisplayItem(player);

if (stack.hasItemMeta()) {
stack.editMeta(itemMeta -> itemMeta.setMaxStackSize(64));
}

prizes.add(stack);
prizes.add(prize.getDisplayItem(player));
}
}

Expand Down

0 comments on commit c9242ba

Please sign in to comment.