mirror of
https://github.com/PikaMug/Quests.git
synced 2024-11-26 12:46:18 +01:00
Improved error for null stage on block objective, fixes #1739
This commit is contained in:
parent
a89da8920c
commit
95c8da0590
@ -12,9 +12,15 @@
|
|||||||
|
|
||||||
package me.blackvein.quests.listeners;
|
package me.blackvein.quests.listeners;
|
||||||
|
|
||||||
import java.util.HashSet;
|
import me.blackvein.quests.Objective;
|
||||||
import java.util.Set;
|
import me.blackvein.quests.Quest;
|
||||||
|
import me.blackvein.quests.Quester;
|
||||||
|
import me.blackvein.quests.Quests;
|
||||||
|
import me.blackvein.quests.enums.ObjectiveType;
|
||||||
|
import me.blackvein.quests.events.quester.QuesterPostUpdateObjectiveEvent;
|
||||||
|
import me.blackvein.quests.events.quester.QuesterPreUpdateObjectiveEvent;
|
||||||
|
import me.blackvein.quests.util.ItemUtil;
|
||||||
|
import me.blackvein.quests.util.Lang;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.enchantments.Enchantment;
|
import org.bukkit.enchantments.Enchantment;
|
||||||
@ -30,15 +36,8 @@ import org.bukkit.event.player.PlayerInteractEvent;
|
|||||||
import org.bukkit.inventory.EquipmentSlot;
|
import org.bukkit.inventory.EquipmentSlot;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import me.blackvein.quests.Objective;
|
import java.util.HashSet;
|
||||||
import me.blackvein.quests.Quest;
|
import java.util.Set;
|
||||||
import me.blackvein.quests.Quester;
|
|
||||||
import me.blackvein.quests.Quests;
|
|
||||||
import me.blackvein.quests.enums.ObjectiveType;
|
|
||||||
import me.blackvein.quests.events.quester.QuesterPostUpdateObjectiveEvent;
|
|
||||||
import me.blackvein.quests.events.quester.QuesterPreUpdateObjectiveEvent;
|
|
||||||
import me.blackvein.quests.util.ItemUtil;
|
|
||||||
import me.blackvein.quests.util.Lang;
|
|
||||||
|
|
||||||
public class BlockListener implements Listener {
|
public class BlockListener implements Listener {
|
||||||
|
|
||||||
@ -63,12 +62,17 @@ public class BlockListener implements Listener {
|
|||||||
final Set<String> dispatchedPlaceQuestIDs = new HashSet<String>();
|
final Set<String> dispatchedPlaceQuestIDs = new HashSet<String>();
|
||||||
final Set<String> dispatchedCutQuestIDs = new HashSet<String>();
|
final Set<String> dispatchedCutQuestIDs = new HashSet<String>();
|
||||||
for (final Quest quest : plugin.getLoadedQuests()) {
|
for (final Quest quest : plugin.getLoadedQuests()) {
|
||||||
if (evt.isCancelled() == false) {
|
if (!evt.isCancelled()) {
|
||||||
if (!quester.meetsCondition(quest, true)) {
|
if (!quester.meetsCondition(quest, true)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (quester.getCurrentQuests().containsKey(quest)
|
if (quester.getCurrentQuests().containsKey(quest)) {
|
||||||
&& quester.getCurrentStage(quest).containsObjective(breakType)) {
|
if (quester.getCurrentStage(quest) == null) {
|
||||||
|
plugin.getLogger().severe("Player " + player.getName() + " (" + player.getUniqueId()
|
||||||
|
+ ") has invalid stage for quest " + quest.getName() + " (" + quest.getId() + ")");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (quester.getCurrentStage(quest).containsObjective(breakType)) {
|
||||||
if (quest.getOptions().canIgnoreSilkTouch()
|
if (quest.getOptions().canIgnoreSilkTouch()
|
||||||
&& player.getItemInHand().containsEnchantment(Enchantment.SILK_TOUCH)) {
|
&& player.getItemInHand().containsEnchantment(Enchantment.SILK_TOUCH)) {
|
||||||
player.sendMessage(ChatColor.RED + Lang.get(player, "optionSilkTouchFail")
|
player.sendMessage(ChatColor.RED + Lang.get(player, "optionSilkTouchFail")
|
||||||
@ -86,9 +90,7 @@ public class BlockListener implements Listener {
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (quester.getCurrentStage(quest).containsObjective(placeType)) {
|
||||||
if (quester.getCurrentQuests().containsKey(quest)
|
|
||||||
&& quester.getCurrentStage(quest).containsObjective(placeType)) {
|
|
||||||
for (final ItemStack is : quester.getQuestData(quest).blocksPlaced) {
|
for (final ItemStack is : quester.getQuestData(quest).blocksPlaced) {
|
||||||
if (evt.getBlock().getType().equals(is.getType()) && is.getAmount() > 0) {
|
if (evt.getBlock().getType().equals(is.getType()) && is.getAmount() > 0) {
|
||||||
ItemStack toPlace = new ItemStack(is.getType(), 64);
|
ItemStack toPlace = new ItemStack(is.getType(), 64);
|
||||||
@ -146,8 +148,7 @@ public class BlockListener implements Listener {
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}));
|
}));
|
||||||
if (quester.getCurrentQuests().containsKey(quest)
|
if (quester.getCurrentStage(quest).containsObjective(cutType)) {
|
||||||
&& quester.getCurrentStage(quest).containsObjective(cutType)) {
|
|
||||||
if (player.getItemInHand().getType().equals(Material.SHEARS)) {
|
if (player.getItemInHand().getType().equals(Material.SHEARS)) {
|
||||||
quester.cutBlock(quest, blockItemStack);
|
quester.cutBlock(quest, blockItemStack);
|
||||||
}
|
}
|
||||||
@ -165,6 +166,7 @@ public class BlockListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@SuppressWarnings("deprecation") // since 1.13
|
@SuppressWarnings("deprecation") // since 1.13
|
||||||
@EventHandler
|
@EventHandler
|
||||||
|
Loading…
Reference in New Issue
Block a user