Halt prematurely taking item requirements of duplicate type, fixes #1402

This commit is contained in:
PikaMug 2020-09-16 04:21:25 -04:00
parent a53a8996f6
commit bc7d6b0aae

View File

@ -441,6 +441,7 @@ public class Quester {
* @param q The quest to start * @param q The quest to start
* @param ignoreReqs Whether to ignore Requirements * @param ignoreReqs Whether to ignore Requirements
*/ */
@SuppressWarnings("deprecation")
public void takeQuest(final Quest q, final boolean ignoreReqs) { public void takeQuest(final Quest q, final boolean ignoreReqs) {
if (q == null) { if (q == null) {
return; return;
@ -552,10 +553,13 @@ public class Quester {
} }
if (player.isOnline()) { if (player.isOnline()) {
final Player p = getPlayer(); final Player p = getPlayer();
final ItemStack[] original = p.getInventory().getContents().clone();
for (final ItemStack is : reqs.getItems()) { for (final ItemStack is : reqs.getItems()) {
if (reqs.getRemoveItems().get(reqs.getItems().indexOf(is)) == true) { if (reqs.getRemoveItems().get(reqs.getItems().indexOf(is)) == true) {
if (InventoryUtil.removeItem(p.getInventory(), is) == false) { if (InventoryUtil.removeItem(p.getInventory(), is) == false) {
if (InventoryUtil.stripItem(p.getEquipment(), is) == false) { if (InventoryUtil.stripItem(p.getEquipment(), is) == false) {
p.getInventory().setContents(original);
p.updateInventory();
p.sendMessage(Lang.get(p, "requirementsItemFail")); p.sendMessage(Lang.get(p, "requirementsItemFail"));
hardQuit(q); hardQuit(q);
return; return;