Fix issue with Reward Item changing (#84).

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.
This commit is contained in:
BONNe1704 2019-02-14 14:20:08 +02:00
parent e0022b5c12
commit e26c957797
2 changed files with 10 additions and 4 deletions

View File

@ -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>

View File

@ -210,7 +210,9 @@ public class TryToComplete
// 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));
}
@ -247,7 +249,9 @@ public class TryToComplete
// 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));
}
@ -280,7 +284,9 @@ public class TryToComplete
// 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));
}