diff --git a/main/src/main/java/me/blackvein/quests/CustomObjective.java b/main/src/main/java/me/blackvein/quests/CustomObjective.java index 3658cdc2b..7f8746a64 100644 --- a/main/src/main/java/me/blackvein/quests/CustomObjective.java +++ b/main/src/main/java/me/blackvein/quests/CustomObjective.java @@ -204,9 +204,11 @@ public abstract class CustomObjective implements Listener { if (hasQuest && quester.hasCustomObjective(quest, obj.getName())) { if (quester.getQuestData(quest).customObjectiveCounts.containsKey(obj.getName())) { int old = quester.getQuestData(quest).customObjectiveCounts.get(obj.getName()); - plugin.getQuester(player.getUniqueId()).getQuestData(quest).customObjectiveCounts.put(obj.getName(), old + count); + plugin.getQuester(player.getUniqueId()).getQuestData(quest).customObjectiveCounts + .put(obj.getName(), old + count); } else { - plugin.getQuester(player.getUniqueId()).getQuestData(quest).customObjectiveCounts.put(obj.getName(), count); + plugin.getQuester(player.getUniqueId()).getQuestData(quest).customObjectiveCounts + .put(obj.getName(), count); } int index = -1; for (int i = 0; i < quester.getCurrentStage(quest).customObjectives.size(); i++) { @@ -218,12 +220,15 @@ public abstract class CustomObjective implements Listener { if (index > -1) { int goal = quester.getCurrentStage(quest).customObjectiveCounts.get(index); if (quester.getQuestData(quest).customObjectiveCounts.get(obj.getName()) >= goal) { - quester.finishObjective(quest, "customObj", new ItemStack(Material.AIR, 1), new ItemStack(Material.AIR, goal), null, null, null, null, null, null, null, obj); + quester.finishObjective(quest, "customObj", new ItemStack(Material.AIR, 1), + new ItemStack(Material.AIR, goal), null, null, null, null, null, null, null, obj); // Multiplayer quester.dispatchMultiplayerObjectives(quest, quester.getCurrentStage(quest), (Quester q) -> { - q.getQuestData(quest).customObjectiveCounts.put(obj.getName(), quester.getQuestData(quest).customObjectiveCounts.get(obj.getName())); - q.finishObjective(quest, "customObj", new ItemStack(Material.AIR, 1), new ItemStack(Material.AIR, goal), null, null, null, null, null, null, null, obj); + q.getQuestData(quest).customObjectiveCounts.put(obj.getName(), + quester.getQuestData(quest).customObjectiveCounts.get(obj.getName())); + q.finishObjective(quest, "customObj", new ItemStack(Material.AIR, 1), + new ItemStack(Material.AIR, goal), null, null, null, null, null, null, null, obj); return null; }); } diff --git a/main/src/main/java/me/blackvein/quests/Dependencies.java b/main/src/main/java/me/blackvein/quests/Dependencies.java index 2f18dd812..de32622cb 100644 --- a/main/src/main/java/me/blackvein/quests/Dependencies.java +++ b/main/src/main/java/me/blackvein/quests/Dependencies.java @@ -124,7 +124,8 @@ public class Dependencies { public boolean isPluginAvailable(String pluginName) { if (plugin.getServer().getPluginManager().getPlugin(pluginName) != null ) { if (!plugin.getServer().getPluginManager().getPlugin(pluginName).isEnabled()) { - plugin.getLogger().warning(pluginName + " was detected, but is not enabled! Fix "+ pluginName + " to allow linkage."); + plugin.getLogger().warning(pluginName + + " was detected, but is not enabled! Fix "+ pluginName + " to allow linkage."); } else { return true; } @@ -168,7 +169,8 @@ public class Dependencies { placeholder = (PlaceholderAPIPlugin) plugin.getServer().getPluginManager().getPlugin("PlaceholderAPI"); } if (isPluginAvailable("CitizensBooks")) { - citizensBooks = ((CitizensBooksPlugin) plugin.getServer().getPluginManager().getPlugin("CitizensBooks")).getAPI(); + citizensBooks = ((CitizensBooksPlugin) plugin.getServer().getPluginManager().getPlugin("CitizensBooks")) + .getAPI(); } if (isPluginAvailable("DungeonsXL")) { dungeons = DungeonsXL.getInstance(); @@ -193,7 +195,8 @@ public class Dependencies { private boolean setupEconomy() { try { - RegisteredServiceProvider economyProvider = plugin.getServer().getServicesManager().getRegistration(net.milkbowl.vault.economy.Economy.class); + RegisteredServiceProvider economyProvider = plugin.getServer().getServicesManager() + .getRegistration(net.milkbowl.vault.economy.Economy.class); if (economyProvider != null) { economy = economyProvider.getProvider(); } @@ -204,7 +207,8 @@ public class Dependencies { } private boolean setupPermissions() { - RegisteredServiceProvider permissionProvider = plugin.getServer().getServicesManager().getRegistration(net.milkbowl.vault.permission.Permission.class); + RegisteredServiceProvider permissionProvider = plugin.getServer().getServicesManager() + .getRegistration(net.milkbowl.vault.permission.Permission.class); if (permissionProvider != null) { permission = permissionProvider.getProvider(); } diff --git a/main/src/main/java/me/blackvein/quests/NpcEffectThread.java b/main/src/main/java/me/blackvein/quests/NpcEffectThread.java index f17c97402..1127d891d 100644 --- a/main/src/main/java/me/blackvein/quests/NpcEffectThread.java +++ b/main/src/main/java/me/blackvein/quests/NpcEffectThread.java @@ -36,7 +36,8 @@ public class NpcEffectThread implements Runnable { List nearby = player.getNearbyEntities(32.0, 32.0, 32.0); if (nearby.isEmpty() == false) { for (Entity e : nearby) { - if (plugin.getDependencies().getCitizens() != null && plugin.getDependencies().getCitizens().getNPCRegistry() != null) { + if (plugin.getDependencies().getCitizens() != null + && plugin.getDependencies().getCitizens().getNPCRegistry() != null) { if (plugin.getDependencies().getCitizens().getNPCRegistry().isNPC(e)) { NPC npc = plugin.getDependencies().getCitizens().getNPCRegistry().getNPC(e); if (plugin.hasQuest(npc, quester)) { diff --git a/main/src/main/java/me/blackvein/quests/Quest.java b/main/src/main/java/me/blackvein/quests/Quest.java index 3ffe9944d..3097f2433 100644 --- a/main/src/main/java/me/blackvein/quests/Quest.java +++ b/main/src/main/java/me/blackvein/quests/Quest.java @@ -184,7 +184,8 @@ public class Quest { } String stageCompleteMessage = currentStage.completeMessage; if (stageCompleteMessage != null) { - quester.getPlayer().sendMessage(plugin.parseStringWithPossibleLineBreaks(stageCompleteMessage, this, quester.getPlayer())); + quester.getPlayer().sendMessage(plugin.parseStringWithPossibleLineBreaks(stageCompleteMessage, + this, quester.getPlayer())); } if (plugin.getSettings().canUseCompass()) { quester.resetCompass(); @@ -249,9 +250,6 @@ public class Quest { if (currentStage.script != null) { plugin.getDenizenTrigger().runDenizenScript(currentStage.script, quester); } - /* - * if (quester.getCurrentStage(this).finishEvent != null) { quester.getCurrentStage(this).finishEvent.fire(quester); } - */ if (nextStage.startEvent != null) { nextStage.startEvent.fire(quester, this); } @@ -262,7 +260,8 @@ public class Quest { plugin.showObjectives(this, quester, false); String stageStartMessage = quester.getCurrentStage(this).startMessage; if (stageStartMessage != null) { - quester.getPlayer().sendMessage(plugin.parseStringWithPossibleLineBreaks(stageStartMessage, this, quester.getPlayer())); + quester.getPlayer().sendMessage(plugin.parseStringWithPossibleLineBreaks(stageStartMessage, this, + quester.getPlayer())); } quester.updateJournal(); QuesterPostChangeStageEvent postEvent = new QuesterPostChangeStageEvent(quester, this, currentStage, nextStage); @@ -296,7 +295,8 @@ public class Quest { } else if (nextStage.locationsToReach != null && nextStage.locationsToReach.size() > 0) { targetLocation = nextStage.locationsToReach.getFirst(); } else if (nextStage.itemDeliveryTargets != null && nextStage.itemDeliveryTargets.size() > 0) { - NPC npc = plugin.getDependencies().getCitizens().getNPCRegistry().getById(nextStage.itemDeliveryTargets.getFirst()); + NPC npc = plugin.getDependencies().getCitizens().getNPCRegistry().getById(nextStage.itemDeliveryTargets + .getFirst()); targetLocation = npc.getStoredLocation(); } if (targetLocation != null && targetLocation.getWorld() != null) { @@ -326,7 +326,8 @@ public class Quest { protected boolean testRequirements(Player player) { Quester quester = plugin.getQuester(player.getUniqueId()); if (reqs.getMoney() != 0 && plugin.getDependencies().getVaultEconomy() != null) { - if (plugin.getDependencies().getVaultEconomy().getBalance(Bukkit.getOfflinePlayer(player.getUniqueId())) < reqs.getMoney()) { + if (plugin.getDependencies().getVaultEconomy().getBalance(Bukkit.getOfflinePlayer(player.getUniqueId())) + < reqs.getMoney()) { return false; } } @@ -380,8 +381,8 @@ public class Quest { return false; } } else { - plugin.getLogger().warning("Quester \"" + player.getName() + "\" attempted to take Quest \"" + name + "\", but the Custom Requirement \"" + s - + "\" could not be found. Does it still exist?"); + plugin.getLogger().warning("Quester \"" + player.getName() + "\" attempted to take Quest \"" + name + + "\", but the Custom Requirement \"" + s + "\" could not be found. Does it still exist?"); } } if (quester.questPoints < reqs.getQuestPoints()) { @@ -481,12 +482,14 @@ public class Quest { none = null; } for (String s : rews.getMcmmoSkills()) { - UserManager.getPlayer(player).getProfile().addLevels(Quests.getMcMMOSkill(s), rews.getMcmmoAmounts().get(rews.getMcmmoSkills().indexOf(s))); + UserManager.getPlayer(player).getProfile().addLevels(Quests.getMcMMOSkill(s), + rews.getMcmmoAmounts().get(rews.getMcmmoSkills().indexOf(s))); none = null; } for (String s : rews.getHeroesClasses()) { Hero hero = plugin.getHero(player.getUniqueId()); - hero.addExp(rews.getHeroesAmounts().get(rews.getHeroesClasses().indexOf(s)), plugin.getDependencies().getHeroes().getClassManager().getClass(s), player.getLocation()); + hero.addExp(rews.getHeroesAmounts().get(rews.getHeroesClasses().indexOf(s)), + plugin.getDependencies().getHeroes().getClassManager().getClass(s), player.getLocation()); none = null; } LinkedList phatLootItems = new LinkedList(); @@ -500,7 +503,8 @@ public class Quest { } if (lb.getMoney() > 0) { if (plugin.getDependencies().getVaultEconomy() != null) { - plugin.getDependencies().getVaultEconomy().depositPlayer(Bukkit.getOfflinePlayer(player.getUniqueId()), lb.getMoney()); + plugin.getDependencies().getVaultEconomy() + .depositPlayer(Bukkit.getOfflinePlayer(player.getUniqueId()), lb.getMoney()); } } if (lb.getItemList().isEmpty() == false) { @@ -509,8 +513,8 @@ public class Quest { try { Quests.addItem(player, is); } catch (Exception e) { - plugin.getLogger().severe("Unable to add PhatLoots item to inventory of " - + player.getName() + " upon completion of quest " + name); + plugin.getLogger().severe("Unable to add PhatLoots item to inventory of " + player.getName() + + " upon completion of quest " + name); player.sendMessage(ChatColor.RED + "Quests encountered a problem with an item. " + "Please contact an administrator."); } @@ -535,12 +539,14 @@ public class Quest { player.sendMessage(ChatColor.GREEN + Lang.get(player, "questRewardsTitle")); if (plugin.getSettings().canShowQuestTitles()) { Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "title " + player.getName() - + " title " + "{\"text\":\"" + Lang.get(player, "quest") + " " + Lang.get(player, "complete") + "\",\"color\":\"gold\"}"); + + " title " + "{\"text\":\"" + Lang.get(player, "quest") + " " + Lang.get(player, "complete") + + "\",\"color\":\"gold\"}"); Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "title " + player.getName() + " subtitle " + "{\"text\":\"" + name + "\",\"color\":\"yellow\"}"); } if (rews.getQuestPoints() > 0) { - player.sendMessage("- " + ChatColor.DARK_GREEN + rews.getQuestPoints() + " " + Lang.get(player, "questPoints")); + player.sendMessage("- " + ChatColor.DARK_GREEN + rews.getQuestPoints() + " " + + Lang.get(player, "questPoints")); q.questPoints += rews.getQuestPoints(); none = null; } @@ -548,9 +554,11 @@ public class Quest { String text = "error"; if (i.hasItemMeta() && i.getItemMeta().hasDisplayName()) { if (i.getEnchantments().isEmpty()) { - text = "- " + ChatColor.DARK_AQUA + ChatColor.ITALIC + i.getItemMeta().getDisplayName() + ChatColor.RESET + ChatColor.GRAY + " x " + i.getAmount(); + text = "- " + ChatColor.DARK_AQUA + ChatColor.ITALIC + i.getItemMeta().getDisplayName() + + ChatColor.RESET + ChatColor.GRAY + " x " + i.getAmount(); } else { - text = "- " + ChatColor.DARK_AQUA + ChatColor.ITALIC + i.getItemMeta().getDisplayName() + ChatColor.RESET; + text = "- " + ChatColor.DARK_AQUA + ChatColor.ITALIC + i.getItemMeta().getDisplayName() + + ChatColor.RESET; try { if (!i.getItemMeta().hasItemFlag(ItemFlag.HIDE_ENCHANTS)) { text += ChatColor.GRAY + " " + Lang.get(player, "with") + ChatColor.DARK_PURPLE; @@ -565,9 +573,11 @@ public class Quest { } } else if (i.getDurability() != 0) { if (i.getEnchantments().isEmpty()) { - text = "- " + ChatColor.DARK_GREEN + ItemUtil.getName(i) + ":" + i.getDurability() + ChatColor.GRAY + " x " + i.getAmount(); + text = "- " + ChatColor.DARK_GREEN + ItemUtil.getName(i) + ":" + i.getDurability() + ChatColor.GRAY + + " x " + i.getAmount(); } else { - text = "- " + ChatColor.DARK_GREEN + ItemUtil.getName(i) + ":" + i.getDurability() + ChatColor.GRAY + " " + Lang.get(player, "with"); + text = "- " + ChatColor.DARK_GREEN + ItemUtil.getName(i) + ":" + i.getDurability() + ChatColor.GRAY + + " " + Lang.get(player, "with"); for (Entry e : i.getEnchantments().entrySet()) { text += " " + ItemUtil.getPrettyEnchantmentName(e.getKey()) + ":" + e.getValue(); } @@ -597,44 +607,57 @@ public class Quest { for (ItemStack i : phatLootItems) { if (i.hasItemMeta() && i.getItemMeta().hasDisplayName()) { if (i.getEnchantments().isEmpty()) { - player.sendMessage("- " + ChatColor.DARK_AQUA + ChatColor.ITALIC + i.getItemMeta().getDisplayName() + ChatColor.RESET + ChatColor.GRAY + " x " + i.getAmount()); + player.sendMessage("- " + ChatColor.DARK_AQUA + ChatColor.ITALIC + i.getItemMeta().getDisplayName() + + ChatColor.RESET + ChatColor.GRAY + " x " + i.getAmount()); } else { - player.sendMessage("- " + ChatColor.DARK_AQUA + ChatColor.ITALIC + i.getItemMeta().getDisplayName() + ChatColor.RESET + ChatColor.GRAY + " x " + i.getAmount() + ChatColor.DARK_PURPLE + " " + Lang.get(player, "enchantedItem")); + player.sendMessage("- " + ChatColor.DARK_AQUA + ChatColor.ITALIC + i.getItemMeta().getDisplayName() + + ChatColor.RESET + ChatColor.GRAY + " x " + i.getAmount() + ChatColor.DARK_PURPLE + " " + + Lang.get(player, "enchantedItem")); } } else if (i.getDurability() != 0) { if (i.getEnchantments().isEmpty()) { - player.sendMessage("- " + ChatColor.DARK_GREEN + ItemUtil.getName(i) + ":" + i.getDurability() + ChatColor.GRAY + " x " + i.getAmount()); + player.sendMessage("- " + ChatColor.DARK_GREEN + ItemUtil.getName(i) + ":" + i.getDurability() + + ChatColor.GRAY + " x " + i.getAmount()); } else { - player.sendMessage("- " + ChatColor.DARK_GREEN + ItemUtil.getName(i) + ":" + i.getDurability() + ChatColor.GRAY + " x " + i.getAmount() + ChatColor.DARK_PURPLE + " " + Lang.get(player, "enchantedItem")); + player.sendMessage("- " + ChatColor.DARK_GREEN + ItemUtil.getName(i) + ":" + i.getDurability() + + ChatColor.GRAY + " x " + i.getAmount() + ChatColor.DARK_PURPLE + " " + + Lang.get(player, "enchantedItem")); } } else { if (i.getEnchantments().isEmpty()) { - player.sendMessage("- " + ChatColor.DARK_GREEN + ItemUtil.getName(i) + ChatColor.GRAY + " x " + i.getAmount()); + player.sendMessage("- " + ChatColor.DARK_GREEN + ItemUtil.getName(i) + ChatColor.GRAY + " x " + + i.getAmount()); } else { - player.sendMessage("- " + ChatColor.DARK_GREEN + ItemUtil.getName(i) + ChatColor.GRAY + " x " + i.getAmount() + ChatColor.DARK_PURPLE + " " + Lang.get(player, "enchantedItem")); + player.sendMessage("- " + ChatColor.DARK_GREEN + ItemUtil.getName(i) + ChatColor.GRAY + " x " + + i.getAmount() + ChatColor.DARK_PURPLE + " " + Lang.get(player, "enchantedItem")); } } none = null; } if (rews.getMoney() > 1) { - player.sendMessage("- " + ChatColor.DARK_GREEN + rews.getMoney() + " " + ChatColor.DARK_PURPLE + plugin.getCurrency(true)); + player.sendMessage("- " + ChatColor.DARK_GREEN + rews.getMoney() + " " + ChatColor.DARK_PURPLE + + plugin.getCurrency(true)); none = null; } else if (rews.getMoney() == 1) { - player.sendMessage("- " + ChatColor.DARK_GREEN + rews.getMoney() + " " + ChatColor.DARK_PURPLE + plugin.getCurrency(false)); + player.sendMessage("- " + ChatColor.DARK_GREEN + rews.getMoney() + " " + ChatColor.DARK_PURPLE + + plugin.getCurrency(false)); none = null; } if (rews.getExp() > 0 || phatLootExp > 0) { int tot = rews.getExp() + phatLootExp; - player.sendMessage("- " + ChatColor.DARK_GREEN + tot + ChatColor.DARK_PURPLE + " " + Lang.get(player, "experience")); + player.sendMessage("- " + ChatColor.DARK_GREEN + tot + ChatColor.DARK_PURPLE + " " + + Lang.get(player, "experience")); none = null; } if (rews.getCommands().isEmpty() == false) { int index = 0; for (String s : rews.getCommands()) { - if (rews.getCommandsOverrideDisplay().isEmpty() == false && rews.getCommandsOverrideDisplay().size() >= index) { + if (rews.getCommandsOverrideDisplay().isEmpty() == false && rews.getCommandsOverrideDisplay().size() + >= index) { if (rews.getCommandsOverrideDisplay().size() > index) { if (!rews.getCommandsOverrideDisplay().get(index).trim().equals("")) { - player.sendMessage("- " + ChatColor.DARK_GREEN + rews.getCommandsOverrideDisplay().get(index)); + player.sendMessage("- " + ChatColor.DARK_GREEN + + rews.getCommandsOverrideDisplay().get(index)); } } } else { @@ -646,13 +669,17 @@ public class Quest { } if (rews.getMcmmoSkills().isEmpty() == false) { for (String s : rews.getMcmmoSkills()) { - player.sendMessage("- " + ChatColor.DARK_GREEN + rews.getMcmmoAmounts().get(rews.getMcmmoSkills().indexOf(s)) + " " + ChatColor.DARK_PURPLE + s + " " + Lang.get(player, "experience")); + player.sendMessage("- " + ChatColor.DARK_GREEN + + rews.getMcmmoAmounts().get(rews.getMcmmoSkills().indexOf(s)) + " " + ChatColor.DARK_PURPLE + + s + " " + Lang.get(player, "experience")); } none = null; } if (rews.getHeroesClasses().isEmpty() == false) { for (String s : rews.getHeroesClasses()) { - player.sendMessage("- " + ChatColor.AQUA + rews.getHeroesAmounts().get(rews.getHeroesClasses().indexOf(s)) + " " + ChatColor.BLUE + s + " " + Lang.get(player, "experience")); + player.sendMessage("- " + ChatColor.AQUA + + rews.getHeroesAmounts().get(rews.getHeroesClasses().indexOf(s)) + " " + ChatColor.BLUE + + s + " " + Lang.get(player, "experience")); } none = null; } @@ -683,7 +710,8 @@ public class Quest { } found.giveReward(player, rews.getCustomRewards().get(s)); } else { - plugin.getLogger().warning("Quester \"" + player.getName() + "\" completed the Quest \"" + name + "\", but the Custom Reward \"" + s + "\" could not be found. Does it still exist?"); + plugin.getLogger().warning("Quester \"" + player.getName() + "\" completed the Quest \"" + name + + "\", but the Custom Reward \"" + s + "\" could not be found. Does it still exist?"); } none = null; } @@ -754,7 +782,8 @@ public class Quest { if (region == null) { return false; } - if (plugin.getDependencies().getWorldGuardApi().getApplicableRegionsIDs(player.getWorld(), player.getLocation()).contains(region)) { + if (plugin.getDependencies().getWorldGuardApi() + .getApplicableRegionsIDs(player.getWorld(), player.getLocation()).contains(region)) { return true; } return false; diff --git a/main/src/main/java/me/blackvein/quests/QuestData.java b/main/src/main/java/me/blackvein/quests/QuestData.java index b709e9c1d..3b62b0155 100644 --- a/main/src/main/java/me/blackvein/quests/QuestData.java +++ b/main/src/main/java/me/blackvein/quests/QuestData.java @@ -327,7 +327,8 @@ public class QuestData { } }; - public LinkedHashMap, Integer> itemsEnchanted = new LinkedHashMap, Integer>() { + public LinkedHashMap, Integer> itemsEnchanted + = new LinkedHashMap, Integer>() { private static final long serialVersionUID = 416869352279205852L; diff --git a/main/src/main/java/me/blackvein/quests/QuestFactory.java b/main/src/main/java/me/blackvein/quests/QuestFactory.java index e0b144b7e..10dcfee35 100644 --- a/main/src/main/java/me/blackvein/quests/QuestFactory.java +++ b/main/src/main/java/me/blackvein/quests/QuestFactory.java @@ -79,7 +79,10 @@ public class QuestFactory implements ConversationAbandonedListener { this.plugin = plugin; questsFile = new File(plugin.getDataFolder(), "quests.yml"); // Ensure to initialize convoCreator last so that 'this' is fully initialized before it is passed - this.convoCreator = new ConversationFactory(plugin).withModality(false).withLocalEcho(false).withFirstPrompt(new MainMenuPrompt()).withTimeout(3600).thatExcludesNonPlayersWithMessage("Console may not perform this operation!").addConversationAbandonedListener(this); + this.convoCreator = new ConversationFactory(plugin).withModality(false).withLocalEcho(false) + .withFirstPrompt(new MainMenuPrompt()).withTimeout(3600) + .thatExcludesNonPlayersWithMessage("Console may not perform this operation!") + .addConversationAbandonedListener(this); } public Map getSelectedBlockStarts() { @@ -182,7 +185,8 @@ public class QuestFactory implements ConversationAbandonedListener { plugin.getServer().getPluginManager().callEvent(event); String text = ChatColor.GOLD + getTitle() + "\n"; for (int i = 1; i <= size; i++) { - text += getNumberColor(context, i) + "" + ChatColor.BOLD + i + ChatColor.RESET + " - " + getSelectionText(context, i) + "\n"; + text += getNumberColor(context, i) + "" + ChatColor.BOLD + i + ChatColor.RESET + " - " + + getSelectionText(context, i) + "\n"; } return text; } @@ -290,7 +294,8 @@ public class QuestFactory implements ConversationAbandonedListener { return ChatColor.YELLOW + Lang.get("questEditorFinishMessage"); } case 4: - if (context.getSessionData(CK.Q_START_NPC) == null && plugin.getDependencies().getCitizens() != null) { + if (context.getSessionData(CK.Q_START_NPC) == null && plugin.getDependencies().getCitizens() + != null) { return ChatColor.YELLOW + Lang.get("questEditorNPCStart"); } else if (plugin.getDependencies().getCitizens() != null) { return ChatColor.YELLOW + Lang.get("questEditorNPCStart"); @@ -348,19 +353,23 @@ public class QuestFactory implements ConversationAbandonedListener { if (context.getSessionData(CK.Q_ASK_MESSAGE) == null) { return ChatColor.DARK_RED + "(" + Lang.get("questRequiredNoneSet") + ")"; } else { - return ChatColor.YELLOW + "(" + context.getSessionData(CK.Q_ASK_MESSAGE) + ChatColor.RESET + ChatColor.YELLOW + ")"; + return ChatColor.YELLOW + "(" + context.getSessionData(CK.Q_ASK_MESSAGE) + ChatColor.RESET + + ChatColor.YELLOW + ")"; } case 3: if (context.getSessionData(CK.Q_FINISH_MESSAGE) == null) { return ChatColor.DARK_RED + "(" + Lang.get("questRequiredNoneSet") + ")"; } else { - return ChatColor.YELLOW + "(" + context.getSessionData(CK.Q_FINISH_MESSAGE) + ChatColor.RESET + ChatColor.YELLOW + ")"; + return ChatColor.YELLOW + "(" + context.getSessionData(CK.Q_FINISH_MESSAGE) + ChatColor.RESET + + ChatColor.YELLOW + ")"; } case 4: - if (context.getSessionData(CK.Q_START_NPC) == null && plugin.getDependencies().getCitizens() != null) { + if (context.getSessionData(CK.Q_START_NPC) == null && plugin.getDependencies().getCitizens() + != null) { return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")"; } else if (plugin.getDependencies().getCitizens() != null) { - return ChatColor.YELLOW + "(" + CitizensAPI.getNPCRegistry().getById((Integer) context.getSessionData(CK.Q_START_NPC)).getName() + ChatColor.RESET + ChatColor.YELLOW + ")"; + return ChatColor.YELLOW + "(" + CitizensAPI.getNPCRegistry().getById((Integer) context + .getSessionData(CK.Q_START_NPC)).getName() + ChatColor.RESET + ChatColor.YELLOW + ")"; } else { return ChatColor.GRAY + "(" + Lang.get("notInstalled") + ")"; } @@ -369,14 +378,16 @@ public class QuestFactory implements ConversationAbandonedListener { return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")"; } else { Location l = (Location) context.getSessionData(CK.Q_START_BLOCK); - return ChatColor.YELLOW + "(" + l.getWorld().getName() + ", " + l.getBlockX() + ", " + l.getBlockY() + ", " + l.getBlockZ() + ")"; + return ChatColor.YELLOW + "(" + l.getWorld().getName() + ", " + l.getBlockX() + ", " + + l.getBlockY() + ", " + l.getBlockZ() + ")"; } case 6: if (plugin.getDependencies().getWorldGuardApi() != null) { if (context.getSessionData(CK.Q_REGION) == null) { return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")"; } else { - return ChatColor.YELLOW + "(" + ChatColor.GREEN + (String) context.getSessionData(CK.Q_REGION) + ChatColor.YELLOW + ")"; + return ChatColor.YELLOW + "(" + ChatColor.GREEN + + (String) context.getSessionData(CK.Q_REGION) + ChatColor.YELLOW + ")"; } } else { return ChatColor.GRAY + "(" + Lang.get("notInstalled") + ")"; @@ -392,7 +403,8 @@ public class QuestFactory implements ConversationAbandonedListener { if (context.getSessionData(CK.Q_GUIDISPLAY) == null) { return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")"; } else { - return ChatColor.YELLOW + "(" + ItemUtil.getDisplayString((ItemStack) context.getSessionData(CK.Q_GUIDISPLAY)) + ChatColor.RESET + ChatColor.YELLOW + ")"; + return ChatColor.YELLOW + "(" + ItemUtil.getDisplayString((ItemStack) context + .getSessionData(CK.Q_GUIDISPLAY)) + ChatColor.RESET + ChatColor.YELLOW + ")"; } } else { return ChatColor.GRAY + "(" + Lang.get("notInstalled") + ")"; @@ -415,9 +427,11 @@ public class QuestFactory implements ConversationAbandonedListener { QuestsEditorPostOpenCreatePromptEvent event = new QuestsEditorPostOpenCreatePromptEvent(context); plugin.getServer().getPluginManager().callEvent(event); - String text = ChatColor.GOLD + "- " + getTitle(context).replaceFirst(": ", ": " + ChatColor.AQUA) + ChatColor.GOLD + " -\n"; + String text = ChatColor.GOLD + "- " + getTitle(context).replaceFirst(": ", ": " + ChatColor.AQUA) + + ChatColor.GOLD + " -\n"; for (int i = 1; i <= size; i++) { - text += getNumberColor(context, i) + "" + ChatColor.BOLD + i + ChatColor.RESET + " - " + getSelectionText(context, i) + " " + getAdditionalText(context, i) + "\n"; + text += getNumberColor(context, i) + "" + ChatColor.BOLD + i + ChatColor.RESET + " - " + + getSelectionText(context, i) + " " + getAdditionalText(context, i) + "\n"; } return text; } @@ -586,7 +600,8 @@ public class QuestFactory implements ConversationAbandonedListener { if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) { if (input.startsWith("++")) { if (context.getSessionData(CK.Q_ASK_MESSAGE) != null) { - context.setSessionData(CK.Q_ASK_MESSAGE, context.getSessionData(CK.Q_ASK_MESSAGE) + " " + input.substring(2)); + context.setSessionData(CK.Q_ASK_MESSAGE, context.getSessionData(CK.Q_ASK_MESSAGE) + " " + + input.substring(2)); return new CreateMenuPrompt(); } } @@ -608,7 +623,8 @@ public class QuestFactory implements ConversationAbandonedListener { if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) { if (input.startsWith("++")) { if (context.getSessionData(CK.Q_FINISH_MESSAGE) != null) { - context.setSessionData(CK.Q_FINISH_MESSAGE, context.getSessionData(CK.Q_FINISH_MESSAGE) + " " + input.substring(2)); + context.setSessionData(CK.Q_FINISH_MESSAGE, context.getSessionData(CK.Q_FINISH_MESSAGE) + " " + + input.substring(2)); return new CreateMenuPrompt(); } } @@ -623,12 +639,14 @@ public class QuestFactory implements ConversationAbandonedListener { @Override public String getPromptText(ConversationContext context) { selectingNpcs.add((Player) context.getForWhom()); - return ChatColor.YELLOW + Lang.get("questEditorEnterNPCStart") + "\n" + ChatColor.GOLD + Lang.get("npcHint"); + return ChatColor.YELLOW + Lang.get("questEditorEnterNPCStart") + "\n" + + ChatColor.GOLD + Lang.get("npcHint"); } @Override public Prompt acceptInput(ConversationContext context, String input) { - if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false && input.equalsIgnoreCase(Lang.get("cmdClear")) == false) { + if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false + && input.equalsIgnoreCase(Lang.get("cmdClear")) == false) { try { int i = Integer.parseInt(input); if (i > -1) { @@ -641,7 +659,8 @@ public class QuestFactory implements ConversationAbandonedListener { return new CreateMenuPrompt(); } } catch (NumberFormatException e) { - context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("reqNotANumber").replace("", input)); + context.getForWhom().sendRawMessage(ChatColor.RED + + Lang.get("reqNotANumber").replace("", input)); return new NPCStartPrompt(); } } else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) { @@ -712,7 +731,8 @@ public class QuestFactory implements ConversationAbandonedListener { @Override public Prompt acceptInput(ConversationContext context, String input) { Player player = (Player) context.getForWhom(); - if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false && input.equalsIgnoreCase(Lang.get("cmdClear")) == false) { + if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false + && input.equalsIgnoreCase(Lang.get("cmdClear")) == false) { String found = null; boolean done = false; for (World world : plugin.getServer().getWorlds()) { @@ -766,13 +786,15 @@ public class QuestFactory implements ConversationAbandonedListener { @Override public Prompt acceptInput(ConversationContext context, String input) { Player player = (Player) context.getForWhom(); - if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false && input.equalsIgnoreCase(Lang.get("cmdClear")) == false) { + if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false + && input.equalsIgnoreCase(Lang.get("cmdClear")) == false) { Action a = plugin.getAction(input); if (a != null) { context.setSessionData(CK.Q_INITIAL_EVENT, a.getName()); return new CreateMenuPrompt(); } - player.sendMessage(ChatColor.RED + input + ChatColor.YELLOW + " " + Lang.get("questEditorInvalidEventName")); + player.sendMessage(ChatColor.RED + input + ChatColor.YELLOW + " " + + Lang.get("questEditorInvalidEventName")); return new InitialActionPrompt(); } else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) { context.setSessionData(CK.Q_INITIAL_EVENT, null); @@ -814,17 +836,20 @@ public class QuestFactory implements ConversationAbandonedListener { } public String getQueryText(ConversationContext context) { - return ChatColor.YELLOW + Lang.get("questEditorSave") + " \"" + ChatColor.AQUA + context.getSessionData(CK.Q_NAME) + ChatColor.YELLOW + "\"?\n"; + return ChatColor.YELLOW + Lang.get("questEditorSave") + " \"" + ChatColor.AQUA + + context.getSessionData(CK.Q_NAME) + ChatColor.YELLOW + "\"?\n"; } @Override public String getPromptText(ConversationContext context) { - QuestsEditorPostOpenSavePromptEvent event = new QuestsEditorPostOpenSavePromptEvent(QuestFactory.this, context); + QuestsEditorPostOpenSavePromptEvent event + = new QuestsEditorPostOpenSavePromptEvent(QuestFactory.this, context); plugin.getServer().getPluginManager().callEvent(event); String text = getQueryText(context); for (int i = 1; i <= size; i++) { - text += getNumberColor(context, i) + "" + ChatColor.BOLD + i + ChatColor.RESET + " - " + getSelectionText(context, i) + "\n"; + text += getNumberColor(context, i) + "" + ChatColor.BOLD + i + ChatColor.RESET + " - " + + getSelectionText(context, i) + "\n"; } return text; } @@ -861,7 +886,8 @@ public class QuestFactory implements ConversationAbandonedListener { saveQuest(context, newSection); data.save(new File(plugin.getDataFolder(), "quests.yml")); context.getForWhom().sendRawMessage(ChatColor.GREEN - + Lang.get("questEditorSaved").replaceAll("", "/questadmin " + Lang.get("COMMAND_QUESTADMIN_RELOAD"))); + + Lang.get("questEditorSaved").replaceAll("", "/questadmin " + + Lang.get("COMMAND_QUESTADMIN_RELOAD"))); } catch (IOException e) { e.printStackTrace(); } catch (InvalidConfigurationException e) { @@ -911,12 +937,14 @@ public class QuestFactory implements ConversationAbandonedListener { @Override public String getPromptText(ConversationContext context) { - QuestsEditorPostOpenExitPromptEvent event = new QuestsEditorPostOpenExitPromptEvent(QuestFactory.this, context); + QuestsEditorPostOpenExitPromptEvent event + = new QuestsEditorPostOpenExitPromptEvent(QuestFactory.this, context); plugin.getServer().getPluginManager().callEvent(event); String text = getQueryText(context); for (int i = 1; i <= size; i++) { - text += getNumberColor(context, i) + "" + ChatColor.BOLD + i + ChatColor.RESET + " - " + getSelectionText(context, i) + "\n"; + text += getNumberColor(context, i) + "" + ChatColor.BOLD + i + ChatColor.RESET + " - " + + getSelectionText(context, i) + "\n"; } return text; } @@ -1140,7 +1168,12 @@ public class QuestFactory implements ConversationAbandonedListener { cs.set("event", initialEvent); cs.set("region", region); cs.set("gui-display", guiDisplay); - if (moneyReq != null || questPointsReq != null || itemReqs != null && itemReqs.isEmpty() == false || permReqs != null && permReqs.isEmpty() == false || (questReqs != null && questReqs.isEmpty() == false) || (questBlocks != null && questBlocks.isEmpty() == false) || (mcMMOSkillReqs != null && mcMMOSkillReqs.isEmpty() == false) || heroesPrimaryReq != null || heroesSecondaryReq != null || customReqs != null) { + if (moneyReq != null || questPointsReq != null || itemReqs != null && itemReqs.isEmpty() == false + || permReqs != null && permReqs.isEmpty() == false + || (questReqs != null && questReqs.isEmpty() == false) + || (questBlocks != null && questBlocks.isEmpty() == false) + || (mcMMOSkillReqs != null && mcMMOSkillReqs.isEmpty() == false) + || heroesPrimaryReq != null || heroesSecondaryReq != null || customReqs != null) { ConfigurationSection reqs = cs.createSection("requirements"); reqs.set("items", itemReqs); reqs.set("remove-items", removeItemReqs); @@ -1377,7 +1410,8 @@ public class QuestFactory implements ConversationAbandonedListener { if (cc.getSessionData(pref + CK.S_CUSTOM_OBJECTIVES) != null) { customObjs = (LinkedList) cc.getSessionData(pref + CK.S_CUSTOM_OBJECTIVES); customObjCounts = (LinkedList) cc.getSessionData(pref + CK.S_CUSTOM_OBJECTIVES_COUNT); - customObjsData = (LinkedList>) cc.getSessionData(pref + CK.S_CUSTOM_OBJECTIVES_DATA); + customObjsData + = (LinkedList>) cc.getSessionData(pref + CK.S_CUSTOM_OBJECTIVES_DATA); } if (cc.getSessionData(pref + CK.S_START_EVENT) != null) { startEvent = (String) cc.getSessionData(pref + CK.S_START_EVENT); @@ -1538,15 +1572,20 @@ public class QuestFactory implements ConversationAbandonedListener { stage.set("delay", delay.intValue() / 1000); } stage.set("delay-message", delayMessage == null ? delayMessage : delayMessage.replace("\\n", "\n")); - stage.set("objective-override", overrideDisplay == null ? overrideDisplay : overrideDisplay.replace("\\n", "\n")); + stage.set("objective-override", overrideDisplay == null ? overrideDisplay + : overrideDisplay.replace("\\n", "\n")); stage.set("start-message", startMessage == null ? startMessage : startMessage.replace("\\n", "\n")); - stage.set("complete-message", completeMessage == null ? completeMessage : completeMessage.replace("\\n", "\n")); + stage.set("complete-message", completeMessage == null ? completeMessage + : completeMessage.replace("\\n", "\n")); } if (moneyRew != null || questPointsRew != null || itemRews != null && itemRews.isEmpty() == false - || permRews != null && permRews.isEmpty() == false || expRew != null || commandRews != null && commandRews.isEmpty() == false - || commandDisplayOverrideRews != null && commandDisplayOverrideRews.isEmpty() == false || mcMMOSkillRews != null - || RPGItemRews != null || heroesClassRews != null && heroesClassRews.isEmpty() == false - || phatLootRews != null && phatLootRews.isEmpty() == false || customRews != null && customRews.isEmpty() == false) { + || permRews != null && permRews.isEmpty() == false || expRew != null + || commandRews != null && commandRews.isEmpty() == false + || commandDisplayOverrideRews != null && commandDisplayOverrideRews.isEmpty() == false + || mcMMOSkillRews != null || RPGItemRews != null + || heroesClassRews != null && heroesClassRews.isEmpty() == false + || phatLootRews != null && phatLootRews.isEmpty() == false + || customRews != null && customRews.isEmpty() == false) { ConfigurationSection rews = cs.createSection("rewards"); rews.set("items", (itemRews != null && itemRews.isEmpty() == false) ? itemRews : null); rews.set("money", moneyRew); @@ -1995,7 +2034,8 @@ public class QuestFactory implements ConversationAbandonedListener { Quest found = plugin.getQuest(input); if (found != null) { for (Quest q : plugin.getQuests()) { - if (q.getRequirements().getNeededQuests().contains(q.getName()) || q.getRequirements().getBlockQuests().contains(q.getName())) { + if (q.getRequirements().getNeededQuests().contains(q.getName()) + || q.getRequirements().getBlockQuests().contains(q.getName())) { used.add(q.getName()); } } @@ -2003,11 +2043,15 @@ public class QuestFactory implements ConversationAbandonedListener { context.setSessionData(CK.ED_QUEST_DELETE, found.getName()); return new DeletePrompt(); } else { - ((Player) context.getForWhom()).sendMessage(ChatColor.RED + Lang.get("questEditorQuestAsRequirement1") + " \"" + ChatColor.DARK_PURPLE + context.getSessionData(CK.ED_QUEST_DELETE) + ChatColor.RED + "\" " + Lang.get("questEditorQuestAsRequirement2")); + ((Player) context.getForWhom()).sendMessage(ChatColor.RED + + Lang.get("questEditorQuestAsRequirement1") + " \"" + ChatColor.DARK_PURPLE + + context.getSessionData(CK.ED_QUEST_DELETE) + ChatColor.RED + "\" " + + Lang.get("questEditorQuestAsRequirement2")); for (String s : used) { ((Player) context.getForWhom()).sendMessage(ChatColor.RED + "- " + ChatColor.DARK_RED + s); } - ((Player) context.getForWhom()).sendMessage(ChatColor.RED + Lang.get("questEditorQuestAsRequirement3")); + ((Player) context.getForWhom()).sendMessage(ChatColor.RED + + Lang.get("questEditorQuestAsRequirement3")); return new SelectDeletePrompt(); } } @@ -2023,9 +2067,12 @@ public class QuestFactory implements ConversationAbandonedListener { @Override public String getPromptText(ConversationContext context) { - String text = ChatColor.GREEN + "" + ChatColor.BOLD + "1" + ChatColor.RESET + "" + ChatColor.GREEN + " - " + Lang.get("yesWord") + "\n"; - text += ChatColor.RED + "" + ChatColor.BOLD + "2" + ChatColor.RESET + "" + ChatColor.RED + " - " + Lang.get("noWord"); - return ChatColor.RED + Lang.get("confirmDelete") + " (" + ChatColor.YELLOW + (String) context.getSessionData(CK.ED_QUEST_DELETE) + ChatColor.RED + ")\n" + text; + String text = ChatColor.GREEN + "" + ChatColor.BOLD + "1" + ChatColor.RESET + "" + ChatColor.GREEN + " - " + + Lang.get("yesWord") + "\n"; + text += ChatColor.RED + "" + ChatColor.BOLD + "2" + ChatColor.RESET + "" + ChatColor.RED + " - " + + Lang.get("noWord"); + return ChatColor.RED + Lang.get("confirmDelete") + " (" + ChatColor.YELLOW + + (String) context.getSessionData(CK.ED_QUEST_DELETE) + ChatColor.RED + ")\n" + text; } @Override diff --git a/main/src/main/java/me/blackvein/quests/Quester.java b/main/src/main/java/me/blackvein/quests/Quester.java index 08125c8de..8896f1468 100644 --- a/main/src/main/java/me/blackvein/quests/Quester.java +++ b/main/src/main/java/me/blackvein/quests/Quester.java @@ -349,12 +349,14 @@ public class Quester { int currentLines = 0; String page = ""; for (Quest quest : currentQuests.keySet()) { - if ((currentLength + quest.getName().length() > 240) || (currentLines + ((quest.getName().length() % 19) - == 0 ? (quest.getName().length() / 19) : ((quest.getName().length() / 19) + 1))) > 13) { + if ((currentLength + quest.getName().length() > 240) || (currentLines + + ((quest.getName().length() % 19) == 0 ? (quest.getName().length() / 19) + : ((quest.getName().length() / 19) + 1))) > 13) { book.addPage(page); page += ChatColor.DARK_PURPLE + "" + ChatColor.BOLD + quest.getName() + "\n"; currentLength = quest.getName().length(); - currentLines = (quest.getName().length() % 19) == 0 ? (quest.getName().length() / 19) : (quest.getName().length() + 1); + currentLines = (quest.getName().length() % 19) == 0 ? (quest.getName().length() / 19) + : (quest.getName().length() + 1); } else { page += ChatColor.DARK_PURPLE + "" + ChatColor.BOLD + quest.getName() + "\n"; currentLength += quest.getName().length(); @@ -457,7 +459,8 @@ public class Quester { // Check whether the quest is currently active boolean active = false; for (Entry startEnd : cache.entrySet()) { - if (startEnd.getKey() <= System.currentTimeMillis() && System.currentTimeMillis() < startEnd.getValue()) { + if (startEnd.getKey() <= System.currentTimeMillis() && System.currentTimeMillis() + < startEnd.getValue()) { active = true; } } @@ -499,11 +502,12 @@ public class Quester { player.sendMessage(ChatColor.GREEN + accepted); player.sendMessage(""); if (plugin.getSettings().canShowQuestTitles()) { - Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "title " + player.getName() - + " title " + "{\"text\":\"" + Lang.get(getPlayer(), "quest") + " " + Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "title " + + player.getName() + " title " + "{\"text\":\"" + Lang.get(getPlayer(), "quest") + " " + Lang.get(getPlayer(), "accepted") + "\",\"color\":\"gold\"}"); - Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "title " + player.getName() - + " subtitle " + "{\"text\":\"" + q.getName() + "\",\"color\":\"yellow\"}"); + Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "title " + + player.getName() + " subtitle " + "{\"text\":\"" + q.getName() + + "\",\"color\":\"yellow\"}"); } } String msg = Lang.get(getPlayer(), "questObjectivesTitle"); @@ -567,11 +571,11 @@ public class Quester { for (ItemStack e2 : getQuestData(quest).blocksBroken) { if (e2.getType().equals(e.getType()) && e2.getDurability() == e.getDurability()) { if (e2.getAmount() < e.getAmount()) { - unfinishedObjectives.add(ChatColor.GREEN + Lang.get(getPlayer(), "break") + " " + ItemUtil.getName(e2) - + ChatColor.GREEN + ": " + e2.getAmount() + "/" + e.getAmount()); + unfinishedObjectives.add(ChatColor.GREEN + Lang.get(getPlayer(), "break") + " " + + ItemUtil.getName(e2) + ChatColor.GREEN + ": " + e2.getAmount() + "/" + e.getAmount()); } else { - finishedObjectives.add(ChatColor.GRAY + Lang.get(getPlayer(), "break") + " " + ItemUtil.getName(e2) - + ChatColor.GRAY + ": " + e2.getAmount() + "/" + e.getAmount()); + finishedObjectives.add(ChatColor.GRAY + Lang.get(getPlayer(), "break") + " " + + ItemUtil.getName(e2) + ChatColor.GRAY + ": " + e2.getAmount() + "/" + e.getAmount()); } } } @@ -580,11 +584,11 @@ public class Quester { for (ItemStack e2 : getQuestData(quest).blocksDamaged) { if (e2.getType().equals(e.getType()) && e2.getDurability() == e.getDurability()) { if (e2.getAmount() < e.getAmount()) { - unfinishedObjectives.add(ChatColor.GREEN + Lang.get(getPlayer(), "damage") + " " + ItemUtil.getName(e2) - + ChatColor.GREEN + ": " + e2.getAmount() + "/" + e.getAmount()); + unfinishedObjectives.add(ChatColor.GREEN + Lang.get(getPlayer(), "damage") + " " + + ItemUtil.getName(e2) + ChatColor.GREEN + ": " + e2.getAmount() + "/" + e.getAmount()); } else { - finishedObjectives.add(ChatColor.GRAY + Lang.get(getPlayer(), "damage") + " " + ItemUtil.getName(e2) - + ChatColor.GRAY + ": " + e2.getAmount() + "/" + e.getAmount()); + finishedObjectives.add(ChatColor.GRAY + Lang.get(getPlayer(), "damage") + " " + + ItemUtil.getName(e2) + ChatColor.GRAY + ": " + e2.getAmount() + "/" + e.getAmount()); } } } @@ -593,11 +597,11 @@ public class Quester { for (ItemStack e2 : getQuestData(quest).blocksPlaced) { if (e2.getType().equals(e.getType()) && e2.getDurability() == e.getDurability()) { if (e2.getAmount() < e.getAmount()) { - unfinishedObjectives.add(ChatColor.GREEN + Lang.get(getPlayer(), "place") + " " + ItemUtil.getName(e2) - + ChatColor.GREEN + ": " + e2.getAmount() + "/" + e.getAmount()); + unfinishedObjectives.add(ChatColor.GREEN + Lang.get(getPlayer(), "place") + " " + + ItemUtil.getName(e2) + ChatColor.GREEN + ": " + e2.getAmount() + "/" + e.getAmount()); } else { - finishedObjectives.add(ChatColor.GRAY + Lang.get(getPlayer(), "place") + " " + ItemUtil.getName(e2) - + ChatColor.GRAY + ": " + e2.getAmount() + "/" + e.getAmount()); + finishedObjectives.add(ChatColor.GRAY + Lang.get(getPlayer(), "place") + " " + + ItemUtil.getName(e2) + ChatColor.GRAY + ": " + e2.getAmount() + "/" + e.getAmount()); } } } @@ -606,11 +610,11 @@ public class Quester { for (ItemStack e2 : getQuestData(quest).blocksUsed) { if (e2.getType().equals(e.getType()) && e2.getDurability() == e.getDurability()) { if (e2.getAmount() < e.getAmount()) { - unfinishedObjectives.add(ChatColor.GREEN + Lang.get(getPlayer(), "use") + " " + ItemUtil.getName(e2) - + ChatColor.GREEN + ": " + e2.getAmount() + "/" + e.getAmount()); + unfinishedObjectives.add(ChatColor.GREEN + Lang.get(getPlayer(), "use") + " " + + ItemUtil.getName(e2) + ChatColor.GREEN + ": " + e2.getAmount() + "/" + e.getAmount()); } else { - finishedObjectives.add(ChatColor.GRAY + Lang.get(getPlayer(), "use") + " " + ItemUtil.getName(e2) - + ChatColor.GRAY + ": " + e2.getAmount() + "/" + e.getAmount()); + finishedObjectives.add(ChatColor.GRAY + Lang.get(getPlayer(), "use") + " " + + ItemUtil.getName(e2) + ChatColor.GRAY + ": " + e2.getAmount() + "/" + e.getAmount()); } } } @@ -619,11 +623,11 @@ public class Quester { for (ItemStack e2 : getQuestData(quest).blocksCut) { if (e2.getType().equals(e.getType()) && e2.getDurability() == e.getDurability()) { if (e2.getAmount() < e.getAmount()) { - unfinishedObjectives.add(ChatColor.GREEN + Lang.get(getPlayer(), "cut") + " " + ItemUtil.getName(e2) - + ChatColor.GREEN + ": " + e2.getAmount() + "/" + e.getAmount()); + unfinishedObjectives.add(ChatColor.GREEN + Lang.get(getPlayer(), "cut") + " " + + ItemUtil.getName(e2) + ChatColor.GREEN + ": " + e2.getAmount() + "/" + e.getAmount()); } else { - finishedObjectives.add(ChatColor.GRAY + Lang.get(getPlayer(), "cut") + " " + ItemUtil.getName(e2) - + ChatColor.GRAY + ": " + e2.getAmount() + "/" + e.getAmount()); + finishedObjectives.add(ChatColor.GRAY + Lang.get(getPlayer(), "cut") + " " + + ItemUtil.getName(e2) + ChatColor.GRAY + ": " + e2.getAmount() + "/" + e.getAmount()); } } } @@ -688,12 +692,14 @@ public class Quester { if (num1 < num2) { String obj = Lang.get(getPlayer(), "enchantItem"); obj = obj.replace("", ItemUtil.getName(new ItemStack(mat)) + ChatColor.GREEN); - obj = obj.replace("", ChatColor.LIGHT_PURPLE + ItemUtil.getPrettyEnchantmentName(enchantment) + ChatColor.GREEN); + obj = obj.replace("", ChatColor.LIGHT_PURPLE + + ItemUtil.getPrettyEnchantmentName(enchantment) + ChatColor.GREEN); unfinishedObjectives.add(ChatColor.GREEN + obj + ChatColor.GREEN + ": " + num1 + "/" + num2); } else { String obj = Lang.get(getPlayer(), "enchantItem"); obj = obj.replace("", ItemUtil.getName(new ItemStack(mat)) + ChatColor.GRAY); - obj = obj.replace("", ChatColor.LIGHT_PURPLE + ItemUtil.getPrettyEnchantmentName(enchantment) + ChatColor.GRAY); + obj = obj.replace("", ChatColor.LIGHT_PURPLE + + ItemUtil.getPrettyEnchantmentName(enchantment) + ChatColor.GRAY); finishedObjectives.add(ChatColor.GRAY + obj + ChatColor.GRAY + ": " + num1 + "/" + num2); } } @@ -726,35 +732,43 @@ public class Quester { for (EntityType e2 : getQuestData(quest).mobsKilled) { if (e == e2) { if (getQuestData(quest).mobNumKilled.size() > getQuestData(quest).mobsKilled.indexOf(e2) - && getCurrentStage(quest).mobNumToKill.size() > getCurrentStage(quest).mobsToKill.indexOf(e)) { + && getCurrentStage(quest).mobNumToKill.size() > getCurrentStage(quest).mobsToKill + .indexOf(e)) { if (getQuestData(quest).mobNumKilled.get(getQuestData(quest).mobsKilled.indexOf(e2)) - < getCurrentStage(quest).mobNumToKill.get(getCurrentStage(quest).mobsToKill.indexOf(e))) { + < getCurrentStage(quest).mobNumToKill.get(getCurrentStage(quest).mobsToKill + .indexOf(e))) { if (getCurrentStage(quest).locationsToKillWithin.isEmpty()) { unfinishedObjectives.add(ChatColor.GREEN + Lang.get(getPlayer(), "kill") + " " + ChatColor.AQUA + MiscUtil.getPrettyMobName(e) + ChatColor.GREEN + ": " - + (getQuestData(quest).mobNumKilled.get(getQuestData(quest).mobsKilled.indexOf(e2))) - + "/" + (getCurrentStage(quest).mobNumToKill.get(getCurrentStage(quest).mobsToKill.indexOf(e)))); + + (getQuestData(quest).mobNumKilled.get(getQuestData(quest).mobsKilled + .indexOf(e2))) + "/" + (getCurrentStage(quest).mobNumToKill + .get(getCurrentStage(quest).mobsToKill.indexOf(e)))); } else { String obj = Lang.get(getPlayer(), "killAtLocation"); obj = obj.replace("", ChatColor.LIGHT_PURPLE + MiscUtil.getPrettyMobName(e)); - obj = obj.replace("", getCurrentStage(quest).killNames.get(getCurrentStage(quest).mobsToKill.indexOf(e))); + obj = obj.replace("", getCurrentStage(quest).killNames + .get(getCurrentStage(quest).mobsToKill.indexOf(e))); unfinishedObjectives.add(ChatColor.GREEN + obj + ChatColor.GREEN + ": " - + (getQuestData(quest).mobNumKilled.get(getQuestData(quest).mobsKilled.indexOf(e2))) - + "/" + (getCurrentStage(quest).mobNumToKill.get(getCurrentStage(quest).mobsToKill.indexOf(e)))); + + (getQuestData(quest).mobNumKilled.get(getQuestData(quest).mobsKilled + .indexOf(e2))) + "/" + (getCurrentStage(quest).mobNumToKill + .get(getCurrentStage(quest).mobsToKill.indexOf(e)))); } } else { if (getCurrentStage(quest).locationsToKillWithin.isEmpty()) { finishedObjectives.add(ChatColor.GRAY + Lang.get(getPlayer(), "kill") + " " + ChatColor.AQUA + MiscUtil.getPrettyMobName(e) + ChatColor.GRAY + ": " - + (getQuestData(quest).mobNumKilled.get(getQuestData(quest).mobsKilled.indexOf(e2))) - + "/" + (getCurrentStage(quest).mobNumToKill.get(getCurrentStage(quest).mobsToKill.indexOf(e)))); + + (getQuestData(quest).mobNumKilled.get(getQuestData(quest).mobsKilled + .indexOf(e2))) + "/" + (getCurrentStage(quest).mobNumToKill + .get(getCurrentStage(quest).mobsToKill.indexOf(e)))); } else { String obj = Lang.get(getPlayer(), "killAtLocation"); obj = obj.replace("", ChatColor.LIGHT_PURPLE + MiscUtil.getPrettyMobName(e)); - obj = obj.replace("", getCurrentStage(quest).killNames.get(getCurrentStage(quest).mobsToKill.indexOf(e))); + obj = obj.replace("", getCurrentStage(quest).killNames + .get(getCurrentStage(quest).mobsToKill.indexOf(e))); finishedObjectives.add(ChatColor.GRAY + obj + ChatColor.GRAY + ": " - + (getQuestData(quest).mobNumKilled.get(getQuestData(quest).mobsKilled.indexOf(e2))) - + "/" + (getCurrentStage(quest).mobNumToKill.get(getCurrentStage(quest).mobsToKill.indexOf(e)))); + + (getQuestData(quest).mobNumKilled.get(getQuestData(quest).mobsKilled + .indexOf(e2))) + "/" + (getCurrentStage(quest).mobNumToKill + .get(getCurrentStage(quest).mobsToKill.indexOf(e)))); } } } @@ -810,16 +824,22 @@ public class Quester { for (Integer n2 : getQuestData(quest).citizensKilled) { if (n.equals(n2)) { if (getQuestData(quest).citizenNumKilled.size() > getQuestData(quest).citizensKilled.indexOf(n2) - && getCurrentStage(quest).citizenNumToKill.size() > getCurrentStage(quest).citizensToKill.indexOf(n)) { + && getCurrentStage(quest).citizenNumToKill.size() > getCurrentStage(quest).citizensToKill + .indexOf(n)) { if (getQuestData(quest).citizenNumKilled.get(getQuestData(quest).citizensKilled.indexOf(n2)) - < getCurrentStage(quest).citizenNumToKill.get(getCurrentStage(quest).citizensToKill.indexOf(n))) { - unfinishedObjectives.add(ChatColor.GREEN + Lang.get(getPlayer(), "kill") + " " + plugin.getNPCName(n) - + ChatColor.GREEN + " " + getQuestData(quest).citizenNumKilled.get(getCurrentStage(quest).citizensToKill.indexOf(n)) - + "/" + getCurrentStage(quest).citizenNumToKill.get(getCurrentStage(quest).citizensToKill.indexOf(n))); + < getCurrentStage(quest).citizenNumToKill.get(getCurrentStage(quest).citizensToKill + .indexOf(n))) { + unfinishedObjectives.add(ChatColor.GREEN + Lang.get(getPlayer(), "kill") + " " + + plugin.getNPCName(n) + ChatColor.GREEN + " " + getQuestData(quest) + .citizenNumKilled.get(getCurrentStage(quest).citizensToKill.indexOf(n)) + "/" + + getCurrentStage(quest).citizenNumToKill.get(getCurrentStage(quest).citizensToKill + .indexOf(n))); } else { - finishedObjectives.add(ChatColor.GRAY + Lang.get(getPlayer(), "kill") + " " + plugin.getNPCName(n) - + ChatColor.GRAY + " " + getCurrentStage(quest).citizenNumToKill.get(getCurrentStage(quest).citizensToKill.indexOf(n)) - + "/" + getCurrentStage(quest).citizenNumToKill.get(getCurrentStage(quest).citizensToKill.indexOf(n))); + finishedObjectives.add(ChatColor.GRAY + Lang.get(getPlayer(), "kill") + " " + + plugin.getNPCName(n) + ChatColor.GRAY + " " + getCurrentStage(quest) + .citizenNumToKill.get(getCurrentStage(quest).citizensToKill.indexOf(n)) + "/" + + getCurrentStage(quest).citizenNumToKill.get(getCurrentStage(quest).citizensToKill + .indexOf(n))); } } } @@ -829,11 +849,13 @@ public class Quester { for (Entry e2 : getQuestData(quest).mobsTamed.entrySet()) { if (e.getKey().equals(e2.getKey())) { if (e2.getValue() < e.getValue()) { - unfinishedObjectives.add(ChatColor.GREEN + Lang.get(getPlayer(), "tame") + " " + MiscUtil.getCapitalized(e.getKey().name()) + unfinishedObjectives.add(ChatColor.GREEN + Lang.get(getPlayer(), "tame") + " " + + MiscUtil.getCapitalized(e.getKey().name()) + ChatColor.GREEN + ": " + e2.getValue() + "/" + e.getValue()); } else { - finishedObjectives.add(ChatColor.GRAY + Lang.get(getPlayer(), "tame") + " " + MiscUtil.getCapitalized(e.getKey().name()) - + ChatColor.GRAY + ": " + e2.getValue() + "/" + e.getValue()); + finishedObjectives.add(ChatColor.GRAY + Lang.get(getPlayer(), "tame") + " " + + MiscUtil.getCapitalized(e.getKey().name()) + ChatColor.GRAY + ": " + e2.getValue() + + "/" + e.getValue()); } } } @@ -844,11 +866,13 @@ public class Quester { if (e2.getValue() < e.getValue()) { String obj = Lang.get(getPlayer(), "shearSheep"); obj = obj.replace("", e.getKey().name().toLowerCase()); - unfinishedObjectives.add(ChatColor.GREEN + obj + ChatColor.GREEN + ": " + e2.getValue() + "/" + e.getValue()); + unfinishedObjectives.add(ChatColor.GREEN + obj + ChatColor.GREEN + ": " + e2.getValue() + "/" + + e.getValue()); } else { String obj = Lang.get(getPlayer(), "shearSheep"); obj = obj.replace("", e.getKey().name().toLowerCase()); - finishedObjectives.add(ChatColor.GRAY + obj + ChatColor.GRAY + ": " + e2.getValue() + "/" + e.getValue()); + finishedObjectives.add(ChatColor.GRAY + obj + ChatColor.GRAY + ": " + e2.getValue() + "/" + + e.getValue()); } } } @@ -857,13 +881,16 @@ public class Quester { for (Location l2 : getQuestData(quest).locationsReached) { if (l.equals(l2)) { if (!getQuestData(quest).hasReached.isEmpty()) { - if (getQuestData(quest).hasReached.get(getQuestData(quest).locationsReached.indexOf(l2)) == false) { + if (getQuestData(quest).hasReached.get(getQuestData(quest).locationsReached.indexOf(l2)) + == false) { String obj = Lang.get(getPlayer(), "goTo"); - obj = obj.replace("", getCurrentStage(quest).locationNames.get(getCurrentStage(quest).locationsToReach.indexOf(l))); + obj = obj.replace("", getCurrentStage(quest).locationNames + .get(getCurrentStage(quest).locationsToReach.indexOf(l))); unfinishedObjectives.add(ChatColor.GREEN + obj); } else { String obj = Lang.get(getPlayer(), "goTo"); - obj = obj.replace("", getCurrentStage(quest).locationNames.get(getCurrentStage(quest).locationsToReach.indexOf(l))); + obj = obj.replace("", getCurrentStage(quest).locationNames + .get(getCurrentStage(quest).locationsToReach.indexOf(l))); finishedObjectives.add(ChatColor.GRAY + obj); } } @@ -893,24 +920,28 @@ public class Quester { try { if (display.contains(replacement)) { if (dataIndex < getCurrentStage(quest).customObjectiveData.size()) { - display = display.replace(replacement, ((String) getCurrentStage(quest).customObjectiveData.get(dataIndex).getValue())); + display = display.replace(replacement, ((String) getCurrentStage(quest) + .customObjectiveData.get(dataIndex).getValue())); } } } catch (NullPointerException ne) { - plugin.getLogger().severe("Unable to fetch display for " + co.getName() + " on " + quest.getName()); + plugin.getLogger().severe("Unable to fetch display for " + co.getName() + " on " + + quest.getName()); ne.printStackTrace(); } dataIndex++; } if (entry.getValue() < getCurrentStage(quest).customObjectiveCounts.get(countsIndex)) { if (co.canShowCount()) { - display = display.replace("%count%", entry.getValue() + "/" + getCurrentStage(quest).customObjectiveCounts.get(countsIndex)); + display = display.replace("%count%", entry.getValue() + "/" + getCurrentStage(quest) + .customObjectiveCounts.get(countsIndex)); } addUnfinished = true; } else { if (co.canShowCount()) { - display = display.replace("%count%", getCurrentStage(quest).customObjectiveCounts.get(countsIndex) - + "/" + getCurrentStage(quest).customObjectiveCounts.get(countsIndex)); + display = display.replace("%count%", getCurrentStage(quest).customObjectiveCounts + .get(countsIndex) + "/" + getCurrentStage(quest).customObjectiveCounts + .get(countsIndex)); } addFinished = true; } @@ -1082,8 +1113,10 @@ public class Quester { final ItemStack finalBroken = broken; final ItemStack finalToBreak = toBreak; dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (Quester q) -> { - q.getQuestData(quest).blocksBroken.set(getQuestData(quest).blocksBroken.indexOf(finalBroken), newBroken); - q.finishObjective(quest, "breakBlock", m, finalToBreak, null, null, null, null, null, null, null, null); + q.getQuestData(quest).blocksBroken.set(getQuestData(quest).blocksBroken + .indexOf(finalBroken), newBroken); + q.finishObjective(quest, "breakBlock", m, finalToBreak, null, null, null, null, null, null, + null, null); return null; }); } @@ -1147,8 +1180,10 @@ public class Quester { final ItemStack finalDamaged = damaged; final ItemStack finalToDamage = toDamage; dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (Quester q) -> { - q.getQuestData(quest).blocksDamaged.set(getQuestData(quest).blocksDamaged.indexOf(finalDamaged), newDamaged); - q.finishObjective(quest, "damageBlock", m, finalToDamage, null, null, null, null, null, null, null, null); + q.getQuestData(quest).blocksDamaged.set(getQuestData(quest).blocksDamaged + .indexOf(finalDamaged), newDamaged); + q.finishObjective(quest, "damageBlock", m, finalToDamage, null, null, null, null, null, null, + null, null); return null; }); } @@ -1212,8 +1247,10 @@ public class Quester { final ItemStack finalPlaced = placed; final ItemStack finalToPlace = toPlace; dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (Quester q) -> { - q.getQuestData(quest).blocksPlaced.set(getQuestData(quest).blocksPlaced.indexOf(finalPlaced), newplaced); - q.finishObjective(quest, "damageBlock", m, finalToPlace, null, null, null, null, null, null, null, null); + q.getQuestData(quest).blocksPlaced.set(getQuestData(quest).blocksPlaced + .indexOf(finalPlaced), newplaced); + q.finishObjective(quest, "damageBlock", m, finalToPlace, null, null, null, null, null, null, + null, null); return null; }); } @@ -1277,8 +1314,10 @@ public class Quester { final ItemStack finalUsed = used; final ItemStack finalToUse = toUse; dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (Quester q) -> { - q.getQuestData(quest).blocksUsed.set(getQuestData(quest).blocksUsed.indexOf(finalUsed), newUsed); - q.finishObjective(quest, "useBlock", m, finalToUse, null, null, null, null, null, null, null, null); + q.getQuestData(quest).blocksUsed.set(getQuestData(quest).blocksUsed + .indexOf(finalUsed), newUsed); + q.finishObjective(quest, "useBlock", m, finalToUse, null, null, null, null, null, null, null, + null); return null; }); } @@ -1343,7 +1382,8 @@ public class Quester { final ItemStack finalToCut = toCut; dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (Quester q) -> { q.getQuestData(quest).blocksCut.set(getQuestData(quest).blocksCut.indexOf(finalCut), newCut); - q.finishObjective(quest, "cutBlock", m, finalToCut, null, null, null, null, null, null, null, null); + q.finishObjective(quest, "cutBlock", m, finalToCut, null, null, null, null, null, null, null, + null); return null; }); } @@ -1369,24 +1409,30 @@ public class Quester { if (found != null) { int amount = getQuestData(quest).itemsCrafted.get(found); if (getCurrentStage(quest).itemsToCraft.indexOf(found) < 0) { - plugin.getLogger().severe("Index out of bounds while crafting " + found.getType() + " x " + found.getAmount() + " for quest " - + quest.getName() + " with " + i.getType() + " x " + i.getAmount() + " already crafted. Int -amount- reports value of " + - + amount + ". Please report this error on Github!"); - player.sendMessage(ChatColor.RED + "Quests had a problem crafting your item, please contact an administrator!"); + plugin.getLogger().severe("Index out of bounds while crafting " + found.getType() + " x " + + found.getAmount() + " for quest " + + quest.getName() + " with " + i.getType() + " x " + i.getAmount() + + " already crafted. List amount reports value of " + amount + + ". Please report this error on Github!"); + player.sendMessage(ChatColor.RED + + "Quests had a problem crafting your item, please contact an administrator!"); return; } - int req = getCurrentStage(quest).itemsToCraft.get(getCurrentStage(quest).itemsToCraft.indexOf(found)).getAmount(); + int req = getCurrentStage(quest).itemsToCraft.get(getCurrentStage(quest).itemsToCraft.indexOf(found)) + .getAmount(); Material m = i.getType(); if (amount < req) { if ((i.getAmount() + amount) >= req) { getQuestData(quest).itemsCrafted.put(found, req); - finishObjective(quest, "craftItem", new ItemStack(m, 1), found, null, null, null, null, null, null, null, null); + finishObjective(quest, "craftItem", new ItemStack(m, 1), found, null, null, null, null, null, null, + null, null); // Multiplayer final ItemStack finalFound = found; dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (Quester q) -> { q.getQuestData(quest).itemsCrafted.put(finalFound, req); - q.finishObjective(quest, "craftItem", new ItemStack(m, 1), finalFound, null, null, null, null, null, null, null, null); + q.finishObjective(quest, "craftItem", new ItemStack(m, 1), finalFound, null, null, null, null, + null, null, null, null); return null; }); } else { @@ -1414,24 +1460,29 @@ public class Quester { if (found != null) { int amount = getQuestData(quest).itemsSmelted.get(found); if (getCurrentStage(quest).itemsToSmelt.indexOf(found) < 0) { - plugin.getLogger().severe("Index out of bounds while smelting " + found.getType() + " x " + found.getAmount() + " for quest " - + quest.getName() + " with " + i.getType() + " x " + i.getAmount() + " already smelted. Int -amount- reports value of " + - + amount + ". Please report this error on Github!"); - player.sendMessage(ChatColor.RED + "Quests had a problem smelting your item, please contact an administrator!"); + plugin.getLogger().severe("Index out of bounds while smelting " + found.getType() + " x " + + found.getAmount() + " for quest " + quest.getName() + " with " + i.getType() + " x " + + i.getAmount() + " already smelted. List amount reports value of " + amount + + ". Please report this error on Github!"); + player.sendMessage(ChatColor.RED + + "Quests had a problem smelting your item, please contact an administrator!"); return; } - int req = getCurrentStage(quest).itemsToSmelt.get(getCurrentStage(quest).itemsToSmelt.indexOf(found)).getAmount(); + int req = getCurrentStage(quest).itemsToSmelt.get(getCurrentStage(quest).itemsToSmelt.indexOf(found)) + .getAmount(); Material m = i.getType(); if (amount < req) { if ((i.getAmount() + amount) >= req) { getQuestData(quest).itemsSmelted.put(found, req); - finishObjective(quest, "smeltItem", new ItemStack(m, 1), found, null, null, null, null, null, null, null, null); + finishObjective(quest, "smeltItem", new ItemStack(m, 1), found, null, null, null, null, null, null, + null, null); // Multiplayer final ItemStack finalFound = found; dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (Quester q) -> { q.getQuestData(quest).itemsSmelted.put(finalFound, req); - q.finishObjective(quest, "smeltItem", new ItemStack(m, 1), finalFound, null, null, null, null, null, null, null, null); + q.finishObjective(quest, "smeltItem", new ItemStack(m, 1), finalFound, null, null, null, null, + null, null, null, null); return null; }); } else { @@ -1451,7 +1502,8 @@ public class Quester { public void enchantItem(Quest quest, Enchantment e, Material m) { for (Entry, Integer> entry : getQuestData(quest).itemsEnchanted.entrySet()) { if (entry.getKey().containsKey(e) && entry.getKey().containsValue(m)) { - for (Entry, Integer> entry2 : getCurrentStage(quest).itemsToEnchant.entrySet()) { + for (Entry, Integer> entry2 : getCurrentStage(quest).itemsToEnchant + .entrySet()) { if (entry2.getKey().containsKey(e) && entry2.getKey().containsValue(m)) { if (entry.getValue() < entry2.getValue()) { Integer num = entry.getValue() + 1; @@ -1459,12 +1511,14 @@ public class Quester { if (num.equals(entry2.getValue())) { final ItemStack finalToEnchant = new ItemStack(m, entry.getValue()); - finishObjective(quest, "enchantItem", new ItemStack(m, 1), finalToEnchant, e, null, null, null, null, null, null, null); + finishObjective(quest, "enchantItem", new ItemStack(m, 1), finalToEnchant, e, null, + null, null, null, null, null, null); // Multiplayer dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (Quester q) -> { q.getQuestData(quest).itemsEnchanted.put(entry.getKey(), num); - q.finishObjective(quest, "enchantItem", new ItemStack(m, 1), finalToEnchant, null, null, null, null, null, null, null, null); + q.finishObjective(quest, "enchantItem", new ItemStack(m, 1), finalToEnchant, null, + null, null, null, null, null, null, null); return null; }); } @@ -1495,24 +1549,29 @@ public class Quester { if (found != null) { int amount = getQuestData(quest).itemsBrewed.get(found); if (getCurrentStage(quest).itemsToBrew.indexOf(found) < 0) { - plugin.getLogger().severe("Index out of bounds while brewing " + found.getType() + " x " + found.getAmount() + " for quest " - + quest.getName() + " with " + i.getType() + " x " + i.getAmount() + " already smelted. Int -amount- reports value of " + - + amount + ". Please report this error on Github!"); - player.sendMessage(ChatColor.RED + "Quests had a problem brewing your item, please contact an administrator!"); + plugin.getLogger().severe("Index out of bounds while brewing " + found.getType() + " x " + + found.getAmount() + " for quest " + quest.getName() + " with " + i.getType() + " x " + + i.getAmount() + " already smelted. List amount reports value of " + amount + + ". Please report this error on Github!"); + player.sendMessage(ChatColor.RED + + "Quests had a problem brewing your item, please contact an administrator!"); return; } - int req = getCurrentStage(quest).itemsToBrew.get(getCurrentStage(quest).itemsToBrew.indexOf(found)).getAmount(); + int req = getCurrentStage(quest).itemsToBrew.get(getCurrentStage(quest).itemsToBrew.indexOf(found)) + .getAmount(); Material m = i.getType(); if (amount < req) { if ((i.getAmount() + amount) >= req) { getQuestData(quest).itemsBrewed.put(found, req); - finishObjective(quest, "brewItem", new ItemStack(m, 1), found, null, null, null, null, null, null, null, null); + finishObjective(quest, "brewItem", new ItemStack(m, 1), found, null, null, null, null, null, null, + null, null); // Multiplayer final ItemStack finalFound = found; dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (Quester q) -> { q.getQuestData(quest).itemsBrewed.put(finalFound, req); - q.finishObjective(quest, "brewItem", new ItemStack(m, 1), finalFound, null, null, null, null, null, null, null, null); + q.finishObjective(quest, "brewItem", new ItemStack(m, 1), finalFound, null, null, null, null, + null, null, null, null); return null; }); } else { @@ -1533,12 +1592,14 @@ public class Quester { getQuestData(quest).setFishCaught(getQuestData(quest).getFishCaught() + 1); if (getQuestData(quest).getFishCaught() == fishToCatch) { - finishObjective(quest, "catchFish", new ItemStack(Material.AIR, 1), new ItemStack(Material.AIR, fishToCatch), null, null, null, null, null, null, null, null); + finishObjective(quest, "catchFish", new ItemStack(Material.AIR, 1), + new ItemStack(Material.AIR, fishToCatch), null, null, null, null, null, null, null, null); // Multiplayer dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (Quester q) -> { q.getQuestData(quest).setFishCaught(fishToCatch); - q.finishObjective(quest, "catchFish", new ItemStack(Material.AIR, 1), new ItemStack(Material.AIR, fishToCatch), null, null, null, null, null, null, null, null); + q.finishObjective(quest, "catchFish", new ItemStack(Material.AIR, 1), + new ItemStack(Material.AIR, fishToCatch), null, null, null, null, null, null, null, null); return null; }); } @@ -1572,13 +1633,16 @@ public class Quester { return; } // Radius check, it's a "circle", not cuboid - if ((killedLocation.getX() < (locationToKillWithin.getX() + radius) && killedLocation.getX() > (locationToKillWithin.getX() - radius)) == false) { + if ((killedLocation.getX() < (locationToKillWithin.getX() + radius) && killedLocation.getX() + > (locationToKillWithin.getX() - radius)) == false) { return; } - if ((killedLocation.getZ() < (locationToKillWithin.getZ() + radius) && killedLocation.getZ() > (locationToKillWithin.getZ() - radius)) == false) { + if ((killedLocation.getZ() < (locationToKillWithin.getZ() + radius) && killedLocation.getZ() + > (locationToKillWithin.getZ() - radius)) == false) { return; } - if ((killedLocation.getY() < (locationToKillWithin.getY() + radius) && killedLocation.getY() > (locationToKillWithin.getY() - radius)) == false) { + if ((killedLocation.getY() < (locationToKillWithin.getY() + radius) && killedLocation.getY() + > (locationToKillWithin.getY() - radius)) == false) { return; } } @@ -1587,13 +1651,15 @@ public class Quester { questData.mobNumKilled.set(indexOfMobKilled, newNumberOfSpecificMobKilled); if (newNumberOfSpecificMobKilled == numberOfSpecificMobNeedsToBeKilledInCurrentStage) { finishObjective(quest, "killMob", new ItemStack(Material.AIR, 1), - new ItemStack(Material.AIR, numberOfSpecificMobNeedsToBeKilledInCurrentStage), null, e, null, null, null, null, null, null); + new ItemStack(Material.AIR, numberOfSpecificMobNeedsToBeKilledInCurrentStage), null, e, null, + null, null, null, null, null); // Multiplayer dispatchMultiplayerObjectives(quest, currentStage, (Quester q) -> { q.getQuestData(quest).mobNumKilled.set(indexOfMobKilled, newNumberOfSpecificMobKilled); q.finishObjective(quest, "killMob", new ItemStack(Material.AIR, 1), - new ItemStack(Material.AIR, numberOfSpecificMobNeedsToBeKilledInCurrentStage), null, e, null, null, null, null, null, null); + new ItemStack(Material.AIR, numberOfSpecificMobNeedsToBeKilledInCurrentStage), null, e, + null, null, null, null, null, null); return null; }); } @@ -1611,12 +1677,14 @@ public class Quester { if (getQuestData(quest).getPlayersKilled() < playersToKill) { getQuestData(quest).setPlayersKilled(getQuestData(quest).getPlayersKilled() + 1); if (getQuestData(quest).getPlayersKilled() == playersToKill) { - finishObjective(quest, "killPlayer", new ItemStack(Material.AIR, 1), new ItemStack(Material.AIR, playersToKill), null, null, null, null, null, null, null, null); + finishObjective(quest, "killPlayer", new ItemStack(Material.AIR, 1), + new ItemStack(Material.AIR, playersToKill), null, null, null, null, null, null, null, null); // Multiplayer dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (Quester q) -> { q.getQuestData(quest).setPlayersKilled(getQuestData(quest).getPlayersKilled()); - q.finishObjective(quest, "killPlayer", new ItemStack(Material.AIR, 1), new ItemStack(Material.AIR, playersToKill), null, null, null, null, null, null, null, null); + q.finishObjective(quest, "killPlayer", new ItemStack(Material.AIR, 1), + new ItemStack(Material.AIR, playersToKill), null, null, null, null, null, null, null, null); return null; }); } @@ -1656,34 +1724,39 @@ public class Quester { if (amount < req) { int index = player.getInventory().first(i); if (index == -1) { - Bukkit.getLogger().warning("Uh oh! " + i.getType().name() + " suddenly disappeared from the inventory of " + player.getName() - + " when delivering for quest " + quest.getName()); + Bukkit.getLogger().warning("Uh oh! " + i.getType().name() + + " suddenly disappeared from the inventory of " + player.getName() + + " when delivering for quest " + quest.getName()); return; } if ((i.getAmount() + amount) >= req) { getQuestData(quest).itemsDelivered.put(found, req); if ((i.getAmount() + amount) >= req) { - i.setAmount(i.getAmount() - (req - amount)); // Take away the remaining amount needed to be delivered + i.setAmount(i.getAmount() - (req - amount)); // Take away remaining amount to be delivered player.getInventory().setItem(index, i); } else { player.getInventory().setItem(index, null); } player.updateInventory(); - finishObjective(quest, "deliverItem", new ItemStack(m, 1), found, null, null, null, null, null, null, null, null); + finishObjective(quest, "deliverItem", new ItemStack(m, 1), found, null, null, null, null, null, + null, null, null); // Multiplayer dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (Quester q) -> { q.getQuestData(quest).itemsDelivered.put(found, req); - q.finishObjective(quest, "deliverItem", new ItemStack(m, 1), found, null, null, null, null, null, null, null, null); + q.finishObjective(quest, "deliverItem", new ItemStack(m, 1), found, null, null, null, null, + null, null, null, null); return null; }); } else { getQuestData(quest).itemsDelivered.put(found, (amount + i.getAmount())); player.getInventory().setItem(index, null); player.updateInventory(); - String[] message = Quests.parseStringWithPossibleLineBreaks(getCurrentStage(quest).deliverMessages.get(new Random().nextInt( - getCurrentStage(quest).deliverMessages.size())), plugin.getDependencies().getCitizens().getNPCRegistry().getById( - getCurrentStage(quest).itemDeliveryTargets.get(getCurrentStage(quest).itemsToDeliver.indexOf(found)))); + String[] message = Quests.parseStringWithPossibleLineBreaks(getCurrentStage(quest) + .deliverMessages.get(new Random().nextInt(getCurrentStage(quest).deliverMessages + .size())), plugin.getDependencies().getCitizens().getNPCRegistry() + .getById(getCurrentStage(quest).itemDeliveryTargets.get(getCurrentStage(quest) + .itemsToDeliver.indexOf(found)))); player.sendMessage(message); } } @@ -1710,41 +1783,46 @@ public class Quester { if (found != null) { int amount = getQuestData(quest).itemsDelivered.get(found); if (getCurrentStage(quest).itemsToDeliver.indexOf(found) < 0) { - plugin.getLogger().severe("Index out of bounds while delivering " + found.getType() + " x " + found.getAmount() + " for quest " - + quest.getName() + " with " + i.getType() + " x " + i.getAmount() + " already delivered. Int -amount- reports value of " + - + amount + ". Please report this error on Github!"); + plugin.getLogger().severe("Index out of bounds while delivering " + found.getType() + " x " + + found.getAmount() + " for quest " + quest.getName() + " with " + i.getType() + " x " + + i.getAmount() + " already delivered. List amount reports value of " + amount + + ". Please report this error on Github!"); player.sendMessage("Quests had a problem delivering your item, please contact an administrator!"); return; } - int req = getCurrentStage(quest).itemsToDeliver.get(getCurrentStage(quest).itemsToDeliver.indexOf(found)).getAmount(); + int req = getCurrentStage(quest).itemsToDeliver.get(getCurrentStage(quest).itemsToDeliver.indexOf(found)) + .getAmount(); Material m = i.getType(); if (amount < req) { if ((i.getAmount() + amount) > req) { getQuestData(quest).itemsDelivered.put(found, req); if ((i.getAmount() + amount) > req) { int index = player.getInventory().first(i); - i.setAmount(i.getAmount() - (req - amount)); // Take away the remaining amount needed to be delivered + i.setAmount(i.getAmount() - (req - amount)); // Take away remaining amount to be delivered player.getInventory().setItem(index, i); } else { player.getInventory().setItem(player.getInventory().first(i), null); } player.updateInventory(); - finishObjective(quest, "deliverItem", new ItemStack(m, 1), found, null, null, null, null, null, null, null, null); + finishObjective(quest, "deliverItem", new ItemStack(m, 1), found, null, null, null, null, null, + null, null, null); // Multiplayer final ItemStack finalFound = found; dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (Quester q) -> { q.getQuestData(quest).itemsDelivered.put(finalFound, req); - q.finishObjective(quest, "deliverItem", new ItemStack(m, 1), finalFound, null, null, null, null, null, null, null, null); + q.finishObjective(quest, "deliverItem", new ItemStack(m, 1), finalFound, null, null, null, + null, null, null, null, null); return null; }); } else { getQuestData(quest).itemsDelivered.put(found, (amount + i.getAmount())); player.getInventory().setItem(player.getInventory().first(i), null); player.updateInventory(); - String[] message = Quests.parseStringWithPossibleLineBreaks(getCurrentStage(quest).deliverMessages.get(new Random().nextInt( - getCurrentStage(quest).deliverMessages.size())), plugin.getDependencies().getCitizens().getNPCRegistry().getById( - getCurrentStage(quest).itemDeliveryTargets.get(getCurrentStage(quest).itemsToDeliver.indexOf(found)))); + String[] message = Quests.parseStringWithPossibleLineBreaks(getCurrentStage(quest).deliverMessages + .get(new Random().nextInt(getCurrentStage(quest).deliverMessages.size())), plugin + .getDependencies().getCitizens().getNPCRegistry().getById(getCurrentStage(quest) + .itemDeliveryTargets.get(getCurrentStage(quest).itemsToDeliver.indexOf(found)))); player.sendMessage(message); } } @@ -1762,12 +1840,14 @@ public class Quester { Boolean b = getQuestData(quest).citizensInteracted.get(n.getId()); if (b != null && !b) { getQuestData(quest).citizensInteracted.put(n.getId(), true); - finishObjective(quest, "talkToNPC", new ItemStack(Material.AIR, 1), new ItemStack(Material.AIR, 1), null, null, null, n, null, null, null, null); + finishObjective(quest, "talkToNPC", new ItemStack(Material.AIR, 1), new ItemStack(Material.AIR, 1), + null, null, null, n, null, null, null, null); // Multiplayer dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (Quester q) -> { q.getQuestData(quest).citizensInteracted.put(n.getId(), true); - q.finishObjective(quest, "talkToNPC", new ItemStack(Material.AIR, 1), new ItemStack(Material.AIR, 1), null, null, null, n, null, null, null, null); + q.finishObjective(quest, "talkToNPC", new ItemStack(Material.AIR, 1), + new ItemStack(Material.AIR, 1), null, null, null, n, null, null, null, null); return null; }); } @@ -1787,12 +1867,15 @@ public class Quester { if (getQuestData(quest).citizenNumKilled.get(index) < npcsToKill) { getQuestData(quest).citizenNumKilled.set(index, getQuestData(quest).citizenNumKilled.get(index) + 1); if (getQuestData(quest).citizenNumKilled.get(index).equals(npcsToKill)) { - finishObjective(quest, "killNPC", new ItemStack(Material.AIR, 1), new ItemStack(Material.AIR, npcsToKill), null, null, null, n, null, null, null, null); + finishObjective(quest, "killNPC", new ItemStack(Material.AIR, 1), + new ItemStack(Material.AIR, npcsToKill), null, null, null, n, null, null, null, null); // Multiplayer dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (Quester q) -> { - q.getQuestData(quest).citizenNumKilled.set(index, getQuestData(quest).citizenNumKilled.get(index)); - q.finishObjective(quest, "killNPC", new ItemStack(Material.AIR, 1), new ItemStack(Material.AIR, npcsToKill), null, null, null, n, null, null, null, null); + q.getQuestData(quest).citizenNumKilled.set(index, getQuestData(quest).citizenNumKilled + .get(index)); + q.finishObjective(quest, "killNPC", new ItemStack(Material.AIR, 1), + new ItemStack(Material.AIR, npcsToKill), null, null, null, n, null, null, null, null); return null; }); } @@ -1823,7 +1906,8 @@ public class Quester { double radius = getQuestData(quest).radiiToReachWithin.get(index); if (l.getX() < (locationToReach.getX() + radius) && l.getX() > (locationToReach.getX() - radius)) { if (l.getZ() < (locationToReach.getZ() + radius) && l.getZ() > (locationToReach.getZ() - radius)) { - if (l.getY() < (locationToReach.getY() + radius) && l.getY() > (locationToReach.getY() - radius)) { + if (l.getY() < (locationToReach.getY() + radius) && l.getY() + > (locationToReach.getY() - radius)) { if (l.getWorld().getName().equals(locationToReach.getWorld().getName())) { // TODO - Find proper cause of Github issues #646 and #825 if (index >= getQuestData(quest).hasReached.size()) { @@ -1831,7 +1915,9 @@ public class Quester { } else { getQuestData(quest).hasReached.set(index, true); } - finishObjective(quest, "reachLocation", new ItemStack(Material.AIR, 1), new ItemStack(Material.AIR, 1), null, null, null, null, location, null, null, null); + finishObjective(quest, "reachLocation", new ItemStack(Material.AIR, 1), + new ItemStack(Material.AIR, 1), null, null, null, null, location, null, null, + null); // Multiplayer final int finalIndex = index; @@ -1841,7 +1927,9 @@ public class Quester { } else { q.getQuestData(quest).hasReached.set(finalIndex, true); } - q.finishObjective(quest, "reachLocation", new ItemStack(Material.AIR, 1), new ItemStack(Material.AIR, 1), null, null, null, null, location, null, null, null); + q.finishObjective(quest, "reachLocation", new ItemStack(Material.AIR, 1), + new ItemStack(Material.AIR, 1), null, null, null, null, location, null, + null, null); return null; }); } @@ -1851,7 +1939,7 @@ public class Quester { index++; } catch (IndexOutOfBoundsException e) { - plugin.getLogger().severe("An error has occurred with Quests. Please report on Github. Include the info below"); + plugin.getLogger().severe("An error has occurred with Quests. Please report on Github with info below"); plugin.getLogger().warning("index = " + index); plugin.getLogger().warning("currentLocation = " + location.toString()); plugin.getLogger().warning("locationsReached = " + getQuestData(quest).locationsReached.size()); @@ -1872,12 +1960,14 @@ public class Quester { getQuestData(quest).mobsTamed.put(entity, (getQuestData(quest).mobsTamed.get(entity) + 1)); final int mobsToTame = getCurrentStage(quest).mobsToTame.get(entity); if (getQuestData(quest).mobsTamed.get(entity).equals(mobsToTame)) { - finishObjective(quest, "tameMob", new ItemStack(Material.AIR, 1), new ItemStack(Material.AIR, mobsToTame), null, entity, null, null, null, null, null, null); + finishObjective(quest, "tameMob", new ItemStack(Material.AIR, 1), + new ItemStack(Material.AIR, mobsToTame), null, entity, null, null, null, null, null, null); // Multiplayer dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (Quester q) -> { q.getQuestData(quest).mobsTamed.put(entity, getQuestData(quest).mobsTamed.get(entity)); - q.finishObjective(quest, "tameMob", new ItemStack(Material.AIR, 1), new ItemStack(Material.AIR, mobsToTame), null, entity, null, null, null, null, null, null); + q.finishObjective(quest, "tameMob", new ItemStack(Material.AIR, 1), + new ItemStack(Material.AIR, mobsToTame), null, entity, null, null, null, null, null, null); return null; }); } @@ -1895,12 +1985,14 @@ public class Quester { getQuestData(quest).sheepSheared.put(color, (getQuestData(quest).sheepSheared.get(color) + 1)); final int sheepToShear = getCurrentStage(quest).sheepToShear.get(color); if (getQuestData(quest).sheepSheared.get(color).equals(sheepToShear)) { - finishObjective(quest, "shearSheep", new ItemStack(Material.AIR, 1), new ItemStack(Material.AIR, sheepToShear), null, null, null, null, null, color, null, null); + finishObjective(quest, "shearSheep", new ItemStack(Material.AIR, 1), + new ItemStack(Material.AIR, sheepToShear), null, null, null, null, null, color, null, null); // Multiplayer dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (Quester q) -> { q.getQuestData(quest).sheepSheared.put(color, getQuestData(quest).sheepSheared.get(color)); - q.finishObjective(quest, "shearSheep", new ItemStack(Material.AIR, 1), new ItemStack(Material.AIR, sheepToShear), null, null, null, null, null, color, null, null); + q.finishObjective(quest, "shearSheep", new ItemStack(Material.AIR, 1), + new ItemStack(Material.AIR, sheepToShear), null, null, null, null, null, color, null, null); return null; }); } @@ -1920,16 +2012,19 @@ public class Quester { for (String pass : passes) { if (pass.equalsIgnoreCase(evt.getMessage())) { evt.setCancelled(true); - String display = getCurrentStage(quest).passwordDisplays.get(getCurrentStage(quest).passwordPhrases.indexOf(passes)); + String display = getCurrentStage(quest).passwordDisplays.get(getCurrentStage(quest).passwordPhrases + .indexOf(passes)); getQuestData(quest).passwordsSaid.put(display, true); done = true; plugin.getServer().getScheduler().runTask(plugin, () -> { - finishObjective(quest, "password", new ItemStack(Material.AIR, 1), new ItemStack(Material.AIR, 1), null, null, null, null, null, null, display, null); + finishObjective(quest, "password", new ItemStack(Material.AIR, 1), + new ItemStack(Material.AIR, 1), null, null, null, null, null, null, display, null); // Multiplayer dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (Quester q) -> { q.getQuestData(quest).passwordsSaid.put(display, true); - q.finishObjective(quest, "password", new ItemStack(Material.AIR, 1), new ItemStack(Material.AIR, 1), null, null, null, null, null, null, display, null); + q.finishObjective(quest, "password", new ItemStack(Material.AIR, 1), + new ItemStack(Material.AIR, 1), null, null, null, null, null, null, display, null); return null; }); }); @@ -1971,11 +2066,13 @@ public class Quester { * See CustomObjective class */ @SuppressWarnings("deprecation") - public void finishObjective(Quest quest, String objective, ItemStack increment, ItemStack goal, Enchantment enchantment, - EntityType mob, String extra, NPC npc, Location location, DyeColor color, String pass, CustomObjective co) { + public void finishObjective(Quest quest, String objective, ItemStack increment, ItemStack goal, + Enchantment enchantment, EntityType mob, String extra, NPC npc, Location location, DyeColor color, + String pass, CustomObjective co) { Player p = getPlayer(); if (getCurrentStage(quest).objectiveOverride != null) { - String message = ChatColor.GREEN + "(" + Lang.get(p, "completed") + ") " + getCurrentStage(quest).objectiveOverride; + String message = ChatColor.GREEN + "(" + Lang.get(p, "completed") + ") " + getCurrentStage(quest) + .objectiveOverride; p.sendMessage(message); } else if (objective.equalsIgnoreCase("password")) { String message = ChatColor.GREEN + "(" + Lang.get(p, "completed") + ") " + pass; @@ -1983,15 +2080,18 @@ public class Quester { } else if (objective.equalsIgnoreCase("breakBlock")) { String message = ChatColor.GREEN + "(" + Lang.get(p, "completed") + ") " + Lang.get(p, "break") + " "; message = message + " " + goal.getAmount() + "/" + goal.getAmount(); - if (plugin.getSettings().canTranslateItems() && !increment.hasItemMeta() && !increment.getItemMeta().hasDisplayName()) { + if (plugin.getSettings().canTranslateItems() && !increment.hasItemMeta() + && !increment.getItemMeta().hasDisplayName()) { plugin.getLocaleQuery().sendMessage(p, message, increment.getType(), increment.getDurability(), null); } else { p.sendMessage(message.replace("", ItemUtil.getName(increment))); } } else if (objective.equalsIgnoreCase("damageBlock")) { - String message = ChatColor.GREEN + "(" + Lang.get(p, "completed") + ") " + Lang.get(p, "damage") + " "; + String message = ChatColor.GREEN + "(" + Lang.get(p, "completed") + ") " + Lang.get(p, "damage") + + " "; message = message + " " + goal.getAmount() + "/" + goal.getAmount(); - if (plugin.getSettings().canTranslateItems() && !increment.hasItemMeta() && !increment.getItemMeta().hasDisplayName()) { + if (plugin.getSettings().canTranslateItems() && !increment.hasItemMeta() + && !increment.getItemMeta().hasDisplayName()) { plugin.getLocaleQuery().sendMessage(p, message, increment.getType(), increment.getDurability(), null); } else { p.sendMessage(message.replace("", ItemUtil.getName(increment))); @@ -1999,7 +2099,8 @@ public class Quester { } else if (objective.equalsIgnoreCase("placeBlock")) { String message = ChatColor.GREEN + "(" + Lang.get(p, "completed") + ") " + Lang.get(p, "place") + " "; message = message + " " + goal.getAmount() + "/" + goal.getAmount(); - if (plugin.getSettings().canTranslateItems() && !increment.hasItemMeta() && !increment.getItemMeta().hasDisplayName()) { + if (plugin.getSettings().canTranslateItems() && !increment.hasItemMeta() + && !increment.getItemMeta().hasDisplayName()) { plugin.getLocaleQuery().sendMessage(p, message, increment.getType(), increment.getDurability(), null); } else { p.sendMessage(message.replace("", ItemUtil.getName(increment))); @@ -2007,7 +2108,8 @@ public class Quester { } else if (objective.equalsIgnoreCase("useBlock")) { String message = ChatColor.GREEN + "(" + Lang.get(p, "completed") + ") " + Lang.get(p, "use") + " "; message = message + " " + goal.getAmount() + "/" + goal.getAmount(); - if (plugin.getSettings().canTranslateItems() && !increment.hasItemMeta() && !increment.getItemMeta().hasDisplayName()) { + if (plugin.getSettings().canTranslateItems() && !increment.hasItemMeta() + && !increment.getItemMeta().hasDisplayName()) { plugin.getLocaleQuery().sendMessage(p, message, increment.getType(), increment.getDurability(), null); } else { p.sendMessage(message.replace("", ItemUtil.getName(increment))); @@ -2015,7 +2117,8 @@ public class Quester { } else if (objective.equalsIgnoreCase("cutBlock")) { String message = ChatColor.GREEN + "(" + Lang.get(p, "completed") + ") " + Lang.get(p, "cut") + " "; message = message + " " + goal.getAmount() + "/" + goal.getAmount(); - if (plugin.getSettings().canTranslateItems() && !increment.hasItemMeta() && !increment.getItemMeta().hasDisplayName()) { + if (plugin.getSettings().canTranslateItems() && !increment.hasItemMeta() + && !increment.getItemMeta().hasDisplayName()) { plugin.getLocaleQuery().sendMessage(p, message, increment.getType(), increment.getDurability(), null); } else { p.sendMessage(message.replace("", ItemUtil.getName(increment))); @@ -2024,7 +2127,8 @@ public class Quester { ItemStack is = getCurrentStage(quest).itemsToCraft.get(getCurrentStage(quest).itemsToCraft.indexOf(goal)); String message = ChatColor.GREEN + "(" + Lang.get(p, "completed") + ") " + Lang.get(p, "craft") + " " + is.getAmount() + "/" + is.getAmount(); - if (plugin.getSettings().canTranslateItems() && !increment.hasItemMeta() && !increment.getItemMeta().hasDisplayName()) { + if (plugin.getSettings().canTranslateItems() && !increment.hasItemMeta() + && !increment.getItemMeta().hasDisplayName()) { plugin.getLocaleQuery().sendMessage(p, message, goal.getType(), goal.getDurability(), null); } else { p.sendMessage(message.replace("", ItemUtil.getName(is))); @@ -2033,7 +2137,8 @@ public class Quester { ItemStack is = getCurrentStage(quest).itemsToSmelt.get(getCurrentStage(quest).itemsToSmelt.indexOf(goal)); String message = ChatColor.GREEN + "(" + Lang.get(p, "completed") + ") " + Lang.get(p, "smelt") + " " + is.getAmount() + "/" + is.getAmount(); - if (plugin.getSettings().canTranslateItems() && !increment.hasItemMeta() && !increment.getItemMeta().hasDisplayName()) { + if (plugin.getSettings().canTranslateItems() && !increment.hasItemMeta() + && !increment.getItemMeta().hasDisplayName()) { plugin.getLocaleQuery().sendMessage(p, message, goal.getType(), goal.getDurability(), null); } else { p.sendMessage(message.replace("", ItemUtil.getName(is))); @@ -2049,7 +2154,8 @@ public class Quester { break; } } - if (plugin.getSettings().canTranslateItems() && !increment.hasItemMeta() && !increment.getItemMeta().hasDisplayName()) { + if (plugin.getSettings().canTranslateItems() && !increment.hasItemMeta() + && !increment.getItemMeta().hasDisplayName()) { plugin.getLocaleQuery().sendMessage(p, message, increment.getType(), increment.getDurability(), ench); } else { p.sendMessage(message.replace("", ItemUtil.getName(increment)) @@ -2059,17 +2165,21 @@ public class Quester { ItemStack is = getCurrentStage(quest).itemsToBrew.get(getCurrentStage(quest).itemsToBrew.indexOf(goal)); String message = ChatColor.GREEN + "(" + Lang.get(p, "completed") + ") " + Lang.get(p, "brew") + " " + is.getAmount() + "/" + is.getAmount(); - if (plugin.getSettings().canTranslateItems() && !increment.hasItemMeta() && !increment.getItemMeta().hasDisplayName()) { + if (plugin.getSettings().canTranslateItems() && !increment.hasItemMeta() + && !increment.getItemMeta().hasDisplayName()) { plugin.getLocaleQuery().sendMessage(p, message, goal.getType(), goal.getDurability(), null); } else { p.sendMessage(message.replace("", ItemUtil.getName(is))); } } else if (objective.equalsIgnoreCase("deliverItem")) { String obj = Lang.get(p, "deliver"); - obj = obj.replace("", plugin.getNPCName(getCurrentStage(quest).itemDeliveryTargets.get(getCurrentStage(quest).itemsToDeliver.indexOf(goal)))); + obj = obj.replace("", plugin.getNPCName(getCurrentStage(quest).itemDeliveryTargets + .get(getCurrentStage(quest).itemsToDeliver.indexOf(goal)))); String message = ChatColor.GREEN + "(" + Lang.get(p, "completed") + ") " + obj; - ItemStack is = getCurrentStage(quest).itemsToDeliver.get(getCurrentStage(quest).itemsToDeliver.indexOf(goal)); - if (plugin.getSettings().canTranslateItems() && !increment.hasItemMeta() && !increment.getItemMeta().hasDisplayName()) { + ItemStack is = getCurrentStage(quest).itemsToDeliver.get(getCurrentStage(quest).itemsToDeliver + .indexOf(goal)); + if (plugin.getSettings().canTranslateItems() && !increment.hasItemMeta() + && !increment.getItemMeta().hasDisplayName()) { plugin.getLocaleQuery().sendMessage(p, message, is.getType(), is.getDurability(), null); } else { p.sendMessage(message.replace("", ItemUtil.getName(is))); @@ -2096,7 +2206,8 @@ public class Quester { String message = ChatColor.GREEN + "(" + Lang.get(p, "completed") + ") " + obj; p.sendMessage(message); } else if (objective.equalsIgnoreCase("killNPC")) { - String message = ChatColor.GREEN + "(" + Lang.get(p, "completed") + ") " + Lang.get(p, "kill") + " " + npc.getName(); + String message = ChatColor.GREEN + "(" + Lang.get(p, "completed") + ") " + Lang.get(p, "kill") + " " + + npc.getName(); message = message + " " + goal.getAmount() + "/" + goal.getAmount(); p.sendMessage(message); } else if (objective.equalsIgnoreCase("tameMob")) { @@ -2115,7 +2226,8 @@ public class Quester { p.sendMessage(message); } else if (objective.equalsIgnoreCase("reachLocation")) { String obj = Lang.get(p, "goTo"); - obj = obj.replace("", getCurrentStage(quest).locationNames.get(getCurrentStage(quest).locationsToReach.indexOf(location))); + obj = obj.replace("", getCurrentStage(quest).locationNames.get(getCurrentStage(quest) + .locationsToReach.indexOf(location))); String message = ChatColor.GREEN + "(" + Lang.get(p, "completed") + ") " + obj; p.sendMessage(message); } else if (co != null) { @@ -2128,11 +2240,13 @@ public class Quester { } } List> sub = new LinkedList<>(); - sub.addAll(getCurrentStage(quest).customObjectiveData.subList(index, getCurrentStage(quest).customObjectiveData.size())); + sub.addAll(getCurrentStage(quest).customObjectiveData.subList(index, getCurrentStage(quest) + .customObjectiveData.size())); List> end = new LinkedList>(sub); sub.clear(); // since sub is backed by end, this removes all sub-list items from end for (Entry datamap : end) { - message = message.replace("%" + (String.valueOf(datamap.getKey())) + "%", String.valueOf(datamap.getValue())); + message = message.replace("%" + (String.valueOf(datamap.getKey())) + "%", String.valueOf(datamap + .getValue())); } if (co.canShowCount()) { @@ -2251,7 +2365,8 @@ public class Quester { data.mobsKilled.add(e); data.mobNumKilled.add(0); if (quest.getStage(stage).locationsToKillWithin.isEmpty() == false) { - data.locationsToKillWithin.add(quest.getStage(stage).locationsToKillWithin.get(data.mobsKilled.indexOf(e))); + data.locationsToKillWithin.add(quest.getStage(stage).locationsToKillWithin.get(data.mobsKilled + .indexOf(e))); } if (quest.getStage(stage).radiiToKillWithin.isEmpty() == false) { data.radiiToKillWithin.add(quest.getStage(stage).radiiToKillWithin.get(data.mobsKilled.indexOf(e))); @@ -2280,7 +2395,8 @@ public class Quester { for (Location l : quest.getStage(stage).locationsToReach) { data.locationsReached.add(l); data.hasReached.add(false); - data.radiiToReachWithin.add(quest.getStage(stage).radiiToReachWithin.get(data.locationsReached.indexOf(l))); + data.radiiToReachWithin.add(quest.getStage(stage).radiiToReachWithin.get(data.locationsReached + .indexOf(l))); } } if (quest.getStage(stage).mobsToTame.isEmpty() == false) { @@ -2730,7 +2846,8 @@ public class Quester { stage = getCurrentStage(quest); if (stage == null) { quest.completeQuest(this); - plugin.getLogger().severe("[Quests] Invalid stage number for player: \"" + id + "\" on Quest \"" + quest.getName() + "\". Quest ended."); + plugin.getLogger().severe("[Quests] Invalid stage number for player: \"" + id + "\" on Quest \"" + + quest.getName() + "\". Quest ended."); continue; } addEmptiesFor(quest, currentQuests.get(quest)); @@ -2835,7 +2952,8 @@ public class Quester { List craftAmounts = questSec.getIntegerList("item-craft-amounts"); for (int i = 0; i < craftAmounts.size(); i++) { if (i < getCurrentStage(quest).itemsToCraft.size()) { - getQuestData(quest).itemsCrafted.put(getCurrentStage(quest).itemsToCraft.get(i), craftAmounts.get(i)); + getQuestData(quest).itemsCrafted.put(getCurrentStage(quest).itemsToCraft + .get(i), craftAmounts.get(i)); } } } @@ -2843,7 +2961,8 @@ public class Quester { List smeltAmounts = questSec.getIntegerList("item-smelt-amounts"); for (int i = 0; i < smeltAmounts.size(); i++) { if (i < getCurrentStage(quest).itemsToSmelt.size()) { - getQuestData(quest).itemsSmelted.put(getCurrentStage(quest).itemsToSmelt.get(i), smeltAmounts.get(i)); + getQuestData(quest).itemsSmelted.put(getCurrentStage(quest).itemsToSmelt + .get(i), smeltAmounts.get(i)); } } } @@ -2869,7 +2988,8 @@ public class Quester { List brewAmounts = questSec.getIntegerList("item-brew-amounts"); for (int i = 0; i < brewAmounts.size(); i++) { if (i < getCurrentStage(quest).itemsToBrew.size()) { - getQuestData(quest).itemsBrewed.put(getCurrentStage(quest).itemsToBrew.get(i), brewAmounts.get(i)); + getQuestData(quest).itemsBrewed.put(getCurrentStage(quest).itemsToBrew + .get(i), brewAmounts.get(i)); } } } @@ -2913,7 +3033,8 @@ public class Quester { List deliveryAmounts = questSec.getIntegerList("item-delivery-amounts"); for (int i = 0; i < deliveryAmounts.size(); i++) { if (i < getCurrentStage(quest).itemsToDeliver.size()) { - getQuestData(quest).itemsDelivered.put(getCurrentStage(quest).itemsToDeliver.get(i), deliveryAmounts.get(i)); + getQuestData(quest).itemsDelivered.put(getCurrentStage(quest).itemsToDeliver + .get(i), deliveryAmounts.get(i)); } } } @@ -2962,14 +3083,16 @@ public class Quester { List mobs = questSec.getStringList("mobs-to-tame"); List amounts = questSec.getIntegerList("mob-tame-amounts"); for (String mob : mobs) { - getQuestData(quest).mobsTamed.put(EntityType.valueOf(mob.toUpperCase()), amounts.get(mobs.indexOf(mob))); + getQuestData(quest).mobsTamed.put(EntityType.valueOf(mob.toUpperCase()), amounts + .get(mobs.indexOf(mob))); } } if (questSec.contains("sheep-to-shear")) { List colors = questSec.getStringList("sheep-to-shear"); List amounts = questSec.getIntegerList("sheep-sheared"); for (String color : colors) { - getQuestData(quest).sheepSheared.put(MiscUtil.getDyeColor(color), amounts.get(colors.indexOf(color))); + getQuestData(quest).sheepSheared.put(MiscUtil.getDyeColor(color), amounts.get(colors + .indexOf(color))); } } if (questSec.contains("passwords")) { @@ -3029,7 +3152,8 @@ public class Quester { (long) (getCurrentStage(quest).delay * 0.02)); if (getCurrentStage(quest).delayMessage != null) { Player p = plugin.getServer().getPlayer(id); - p.sendMessage(plugin.parseStringWithPossibleLineBreaks((getCurrentStage(quest).delayMessage), quest, p)); + p.sendMessage(plugin.parseStringWithPossibleLineBreaks((getCurrentStage(quest) + .delayMessage), quest, p)); } } getQuestData(quest).delayStartTime = System.currentTimeMillis(); @@ -3041,9 +3165,11 @@ public class Quester { */ public void stopStageTimer(Quest quest) { if (getQuestData(quest).delayTimeLeft > -1) { - getQuestData(quest).delayTimeLeft = getQuestData(quest).delayTimeLeft - (System.currentTimeMillis() - getQuestData(quest).delayStartTime); + getQuestData(quest).delayTimeLeft = getQuestData(quest).delayTimeLeft - (System.currentTimeMillis() + - getQuestData(quest).delayStartTime); } else { - getQuestData(quest).delayTimeLeft = getCurrentStage(quest).delay - (System.currentTimeMillis() - getQuestData(quest).delayStartTime); + getQuestData(quest).delayTimeLeft = getCurrentStage(quest).delay - (System.currentTimeMillis() + - getQuestData(quest).delayStartTime); } getQuestData(quest).delayOver = false; } @@ -3055,7 +3181,8 @@ public class Quester { */ public long getStageTime(Quest quest) { if (getQuestData(quest).delayTimeLeft > -1) { - return getQuestData(quest).delayTimeLeft - (System.currentTimeMillis() - getQuestData(quest).delayStartTime); + return getQuestData(quest).delayTimeLeft - (System.currentTimeMillis() + - getQuestData(quest).delayStartTime); } else { return getCurrentStage(quest).delay - (System.currentTimeMillis() - getQuestData(quest).delayStartTime); } @@ -3105,7 +3232,8 @@ public class Quester { public void showGUIDisplay(NPC npc, LinkedList quests) { Player player = getPlayer(); int size = ((quests.size() / 9) + 1) * 9; - Inventory inv = Bukkit.getServer().createInventory(player, size, Lang.get(player, "quests") + " | " + npc.getName()); + Inventory inv = Bukkit.getServer().createInventory(player, size, Lang.get(player, "quests") + " | " + + npc.getName()); int inc = 0; for (int i = 0; i < quests.size(); i++) { if (quests.get(i).guiDisplay != null) { @@ -3325,7 +3453,8 @@ public class Quester { List mq = new LinkedList(); if (plugin.getDependencies().getPartiesApi() != null) { if (quest.getOptions().getUsePartiesPlugin()) { - Party party = plugin.getDependencies().getPartiesApi().getParty(plugin.getDependencies().getPartiesApi().getPartyPlayer(getUUID()).getPartyName()); + Party party = plugin.getDependencies().getPartiesApi().getParty(plugin.getDependencies() + .getPartiesApi().getPartyPlayer(getUUID()).getPartyName()); if (party != null) { for (UUID id : party.getMembers()) { if (!id.equals(getUUID())) { @@ -3382,7 +3511,9 @@ public class Quester { if (getPlayer() instanceof Conversable) { if (getPlayer().isConversing() == false) { setQuestToTake(quest.getName()); - String s = ChatColor.GOLD + "- " + ChatColor.DARK_PURPLE + getQuestToTake() + ChatColor.GOLD + " -\n" + "\n" + ChatColor.RESET + plugin.getQuest(getQuestToTake()).getDescription() + "\n"; + String s = ChatColor.GOLD + "- " + ChatColor.DARK_PURPLE + getQuestToTake() + ChatColor.GOLD + + " -\n" + "\n" + ChatColor.RESET + plugin.getQuest(getQuestToTake()).getDescription() + + "\n"; for (String msg : s.split("
")) { getPlayer().sendMessage(msg); } @@ -3411,7 +3542,8 @@ public class Quester { if (quest == null) { return false; } - if (getCurrentQuests().size() >= plugin.getSettings().getMaxQuests() && plugin.getSettings().getMaxQuests() > 0) { + if (getCurrentQuests().size() >= plugin.getSettings().getMaxQuests() && plugin.getSettings().getMaxQuests() + > 0) { if (giveReason) { String msg = Lang.get(getPlayer(), "questMaxAllowed"); msg = msg.replace("", String.valueOf(plugin.getSettings().getMaxQuests())); @@ -3449,7 +3581,8 @@ public class Quester { if (giveReason) { String msg = Lang.get(getPlayer(), "questTooEarly"); msg = msg.replace("", ChatColor.AQUA + quest.getName() + ChatColor.YELLOW); - msg = msg.replace("