Apply support to all objective types

This commit is contained in:
PikaMug 2019-09-16 22:19:07 -04:00
parent aaecb130f2
commit f31730ce73

View File

@ -205,20 +205,18 @@ public class PlayerListener implements Listener {
boolean hasObjective = false; boolean hasObjective = false;
if (evt.isCancelled() == false) { if (evt.isCancelled() == false) {
final ItemStack blockItemStack = new ItemStack(evt.getClickedBlock().getType(), 1, evt.getClickedBlock().getState().getData().toItemStack().getDurability()); final ItemStack blockItemStack = new ItemStack(evt.getClickedBlock().getType(), 1, evt.getClickedBlock().getState().getData().toItemStack().getDurability());
for (Quest quest : plugin.getQuests()) {
for (Quest quest : quester.getCurrentQuests().keySet()) { if (quester.getCurrentQuests().containsKey(quest) && quester.containsObjective(quest, "useBlock")) {
if (quester.containsObjective(quest, "useBlock")) {
quester.useBlock(quest, blockItemStack); quester.useBlock(quest, blockItemStack);
hasObjective = true; hasObjective = true;
}
// Multiplayer
quester.dispatchMultiplayerEverything(quest, "useBlock", (Quester q) -> { quester.dispatchMultiplayerEverything(quest, "useBlock", (Quester q) -> {
q.useBlock(quest, blockItemStack); q.useBlock(quest, blockItemStack);
return null; return null;
}); });
} }
} }
}
if (!hasObjective) { if (!hasObjective) {
if (plugin.getQuestFactory().getSelectedBlockStarts().containsKey(evt.getPlayer().getUniqueId())) { if (plugin.getQuestFactory().getSelectedBlockStarts().containsKey(evt.getPlayer().getUniqueId())) {
Block block = evt.getClickedBlock(); Block block = evt.getClickedBlock();
@ -340,8 +338,8 @@ public class PlayerListener implements Listener {
public void onPlayerChat(AsyncPlayerChatEvent evt) { public void onPlayerChat(AsyncPlayerChatEvent evt) {
if (plugin.canUseQuests(evt.getPlayer().getUniqueId())) { if (plugin.canUseQuests(evt.getPlayer().getUniqueId())) {
final Quester quester = plugin.getQuester(evt.getPlayer().getUniqueId()); final Quester quester = plugin.getQuester(evt.getPlayer().getUniqueId());
if (quester.getCurrentQuests().isEmpty() == false) { for (final Quest quest : plugin.getQuests()) {
for (final Quest quest : quester.getCurrentQuests().keySet()) { if (quester.getCurrentQuests().containsKey(quest)) {
final Stage currentStage = quester.getCurrentStage(quest); final Stage currentStage = quester.getCurrentStage(quest);
if (currentStage == null) { if (currentStage == null) {
plugin.getLogger().severe("currentStage was null for " + quester.getUUID().toString() + " on chat for quest " + quest.getName()); plugin.getLogger().severe("currentStage was null for " + quester.getUUID().toString() + " on chat for quest " + quest.getName());
@ -366,8 +364,9 @@ public class PlayerListener implements Listener {
} }
if (quester.containsObjective(quest, "password")) { if (quester.containsObjective(quest, "password")) {
quester.sayPassword(quest, evt); quester.sayPassword(quest, evt);
}
}
// Multiplayer
quester.dispatchMultiplayerEverything(quest, "password", (Quester q) -> { quester.dispatchMultiplayerEverything(quest, "password", (Quester q) -> {
q.sayPassword(quest, evt); q.sayPassword(quest, evt);
return null; return null;
@ -375,8 +374,6 @@ public class PlayerListener implements Listener {
} }
} }
} }
}
}
@EventHandler @EventHandler
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent evt) { public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent evt) {
@ -419,13 +416,12 @@ public class PlayerListener implements Listener {
public void onBlockDamage(BlockDamageEvent evt) { public void onBlockDamage(BlockDamageEvent evt) {
if (plugin.checkQuester(evt.getPlayer().getUniqueId()) == false) { if (plugin.checkQuester(evt.getPlayer().getUniqueId()) == false) {
final ItemStack blockItemStack = new ItemStack(evt.getBlock().getType(), 1, evt.getBlock().getState().getData().toItemStack().getDurability()); final ItemStack blockItemStack = new ItemStack(evt.getBlock().getType(), 1, evt.getBlock().getState().getData().toItemStack().getDurability());
Quester quester = plugin.getQuester(evt.getPlayer().getUniqueId()); Quester quester = plugin.getQuester(evt.getPlayer().getUniqueId());
for (Quest quest : quester.getCurrentQuests().keySet()) { for (Quest quest : plugin.getQuests()) {
if (quester.containsObjective(quest, "damageBlock")) { if (quester.getCurrentQuests().containsKey(quest) && quester.containsObjective(quest, "damageBlock")) {
quester.damageBlock(quest, blockItemStack); quester.damageBlock(quest, blockItemStack);
}
// Multiplayer
quester.dispatchMultiplayerEverything(quest, "placeBlock", (Quester q) -> { quester.dispatchMultiplayerEverything(quest, "placeBlock", (Quester q) -> {
q.placeBlock(quest, blockItemStack); q.placeBlock(quest, blockItemStack);
return null; return null;
@ -433,21 +429,19 @@ public class PlayerListener implements Listener {
} }
} }
} }
}
@SuppressWarnings("deprecation") // since 1.13 @SuppressWarnings("deprecation") // since 1.13
@EventHandler(priority = EventPriority.HIGHEST) @EventHandler(priority = EventPriority.HIGHEST)
public void onBlockPlace(BlockPlaceEvent evt) { public void onBlockPlace(BlockPlaceEvent evt) {
if (plugin.checkQuester(evt.getPlayer().getUniqueId()) == false) { if (plugin.checkQuester(evt.getPlayer().getUniqueId()) == false) {
final ItemStack blockItemStack = new ItemStack(evt.getBlock().getType(), 1, evt.getBlock().getState().getData().toItemStack().getDurability()); final ItemStack blockItemStack = new ItemStack(evt.getBlock().getType(), 1, evt.getBlock().getState().getData().toItemStack().getDurability());
Quester quester = plugin.getQuester(evt.getPlayer().getUniqueId()); Quester quester = plugin.getQuester(evt.getPlayer().getUniqueId());
for (Quest quest : quester.getCurrentQuests().keySet()) { for (Quest quest : plugin.getQuests()) {
if (quester.containsObjective(quest, "placeBlock")) {
if (evt.isCancelled() == false) { if (evt.isCancelled() == false) {
if (quester.getCurrentQuests().containsKey(quest) && quester.containsObjective(quest, "placeBlock")) {
quester.placeBlock(quest, blockItemStack); quester.placeBlock(quest, blockItemStack);
}
// Multiplayer
quester.dispatchMultiplayerEverything(quest, "placeBlock", (Quester q) -> { quester.dispatchMultiplayerEverything(quest, "placeBlock", (Quester q) -> {
q.placeBlock(quest, blockItemStack); q.placeBlock(quest, blockItemStack);
return null; return null;
@ -456,56 +450,50 @@ public class PlayerListener implements Listener {
} }
} }
} }
}
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
@EventHandler(priority = EventPriority.HIGHEST) @EventHandler(priority = EventPriority.HIGHEST)
public void onBlockBreak(BlockBreakEvent evt) { public void onBlockBreak(BlockBreakEvent evt) {
if (plugin.checkQuester(evt.getPlayer().getUniqueId()) == false) { if (plugin.checkQuester(evt.getPlayer().getUniqueId()) == false) {
final ItemStack blockItemStack = new ItemStack(evt.getBlock().getType(), 1, evt.getBlock().getState().getData().toItemStack().getDurability()); final ItemStack blockItemStack = new ItemStack(evt.getBlock().getType(), 1, evt.getBlock().getState().getData().toItemStack().getDurability());
Quester quester = plugin.getQuester(evt.getPlayer().getUniqueId()); Quester quester = plugin.getQuester(evt.getPlayer().getUniqueId());
for (Quest quest : quester.getCurrentQuests().keySet()) { for (Quest quest : plugin.getQuests()) {
if (evt.isCancelled() == false) { if (evt.isCancelled() == false) {
if (quester.containsObjective(quest, "breakBlock")) { if (quester.getCurrentQuests().containsKey(quest) && quester.containsObjective(quest, "breakBlock")) {
if (evt.getPlayer().getItemInHand().containsEnchantment(Enchantment.SILK_TOUCH) == false) { if (!evt.getPlayer().getItemInHand().containsEnchantment(Enchantment.SILK_TOUCH)) {
quester.breakBlock(quest, blockItemStack); quester.breakBlock(quest, blockItemStack);
}
// Multiplayer }
quester.dispatchMultiplayerEverything(quest, "breakBlock", (Quester q) -> { quester.dispatchMultiplayerEverything(quest, "breakBlock", (Quester q) -> {
if (evt.getPlayer().getItemInHand().containsEnchantment(Enchantment.SILK_TOUCH) == false) { if (!evt.getPlayer().getItemInHand().containsEnchantment(Enchantment.SILK_TOUCH)) {
q.breakBlock(quest, blockItemStack); q.breakBlock(quest, blockItemStack);
} }
return null; return null;
}); });
} if (quester.getCurrentQuests().containsKey(quest) && quester.containsObjective(quest, "placeBlock")) {
}
if (quester.containsObjective(quest, "placeBlock")) {
for (ItemStack is : quester.getQuestData(quest).blocksPlaced) { for (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) {
int index = quester.getQuestData(quest).blocksPlaced.indexOf(is); int index = quester.getQuestData(quest).blocksPlaced.indexOf(is);
is.setAmount(is.getAmount() - 1); is.setAmount(is.getAmount() - 1);
quester.getQuestData(quest).blocksPlaced.set(index, is); quester.getQuestData(quest).blocksPlaced.set(index, is);
}
// Multiplayer }
}
quester.dispatchMultiplayerEverything(quest, "placeBlock", (Quester q) -> { quester.dispatchMultiplayerEverything(quest, "placeBlock", (Quester q) -> {
for (ItemStack is2 : q.getQuestData(quest).blocksPlaced) { for (ItemStack is : q.getQuestData(quest).blocksPlaced) {
if (evt.getBlock().getType().equals(is2.getType()) && is2.getAmount() > 0) { if (evt.getBlock().getType().equals(is.getType()) && is.getAmount() > 0) {
int index2 = q.getQuestData(quest).blocksPlaced.indexOf(is2); int index = q.getQuestData(quest).blocksPlaced.indexOf(is);
is2.setAmount(is2.getAmount() - 1); is.setAmount(is.getAmount() - 1);
q.getQuestData(quest).blocksPlaced.set(index2, is2); q.getQuestData(quest).blocksPlaced.set(index, is);
} }
} }
return null; return null;
}); });
} if (quester.getCurrentQuests().containsKey(quest) && quester.containsObjective(quest, "cutBlock")) {
}
}
if (quester.containsObjective(quest, "cutBlock")) {
if (evt.getPlayer().getItemInHand().getType().equals(Material.SHEARS)) { if (evt.getPlayer().getItemInHand().getType().equals(Material.SHEARS)) {
quester.cutBlock(quest, blockItemStack); quester.cutBlock(quest, blockItemStack);
}
// Multiplayer }
quester.dispatchMultiplayerEverything(quest, "cutBlock", (Quester q) -> { quester.dispatchMultiplayerEverything(quest, "cutBlock", (Quester q) -> {
if (evt.getPlayer().getItemInHand().getType().equals(Material.SHEARS)) { if (evt.getPlayer().getItemInHand().getType().equals(Material.SHEARS)) {
q.cutBlock(quest, blockItemStack); q.cutBlock(quest, blockItemStack);
@ -516,8 +504,6 @@ public class PlayerListener implements Listener {
} }
} }
} }
}
}
@EventHandler @EventHandler
public void onPlayerShearEntity(PlayerShearEntityEvent evt) { public void onPlayerShearEntity(PlayerShearEntityEvent evt) {
@ -525,11 +511,11 @@ public class PlayerListener implements Listener {
if (plugin.canUseQuests(evt.getPlayer().getUniqueId())) { if (plugin.canUseQuests(evt.getPlayer().getUniqueId())) {
Sheep sheep = (Sheep) evt.getEntity(); Sheep sheep = (Sheep) evt.getEntity();
Quester quester = plugin.getQuester(evt.getPlayer().getUniqueId()); Quester quester = plugin.getQuester(evt.getPlayer().getUniqueId());
for (Quest quest : quester.getCurrentQuests().keySet()) { for (Quest quest : plugin.getQuests()) {
if (quester.containsObjective(quest, "shearSheep")) { if (quester.getCurrentQuests().containsKey(quest) && quester.containsObjective(quest, "shearSheep")) {
quester.shearSheep(quest, sheep.getColor()); quester.shearSheep(quest, sheep.getColor());
}
// Multiplayer
quester.dispatchMultiplayerEverything(quest, "shearSheep", (Quester q) -> { quester.dispatchMultiplayerEverything(quest, "shearSheep", (Quester q) -> {
q.shearSheep(quest, sheep.getColor()); q.shearSheep(quest, sheep.getColor());
return null; return null;
@ -538,7 +524,6 @@ public class PlayerListener implements Listener {
} }
} }
} }
}
@EventHandler @EventHandler
public void onEntityTame(EntityTameEvent evt) { public void onEntityTame(EntityTameEvent evt) {
@ -546,11 +531,11 @@ public class PlayerListener implements Listener {
Player p = (Player) evt.getOwner(); Player p = (Player) evt.getOwner();
if (plugin.canUseQuests(p.getUniqueId())) { if (plugin.canUseQuests(p.getUniqueId())) {
Quester quester = plugin.getQuester(p.getUniqueId()); Quester quester = plugin.getQuester(p.getUniqueId());
for (Quest quest : quester.getCurrentQuests().keySet()) { for (Quest quest : plugin.getQuests()) {
if (quester.containsObjective(quest, "tameMob")) { if (quester.getCurrentQuests().containsKey(quest) && quester.containsObjective(quest, "tameMob")) {
quester.tameMob(quest, evt.getEntityType()); quester.tameMob(quest, evt.getEntityType());
}
// Multiplayer
quester.dispatchMultiplayerEverything(quest, "tameMob", (Quester q) -> { quester.dispatchMultiplayerEverything(quest, "tameMob", (Quester q) -> {
q.tameMob(quest, evt.getEntityType()); q.tameMob(quest, evt.getEntityType());
return null; return null;
@ -559,7 +544,6 @@ public class PlayerListener implements Listener {
} }
} }
} }
}
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
@ -569,11 +553,11 @@ public class PlayerListener implements Listener {
if (plugin.checkQuester(evt.getWhoClicked().getUniqueId()) == false) { if (plugin.checkQuester(evt.getWhoClicked().getUniqueId()) == false) {
final ItemStack craftedItem = getCraftedItem(evt); final ItemStack craftedItem = getCraftedItem(evt);
Quester quester = plugin.getQuester(evt.getWhoClicked().getUniqueId()); Quester quester = plugin.getQuester(evt.getWhoClicked().getUniqueId());
for (Quest quest : quester.getCurrentQuests().keySet()) { for (Quest quest : plugin.getQuests()) {
if (quester.containsObjective(quest, "craftItem")) { if (quester.getCurrentQuests().containsKey(quest) && quester.containsObjective(quest, "craftItem")) {
quester.craftItem(quest, craftedItem); quester.craftItem(quest, craftedItem);
}
// Multiplayer
quester.dispatchMultiplayerEverything(quest, "craftItem", (Quester q) -> { quester.dispatchMultiplayerEverything(quest, "craftItem", (Quester q) -> {
q.craftItem(quest, craftedItem); q.craftItem(quest, craftedItem);
return null; return null;
@ -582,7 +566,6 @@ public class PlayerListener implements Listener {
} }
} }
} }
}
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
private ItemStack getCraftedItem(CraftItemEvent evt) { private ItemStack getCraftedItem(CraftItemEvent evt) {
@ -613,26 +596,25 @@ public class PlayerListener implements Listener {
if (evt.getInventory().getType() == InventoryType.FURNACE) { if (evt.getInventory().getType() == InventoryType.FURNACE) {
if (evt.getSlotType() == SlotType.RESULT) { if (evt.getSlotType() == SlotType.RESULT) {
Quester quester = plugin.getQuester(evt.getWhoClicked().getUniqueId()); Quester quester = plugin.getQuester(evt.getWhoClicked().getUniqueId());
for (Quest quest : quester.getCurrentQuests().keySet()) { for (Quest quest : plugin.getQuests()) {
if (quester.containsObjective(quest, "smeltItem")) { if (quester.getCurrentQuests().containsKey(quest) && quester.containsObjective(quest, "smeltItem")) {
quester.smeltItem(quest, evt.getCurrentItem()); quester.smeltItem(quest, evt.getCurrentItem());
}
// Multiplayer
quester.dispatchMultiplayerEverything(quest, "smeltItem", (Quester q) -> { quester.dispatchMultiplayerEverything(quest, "smeltItem", (Quester q) -> {
q.smeltItem(quest, evt.getCurrentItem()); q.smeltItem(quest, evt.getCurrentItem());
return null; return null;
}); });
} }
} }
}
} else if (evt.getInventory().getType() == InventoryType.BREWING) { } else if (evt.getInventory().getType() == InventoryType.BREWING) {
if (evt.getSlotType() == SlotType.CRAFTING) { if (evt.getSlotType() == SlotType.CRAFTING) {
Quester quester = plugin.getQuester(evt.getWhoClicked().getUniqueId()); Quester quester = plugin.getQuester(evt.getWhoClicked().getUniqueId());
for (Quest quest : quester.getCurrentQuests().keySet()) { for (Quest quest : plugin.getQuests()) {
if (quester.containsObjective(quest, "brewItem")) { if (quester.getCurrentQuests().containsKey(quest) && quester.containsObjective(quest, "brewItem")) {
quester.brewItem(quest, evt.getCurrentItem()); quester.brewItem(quest, evt.getCurrentItem());
}
// Multiplayer
quester.dispatchMultiplayerEverything(quest, "brewItem", (Quester q) -> { quester.dispatchMultiplayerEverything(quest, "brewItem", (Quester q) -> {
q.brewItem(quest, evt.getCurrentItem()); q.brewItem(quest, evt.getCurrentItem());
return null; return null;
@ -642,27 +624,27 @@ public class PlayerListener implements Listener {
} }
} }
} }
}
@EventHandler @EventHandler
public void onEnchantItem(EnchantItemEvent evt) { public void onEnchantItem(EnchantItemEvent evt) {
if (plugin.canUseQuests(evt.getEnchanter().getUniqueId())) { if (plugin.canUseQuests(evt.getEnchanter().getUniqueId())) {
Quester quester = plugin.getQuester(evt.getEnchanter().getUniqueId()); Quester quester = plugin.getQuester(evt.getEnchanter().getUniqueId());
for (Quest quest : quester.getCurrentQuests().keySet()) { for (Quest quest : plugin.getQuests()) {
if (quester.containsObjective(quest, "enchantItem")) { if (quester.getCurrentQuests().containsKey(quest) && quester.containsObjective(quest, "enchantItem")) {
for (Enchantment e : evt.getEnchantsToAdd().keySet()) { for (Enchantment e : evt.getEnchantsToAdd().keySet()) {
quester.enchantItem(quest, e, evt.getItem().getType()); quester.enchantItem(quest, e, evt.getItem().getType());
}
}
// Multiplayer
quester.dispatchMultiplayerEverything(quest, "enchantItem", (Quester q) -> { quester.dispatchMultiplayerEverything(quest, "enchantItem", (Quester q) -> {
for (Enchantment e : evt.getEnchantsToAdd().keySet()) {
q.enchantItem(quest, e, evt.getItem().getType()); q.enchantItem(quest, e, evt.getItem().getType());
}
return null; return null;
}); });
} }
} }
} }
}
}
@EventHandler @EventHandler
public void onEntityDeath(EntityDeathEvent evt) { public void onEntityDeath(EntityDeathEvent evt) {
@ -709,26 +691,20 @@ public class PlayerListener implements Listener {
return; return;
} }
if (damager instanceof Player) { if (damager instanceof Player) {
if (plugin.getDependencies().getCitizens() != null) {
if (CitizensAPI.getNPCRegistry().isNPC(target)) {
Quester quester = plugin.getQuester(damager.getUniqueId()); Quester quester = plugin.getQuester(damager.getUniqueId());
for (Quest quest : quester.getCurrentQuests().keySet()) { if (plugin.getDependencies().getCitizens() != null && CitizensAPI.getNPCRegistry().isNPC(target)) {
if (quester.containsObjective(quest, "killNPC")) { for (Quest quest : plugin.getQuests()) {
if (quester.getCurrentQuests().containsKey(quest) && quester.containsObjective(quest, "killNPC")) {
quester.killNPC(quest, CitizensAPI.getNPCRegistry().getNPC(target)); quester.killNPC(quest, CitizensAPI.getNPCRegistry().getNPC(target));
}
// Multiplayer
quester.dispatchMultiplayerEverything(quest, "killNPC", (Quester q) -> { quester.dispatchMultiplayerEverything(quest, "killNPC", (Quester q) -> {
q.killNPC(quest, CitizensAPI.getNPCRegistry().getNPC(target)); q.killNPC(quest, CitizensAPI.getNPCRegistry().getNPC(target));
return null; return null;
}); });
} }
} } else {
return; for (Quest quest : plugin.getQuests()) {
}
}
Quester quester = plugin.getQuester(damager.getUniqueId());
LinkedList<Quest> allQuests = plugin.getQuests();
for (Quest quest : allQuests) {
if (quester.getCurrentQuests().containsKey(quest) && quester.containsObjective(quest, "killMob")) { if (quester.getCurrentQuests().containsKey(quest) && quester.containsObjective(quest, "killMob")) {
quester.killMob(quest, target.getLocation(), target.getType()); quester.killMob(quest, target.getLocation(), target.getType());
} }
@ -740,6 +716,7 @@ public class PlayerListener implements Listener {
} }
} }
} }
}
@EventHandler @EventHandler
public void onPlayerDeath(PlayerDeathEvent evt) { public void onPlayerDeath(PlayerDeathEvent evt) {
@ -822,11 +799,11 @@ public class PlayerListener implements Listener {
} }
} }
Quester quester = plugin.getQuester(damager.getUniqueId()); Quester quester = plugin.getQuester(damager.getUniqueId());
for (Quest quest : quester.getCurrentQuests().keySet()) { for (Quest quest : plugin.getQuests()) {
if (quester.containsObjective(quest, "killPlayer")) { if (quester.getCurrentQuests().containsKey(quest) && quester.containsObjective(quest, "killPlayer")) {
quester.killPlayer(quest, (Player)target); quester.killPlayer(quest, (Player)target);
}
// Multiplayer
quester.dispatchMultiplayerEverything(quest, "killPlayer", (Quester q) -> { quester.dispatchMultiplayerEverything(quest, "killPlayer", (Quester q) -> {
q.killPlayer(quest, (Player)target); q.killPlayer(quest, (Player)target);
return null; return null;
@ -834,18 +811,17 @@ public class PlayerListener implements Listener {
} }
} }
} }
}
@EventHandler @EventHandler
public void onPlayerFish(PlayerFishEvent evt) { public void onPlayerFish(PlayerFishEvent evt) {
Player player = evt.getPlayer(); Player player = evt.getPlayer();
if (plugin.canUseQuests(player.getUniqueId())) { if (plugin.canUseQuests(player.getUniqueId())) {
Quester quester = plugin.getQuester(player.getUniqueId()); Quester quester = plugin.getQuester(player.getUniqueId());
for (Quest quest : quester.getCurrentQuests().keySet()) { for (Quest quest : plugin.getQuests()) {
if (quester.containsObjective(quest, "catchFish") && evt.getState().equals(State.CAUGHT_FISH)) { if (quester.getCurrentQuests().containsKey(quest) && quester.containsObjective(quest, "catchFish") && evt.getState().equals(State.CAUGHT_FISH)) {
quester.catchFish(quest); quester.catchFish(quest);
}
// Multiplayer
quester.dispatchMultiplayerEverything(quest, "catchFish", (Quester q) -> { quester.dispatchMultiplayerEverything(quest, "catchFish", (Quester q) -> {
q.catchFish(quest); q.catchFish(quest);
return null; return null;
@ -853,7 +829,6 @@ public class PlayerListener implements Listener {
} }
} }
} }
}
@EventHandler @EventHandler
public void onPlayerChangeWorld(PlayerChangedWorldEvent event) { public void onPlayerChangeWorld(PlayerChangedWorldEvent event) {
@ -973,11 +948,11 @@ public class PlayerListener implements Listener {
if (plugin.getQuester(evt.getPlayer().getUniqueId()) != null) { if (plugin.getQuester(evt.getPlayer().getUniqueId()) != null) {
if (plugin.canUseQuests(evt.getPlayer().getUniqueId())) { if (plugin.canUseQuests(evt.getPlayer().getUniqueId())) {
Quester quester = plugin.getQuester(evt.getPlayer().getUniqueId()); Quester quester = plugin.getQuester(evt.getPlayer().getUniqueId());
for (Quest quest : quester.getCurrentQuests().keySet()) { for (Quest quest : plugin.getQuests()) {
if (quester.containsObjective(quest, "reachLocation")) { if (quester.getCurrentQuests().containsKey(quest) && quester.containsObjective(quest, "reachLocation")) {
quester.reachLocation(quest, evt.getTo()); quester.reachLocation(quest, evt.getTo());
}
// Multiplayer
quester.dispatchMultiplayerEverything(quest, "reachLocation", (Quester q) -> { quester.dispatchMultiplayerEverything(quest, "reachLocation", (Quester q) -> {
q.reachLocation(quest, evt.getTo()); q.reachLocation(quest, evt.getTo());
return null; return null;
@ -987,4 +962,3 @@ public class PlayerListener implements Listener {
} }
} }
} }
}