From 3b8e0aa7afdabf140c3054df7534836e74e47bc3 Mon Sep 17 00:00:00 2001 From: PikaMug <2267126+PikaMug@users.noreply.github.com> Date: Tue, 5 Jan 2021 16:06:14 -0500 Subject: [PATCH] Address several multiplayer objective issues, by @AlessioDP --- .../quests/listeners/BlockListener.java | 21 +++++++------------ .../quests/listeners/ItemListener.java | 4 ++-- 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/main/src/main/java/me/blackvein/quests/listeners/BlockListener.java b/main/src/main/java/me/blackvein/quests/listeners/BlockListener.java index 5f077a74a..0a723c93b 100644 --- a/main/src/main/java/me/blackvein/quests/listeners/BlockListener.java +++ b/main/src/main/java/me/blackvein/quests/listeners/BlockListener.java @@ -70,18 +70,13 @@ public class BlockListener implements Listener { .replace("", quest.getName())); } else { quester.breakBlock(quest, blockItemStack); + + quester.dispatchMultiplayerEverything(quest, breakType, (final Quester q) -> { + q.breakBlock(quest, blockItemStack); + return null; + }); } } - quester.dispatchMultiplayerEverything(quest, breakType, (final Quester q) -> { - if (quest.getOptions().canIgnoreSilkTouch() - && player.getItemInHand().containsEnchantment(Enchantment.SILK_TOUCH)) { - player.sendMessage(ChatColor.RED + Lang.get(player, "optionSilkTouchFail") - .replace("", quest.getName())); - } else { - quester.breakBlock(quest, blockItemStack); - } - return null; - }); if (quester.getCurrentQuests().containsKey(quest) && quester.getCurrentStage(quest).containsObjective(placeType)) { for (final ItemStack is : quester.getQuestData(quest).blocksPlaced) { @@ -115,7 +110,7 @@ public class BlockListener implements Listener { for (final ItemStack is : q.getQuestData(quest).blocksPlaced) { if (evt.getBlock().getType().equals(is.getType()) && is.getAmount() > 0) { ItemStack toPlace = new ItemStack(is.getType(), 64); - for (final ItemStack stack : quester.getCurrentStage(quest).getBlocksToPlace()) { + for (final ItemStack stack : q.getCurrentStage(quest).getBlocksToPlace()) { if (ItemUtil.compareItems(is, stack, true) == 0) { toPlace = stack; } @@ -123,7 +118,7 @@ public class BlockListener implements Listener { final ObjectiveType type = ObjectiveType.PLACE_BLOCK; final QuesterPreUpdateObjectiveEvent preEvent - = new QuesterPreUpdateObjectiveEvent(quester, quest, + = new QuesterPreUpdateObjectiveEvent(q, quest, new Objective(type, is.getAmount(), toPlace.getAmount())); plugin.getServer().getPluginManager().callEvent(preEvent); @@ -133,7 +128,7 @@ public class BlockListener implements Listener { q.getQuestData(quest).blocksPlaced.set(index, is); final QuesterPostUpdateObjectiveEvent postEvent - = new QuesterPostUpdateObjectiveEvent(quester, quest, + = new QuesterPostUpdateObjectiveEvent(q, quest, new Objective(type, newAmount, toPlace.getAmount())); plugin.getServer().getPluginManager().callEvent(postEvent); } diff --git a/main/src/main/java/me/blackvein/quests/listeners/ItemListener.java b/main/src/main/java/me/blackvein/quests/listeners/ItemListener.java index 5dcb3bd8c..25e9af1d1 100644 --- a/main/src/main/java/me/blackvein/quests/listeners/ItemListener.java +++ b/main/src/main/java/me/blackvein/quests/listeners/ItemListener.java @@ -154,7 +154,7 @@ public class ItemListener implements Listener { } quester.dispatchMultiplayerEverything(quest, type, (final Quester q) -> { - quester.enchantItem(quest, enchantedItem); + q.enchantItem(quest, enchantedItem); return null; }); } @@ -180,7 +180,7 @@ public class ItemListener implements Listener { } quester.dispatchMultiplayerEverything(quest, type, (final Quester q) -> { - quester.consumeItem(quest, consumedItem); + q.consumeItem(quest, consumedItem); return null; }); }