Return cancelled objective events

This commit is contained in:
PikaMug 2022-12-10 05:18:41 -05:00
parent 35819b619c
commit cd4818bfee
5 changed files with 437 additions and 412 deletions

View File

@ -52,10 +52,13 @@ public class BlockListener implements Listener {
@SuppressWarnings("deprecation")
@EventHandler(priority = EventPriority.HIGH) // Because HIGHEST conflicts with AutoSell by extendedclip
public void onBlockBreak(final BlockBreakEvent evt) {
final Player player = evt.getPlayer();
public void onBlockBreak(final BlockBreakEvent event) {
if (event.isCancelled()) {
return;
}
final Player player = event.getPlayer();
if (plugin.canUseQuests(player.getUniqueId())) {
final ItemStack blockItemStack = new ItemStack(evt.getBlock().getType(), 1, evt.getBlock().getState()
final ItemStack blockItemStack = new ItemStack(event.getBlock().getType(), 1, event.getBlock().getState()
.getData().toItemStack().getDurability());
final Quester quester = plugin.getQuester(player.getUniqueId());
final ObjectiveType breakType = ObjectiveType.BREAK_BLOCK;
@ -65,111 +68,109 @@ public class BlockListener implements Listener {
final Set<String> dispatchedPlaceQuestIDs = new HashSet<>();
final Set<String> dispatchedCutQuestIDs = new HashSet<>();
for (final IQuest quest : plugin.getLoadedQuests()) {
if (!evt.isCancelled()) {
if (!quester.meetsCondition(quest, true)) {
if (!quester.meetsCondition(quest, true)) {
continue;
}
if (quester.getCurrentQuestsTemp().containsKey(quest)) {
final IStage currentStage = quester.getCurrentStage(quest);
if (currentStage == null) {
plugin.getLogger().severe("Player " + player.getName() + " (" + player.getUniqueId()
+ ") has invalid stage for quest " + quest.getName() + " (" + quest.getId() + ")");
continue;
}
if (quester.getCurrentQuestsTemp().containsKey(quest)) {
final IStage currentStage = quester.getCurrentStage(quest);
if (currentStage == null) {
plugin.getLogger().severe("Player " + player.getName() + " (" + player.getUniqueId()
+ ") has invalid stage for quest " + quest.getName() + " (" + quest.getId() + ")");
continue;
}
if (currentStage.containsObjective(breakType)) {
if (quest.getOptions().canIgnoreSilkTouch()
&& player.getItemInHand().containsEnchantment(Enchantment.SILK_TOUCH)) {
ActionBarProvider.sendActionBar(player, ChatColor.RED + Lang
.get(player, "optionSilkTouchFail").replace("<quest>", quest.getName()));
} else {
quester.breakBlock(quest, blockItemStack);
if (currentStage.containsObjective(breakType)) {
if (quest.getOptions().canIgnoreSilkTouch()
&& player.getItemInHand().containsEnchantment(Enchantment.SILK_TOUCH)) {
ActionBarProvider.sendActionBar(player, ChatColor.RED + Lang
.get(player, "optionSilkTouchFail").replace("<quest>", quest.getName()));
} else {
quester.breakBlock(quest, blockItemStack);
dispatchedBreakQuestIDs.addAll(quester.dispatchMultiplayerEverything(quest, breakType,
(final IQuester q, final IQuest cq) -> {
if (!dispatchedBreakQuestIDs.contains(cq.getId())) {
q.breakBlock(cq, blockItemStack);
}
return null;
}));
}
}
if (quest.getOptions().canIgnoreBlockReplace()) {
// Ignore blocks broken once replaced (self)
if (currentStage.containsObjective(placeType)) {
for (final ItemStack is : quester.getQuestData(quest).blocksPlaced) {
if (evt.getBlock().getType().equals(is.getType()) && is.getAmount() > 0) {
ItemStack toPlace = new ItemStack(is.getType(), 64);
for (final ItemStack stack : currentStage.getBlocksToPlace()) {
if (ItemUtil.compareItems(is, stack, true) == 0) {
toPlace = stack;
}
}
final QuesterPreUpdateObjectiveEvent preEvent
= new QuesterPreUpdateObjectiveEvent(quester, quest,
new BukkitObjective(placeType, is.getAmount(), toPlace.getAmount()));
plugin.getServer().getPluginManager().callEvent(preEvent);
final int index = quester.getQuestData(quest).blocksPlaced.indexOf(is);
final int newAmount = is.getAmount() - 1;
is.setAmount(newAmount);
quester.getQuestData(quest).blocksPlaced.set(index, is);
final QuesterPostUpdateObjectiveEvent postEvent
= new QuesterPostUpdateObjectiveEvent(quester, quest,
new BukkitObjective(placeType, newAmount, toPlace.getAmount()));
plugin.getServer().getPluginManager().callEvent(postEvent);
}
}
}
// Ignore blocks broken once replaced (party support)
dispatchedPlaceQuestIDs.addAll(quester.dispatchMultiplayerEverything(quest, placeType,
dispatchedBreakQuestIDs.addAll(quester.dispatchMultiplayerEverything(quest, breakType,
(final IQuester q, final IQuest cq) -> {
if (!dispatchedPlaceQuestIDs.contains(cq.getId())) {
for (final ItemStack is : q.getQuestData(cq).blocksPlaced) {
if (evt.getBlock().getType().equals(is.getType()) && is.getAmount() > 0) {
ItemStack toPlace = new ItemStack(is.getType(), 64);
for (final ItemStack stack : quester.getCurrentStage(cq).getBlocksToPlace()) {
if (ItemUtil.compareItems(is, stack, true) == 0) {
toPlace = stack;
}
}
final QuesterPreUpdateObjectiveEvent preEvent
= new QuesterPreUpdateObjectiveEvent((Quester) q, cq,
new BukkitObjective(placeType, is.getAmount(), toPlace.getAmount()));
plugin.getServer().getPluginManager().callEvent(preEvent);
final int index = q.getQuestData(cq).blocksPlaced.indexOf(is);
final int newAmount = is.getAmount() - 1;
is.setAmount(newAmount);
q.getQuestData(cq).blocksPlaced.set(index, is);
final QuesterPostUpdateObjectiveEvent postEvent
= new QuesterPostUpdateObjectiveEvent((Quester) q, cq,
new BukkitObjective(placeType, newAmount, toPlace.getAmount()));
plugin.getServer().getPluginManager().callEvent(postEvent);
}
}
if (!dispatchedBreakQuestIDs.contains(cq.getId())) {
q.breakBlock(cq, blockItemStack);
}
return null;
}));
}
if (currentStage.containsObjective(cutType)) {
if (player.getItemInHand().getType().equals(Material.SHEARS)) {
quester.cutBlock(quest, blockItemStack);
}
if (quest.getOptions().canIgnoreBlockReplace()) {
// Ignore blocks broken once replaced (self)
if (currentStage.containsObjective(placeType)) {
for (final ItemStack is : quester.getQuestData(quest).blocksPlaced) {
if (event.getBlock().getType().equals(is.getType()) && is.getAmount() > 0) {
ItemStack toPlace = new ItemStack(is.getType(), 64);
for (final ItemStack stack : currentStage.getBlocksToPlace()) {
if (ItemUtil.compareItems(is, stack, true) == 0) {
toPlace = stack;
}
}
final QuesterPreUpdateObjectiveEvent preEvent
= new QuesterPreUpdateObjectiveEvent(quester, quest,
new BukkitObjective(placeType, is.getAmount(), toPlace.getAmount()));
plugin.getServer().getPluginManager().callEvent(preEvent);
final int index = quester.getQuestData(quest).blocksPlaced.indexOf(is);
final int newAmount = is.getAmount() - 1;
is.setAmount(newAmount);
quester.getQuestData(quest).blocksPlaced.set(index, is);
final QuesterPostUpdateObjectiveEvent postEvent
= new QuesterPostUpdateObjectiveEvent(quester, quest,
new BukkitObjective(placeType, newAmount, toPlace.getAmount()));
plugin.getServer().getPluginManager().callEvent(postEvent);
}
}
}
dispatchedCutQuestIDs.addAll(quester.dispatchMultiplayerEverything(quest, cutType,
// Ignore blocks broken once replaced (party support)
dispatchedPlaceQuestIDs.addAll(quester.dispatchMultiplayerEverything(quest, placeType,
(final IQuester q, final IQuest cq) -> {
if (!dispatchedCutQuestIDs.contains(cq.getId())) {
if (player.getItemInHand().getType().equals(Material.SHEARS)) {
q.cutBlock(cq, blockItemStack);
if (!dispatchedPlaceQuestIDs.contains(cq.getId())) {
for (final ItemStack is : q.getQuestData(cq).blocksPlaced) {
if (event.getBlock().getType().equals(is.getType()) && is.getAmount() > 0) {
ItemStack toPlace = new ItemStack(is.getType(), 64);
for (final ItemStack stack : quester.getCurrentStage(cq).getBlocksToPlace()) {
if (ItemUtil.compareItems(is, stack, true) == 0) {
toPlace = stack;
}
}
final QuesterPreUpdateObjectiveEvent preEvent
= new QuesterPreUpdateObjectiveEvent((Quester) q, cq,
new BukkitObjective(placeType, is.getAmount(), toPlace.getAmount()));
plugin.getServer().getPluginManager().callEvent(preEvent);
final int index = q.getQuestData(cq).blocksPlaced.indexOf(is);
final int newAmount = is.getAmount() - 1;
is.setAmount(newAmount);
q.getQuestData(cq).blocksPlaced.set(index, is);
final QuesterPostUpdateObjectiveEvent postEvent
= new QuesterPostUpdateObjectiveEvent((Quester) q, cq,
new BukkitObjective(placeType, newAmount, toPlace.getAmount()));
plugin.getServer().getPluginManager().callEvent(postEvent);
}
}
}
return null;
}));
}
if (currentStage.containsObjective(cutType)) {
if (player.getItemInHand().getType().equals(Material.SHEARS)) {
quester.cutBlock(quest, blockItemStack);
}
}
dispatchedCutQuestIDs.addAll(quester.dispatchMultiplayerEverything(quest, cutType,
(final IQuester q, final IQuest cq) -> {
if (!dispatchedCutQuestIDs.contains(cq.getId())) {
if (player.getItemInHand().getType().equals(Material.SHEARS)) {
q.cutBlock(cq, blockItemStack);
}
}
return null;
}));
}
}
}
@ -177,10 +178,13 @@ public class BlockListener implements Listener {
@SuppressWarnings("deprecation") // since 1.13
@EventHandler
public void onBlockDamage(final BlockDamageEvent evt) {
final Player player = evt.getPlayer();
public void onBlockDamage(final BlockDamageEvent event) {
if (event.isCancelled()) {
return;
}
final Player player = event.getPlayer();
if (plugin.canUseQuests(player.getUniqueId())) {
final ItemStack blockItemStack = new ItemStack(evt.getBlock().getType(), 1, evt.getBlock().getState()
final ItemStack blockItemStack = new ItemStack(event.getBlock().getType(), 1, event.getBlock().getState()
.getData().toItemStack().getDurability());
final IQuester quester = plugin.getQuester(player.getUniqueId());
final ObjectiveType type = ObjectiveType.DAMAGE_BLOCK;
@ -208,10 +212,13 @@ public class BlockListener implements Listener {
@SuppressWarnings("deprecation") // since 1.13
@EventHandler(priority = EventPriority.HIGHEST)
public void onBlockPlace(final BlockPlaceEvent evt) {
final Player player = evt.getPlayer();
public void onBlockPlace(final BlockPlaceEvent event) {
if (event.isCancelled()) {
return;
}
final Player player = event.getPlayer();
if (plugin.canUseQuests(player.getUniqueId())) {
final ItemStack blockItemStack = new ItemStack(evt.getBlock().getType(), 1, evt.getBlock().getState()
final ItemStack blockItemStack = new ItemStack(event.getBlock().getType(), 1, event.getBlock().getState()
.getData().toItemStack().getDurability());
final Quester quester = plugin.getQuester(player.getUniqueId());
final ObjectiveType placeType = ObjectiveType.PLACE_BLOCK;
@ -219,113 +226,114 @@ public class BlockListener implements Listener {
final Set<String> dispatchedPlaceQuestIDs = new HashSet<>();
final Set<String> dispatchedBreakQuestIDs = new HashSet<>();
for (final IQuest quest : plugin.getLoadedQuests()) {
if (!evt.isCancelled()) {
if (!quester.meetsCondition(quest, true)) {
continue;
if (!quester.meetsCondition(quest, true)) {
continue;
}
if (quester.getCurrentQuestsTemp().containsKey(quest)) {
final IStage currentStage = quester.getCurrentStage(quest);
if (currentStage.containsObjective(placeType)) {
quester.placeBlock(quest, blockItemStack);
}
if (quester.getCurrentQuestsTemp().containsKey(quest)) {
final IStage currentStage = quester.getCurrentStage(quest);
if (currentStage.containsObjective(placeType)) {
quester.placeBlock(quest, blockItemStack);
}
if (quest.getOptions().canIgnoreBlockReplace()) {
// Ignore blocks replaced once broken (self)
if (currentStage.containsObjective(breakType)) {
for (final ItemStack is : quester.getQuestData(quest).blocksBroken) {
if (evt.getBlock().getType().equals(is.getType()) && is.getAmount() > 0) {
ItemStack toBreak = new ItemStack(is.getType(), 64);
for (final ItemStack stack : currentStage.getBlocksToBreak()) {
if (ItemUtil.compareItems(is, stack, true) == 0) {
toBreak = stack;
}
if (quest.getOptions().canIgnoreBlockReplace()) {
// Ignore blocks replaced once broken (self)
if (currentStage.containsObjective(breakType)) {
for (final ItemStack is : quester.getQuestData(quest).blocksBroken) {
if (event.getBlock().getType().equals(is.getType()) && is.getAmount() > 0) {
ItemStack toBreak = new ItemStack(is.getType(), 64);
for (final ItemStack stack : currentStage.getBlocksToBreak()) {
if (ItemUtil.compareItems(is, stack, true) == 0) {
toBreak = stack;
}
final QuesterPreUpdateObjectiveEvent preEvent
= new QuesterPreUpdateObjectiveEvent(quester, quest,
new BukkitObjective(placeType, is.getAmount(), toBreak.getAmount()));
plugin.getServer().getPluginManager().callEvent(preEvent);
final int index = quester.getQuestData(quest).blocksBroken.indexOf(is);
final int newAmount = is.getAmount() - 1;
is.setAmount(newAmount);
quester.getQuestData(quest).blocksBroken.set(index, is);
final QuesterPostUpdateObjectiveEvent postEvent
= new QuesterPostUpdateObjectiveEvent(quester, quest,
new BukkitObjective(placeType, newAmount, toBreak.getAmount()));
plugin.getServer().getPluginManager().callEvent(postEvent);
}
final QuesterPreUpdateObjectiveEvent preEvent
= new QuesterPreUpdateObjectiveEvent(quester, quest,
new BukkitObjective(placeType, is.getAmount(), toBreak.getAmount()));
plugin.getServer().getPluginManager().callEvent(preEvent);
final int index = quester.getQuestData(quest).blocksBroken.indexOf(is);
final int newAmount = is.getAmount() - 1;
is.setAmount(newAmount);
quester.getQuestData(quest).blocksBroken.set(index, is);
final QuesterPostUpdateObjectiveEvent postEvent
= new QuesterPostUpdateObjectiveEvent(quester, quest,
new BukkitObjective(placeType, newAmount, toBreak.getAmount()));
plugin.getServer().getPluginManager().callEvent(postEvent);
}
}
// Ignore blocks replaced once broken (party support)
dispatchedBreakQuestIDs.addAll(quester.dispatchMultiplayerEverything(quest, breakType,
(final IQuester q, final IQuest cq) -> {
if (!dispatchedBreakQuestIDs.contains(cq.getId())) {
for (final ItemStack is : q.getQuestData(cq).blocksBroken) {
if (evt.getBlock().getType().equals(is.getType()) && is.getAmount() > 0) {
ItemStack toBreak = new ItemStack(is.getType(), 64);
for (final ItemStack stack : quester.getCurrentStage(cq).getBlocksToBreak()) {
if (ItemUtil.compareItems(is, stack, true) == 0) {
toBreak = stack;
}
}
// Ignore blocks replaced once broken (party support)
dispatchedBreakQuestIDs.addAll(quester.dispatchMultiplayerEverything(quest, breakType,
(final IQuester q, final IQuest cq) -> {
if (!dispatchedBreakQuestIDs.contains(cq.getId())) {
for (final ItemStack is : q.getQuestData(cq).blocksBroken) {
if (event.getBlock().getType().equals(is.getType()) && is.getAmount() > 0) {
ItemStack toBreak = new ItemStack(is.getType(), 64);
for (final ItemStack stack : quester.getCurrentStage(cq).getBlocksToBreak()) {
if (ItemUtil.compareItems(is, stack, true) == 0) {
toBreak = stack;
}
final QuesterPreUpdateObjectiveEvent preEvent
= new QuesterPreUpdateObjectiveEvent((Quester) q, cq,
new BukkitObjective(breakType, is.getAmount(), toBreak.getAmount()));
plugin.getServer().getPluginManager().callEvent(preEvent);
final int index = q.getQuestData(cq).blocksBroken.indexOf(is);
final int newAmount = is.getAmount() - 1;
is.setAmount(newAmount);
q.getQuestData(cq).blocksBroken.set(index, is);
final QuesterPostUpdateObjectiveEvent postEvent
= new QuesterPostUpdateObjectiveEvent((Quester) q, cq,
new BukkitObjective(breakType, newAmount, toBreak.getAmount()));
plugin.getServer().getPluginManager().callEvent(postEvent);
}
final QuesterPreUpdateObjectiveEvent preEvent
= new QuesterPreUpdateObjectiveEvent((Quester) q, cq,
new BukkitObjective(breakType, is.getAmount(), toBreak.getAmount()));
plugin.getServer().getPluginManager().callEvent(preEvent);
final int index = q.getQuestData(cq).blocksBroken.indexOf(is);
final int newAmount = is.getAmount() - 1;
is.setAmount(newAmount);
q.getQuestData(cq).blocksBroken.set(index, is);
final QuesterPostUpdateObjectiveEvent postEvent
= new QuesterPostUpdateObjectiveEvent((Quester) q, cq,
new BukkitObjective(breakType, newAmount, toBreak.getAmount()));
plugin.getServer().getPluginManager().callEvent(postEvent);
}
}
return null;
}));
}
}
return null;
}));
}
dispatchedPlaceQuestIDs.addAll(quester.dispatchMultiplayerEverything(quest, placeType,
(final IQuester q, final IQuest cq) -> {
if (!dispatchedPlaceQuestIDs.contains(cq.getId())) {
q.placeBlock(cq, blockItemStack);
}
return null;
}));
}
dispatchedPlaceQuestIDs.addAll(quester.dispatchMultiplayerEverything(quest, placeType,
(final IQuester q, final IQuest cq) -> {
if (!dispatchedPlaceQuestIDs.contains(cq.getId())) {
q.placeBlock(cq, blockItemStack);
}
return null;
}));
}
}
}
@SuppressWarnings("deprecation") // since 1.13
@EventHandler
public void onBlockUse(final PlayerInteractEvent evt) {
public void onBlockUse(final PlayerInteractEvent event) {
if (event.isCancelled()) {
return;
}
EquipmentSlot e = null;
try {
e = evt.getHand();
e = event.getHand();
} catch (final NoSuchMethodError err) {
// Do nothing, getHand() not present pre-1.9
}
if (e == null || e.equals(EquipmentSlot.HAND)) { // If the event is fired by HAND (main hand)
final Player player = evt.getPlayer();
if (plugin.canUseQuests(evt.getPlayer().getUniqueId())) {
final Player player = event.getPlayer();
if (plugin.canUseQuests(event.getPlayer().getUniqueId())) {
final IQuester quester = plugin.getQuester(player.getUniqueId());
if (quester.isSelectingBlock()) {
return;
}
if (evt.getAction().equals(Action.RIGHT_CLICK_BLOCK)) {
if (!evt.isCancelled() && evt.getClickedBlock() != null) {
final ItemStack blockItemStack = new ItemStack(evt.getClickedBlock().getType(), 1, evt
if (event.getAction().equals(Action.RIGHT_CLICK_BLOCK)) {
if (!event.isCancelled() && event.getClickedBlock() != null) {
final ItemStack blockItemStack = new ItemStack(event.getClickedBlock().getType(), 1, event
.getClickedBlock().getState().getData().toItemStack().getDurability());
final ObjectiveType type = ObjectiveType.USE_BLOCK;
final Set<String> dispatchedQuestIDs = new HashSet<>();

View File

@ -54,19 +54,19 @@ public class CitizensListener implements Listener {
@SuppressWarnings("deprecation")
@EventHandler(priority = EventPriority.LOWEST)
public void onNPCRightClick(final NPCRightClickEvent evt) {
public void onNPCRightClick(final NPCRightClickEvent event) {
if (plugin.getDependencies().getCitizens() == null) {
return;
}
if (plugin.getQuestFactory().getSelectingNpcs().contains(evt.getClicker().getUniqueId())) {
if (evt.getNPC() == null) {
if (plugin.getQuestFactory().getSelectingNpcs().contains(event.getClicker().getUniqueId())) {
if (event.getNPC() == null) {
plugin.getLogger().severe("NPC was null while selecting by right-click");
return;
}
evt.getClicker().acceptConversationInput(String.valueOf(evt.getNPC().getUniqueId()));
event.getClicker().acceptConversationInput(String.valueOf(event.getNPC().getUniqueId()));
}
if (!evt.getClicker().isConversing()) {
final Player player = evt.getClicker();
if (!event.getClicker().isConversing()) {
final Player player = event.getClicker();
final IQuester quester = plugin.getQuester(player.getUniqueId());
for (final IQuest quest : quester.getCurrentQuestsTemp().keySet()) {
if (quester.getCurrentStage(quest).containsObjective(ObjectiveType.DELIVER_ITEM)) {
@ -81,7 +81,7 @@ public class CitizensListener implements Listener {
matches.add(currentIndex);
}
}
final NPC clicked = evt.getNPC();
final NPC clicked = event.getNPC();
if (!matches.isEmpty()) {
for (final Integer match : matches) {
final UUID uuid = quester.getCurrentStage(quest).getItemDeliveryTargets().get(match);
@ -194,18 +194,18 @@ public class CitizensListener implements Listener {
continue;
}
if (quester.getCurrentStage(quest).containsObjective(ObjectiveType.TALK_TO_NPC)) {
if (quester.getCurrentStage(quest).getNpcsToInteract().contains(evt.getNPC().getUniqueId())) {
final int npcIndex = quester.getCurrentStage(quest).getNpcsToInteract().indexOf(evt.getNPC()
if (quester.getCurrentStage(quest).getNpcsToInteract().contains(event.getNPC().getUniqueId())) {
final int npcIndex = quester.getCurrentStage(quest).getNpcsToInteract().indexOf(event.getNPC()
.getUniqueId());
if (quester.getQuestData(quest) != null && npcIndex > -1
&& !quester.getQuestData(quest).npcsInteracted.get(npcIndex)) {
hasObjective = true;
}
quester.interactWithNPC(quest, evt.getNPC().getUniqueId());
quester.interactWithNPC(quest, event.getNPC().getUniqueId());
}
}
}
if (hasObjective || !plugin.getQuestNpcUuids().contains(evt.getNPC().getUniqueId())) {
if (hasObjective || !plugin.getQuestNpcUuids().contains(event.getNPC().getUniqueId())) {
return;
}
boolean hasAtLeastOneGUI = false;
@ -214,7 +214,7 @@ public class CitizensListener implements Listener {
if (quester.getCurrentQuestsTemp().containsKey(q)) {
continue;
}
if (q.getNpcStart() != null && q.getNpcStart().equals(evt.getNPC().getUniqueId())) {
if (q.getNpcStart() != null && q.getNpcStart().equals(event.getNPC().getUniqueId())) {
if (plugin.getSettings().canIgnoreLockedQuests()
&& (!quester.getCompletedQuestsTemp().contains(q)
|| q.getPlanner().getCooldown() > -1)) {
@ -240,7 +240,7 @@ public class CitizensListener implements Listener {
quester.takeQuest(q, false);
} else {
if (q.getGUIDisplay() != null) {
quester.showGUIDisplay(evt.getNPC().getUniqueId(), npcQuests);
quester.showGUIDisplay(event.getNPC().getUniqueId(), npcQuests);
} else {
for (final String msg : extracted(quester).split("<br>")) {
player.sendMessage(msg);
@ -251,11 +251,11 @@ public class CitizensListener implements Listener {
}
} else if (npcQuests.size() > 1) {
if (hasAtLeastOneGUI) {
quester.showGUIDisplay(evt.getNPC().getUniqueId(), npcQuests);
quester.showGUIDisplay(event.getNPC().getUniqueId(), npcQuests);
} else {
final Conversation c = plugin.getNpcConversationFactory().buildConversation(player);
c.getContext().setSessionData("npcQuests", npcQuests);
c.getContext().setSessionData("npc", evt.getNPC().getName());
c.getContext().setSessionData("npc", event.getNPC().getName());
c.begin();
}
} else {
@ -265,31 +265,31 @@ public class CitizensListener implements Listener {
}
@EventHandler
public void onNPCLeftClick(final NPCLeftClickEvent evt) {
public void onNPCLeftClick(final NPCLeftClickEvent event) {
if (plugin.getDependencies().getCitizens() == null) {
return;
}
if (plugin.getQuestFactory().getSelectingNpcs().contains(evt.getClicker().getUniqueId())) {
if (evt.getNPC() == null) {
if (plugin.getQuestFactory().getSelectingNpcs().contains(event.getClicker().getUniqueId())) {
if (event.getNPC() == null) {
plugin.getLogger().severe("NPC was null while selecting by left-click");
return;
}
evt.getClicker().acceptConversationInput(String.valueOf(evt.getNPC().getUniqueId()));
event.getClicker().acceptConversationInput(String.valueOf(event.getNPC().getUniqueId()));
}
}
@EventHandler
public void onNPCDeath(final NPCDeathEvent evt) {
public void onNPCDeath(final NPCDeathEvent event) {
if (plugin.getDependencies().getCitizens() == null) {
return;
}
if (evt.getNPC() == null || evt.getNPC().getEntity() == null
|| evt.getNPC().getEntity().getLastDamageCause() == null) {
if (event.getNPC() == null || event.getNPC().getEntity() == null
|| event.getNPC().getEntity().getLastDamageCause() == null) {
return;
}
if (evt.getNPC().getEntity().getLastDamageCause() instanceof EntityDamageByEntityEvent) {
if (event.getNPC().getEntity().getLastDamageCause() instanceof EntityDamageByEntityEvent) {
final EntityDamageByEntityEvent damageEvent
= (EntityDamageByEntityEvent) evt.getNPC().getEntity().getLastDamageCause();
= (EntityDamageByEntityEvent) event.getNPC().getEntity().getLastDamageCause();
final Entity damager = damageEvent.getDamager();
if (plugin.getDependencies().getCitizens().getNPCRegistry().isNPC(damager)) {
return;
@ -311,13 +311,13 @@ public class CitizensListener implements Listener {
if (quester.getCurrentQuestsTemp().containsKey(quest)
&& quester.getCurrentStage(quest).containsObjective(type)) {
quester.killNPC(quest, evt.getNPC().getUniqueId());
quester.killNPC(quest, event.getNPC().getUniqueId());
}
dispatchedQuestIDs.addAll(quester.dispatchMultiplayerEverything(quest, type,
(final IQuester q, final IQuest cq) -> {
if (!dispatchedQuestIDs.contains(cq.getId())) {
q.killNPC(cq, evt.getNPC().getUniqueId());
q.killNPC(cq, event.getNPC().getUniqueId());
}
return null;
}));

View File

@ -41,14 +41,14 @@ public class ItemListener implements Listener {
}
@EventHandler
public void onCraftItem(final CraftItemEvent evt) {
if (evt.getAction().equals(InventoryAction.NOTHING)) {
public void onCraftItem(final CraftItemEvent event) {
if (event.getAction().equals(InventoryAction.NOTHING)) {
return;
}
if (evt.getWhoClicked() instanceof Player) {
final Player player = (Player) evt.getWhoClicked();
if (event.getWhoClicked() instanceof Player) {
final Player player = (Player) event.getWhoClicked();
if (plugin.canUseQuests(player.getUniqueId())) {
final ItemStack craftedItem = getCraftedItem(evt);
final ItemStack craftedItem = getCraftedItem(event);
final IQuester quester = plugin.getQuester(player.getUniqueId());
final ObjectiveType type = ObjectiveType.CRAFT_ITEM;
final Set<String> dispatchedQuestIDs = new HashSet<>();
@ -74,12 +74,12 @@ public class ItemListener implements Listener {
}
@SuppressWarnings("deprecation")
private ItemStack getCraftedItem(final CraftItemEvent evt) {
if (evt.isShiftClick()) {
final ItemStack recipeResult = evt.getRecipe().getResult();
private ItemStack getCraftedItem(final CraftItemEvent event) {
if (event.isShiftClick()) {
final ItemStack recipeResult = event.getRecipe().getResult();
final int resultAmt = recipeResult.getAmount(); // Bread = 1, Cookie = 8, etc.
int leastIngredient = -1;
for (final ItemStack item : evt.getInventory().getMatrix()) {
for (final ItemStack item : event.getInventory().getMatrix()) {
if (item != null && !item.getType().equals(Material.AIR)) {
final int re = item.getAmount() * resultAmt;
if (leastIngredient == -1 || re < leastIngredient) {
@ -89,17 +89,17 @@ public class ItemListener implements Listener {
}
return new ItemStack(recipeResult.getType(), leastIngredient, recipeResult.getDurability());
}
return evt.getCurrentItem();
return event.getCurrentItem();
}
@EventHandler
public void onInventoryClick(final InventoryClickEvent evt) {
if (evt.getWhoClicked() instanceof Player) {
final Player player = (Player) evt.getWhoClicked();
if (evt.getInventory().getType() == InventoryType.FURNACE
|| evt.getInventory().getType().name().equals("BLAST_FURNACE")
|| evt.getInventory().getType().name().equals("SMOKER")) {
if (evt.getSlotType() == SlotType.RESULT) {
public void onInventoryClick(final InventoryClickEvent event) {
if (event.getWhoClicked() instanceof Player) {
final Player player = (Player) event.getWhoClicked();
if (event.getInventory().getType() == InventoryType.FURNACE
|| event.getInventory().getType().name().equals("BLAST_FURNACE")
|| event.getInventory().getType().name().equals("SMOKER")) {
if (event.getSlotType() == SlotType.RESULT) {
final IQuester quester = plugin.getQuester(player.getUniqueId());
final ObjectiveType type = ObjectiveType.SMELT_ITEM;
final Set<String> dispatchedQuestIDs = new HashSet<>();
@ -110,19 +110,19 @@ public class ItemListener implements Listener {
if (quester.getCurrentQuestsTemp().containsKey(quest)
&& quester.getCurrentStage(quest).containsObjective(type)) {
quester.smeltItem(quest, evt.getCurrentItem());
quester.smeltItem(quest, event.getCurrentItem());
}
dispatchedQuestIDs.addAll(quester.dispatchMultiplayerEverything(quest, type, (final IQuester q, final IQuest cq) -> {
if (!dispatchedQuestIDs.contains(cq.getId())) {
q.smeltItem(cq, evt.getCurrentItem());
q.smeltItem(cq, event.getCurrentItem());
}
return null;
}));
}
}
} else if (evt.getInventory().getType() == InventoryType.BREWING) {
if (evt.getSlotType() == SlotType.CRAFTING) {
} else if (event.getInventory().getType() == InventoryType.BREWING) {
if (event.getSlotType() == SlotType.CRAFTING) {
final IQuester quester = plugin.getQuester(player.getUniqueId());
final ObjectiveType type = ObjectiveType.BREW_ITEM;
final Set<String> dispatchedQuestIDs = new HashSet<>();
@ -133,12 +133,12 @@ public class ItemListener implements Listener {
if (quester.getCurrentQuestsTemp().containsKey(quest)
&& quester.getCurrentStage(quest).containsObjective(type)) {
quester.brewItem(quest, evt.getCurrentItem());
quester.brewItem(quest, event.getCurrentItem());
}
dispatchedQuestIDs.addAll(quester.dispatchMultiplayerEverything(quest, type, (final IQuester q, final IQuest cq) -> {
if (!dispatchedQuestIDs.contains(cq.getId())) {
q.brewItem(cq, evt.getCurrentItem());
q.brewItem(cq, event.getCurrentItem());
}
return null;
}));
@ -149,12 +149,12 @@ public class ItemListener implements Listener {
}
@EventHandler
public void onEnchantItem(final EnchantItemEvent evt) {
if (plugin.canUseQuests(evt.getEnchanter().getUniqueId())) {
final ItemStack enchantedItem = evt.getItem().clone();
public void onEnchantItem(final EnchantItemEvent event) {
if (plugin.canUseQuests(event.getEnchanter().getUniqueId())) {
final ItemStack enchantedItem = event.getItem().clone();
enchantedItem.setAmount(1);
enchantedItem.addUnsafeEnchantments(evt.getEnchantsToAdd());
final IQuester quester = plugin.getQuester(evt.getEnchanter().getUniqueId());
enchantedItem.addUnsafeEnchantments(event.getEnchantsToAdd());
final IQuester quester = plugin.getQuester(event.getEnchanter().getUniqueId());
final ObjectiveType type = ObjectiveType.ENCHANT_ITEM;
final Set<String> dispatchedQuestIDs = new HashSet<>();
for (final IQuest quest : plugin.getLoadedQuests()) {
@ -165,7 +165,7 @@ public class ItemListener implements Listener {
if (quester.getCurrentQuestsTemp().containsKey(quest)
&& quester.getCurrentStage(quest).containsObjective(type)) {
if (enchantedItem.getType().equals(Material.BOOK)) {
quester.enchantBook(quest, enchantedItem, evt.getEnchantsToAdd());
quester.enchantBook(quest, enchantedItem, event.getEnchantsToAdd());
} else {
quester.enchantItem(quest, enchantedItem);
}
@ -174,7 +174,7 @@ public class ItemListener implements Listener {
dispatchedQuestIDs.addAll(quester.dispatchMultiplayerEverything(quest, type, (final IQuester q, final IQuest cq) -> {
if (!dispatchedQuestIDs.contains(cq.getId())) {
if (enchantedItem.getType().equals(Material.BOOK)) {
q.enchantBook(cq, enchantedItem, evt.getEnchantsToAdd());
q.enchantBook(cq, enchantedItem, event.getEnchantsToAdd());
} else {
q.enchantItem(cq, enchantedItem);
}
@ -187,11 +187,11 @@ public class ItemListener implements Listener {
@EventHandler
public void onConsumeItem(final PlayerItemConsumeEvent evt) {
if (plugin.canUseQuests(evt.getPlayer().getUniqueId())) {
final ItemStack consumedItem = evt.getItem().clone();
public void onConsumeItem(final PlayerItemConsumeEvent event) {
if (plugin.canUseQuests(event.getPlayer().getUniqueId())) {
final ItemStack consumedItem = event.getItem().clone();
consumedItem.setAmount(1);
final IQuester quester = plugin.getQuester(evt.getPlayer().getUniqueId());
final IQuester quester = plugin.getQuester(event.getPlayer().getUniqueId());
final ObjectiveType type = ObjectiveType.CONSUME_ITEM;
final Set<String> dispatchedQuestIDs = new HashSet<>();
for (final IQuest quest : plugin.getLoadedQuests()) {

View File

@ -82,49 +82,49 @@ public class PlayerListener implements Listener {
}
@EventHandler(priority = EventPriority.HIGHEST)
public void onInventoryClickEvent(final InventoryClickEvent evt) {
final InventoryAction ac = evt.getAction();
public void onInventoryClickEvent(final InventoryClickEvent event) {
final InventoryAction ac = event.getAction();
if (ac.equals(InventoryAction.NOTHING)) {
return;
}
if (ItemUtil.isItem(evt.getCurrentItem()) && ItemUtil.isJournal(evt.getCurrentItem())) {
if (ItemUtil.isItem(event.getCurrentItem()) && ItemUtil.isJournal(event.getCurrentItem())) {
if (ac.equals(InventoryAction.MOVE_TO_OTHER_INVENTORY) || ac.equals(InventoryAction.DROP_ALL_SLOT)
|| ac.equals(InventoryAction.DROP_ONE_SLOT)) {
evt.setCancelled(true);
event.setCancelled(true);
return;
}
} else if (ItemUtil.isItem(evt.getCurrentItem()) && ItemUtil.isJournal(evt.getCursor())) {
} else if (ItemUtil.isItem(event.getCurrentItem()) && ItemUtil.isJournal(event.getCursor())) {
if (ac.equals(InventoryAction.MOVE_TO_OTHER_INVENTORY) || ac.equals(InventoryAction.DROP_ALL_CURSOR)
|| ac.equals(InventoryAction.DROP_ONE_CURSOR)) {
evt.setCancelled(true);
event.setCancelled(true);
return;
}
} else if (ac.equals(InventoryAction.SWAP_WITH_CURSOR) || ac.equals(InventoryAction.HOTBAR_SWAP)
|| ac.equals(InventoryAction.HOTBAR_MOVE_AND_READD)) {
if (evt.getHotbarButton() > -1) {
final ItemStack item = evt.getWhoClicked().getInventory().getItem(evt.getHotbarButton());
if (event.getHotbarButton() > -1) {
final ItemStack item = event.getWhoClicked().getInventory().getItem(event.getHotbarButton());
if (ItemUtil.isItem(item) && ItemUtil.isJournal(item)) {
evt.setCancelled(true);
event.setCancelled(true);
return;
}
}
}
if (ItemUtil.isItem(evt.getCurrentItem()) && ItemUtil.isJournal(evt.getCurrentItem())
|| ItemUtil.isItem(evt.getCursor()) && ItemUtil.isJournal(evt.getCursor())) {
int upper = evt.getView().getTopInventory().getSize();
if (evt.getView().getTopInventory().getType().equals(InventoryType.CRAFTING))
if (ItemUtil.isItem(event.getCurrentItem()) && ItemUtil.isJournal(event.getCurrentItem())
|| ItemUtil.isItem(event.getCursor()) && ItemUtil.isJournal(event.getCursor())) {
int upper = event.getView().getTopInventory().getSize();
if (event.getView().getTopInventory().getType().equals(InventoryType.CRAFTING))
upper += 4;
final int lower = evt.getView().getBottomInventory().getSize();
final int relative = evt.getRawSlot() - upper;
final int lower = event.getView().getBottomInventory().getSize();
final int relative = event.getRawSlot() - upper;
if (relative < 0 || relative >= (lower)) {
evt.setCancelled(true);
event.setCancelled(true);
return;
}
}
final Quester quester = plugin.getQuester(evt.getWhoClicked().getUniqueId());
final Player player = (Player) evt.getWhoClicked();
if (evt.getView().getTitle().contains(Lang.get(player, "quests"))) {
final ItemStack clicked = evt.getCurrentItem();
final Quester quester = plugin.getQuester(event.getWhoClicked().getUniqueId());
final Player player = (Player) event.getWhoClicked();
if (event.getView().getTitle().contains(Lang.get(player, "quests"))) {
final ItemStack clicked = event.getCurrentItem();
if (ItemUtil.isItem(clicked)) {
for (final IQuest quest : plugin.getLoadedQuests()) {
final Quest bukkitQuest = (Quest)quest;
@ -137,28 +137,28 @@ public class PlayerListener implements Listener {
e.printStackTrace();
}
}
evt.getWhoClicked().closeInventory();
event.getWhoClicked().closeInventory();
break;
}
}
}
evt.setCancelled(true);
event.setCancelled(true);
}
}
}
@EventHandler(priority = EventPriority.HIGHEST)
public void onInventoryDragEvent(final InventoryDragEvent evt) {
if (ItemUtil.isItem(evt.getOldCursor()) && ItemUtil.isJournal(evt.getOldCursor())
|| ItemUtil.isItem(evt.getCursor()) && ItemUtil.isJournal(evt.getCursor())) {
int upper = evt.getView().getTopInventory().getSize();
if (evt.getView().getTopInventory().getType().equals(InventoryType.CRAFTING))
public void onInventoryDragEvent(final InventoryDragEvent event) {
if (ItemUtil.isItem(event.getOldCursor()) && ItemUtil.isJournal(event.getOldCursor())
|| ItemUtil.isItem(event.getCursor()) && ItemUtil.isJournal(event.getCursor())) {
int upper = event.getView().getTopInventory().getSize();
if (event.getView().getTopInventory().getType().equals(InventoryType.CRAFTING))
upper += 4;
final int lower = evt.getView().getBottomInventory().getSize();
for (int relative : evt.getRawSlots()) {
final int lower = event.getView().getBottomInventory().getSize();
for (int relative : event.getRawSlots()) {
relative -= upper;
if (relative < 0 || relative >= (lower)) {
evt.setCancelled(true);
event.setCancelled(true);
break;
}
}
@ -166,62 +166,62 @@ public class PlayerListener implements Listener {
}
@EventHandler
public void onPlayerDropItem(final PlayerDropItemEvent evt) {
if (ItemUtil.isJournal(evt.getItemDrop().getItemStack())) {
if (!evt.getPlayer().hasPermission("quests.admin.drop")) {
evt.setCancelled(true);
public void onPlayerDropItem(final PlayerDropItemEvent event) {
if (ItemUtil.isJournal(event.getItemDrop().getItemStack())) {
if (!event.getPlayer().hasPermission("quests.admin.drop")) {
event.setCancelled(true);
}
}
}
@SuppressWarnings("deprecation") // since 1.13
@EventHandler
public void onPlayerInteract(final PlayerInteractEvent evt) {
public void onPlayerInteract(final PlayerInteractEvent event) {
EquipmentSlot e = null;
try {
e = evt.getHand();
e = event.getHand();
} catch (final NoSuchMethodError err) {
// Do nothing, getHand() not present pre-1.9
}
if (e == null || e.equals(EquipmentSlot.HAND)) { // If the event is fired by HAND (main hand)
if (ItemUtil.isJournal(evt.getPlayer().getItemInHand())) {
final Player player = evt.getPlayer();
if (evt.hasBlock()) {
if (evt.getClickedBlock() == null) {
if (ItemUtil.isJournal(event.getPlayer().getItemInHand())) {
final Player player = event.getPlayer();
if (event.hasBlock()) {
if (event.getClickedBlock() == null) {
return;
}
if (evt.getClickedBlock().getType().name().equals("LECTERN")) {
evt.setCancelled(true);
Lang.send(player, ChatColor.RED + Lang.get(evt.getPlayer(), "journalDenied")
.replace("<journal>", Lang.get(evt.getPlayer(), "journalTitle")));
if (event.getClickedBlock().getType().name().equals("LECTERN")) {
event.setCancelled(true);
Lang.send(player, ChatColor.RED + Lang.get(event.getPlayer(), "journalDenied")
.replace("<journal>", Lang.get(event.getPlayer(), "journalTitle")));
return;
}
if (plugin.getSettings().canAllowPranks()
&& evt.getClickedBlock().getType().name().contains("PORTAL")) {
evt.setCancelled(true);
&& event.getClickedBlock().getType().name().contains("PORTAL")) {
event.setCancelled(true);
Lang.send(player, " " + ChatColor.AQUA + ChatColor.UNDERLINE
+ "https://www.youtube.com/watch?v=dQw4w9WgXcQ");
return;
}
}
if (plugin.getSettings().canAllowPranks()
&& evt.getPlayer().getInventory().getHelmet() != null
&& (evt.getPlayer().getInventory().getHelmet().getType().name().equals("PUMPKIN")
|| evt.getPlayer().getInventory().getHelmet().getType().name().equals("CARVED_PUMPKIN"))) {
if (!evt.getAction().equals(Action.RIGHT_CLICK_AIR)) {
&& event.getPlayer().getInventory().getHelmet() != null
&& (event.getPlayer().getInventory().getHelmet().getType().name().equals("PUMPKIN")
|| event.getPlayer().getInventory().getHelmet().getType().name().equals("CARVED_PUMPKIN"))) {
if (!event.getAction().equals(Action.RIGHT_CLICK_AIR)) {
Lang.send(player, " " + ChatColor.AQUA + ChatColor.UNDERLINE
+ "https://www.youtube.com/watch?v=v4IC7qaNr7I");
}
evt.setCancelled(true);
event.setCancelled(true);
return;
}
}
if (plugin.canUseQuests(evt.getPlayer().getUniqueId())) {
final IQuester quester = plugin.getQuester(evt.getPlayer().getUniqueId());
final Player player = evt.getPlayer();
if (evt.getAction().equals(Action.RIGHT_CLICK_BLOCK)) {
if (plugin.canUseQuests(event.getPlayer().getUniqueId())) {
final IQuester quester = plugin.getQuester(event.getPlayer().getUniqueId());
final Player player = event.getPlayer();
if (event.getAction().equals(Action.RIGHT_CLICK_BLOCK)) {
boolean hasObjective = false;
if (!evt.isCancelled()) {
if (!event.isCancelled()) {
for (final IQuest quest : plugin.getLoadedQuests()) {
if (quester.getCurrentQuestsTemp().containsKey(quest)
&& quester.getCurrentStage(quest).containsObjective(ObjectiveType.USE_BLOCK)) {
@ -230,9 +230,9 @@ public class PlayerListener implements Listener {
}
}
if (!hasObjective) {
if (plugin.getQuestFactory().getSelectedBlockStarts().containsKey(evt.getPlayer()
if (plugin.getQuestFactory().getSelectedBlockStarts().containsKey(event.getPlayer()
.getUniqueId())) {
final Block block = evt.getClickedBlock();
final Block block = event.getClickedBlock();
if (block == null) {
return;
}
@ -246,10 +246,10 @@ public class PlayerListener implements Listener {
+ loc.getY() + ", " + loc.getZ() + ChatColor.GOLD + " (" + ChatColor.GREEN
+ ItemUtil.getName(new ItemStack(block.getType())) + ChatColor.GOLD + ")");
}
evt.setCancelled(true);
} else if (plugin.getActionFactory().getSelectedExplosionLocations().containsKey(evt.getPlayer()
event.setCancelled(true);
} else if (plugin.getActionFactory().getSelectedExplosionLocations().containsKey(event.getPlayer()
.getUniqueId())) {
final Block block = evt.getClickedBlock();
final Block block = event.getClickedBlock();
if (block == null) {
return;
}
@ -263,10 +263,10 @@ public class PlayerListener implements Listener {
+ loc.getY() + ", " + loc.getZ() + ChatColor.GOLD + " (" + ChatColor.GREEN
+ ItemUtil.getName(new ItemStack(block.getType())) + ChatColor.GOLD + ")");
}
evt.setCancelled(true);
} else if (plugin.getActionFactory().getSelectedEffectLocations().containsKey(evt.getPlayer()
event.setCancelled(true);
} else if (plugin.getActionFactory().getSelectedEffectLocations().containsKey(event.getPlayer()
.getUniqueId())) {
final Block block = evt.getClickedBlock();
final Block block = event.getClickedBlock();
if (block == null) {
return;
}
@ -280,10 +280,10 @@ public class PlayerListener implements Listener {
+ loc.getY() + ", " + loc.getZ() + ChatColor.GOLD + " (" + ChatColor.GREEN
+ ItemUtil.getName(new ItemStack(block.getType())) + ChatColor.GOLD + ")");
}
evt.setCancelled(true);
} else if (plugin.getActionFactory().getSelectedMobLocations().containsKey(evt.getPlayer()
event.setCancelled(true);
} else if (plugin.getActionFactory().getSelectedMobLocations().containsKey(event.getPlayer()
.getUniqueId())) {
final Block block = evt.getClickedBlock();
final Block block = event.getClickedBlock();
if (block == null) {
return;
}
@ -297,10 +297,10 @@ public class PlayerListener implements Listener {
+ loc.getY() + ", " + loc.getZ() + ChatColor.GOLD + " (" + ChatColor.GREEN
+ ItemUtil.getName(new ItemStack(block.getType())) + ChatColor.GOLD + ")");
}
evt.setCancelled(true);
} else if (plugin.getActionFactory().getSelectedLightningLocations().containsKey(evt.getPlayer()
event.setCancelled(true);
} else if (plugin.getActionFactory().getSelectedLightningLocations().containsKey(event.getPlayer()
.getUniqueId())) {
final Block block = evt.getClickedBlock();
final Block block = event.getClickedBlock();
if (block == null) {
return;
}
@ -314,10 +314,10 @@ public class PlayerListener implements Listener {
+ loc.getY() + ", " + loc.getZ() + ChatColor.GOLD + " (" + ChatColor.GREEN
+ ItemUtil.getName(new ItemStack(block.getType())) + ChatColor.GOLD + ")");
}
evt.setCancelled(true);
} else if (plugin.getActionFactory().getSelectedTeleportLocations().containsKey(evt.getPlayer()
event.setCancelled(true);
} else if (plugin.getActionFactory().getSelectedTeleportLocations().containsKey(event.getPlayer()
.getUniqueId())) {
final Block block = evt.getClickedBlock();
final Block block = event.getClickedBlock();
if (block == null) {
return;
}
@ -331,10 +331,10 @@ public class PlayerListener implements Listener {
+ loc.getY() + ", " + loc.getZ() + ChatColor.GOLD + " (" + ChatColor.GREEN
+ ItemUtil.getName(new ItemStack(block.getType())) + ChatColor.GOLD + ")");
}
evt.setCancelled(true);
} else if (plugin.getQuestFactory().getSelectedKillLocations().containsKey(evt.getPlayer()
event.setCancelled(true);
} else if (plugin.getQuestFactory().getSelectedKillLocations().containsKey(event.getPlayer()
.getUniqueId())) {
final Block block = evt.getClickedBlock();
final Block block = event.getClickedBlock();
if (block == null) {
return;
}
@ -348,10 +348,10 @@ public class PlayerListener implements Listener {
+ loc.getY() + ", " + loc.getZ() + ChatColor.GOLD + " (" + ChatColor.GREEN
+ ItemUtil.getName(new ItemStack(block.getType())) + ChatColor.GOLD + ")");
}
evt.setCancelled(true);
} else if (plugin.getQuestFactory().getSelectedReachLocations().containsKey(evt.getPlayer()
event.setCancelled(true);
} else if (plugin.getQuestFactory().getSelectedReachLocations().containsKey(event.getPlayer()
.getUniqueId())) {
final Block block = evt.getClickedBlock();
final Block block = event.getClickedBlock();
if (block == null) {
return;
}
@ -365,11 +365,11 @@ public class PlayerListener implements Listener {
+ loc.getY() + ", " + loc.getZ() + ChatColor.GOLD + " (" + ChatColor.GREEN
+ ItemUtil.getName(new ItemStack(block.getType())) + ChatColor.GOLD + ")");
}
evt.setCancelled(true);
event.setCancelled(true);
} else if (!player.isConversing()) {
for (final IQuest q : plugin.getLoadedQuests()) {
if (q.getBlockStart() != null && evt.getClickedBlock() != null) {
if (q.getBlockStart().equals(evt.getClickedBlock().getLocation())) {
if (q.getBlockStart() != null && event.getClickedBlock() != null) {
if (q.getBlockStart().equals(event.getClickedBlock().getLocation())) {
if (quester.getCurrentQuestsTemp().size() >= plugin.getSettings().getMaxQuests()
&& plugin.getSettings().getMaxQuests() > 0) {
String msg = Lang.get(player, "questMaxAllowed");
@ -424,16 +424,16 @@ public class PlayerListener implements Listener {
}
}
}
if (evt.getItem() != null && evt.getItem().getType().equals(Material.COMPASS)) {
if (event.getItem() != null && event.getItem().getType().equals(Material.COMPASS)) {
if (!quester.canUseCompass()) {
return;
}
if (evt.getAction().equals(Action.LEFT_CLICK_AIR)
|| evt.getAction().equals(Action.LEFT_CLICK_BLOCK)) {
if (event.getAction().equals(Action.LEFT_CLICK_AIR)
|| event.getAction().equals(Action.LEFT_CLICK_BLOCK)) {
quester.resetCompass();
Lang.send(player, ChatColor.YELLOW + Lang.get(player, "compassReset"));
} else if (evt.getAction().equals(Action.RIGHT_CLICK_AIR)
|| evt.getAction().equals(Action.RIGHT_CLICK_BLOCK)) {
} else if (event.getAction().equals(Action.RIGHT_CLICK_AIR)
|| event.getAction().equals(Action.RIGHT_CLICK_BLOCK)) {
quester.findNextCompassTarget(true);
}
}
@ -443,11 +443,11 @@ public class PlayerListener implements Listener {
@SuppressWarnings("deprecation")
@EventHandler
public void onPlayerInteractEntity(final PlayerInteractEntityEvent evt) {
if (evt.getRightClicked().getType() == EntityType.ITEM_FRAME) {
final Player player = evt.getPlayer();
public void onPlayerInteractEntity(final PlayerInteractEntityEvent event) {
if (event.getRightClicked().getType() == EntityType.ITEM_FRAME) {
final Player player = event.getPlayer();
if (ItemUtil.isJournal(player.getItemInHand())) {
evt.setCancelled(true);
event.setCancelled(true);
Lang.send(player, ChatColor.RED + Lang.get(player, "journalDenied")
.replace("<journal>", Lang.get(player, "journalTitle")));
}
@ -455,9 +455,12 @@ public class PlayerListener implements Listener {
}
@EventHandler
public void onPlayerBucketFill(final PlayerBucketFillEvent evt) {
if (evt.getItemStack() != null && evt.getItemStack().getType() == Material.MILK_BUCKET) {
final Player player = evt.getPlayer();
public void onPlayerBucketFill(final PlayerBucketFillEvent event) {
if (event.isCancelled()) {
return;
}
if (event.getItemStack() != null && event.getItemStack().getType() == Material.MILK_BUCKET) {
final Player player = event.getPlayer();
if (plugin.canUseQuests(player.getUniqueId())) {
final IQuester quester = plugin.getQuester(player.getUniqueId());
final ObjectiveType type = ObjectiveType.MILK_COW;
@ -485,9 +488,12 @@ public class PlayerListener implements Listener {
}
@EventHandler
public void onPlayerChat(final AsyncPlayerChatEvent evt) {
if (plugin.canUseQuests(evt.getPlayer().getUniqueId())) {
final IQuester quester = plugin.getQuester(evt.getPlayer().getUniqueId());
public void onPlayerChat(final AsyncPlayerChatEvent event) {
if (event.isCancelled()) {
return;
}
if (plugin.canUseQuests(event.getPlayer().getUniqueId())) {
final IQuester quester = plugin.getQuester(event.getPlayer().getUniqueId());
for (final IQuest quest : plugin.getLoadedQuests()) {
if (!quester.meetsCondition(quest, true)) {
continue;
@ -499,7 +505,7 @@ public class PlayerListener implements Listener {
continue;
}
if (!currentStage.getChatActions().isEmpty()) {
final String chat = evt.getMessage();
final String chat = event.getMessage();
for (final String s : currentStage.getChatActions().keySet()) {
if (s.equalsIgnoreCase(chat)) {
new BukkitRunnable() {
@ -516,18 +522,18 @@ public class PlayerListener implements Listener {
final Set<String> dispatchedQuestIDs = new HashSet<>();
if (quester.getCurrentStage(quest).containsObjective(type)) {
for (final String pass : quester.getCurrentStage(quest).getPasswordPhrases()) {
if (pass.equalsIgnoreCase(evt.getMessage())) {
evt.setCancelled(true);
if (pass.equalsIgnoreCase(event.getMessage())) {
event.setCancelled(true);
break;
}
}
quester.sayPassword(quest, evt);
quester.sayPassword(quest, event);
}
dispatchedQuestIDs.addAll(quester.dispatchMultiplayerEverything(quest, type,
(final IQuester q, final IQuest cq) -> {
if (!dispatchedQuestIDs.contains(cq.getId())) {
q.sayPassword(cq, evt);
q.sayPassword(cq, event);
}
return null;
}));
@ -537,19 +543,19 @@ public class PlayerListener implements Listener {
}
@EventHandler
public void onPlayerCommandPreprocess(final PlayerCommandPreprocessEvent evt) {
if (plugin.canUseQuests(evt.getPlayer().getUniqueId())) {
final IQuester quester = plugin.getQuester(evt.getPlayer().getUniqueId());
public void onPlayerCommandPreprocess(final PlayerCommandPreprocessEvent event) {
if (plugin.canUseQuests(event.getPlayer().getUniqueId())) {
final IQuester quester = plugin.getQuester(event.getPlayer().getUniqueId());
if (!quester.getCurrentQuestsTemp().isEmpty()) {
for (final IQuest quest : quester.getCurrentQuestsTemp().keySet()) {
if (!quest.getOptions().canAllowCommands()) {
if (!evt.getMessage().startsWith("/quest")) {
final Player player = evt.getPlayer();
if (!event.getMessage().startsWith("/quest")) {
final Player player = event.getPlayer();
Lang.send(player, ChatColor.RED + Lang.get(player, "optCommandsDenied")
.replace("<quest>", ChatColor.DARK_PURPLE + quest.getName() + ChatColor.RED));
evt.setCancelled(true);
event.setCancelled(true);
plugin.getLogger().info("Player " + player.getName() + " tried to use command "
+ evt.getMessage() + " but was denied because they are currently on quest "
+ event.getMessage() + " but was denied because they are currently on quest "
+ quest.getName());
return;
}
@ -561,7 +567,7 @@ public class PlayerListener implements Listener {
continue;
}
if (!currentStage.getCommandActions().isEmpty()) {
final String command = evt.getMessage();
final String command = event.getMessage();
for (final String s : currentStage.getCommandActions().keySet()) {
if (command.equalsIgnoreCase("/" + s)) {
currentStage.getCommandActions().get(s).fire(quester, quest);
@ -574,11 +580,14 @@ public class PlayerListener implements Listener {
}
@EventHandler
public void onPlayerShearEntity(final PlayerShearEntityEvent evt) {
if (evt.getEntity().getType() == EntityType.SHEEP) {
final Player player = evt.getPlayer();
public void onPlayerShearEntity(final PlayerShearEntityEvent event) {
if (event.isCancelled()) {
return;
}
if (event.getEntity().getType() == EntityType.SHEEP) {
final Player player = event.getPlayer();
if (plugin.canUseQuests(player.getUniqueId())) {
final Sheep sheep = (Sheep) evt.getEntity();
final Sheep sheep = (Sheep) event.getEntity();
final IQuester quester = plugin.getQuester(player.getUniqueId());
final ObjectiveType type = ObjectiveType.SHEAR_SHEEP;
final Set<String> dispatchedQuestIDs = new HashSet<>();
@ -605,9 +614,12 @@ public class PlayerListener implements Listener {
}
@EventHandler
public void onEntityTame(final EntityTameEvent evt) {
if (evt.getOwner() instanceof Player) {
final Player player = (Player) evt.getOwner();
public void onEntityTame(final EntityTameEvent event) {
if (event.isCancelled()) {
return;
}
if (event.getOwner() instanceof Player) {
final Player player = (Player) event.getOwner();
if (plugin.canUseQuests(player.getUniqueId())) {
final IQuester quester = plugin.getQuester(player.getUniqueId());
final ObjectiveType type = ObjectiveType.TAME_MOB;
@ -619,13 +631,13 @@ public class PlayerListener implements Listener {
if (quester.getCurrentQuestsTemp().containsKey(quest)
&& quester.getCurrentStage(quest).containsObjective(type)) {
quester.tameMob(quest, evt.getEntityType());
quester.tameMob(quest, event.getEntityType());
}
dispatchedQuestIDs.addAll(quester.dispatchMultiplayerEverything(quest, type,
(final IQuester q, final IQuest cq) -> {
if (!dispatchedQuestIDs.contains(cq.getId())) {
q.tameMob(cq, evt.getEntityType());
q.tameMob(cq, event.getEntityType());
}
return null;
}));
@ -635,32 +647,33 @@ public class PlayerListener implements Listener {
}
@EventHandler
public void onEntityDeath(final EntityDeathEvent evt) {
if (evt.getEntity().getLastDamageCause() instanceof EntityDamageByEntityEvent) {
final EntityDamageByEntityEvent damageEvent = (EntityDamageByEntityEvent) evt.getEntity().getLastDamageCause();
public void onEntityDeath(final EntityDeathEvent event) {
if (event.getEntity().getLastDamageCause() instanceof EntityDamageByEntityEvent) {
final EntityDamageByEntityEvent damageEvent = (EntityDamageByEntityEvent) event.getEntity()
.getLastDamageCause();
final Entity damager = damageEvent.getDamager();
if (damager instanceof Projectile) {
final Projectile projectile = (Projectile) damager;
if (projectile.getShooter() != null && projectile.getShooter() instanceof Entity) {
preKillMob((Entity)projectile.getShooter(), evt.getEntity());
preKillMob((Entity)projectile.getShooter(), event.getEntity());
}
} else if (damager instanceof TNTPrimed) {
final TNTPrimed tnt = (TNTPrimed) damager;
final Entity source = tnt.getSource();
if (source != null && source.isValid()) {
preKillMob(source, evt.getEntity());
preKillMob(source, event.getEntity());
}
} else if (damager instanceof Wolf) {
final Wolf wolf = (Wolf) damager;
if (wolf.isTamed() && wolf.getOwner() != null) {
final IQuester quester = plugin.getQuester(wolf.getOwner().getUniqueId());
if (quester != null) {
preKillPlayer(quester.getPlayer(), evt.getEntity());
preKillPlayer(quester.getPlayer(), event.getEntity());
}
}
} else {
preKillMob(damager, evt.getEntity());
preKillMob(damager, event.getEntity());
}
}
}
@ -707,39 +720,40 @@ public class PlayerListener implements Listener {
}
@EventHandler
public void onPlayerDeath(final PlayerDeathEvent evt) {
if (evt.getEntity().getLastDamageCause() instanceof EntityDamageByEntityEvent) {
final EntityDamageByEntityEvent damageEvent = (EntityDamageByEntityEvent) evt.getEntity().getLastDamageCause();
public void onPlayerDeath(final PlayerDeathEvent event) {
if (event.getEntity().getLastDamageCause() instanceof EntityDamageByEntityEvent) {
final EntityDamageByEntityEvent damageEvent = (EntityDamageByEntityEvent) event.getEntity()
.getLastDamageCause();
final Entity damager = damageEvent.getDamager();
if (evt.getEntity().getUniqueId().equals(damager.getUniqueId())) {
if (event.getEntity().getUniqueId().equals(damager.getUniqueId())) {
return;
}
if (damager instanceof Projectile) {
final Projectile projectile = (Projectile) damager;
if (projectile.getShooter() != null && projectile.getShooter() instanceof Entity) {
preKillPlayer((Entity)projectile.getShooter(), evt.getEntity());
preKillPlayer((Entity)projectile.getShooter(), event.getEntity());
}
} else if (damager instanceof TNTPrimed) {
final TNTPrimed tnt = (TNTPrimed) damager;
final Entity source = tnt.getSource();
if (source != null) {
if (source.isValid()) {
preKillPlayer(source, evt.getEntity());
preKillPlayer(source, event.getEntity());
}
}
} else if (damager instanceof Wolf) {
final Wolf wolf = (Wolf) damager;
if (wolf.isTamed() && wolf.getOwner() != null) {
final IQuester quester = plugin.getQuester(wolf.getOwner().getUniqueId());
preKillPlayer(quester.getPlayer(), evt.getEntity());
preKillPlayer(quester.getPlayer(), event.getEntity());
}
} else {
preKillPlayer(damager, evt.getEntity());
preKillPlayer(damager, event.getEntity());
}
}
final Player target = evt.getEntity();
final Player target = event.getEntity();
if (plugin.canUseQuests(target.getUniqueId())) {
final IQuester quester = plugin.getQuester(target.getUniqueId());
for (final IQuest quest : quester.getCurrentQuestsTemp().keySet()) {
@ -750,14 +764,14 @@ public class PlayerListener implements Listener {
}
}
ItemStack found = null;
for (final ItemStack stack : evt.getDrops()) {
for (final ItemStack stack : event.getDrops()) {
if (ItemUtil.isJournal(stack)) {
found = stack;
break;
}
}
if (found != null) {
evt.getDrops().remove(found);
event.getDrops().remove(found);
}
}
@ -811,8 +825,11 @@ public class PlayerListener implements Listener {
}
@EventHandler
public void onPlayerFish(final PlayerFishEvent evt) {
final Player player = evt.getPlayer();
public void onPlayerFish(final PlayerFishEvent event) {
if (event.isCancelled()) {
return;
}
final Player player = event.getPlayer();
if (plugin.canUseQuests(player.getUniqueId())) {
final IQuester quester = plugin.getQuester(player.getUniqueId());
final ObjectiveType type = ObjectiveType.CATCH_FISH;
@ -822,7 +839,7 @@ public class PlayerListener implements Listener {
continue;
}
if (evt.getState().equals(State.CAUGHT_FISH)) {
if (event.getState().equals(State.CAUGHT_FISH)) {
if (quester.getCurrentQuestsTemp().containsKey(quest)
&& quester.getCurrentStage(quest).containsObjective(type)) {
quester.catchFish(quest);
@ -862,12 +879,12 @@ public class PlayerListener implements Listener {
}
@EventHandler
public void onPlayerJoin(final PlayerJoinEvent evt) {
final Player player = evt.getPlayer();
public void onPlayerJoin(final PlayerJoinEvent event) {
final Player player = event.getPlayer();
if (player.hasPermission("quests.admin.update")) {
new UpdateChecker(plugin, 3711).getVersion(version -> {
if (!plugin.getDescription().getVersion().split("-")[0].equalsIgnoreCase(version)) {
evt.getPlayer().sendMessage(ChatColor.GRAY + "[" + ChatColor.YELLOW + "Quests" + ChatColor.GRAY
event.getPlayer().sendMessage(ChatColor.GRAY + "[" + ChatColor.YELLOW + "Quests" + ChatColor.GRAY
+ "] " + ChatColor.GREEN + Lang.get(player, "updateTo").replace("<version>",
version).replace("<url>", ChatColor.DARK_AQUA + "" + ChatColor.UNDERLINE
+ plugin.getDescription().getWebsite()));
@ -918,9 +935,9 @@ public class PlayerListener implements Listener {
}
@EventHandler
public void onPlayerQuit(final PlayerQuitEvent evt) {
if (plugin.canUseQuests(evt.getPlayer().getUniqueId())) {
final IQuester quester = plugin.getQuester(evt.getPlayer().getUniqueId());
public void onPlayerQuit(final PlayerQuitEvent event) {
if (plugin.canUseQuests(event.getPlayer().getUniqueId())) {
final IQuester quester = plugin.getQuester(event.getPlayer().getUniqueId());
for (final IQuest quest : quester.getCurrentQuestsTemp().keySet()) {
final IStage currentStage = quester.getCurrentStage(quest);
if (currentStage == null) {
@ -950,9 +967,9 @@ public class PlayerListener implements Listener {
quester.saveData();
}
if (plugin.getQuestFactory().getSelectingNpcs().contains(evt.getPlayer().getUniqueId())) {
if (plugin.getQuestFactory().getSelectingNpcs().contains(event.getPlayer().getUniqueId())) {
final Set<UUID> temp = plugin.getQuestFactory().getSelectingNpcs();
temp.remove(evt.getPlayer().getUniqueId());
temp.remove(event.getPlayer().getUniqueId());
plugin.getQuestFactory().setSelectingNpcs(temp);
}
final ConcurrentSkipListSet<IQuester> temp = (ConcurrentSkipListSet<IQuester>) plugin.getOfflineQuesters();
@ -962,19 +979,19 @@ public class PlayerListener implements Listener {
}
@EventHandler
public void onPlayerMove(final PlayerMoveEvent evt) {
if (evt.getTo() == null) {
public void onPlayerMove(final PlayerMoveEvent event) {
if (event.getTo() == null) {
return;
}
if (evt.getFrom().getBlock().equals(evt.getTo().getBlock())) {
if (event.getFrom().getBlock().equals(event.getTo().getBlock())) {
return;
}
if (plugin.getDependencies().getCitizens() != null) {
if (CitizensAPI.getNPCRegistry().isNPC(evt.getPlayer())) {
if (CitizensAPI.getNPCRegistry().isNPC(event.getPlayer())) {
return;
}
}
playerMove(evt.getPlayer().getUniqueId(), evt.getTo());
playerMove(event.getPlayer().getUniqueId(), event.getTo());
}
/**

View File

@ -33,37 +33,37 @@ public class ZnpcsListener implements Listener {
}
@EventHandler
public void onNPCInteract(final NPCInteractEvent evt) {
if (evt.isLeftClick()) {
public void onNPCInteract(final NPCInteractEvent event) {
if (event.isLeftClick()) {
if (plugin.getDependencies().getZnpcs() == null) {
return;
}
if (plugin.getQuestFactory().getSelectingNpcs().contains(evt.getPlayer().getUniqueId())) {
if (evt.getNpc() == null) {
if (plugin.getQuestFactory().getSelectingNpcs().contains(event.getPlayer().getUniqueId())) {
if (event.getNpc() == null) {
plugin.getLogger().severe("ZNPC was null while selecting by left-click");
return;
}
evt.getPlayer().acceptConversationInput(String.valueOf(evt.getNpc().getUUID()));
evt.getPlayer().sendMessage(ChatColor.RED + "Warning: " + ChatColor.RESET
event.getPlayer().acceptConversationInput(String.valueOf(event.getNpc().getUUID()));
event.getPlayer().sendMessage(ChatColor.RED + "Warning: " + ChatColor.RESET
+ "ZNPCs is not fully supported and will break after server restart. Please ask its developer "
+ "to fix this at https://github.com/gonalez/znpc-servers/issues/36");
}
} else if (evt.isRightClick()) {
} else if (event.isRightClick()) {
if (plugin.getDependencies().getCitizens() == null) {
return;
}
if (plugin.getQuestFactory().getSelectingNpcs().contains(evt.getPlayer().getUniqueId())) {
if (evt.getNpc() == null) {
if (plugin.getQuestFactory().getSelectingNpcs().contains(event.getPlayer().getUniqueId())) {
if (event.getNpc() == null) {
plugin.getLogger().severe("ZNPC was null while selecting by right-click");
return;
}
evt.getPlayer().acceptConversationInput(String.valueOf(evt.getNpc().getUUID()));
evt.getPlayer().sendMessage(ChatColor.RED + "Warning: " + ChatColor.RESET
event.getPlayer().acceptConversationInput(String.valueOf(event.getNpc().getUUID()));
event.getPlayer().sendMessage(ChatColor.RED + "Warning: " + ChatColor.RESET
+ "ZNPCs is not fully supported and will break after server restart. Please ask its developer "
+ "to fix this at https://github.com/gonalez/znpc-servers/issues/36");
}
if (!evt.getPlayer().isConversing()) {
final Player player = evt.getPlayer();
if (!event.getPlayer().isConversing()) {
final Player player = event.getPlayer();
final IQuester quester = plugin.getQuester(player.getUniqueId());
for (final IQuest quest : quester.getCurrentQuestsTemp().keySet()) {
if (quester.getCurrentStage(quest).containsObjective(ObjectiveType.DELIVER_ITEM)) {
@ -78,7 +78,7 @@ public class ZnpcsListener implements Listener {
matches.add(currentIndex);
}
}
final NPC clicked = evt.getNpc();
final NPC clicked = event.getNpc();
if (!matches.isEmpty()) {
for (final Integer match : matches) {
final UUID uuid = quester.getCurrentStage(quest).getItemDeliveryTargets().get(match);
@ -191,18 +191,18 @@ public class ZnpcsListener implements Listener {
continue;
}
if (quester.getCurrentStage(quest).containsObjective(ObjectiveType.TALK_TO_NPC)) {
if (quester.getCurrentStage(quest).getNpcsToInteract().contains(evt.getNpc().getUUID())) {
final int npcIndex = quester.getCurrentStage(quest).getNpcsToInteract().indexOf(evt.getNpc()
if (quester.getCurrentStage(quest).getNpcsToInteract().contains(event.getNpc().getUUID())) {
final int npcIndex = quester.getCurrentStage(quest).getNpcsToInteract().indexOf(event.getNpc()
.getUUID());
if (quester.getQuestData(quest) != null && npcIndex > -1
&& !quester.getQuestData(quest).npcsInteracted.get(npcIndex)) {
hasObjective = true;
}
quester.interactWithNPC(quest, evt.getNpc().getUUID());
quester.interactWithNPC(quest, event.getNpc().getUUID());
}
}
}
if (hasObjective || !plugin.getQuestNpcUuids().contains(evt.getNpc().getUUID())) {
if (hasObjective || !plugin.getQuestNpcUuids().contains(event.getNpc().getUUID())) {
return;
}
boolean hasAtLeastOneGUI = false;
@ -211,7 +211,7 @@ public class ZnpcsListener implements Listener {
if (quester.getCurrentQuestsTemp().containsKey(q)) {
continue;
}
if (q.getNpcStart() != null && q.getNpcStart().equals(evt.getNpc().getUUID())) {
if (q.getNpcStart() != null && q.getNpcStart().equals(event.getNpc().getUUID())) {
if (plugin.getSettings().canIgnoreLockedQuests()
&& (!quester.getCompletedQuestsTemp().contains(q)
|| q.getPlanner().getCooldown() > -1)) {
@ -237,7 +237,7 @@ public class ZnpcsListener implements Listener {
quester.takeQuest(q, false);
} else {
if (q.getGUIDisplay() != null) {
quester.showGUIDisplay(evt.getNpc().getUUID(), npcQuests);
quester.showGUIDisplay(event.getNpc().getUUID(), npcQuests);
} else {
for (final String msg : extracted(quester).split("<br>")) {
player.sendMessage(msg);
@ -248,11 +248,11 @@ public class ZnpcsListener implements Listener {
}
} else if (npcQuests.size() > 1) {
if (hasAtLeastOneGUI) {
quester.showGUIDisplay(evt.getNpc().getUUID(), npcQuests);
quester.showGUIDisplay(event.getNpc().getUUID(), npcQuests);
} else {
final Conversation c = plugin.getNpcConversationFactory().buildConversation(player);
c.getContext().setSessionData("npcQuests", npcQuests);
c.getContext().setSessionData("npc", evt.getNpc().getGameProfile().getName());
c.getContext().setSessionData("npc", event.getNpc().getGameProfile().getName());
c.begin();
}
} else {