Skip to content

Commit

Permalink
Fix issue with Reward Item changing (#84).
Browse files Browse the repository at this point in the history
This issue may happened because Player#getInventory()#addItem(ItemStack) tries to add element into existing items in player inventory. If it did not manage to add it, it splits it in parts. This splitting created this issue.
It was fixed, by using clone of reward items, instead of using original elements.
  • Loading branch information
BONNe committed Feb 14, 2019
1 parent e0022b5 commit e26c957
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>world.bentobox</groupId>
<artifactId>challenges</artifactId>
<version>0.5.0</version>
<version>0.5.1</version>

<name>Challenges</name>
<description>Challenges is an add-on for BentoBox, an expandable Minecraft Bukkit plugin for island-type games like SkyBlock, AcidIsland or CaveBlock.</description>
Expand Down
12 changes: 9 additions & 3 deletions src/main/java/world/bentobox/challenges/panel/TryToComplete.java
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,9 @@ public ChallengeResult build()
// Item rewards
for (ItemStack reward : this.challenge.getRewardItems())
{
this.user.getInventory().addItem(reward).forEach((k, v) ->
// Clone is necessary because otherwise it will chane reward itemstack
// amount.
this.user.getInventory().addItem(reward.clone()).forEach((k, v) ->
this.user.getWorld().dropItem(this.user.getLocation(), v));
}

Expand Down Expand Up @@ -247,7 +249,9 @@ public ChallengeResult build()
// Item Repeat Rewards
for (ItemStack reward : this.challenge.getRepeatItemReward())
{
this.user.getInventory().addItem(reward).forEach((k, v) ->
// Clone is necessary because otherwise it will chane reward itemstack
// amount.
this.user.getInventory().addItem(reward.clone()).forEach((k, v) ->
this.user.getWorld().dropItem(this.user.getLocation(), v));
}

Expand Down Expand Up @@ -280,7 +284,9 @@ public ChallengeResult build()
// Item rewards
for (ItemStack reward : level.getRewardItems())
{
this.user.getInventory().addItem(reward).forEach((k, v) ->
// Clone is necessary because otherwise it will chane reward itemstack
// amount.
this.user.getInventory().addItem(reward.clone()).forEach((k, v) ->
this.user.getWorld().dropItem(this.user.getLocation(), v));
}

Expand Down

0 comments on commit e26c957

Please sign in to comment.