From e26c9577979ff867d63d39443bf05fed75d9a38c Mon Sep 17 00:00:00 2001 From: BONNe1704 Date: Thu, 14 Feb 2019 14:20:08 +0200 Subject: [PATCH] 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. --- pom.xml | 2 +- .../bentobox/challenges/panel/TryToComplete.java | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index 7f4425e..5adb789 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ world.bentobox challenges - 0.5.0 + 0.5.1 Challenges Challenges is an add-on for BentoBox, an expandable Minecraft Bukkit plugin for island-type games like SkyBlock, AcidIsland or CaveBlock. diff --git a/src/main/java/world/bentobox/challenges/panel/TryToComplete.java b/src/main/java/world/bentobox/challenges/panel/TryToComplete.java index fcabbc4..934201c 100644 --- a/src/main/java/world/bentobox/challenges/panel/TryToComplete.java +++ b/src/main/java/world/bentobox/challenges/panel/TryToComplete.java @@ -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)); }