Skip to content

Commit

Permalink
Fixes an issue where prizes were picked incorrectly.
Browse files Browse the repository at this point in the history
The issue was I was using a method that got the `DisplayName` of the item which is only for previews. If the display name of 2 prizes were exactly the same. It would just get confused and not give prizes correctly.

getPrizeNumber() returns `1` which is what we want when picking prizes.

This is likely the last update for 1.20.4 unless another bug shows up.

```yml
Crate:
  Prizes:
    1:
      DisplayName: "&cAn example of a Player Head!"
```
  • Loading branch information
ryderbelserion authored Apr 27, 2024
2 parents fc5dffc + 5c80ae7 commit 10516f3
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ issues = https://github.com/Crazy-Crew/CrazyCrates/issues

group = com.badbones69.crazycrates
description = Add unlimited crates to your server with 10 different crate types to choose from!
version = 2.0.4
version = 2.0.5
apiVersion = 1.20

mcVersion = 1.20.4
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,7 @@ public List<Prize> getPrizes() {
*/
public Prize getPrize(String name) {
for (Prize prize : this.prizes) {
if (prize.getPrizeName().equalsIgnoreCase(name)) return prize;
if (prize.getPrizeNumber().equalsIgnoreCase(name)) return prize;
}

return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public Prize(String prizeName, String prizeNumber, ConfigurationSection section)

this.section = section;
}

/**
* @return the name of the prize.
*/
Expand All @@ -118,7 +118,7 @@ public String getPrizeNumber() {
public ItemStack getDisplayItem() {
ItemStack itemStack = this.displayItem.build();

itemStack.editMeta(itemMeta -> itemMeta.getPersistentDataContainer().set(PersistentKeys.crate_prize.getNamespacedKey(), PersistentDataType.STRING, this.prizeName));
itemStack.editMeta(itemMeta -> itemMeta.getPersistentDataContainer().set(PersistentKeys.crate_prize.getNamespacedKey(), PersistentDataType.STRING, this.prizeNumber));

return itemStack;
}
Expand All @@ -129,7 +129,7 @@ public ItemStack getDisplayItem() {
public ItemStack getDisplayItem(Player player) {
ItemStack itemStack = this.displayItem.setTarget(player).build();

itemStack.editMeta(itemMeta -> itemMeta.getPersistentDataContainer().set(PersistentKeys.crate_prize.getNamespacedKey(), PersistentDataType.STRING, this.prizeName));
itemStack.editMeta(itemMeta -> itemMeta.getPersistentDataContainer().set(PersistentKeys.crate_prize.getNamespacedKey(), PersistentDataType.STRING, this.prizeNumber));

return itemStack;
}
Expand Down

0 comments on commit 10516f3

Please sign in to comment.