diff --git a/main/src/main/java/me/blackvein/quests/CustomRequirement.java b/main/src/main/java/me/blackvein/quests/CustomRequirement.java index 58d603952..e4d4afc4e 100644 --- a/main/src/main/java/me/blackvein/quests/CustomRequirement.java +++ b/main/src/main/java/me/blackvein/quests/CustomRequirement.java @@ -12,19 +12,19 @@ package me.blackvein.quests; +import org.bukkit.entity.Player; + import java.util.HashMap; import java.util.Map; -import org.bukkit.entity.Player; - public abstract class CustomRequirement { private String name = null; private String author = null; private String display = null; - private final Map items = new HashMap(); - private final Map data = new HashMap(); - private final Map descriptions = new HashMap(); + private final Map items = new HashMap<>(); + private final Map data = new HashMap<>(); + private final Map descriptions = new HashMap<>(); public abstract boolean testRequirement(Player p, Map m); diff --git a/main/src/main/java/me/blackvein/quests/CustomReward.java b/main/src/main/java/me/blackvein/quests/CustomReward.java index ab6ed7e38..ada4e17f8 100644 --- a/main/src/main/java/me/blackvein/quests/CustomReward.java +++ b/main/src/main/java/me/blackvein/quests/CustomReward.java @@ -12,19 +12,19 @@ package me.blackvein.quests; +import org.bukkit.entity.Player; + import java.util.HashMap; import java.util.Map; -import org.bukkit.entity.Player; - public abstract class CustomReward { private String name = null; private String author = null; private String display = null; - private final Map items = new HashMap(); - private final Map data = new HashMap(); - private final Map descriptions = new HashMap(); + private final Map items = new HashMap<>(); + private final Map data = new HashMap<>(); + private final Map descriptions = new HashMap<>(); public abstract void giveReward(Player p, Map m); diff --git a/main/src/main/java/me/blackvein/quests/Planner.java b/main/src/main/java/me/blackvein/quests/Planner.java index 8fa281ac3..8dbe002f0 100644 --- a/main/src/main/java/me/blackvein/quests/Planner.java +++ b/main/src/main/java/me/blackvein/quests/Planner.java @@ -31,8 +31,8 @@ public class Planner { } final Calendar cal = Calendar.getInstance(); final String[] s = start.split(":"); - cal.set(Integer.valueOf(s[2]), Integer.valueOf(s[1]), Integer.valueOf(s[0]), - Integer.valueOf(s[3]), Integer.valueOf(s[4]), Integer.valueOf(s[5])); + cal.set(Integer.parseInt(s[2]), Integer.parseInt(s[1]), Integer.parseInt(s[0]), + Integer.parseInt(s[3]), Integer.parseInt(s[4]), Integer.parseInt(s[5])); final TimeZone tz = TimeZone.getTimeZone(s[6]); cal.setTimeZone(tz); return cal.getTimeInMillis(); @@ -52,8 +52,8 @@ public class Planner { } final Calendar cal = Calendar.getInstance(); final String[] s = end.split(":"); - cal.set(Integer.valueOf(s[2]), Integer.valueOf(s[1]), Integer.valueOf(s[0]), - Integer.valueOf(s[3]), Integer.valueOf(s[4]), Integer.valueOf(s[5])); + cal.set(Integer.parseInt(s[2]), Integer.parseInt(s[1]), Integer.parseInt(s[0]), + Integer.parseInt(s[3]), Integer.parseInt(s[4]), Integer.parseInt(s[5])); final TimeZone tz = TimeZone.getTimeZone(s[6]); cal.setTimeZone(tz); return cal.getTimeInMillis(); diff --git a/main/src/main/java/me/blackvein/quests/Quest.java b/main/src/main/java/me/blackvein/quests/Quest.java index 6fcde4ad6..c538659a1 100644 --- a/main/src/main/java/me/blackvein/quests/Quest.java +++ b/main/src/main/java/me/blackvein/quests/Quest.java @@ -69,10 +69,10 @@ public class Quest implements Comparable { protected Location blockStart; protected String regionStart = null; protected Action initialAction; - private final Requirements reqs = new Requirements(); - private final Planner pln = new Planner(); - private final Rewards rews = new Rewards(); - private final Options opts = new Options(); + private final Requirements requirements = new Requirements(); + private final Planner planner = new Planner(); + private final Rewards rewards = new Rewards(); + private final Options options = new Options(); @Override public int compareTo(final Quest quest) { @@ -160,19 +160,19 @@ public class Quest implements Comparable { } public Requirements getRequirements() { - return reqs; + return requirements; } public Planner getPlanner() { - return pln; + return planner; } public Rewards getRewards() { - return rews; + return rewards; } public Options getOptions() { - return opts; + return options; } /** @@ -216,7 +216,7 @@ public class Quest implements Comparable { } // Multiplayer - if (allowSharedProgress && opts.getShareProgressLevel() == 3) { + if (allowSharedProgress && options.getShareProgressLevel() == 3) { final List mq = quester.getMultiplayerQuesters(this); for (final Quester qq : mq) { if (currentStage.equals(qq.getCurrentStage(this))) { @@ -441,36 +441,36 @@ public class Quest implements Comparable { */ protected boolean testRequirements(final OfflinePlayer player) { final Quester quester = plugin.getQuester(player.getUniqueId()); - if (reqs.getMoney() != 0 && plugin.getDependencies().getVaultEconomy() != null) { - if (plugin.getDependencies().getVaultEconomy().getBalance(player) < reqs.getMoney()) { + if (requirements.getMoney() != 0 && plugin.getDependencies().getVaultEconomy() != null) { + if (plugin.getDependencies().getVaultEconomy().getBalance(player) < requirements.getMoney()) { return false; } } - if (quester.questPoints < reqs.getQuestPoints()) { + if (quester.questPoints < requirements.getQuestPoints()) { return false; } - if (!quester.completedQuests.containsAll(reqs.getNeededQuests())) { + if (!quester.completedQuests.containsAll(requirements.getNeededQuests())) { return false; } - for (final Quest q : reqs.getBlockQuests()) { + for (final Quest q : requirements.getBlockQuests()) { if (quester.completedQuests.contains(q) || quester.currentQuests.containsKey(q)) { return false; } } - for (final String s : reqs.getMcmmoSkills()) { + for (final String s : requirements.getMcmmoSkills()) { final SkillType st = Quests.getMcMMOSkill(s); - final int lvl = reqs.getMcmmoAmounts().get(reqs.getMcmmoSkills().indexOf(s)); + final int lvl = requirements.getMcmmoAmounts().get(requirements.getMcmmoSkills().indexOf(s)); if (UserManager.getOfflinePlayer(player).getProfile().getSkillLevel(st) < lvl) { return false; } } - if (reqs.getHeroesPrimaryClass() != null) { - if (!plugin.getDependencies().testPrimaryHeroesClass(reqs.getHeroesPrimaryClass(), player.getUniqueId())) { + if (requirements.getHeroesPrimaryClass() != null) { + if (!plugin.getDependencies().testPrimaryHeroesClass(requirements.getHeroesPrimaryClass(), player.getUniqueId())) { return false; } } - if (reqs.getHeroesSecondaryClass() != null) { - if (!plugin.getDependencies().testSecondaryHeroesClass(reqs.getHeroesSecondaryClass(), + if (requirements.getHeroesSecondaryClass() != null) { + if (!plugin.getDependencies().testSecondaryHeroesClass(requirements.getHeroesSecondaryClass(), player.getUniqueId())) { return false; } @@ -479,19 +479,19 @@ public class Quest implements Comparable { final Player p = (Player)player; final Inventory fakeInv = Bukkit.createInventory(null, InventoryType.PLAYER); fakeInv.setContents(p.getInventory().getContents().clone()); - for (final ItemStack is : reqs.getItems()) { + for (final ItemStack is : requirements.getItems()) { if (InventoryUtil.canRemoveItem(fakeInv, is)) { InventoryUtil.removeItem(fakeInv, is); } else { return false; } } - for (final String s : reqs.getPermissions()) { + for (final String s : requirements.getPermissions()) { if (!p.hasPermission(s)) { return false; } } - for (final String s : reqs.getCustomRequirements().keySet()) { + for (final String s : requirements.getCustomRequirements().keySet()) { CustomRequirement found = null; for (final CustomRequirement cr : plugin.getCustomRequirements()) { if (cr.getName().equalsIgnoreCase(s)) { @@ -500,7 +500,7 @@ public class Quest implements Comparable { } } if (found != null) { - if (!found.testRequirement(p, reqs.getCustomRequirements().get(s))) { + if (!found.testRequirement(p, requirements.getCustomRequirements().get(s))) { return false; } } else { @@ -571,7 +571,7 @@ public class Quest implements Comparable { + finished, this, p); Bukkit.getScheduler().runTaskLater(plugin, () -> p.sendMessage(ps), 40); } - if (pln.getCooldown() > -1) { + if (planner.getCooldown() > -1) { quester.completedTimes.put(this, System.currentTimeMillis()); if (quester.amountsCompleted.containsKey(this)) { quester.amountsCompleted.put(this, quester.amountsCompleted.get(this) + 1); @@ -583,16 +583,16 @@ public class Quest implements Comparable { // Issue rewards final Dependencies depends = plugin.getDependencies(); boolean issuedReward = false; - if (rews.getMoney() > 0 && depends.getVaultEconomy() != null) { - depends.getVaultEconomy().depositPlayer(player, rews.getMoney()); + if (rewards.getMoney() > 0 && depends.getVaultEconomy() != null) { + depends.getVaultEconomy().depositPlayer(player, rewards.getMoney()); issuedReward = true; if (plugin.getSettings().getConsoleLogging() > 2) { plugin.getLogger().info(player.getUniqueId() + " was rewarded " - + depends.getVaultEconomy().format(rews.getMoney())); + + depends.getVaultEconomy().format(rewards.getMoney())); } } if (player.isOnline()) { - for (final ItemStack i : rews.getItems()) { + for (final ItemStack i : rewards.getItems()) { try { InventoryUtil.addItem(player.getPlayer(), i); } catch (final Exception e) { @@ -608,7 +608,7 @@ public class Quest implements Comparable { } } } - for (final String s : rews.getCommands()) { + for (final String s : rewards.getCommands()) { if (player.getName() == null) { continue; } @@ -628,12 +628,12 @@ public class Quest implements Comparable { plugin.getLogger().info(player.getUniqueId() + " was rewarded command " + s); } } - for (int i = 0; i < rews.getPermissions().size(); i++) { + for (int i = 0; i < rewards.getPermissions().size(); i++) { if (depends.getVaultPermission() != null) { - final String perm = rews.getPermissions().get(i); + final String perm = rewards.getPermissions().get(i); String world = null; - if (i < rews.getPermissionWorlds().size()) { - world = rews.getPermissionWorlds().get(i); + if (i < rewards.getPermissionWorlds().size()) { + world = rewards.getPermissionWorlds().get(i); } if (world == null || world.equals("null")) { depends.getVaultPermission().playerAdd(null, player, perm); @@ -646,8 +646,8 @@ public class Quest implements Comparable { issuedReward = true; } } - for (final String s : rews.getMcmmoSkills()) { - final int levels = rews.getMcmmoAmounts().get(rews.getMcmmoSkills().indexOf(s)); + for (final String s : rewards.getMcmmoSkills()) { + final int levels = rewards.getMcmmoAmounts().get(rewards.getMcmmoSkills().indexOf(s)); UserManager.getOfflinePlayer(player).getProfile().addLevels(Quests.getMcMMOSkill(s), levels); if (plugin.getSettings().getConsoleLogging() > 2) { plugin.getLogger().info(player.getUniqueId() + " was rewarded " + s + " x " + levels); @@ -655,9 +655,9 @@ public class Quest implements Comparable { issuedReward = true; } if (player.isOnline()) { - for (final String s : rews.getHeroesClasses()) { + for (final String s : rewards.getHeroesClasses()) { final Hero hero = plugin.getDependencies().getHero(player.getUniqueId()); - final double expChange = rews.getHeroesAmounts().get(rews.getHeroesClasses().indexOf(s)); + final double expChange = rewards.getHeroesAmounts().get(rewards.getHeroesClasses().indexOf(s)); hero.addExp(expChange, plugin.getDependencies().getHeroes().getClassManager().getClass(s), ((Player)player).getLocation()); if (plugin.getSettings().getConsoleLogging() > 2) { @@ -666,16 +666,16 @@ public class Quest implements Comparable { issuedReward = true; } } - if (rews.getPartiesExperience() > 0 && depends.getPartiesApi() != null) { + if (rewards.getPartiesExperience() > 0 && depends.getPartiesApi() != null) { final PartyPlayer partyPlayer = depends.getPartiesApi().getPartyPlayer(player.getUniqueId()); if (partyPlayer != null && partyPlayer.getPartyId() != null) { final Party party = depends.getPartiesApi().getParty(partyPlayer.getPartyId()); if (party != null) { - party.giveExperience(rews.getPartiesExperience()); + party.giveExperience(rewards.getPartiesExperience()); issuedReward = true; if (plugin.getSettings().getConsoleLogging() > 2) { plugin.getLogger().info(player.getUniqueId() + " was rewarded " - + rews.getPartiesExperience() + " party experience"); + + rewards.getPartiesExperience() + " party experience"); } } } @@ -683,7 +683,7 @@ public class Quest implements Comparable { final LinkedList phatLootItems = new LinkedList<>(); int phatLootExp = 0; final LinkedList phatLootMessages = new LinkedList<>(); - for (final String s : rews.getPhatLoots()) { + for (final String s : rewards.getPhatLoots()) { final LootBundle lb = PhatLootsAPI.getPhatLoot(s).rollForLoot(); if (lb.getExp() > 0) { phatLootExp += lb.getExp(); @@ -724,25 +724,25 @@ public class Quest implements Comparable { } issuedReward = true; } - if (rews.getExp() > 0 && player.isOnline()) { - ((Player)player).giveExp(rews.getExp()); + if (rewards.getExp() > 0 && player.isOnline()) { + ((Player)player).giveExp(rewards.getExp()); if (plugin.getSettings().getConsoleLogging() > 2) { - plugin.getLogger().info(player.getUniqueId() + " was rewarded exp " + rews.getExp()); + plugin.getLogger().info(player.getUniqueId() + " was rewarded exp " + rewards.getExp()); } issuedReward = true; } - if (rews.getQuestPoints() > 0) { - quester.questPoints += rews.getQuestPoints(); + if (rewards.getQuestPoints() > 0) { + quester.questPoints += rewards.getQuestPoints(); if (plugin.getSettings().getConsoleLogging() > 2) { - plugin.getLogger().info(player.getUniqueId() + " was rewarded " + rews.getQuestPoints() + " " + plugin.getLogger().info(player.getUniqueId() + " was rewarded " + rewards.getQuestPoints() + " " + Lang.get("questPoints")); } issuedReward = true; } - if (!rews.getCustomRewards().isEmpty()) { + if (!rewards.getCustomRewards().isEmpty()) { issuedReward = true; if (plugin.getSettings().getConsoleLogging() > 2) { - for (final String s : rews.getCustomRewards().keySet()) { + for (final String s : rewards.getCustomRewards().keySet()) { plugin.getLogger().info(player.getUniqueId() + " was custom rewarded " + s); } } @@ -763,8 +763,8 @@ public class Quest implements Comparable { Lang.send(p, ChatColor.GREEN + Lang.get(p, "questRewardsTitle")); if (!issuedReward) { p.sendMessage(ChatColor.GRAY + "- (" + Lang.get("none") + ")"); - } else if (!rews.getDetailsOverride().isEmpty()) { - for (final String s: rews.getDetailsOverride()) { + } else if (!rewards.getDetailsOverride().isEmpty()) { + for (final String s: rewards.getDetailsOverride()) { String message = ChatColor.DARK_GREEN + ConfigUtil.parseString( ChatColor.translateAlternateColorCodes('&', s)); if (plugin.getDependencies().getPlaceholderApi() != null) { @@ -773,11 +773,11 @@ public class Quest implements Comparable { quester.sendMessage("- " + message); } } else { - if (rews.getQuestPoints() > 0) { - quester.sendMessage("- " + ChatColor.DARK_GREEN + rews.getQuestPoints() + " " + if (rewards.getQuestPoints() > 0) { + quester.sendMessage("- " + ChatColor.DARK_GREEN + rewards.getQuestPoints() + " " + Lang.get(p, "questPoints")); } - for (final ItemStack i : rews.getItems()) { + for (final ItemStack i : rewards.getItems()) { StringBuilder text; if (i.getItemMeta() != null && i.getItemMeta().hasDisplayName()) { if (i.getEnchantments().isEmpty()) { @@ -873,23 +873,23 @@ public class Quest implements Comparable { } } } - if (rews.getMoney() > 0 && depends.getVaultEconomy() != null) { + if (rewards.getMoney() > 0 && depends.getVaultEconomy() != null) { quester.sendMessage("- " + ChatColor.DARK_GREEN - + depends.getVaultEconomy().format(rews.getMoney())); + + depends.getVaultEconomy().format(rewards.getMoney())); } - if (rews.getExp() > 0 || phatLootExp > 0) { - final int tot = rews.getExp() + phatLootExp; + if (rewards.getExp() > 0 || phatLootExp > 0) { + final int tot = rewards.getExp() + phatLootExp; quester.sendMessage("- " + ChatColor.DARK_GREEN + tot + ChatColor.DARK_PURPLE + " " + Lang.get(p, "experience")); } - if (!rews.getCommands().isEmpty()) { + if (!rewards.getCommands().isEmpty()) { int index = 0; - for (final String s : rews.getCommands()) { - if (!rews.getCommandsOverrideDisplay().isEmpty() - && rews.getCommandsOverrideDisplay().size() > index) { - if (!rews.getCommandsOverrideDisplay().get(index).trim().equals("")) { + for (final String s : rewards.getCommands()) { + if (!rewards.getCommandsOverrideDisplay().isEmpty() + && rewards.getCommandsOverrideDisplay().size() > index) { + if (!rewards.getCommandsOverrideDisplay().get(index).trim().equals("")) { quester.sendMessage("- " + ChatColor.DARK_GREEN - + rews.getCommandsOverrideDisplay().get(index)); + + rewards.getCommandsOverrideDisplay().get(index)); } } else { quester.sendMessage("- " + ChatColor.DARK_GREEN + s); @@ -897,12 +897,12 @@ public class Quest implements Comparable { index++; } } - if (!rews.getPermissions().isEmpty()) { + if (!rewards.getPermissions().isEmpty()) { int index = 0; - for (final String s : rews.getPermissions()) { - if (rews.getPermissionWorlds() != null && rews.getPermissionWorlds().size() > index) { + for (final String s : rewards.getPermissions()) { + if (rewards.getPermissionWorlds() != null && rewards.getPermissionWorlds().size() > index) { quester.sendMessage("- " + ChatColor.DARK_GREEN + s + " (" - + rews.getPermissionWorlds().get(index) + ")"); + + rewards.getPermissionWorlds().get(index) + ")"); } else { quester.sendMessage("- " + ChatColor.DARK_GREEN + s); @@ -910,22 +910,22 @@ public class Quest implements Comparable { index++; } } - if (!rews.getMcmmoSkills().isEmpty()) { - for (final String s : rews.getMcmmoSkills()) { + if (!rewards.getMcmmoSkills().isEmpty()) { + for (final String s : rewards.getMcmmoSkills()) { quester.sendMessage("- " + ChatColor.DARK_GREEN - + rews.getMcmmoAmounts().get(rews.getMcmmoSkills().indexOf(s)) + " " + + rewards.getMcmmoAmounts().get(rewards.getMcmmoSkills().indexOf(s)) + " " + ChatColor.DARK_PURPLE + s + " " + Lang.get(p, "experience")); } } - if (!rews.getHeroesClasses().isEmpty()) { - for (final String s : rews.getHeroesClasses()) { + if (!rewards.getHeroesClasses().isEmpty()) { + for (final String s : rewards.getHeroesClasses()) { quester.sendMessage("- " + ChatColor.AQUA - + rews.getHeroesAmounts().get(rews.getHeroesClasses().indexOf(s)) + " " + ChatColor.BLUE + + rewards.getHeroesAmounts().get(rewards.getHeroesClasses().indexOf(s)) + " " + ChatColor.BLUE + s + " " + Lang.get(p, "experience")); } } - if (rews.getPartiesExperience() > 0) { - p.sendMessage("- " + ChatColor.DARK_GREEN + rews.getPartiesExperience() + ChatColor.DARK_PURPLE + if (rewards.getPartiesExperience() > 0) { + p.sendMessage("- " + ChatColor.DARK_GREEN + rewards.getPartiesExperience() + ChatColor.DARK_PURPLE + " " + Lang.get(p, "partiesExperience")); } if (!phatLootMessages.isEmpty()) { @@ -933,7 +933,7 @@ public class Quest implements Comparable { quester.sendMessage("- " + s); } } - for (final String s : rews.getCustomRewards().keySet()) { + for (final String s : rewards.getCustomRewards().keySet()) { CustomReward found = null; for (final CustomReward cr : plugin.getCustomRewards()) { if (cr.getName().equalsIgnoreCase(s)) { @@ -942,18 +942,18 @@ public class Quest implements Comparable { } } if (found != null) { - final Map datamap = rews.getCustomRewards().get(found.getName()); + final Map dataMap = rewards.getCustomRewards().get(found.getName()); String message = found.getDisplay(); if (message != null) { - for (final String key : datamap.keySet()) { - message = message.replace("%" + key + "%", datamap.get(key).toString()); + for (final String key : dataMap.keySet()) { + message = message.replace("%" + key + "%", dataMap.get(key).toString()); } quester.sendMessage("- " + ChatColor.GOLD + message); } else { plugin.getLogger().warning("Failed to notify player: " + "Custom Reward does not have an assigned name"); } - found.giveReward(p, rews.getCustomRewards().get(s)); + found.giveReward(p, rewards.getCustomRewards().get(s)); } else { plugin.getLogger().warning("Quester \"" + player.getName() + "\" completed the Quest \"" + name + "\", but the Custom Reward \"" + s @@ -976,7 +976,7 @@ public class Quest implements Comparable { } // Multiplayer - if (allowMultiplayer && opts.getShareProgressLevel() == 4) { + if (allowMultiplayer && options.getShareProgressLevel() == 4) { final List mq = quester.getMultiplayerQuesters(this); for (final Quester qq : mq) { if (qq.getQuestData(this) != null) { @@ -999,7 +999,7 @@ public class Quest implements Comparable { * Force player to quit quest and inform them of their failure * * @param quester The quester to be ejected - * @param ignoreFailAction Whether or not to ignore quest fail Action + * @param ignoreFailAction Whether to ignore quest fail Action */ @SuppressWarnings("deprecation") public void failQuest(final Quester quester, final boolean ignoreFailAction) { diff --git a/main/src/main/java/me/blackvein/quests/QuestData.java b/main/src/main/java/me/blackvein/quests/QuestData.java index 4e48aa9fd..fc460c318 100644 --- a/main/src/main/java/me/blackvein/quests/QuestData.java +++ b/main/src/main/java/me/blackvein/quests/QuestData.java @@ -1403,7 +1403,7 @@ public class QuestData { return sheepSheared; } - public void setSheepSheared(LinkedList sheepSheared) { + public void setSheepSheared(final LinkedList sheepSheared) { this.sheepSheared = sheepSheared; if (doJournalUpdate) { quester.updateJournal(); diff --git a/main/src/main/java/me/blackvein/quests/QuestFactory.java b/main/src/main/java/me/blackvein/quests/QuestFactory.java index ef0d6ed71..52f8157e3 100644 --- a/main/src/main/java/me/blackvein/quests/QuestFactory.java +++ b/main/src/main/java/me/blackvein/quests/QuestFactory.java @@ -176,96 +176,96 @@ public class QuestFactory implements ConversationAbandonedListener { if (q.getGUIDisplay() != null) { context.setSessionData(CK.Q_GUIDISPLAY, q.getGUIDisplay()); } - final Requirements reqs = q.getRequirements(); - if (reqs.getMoney() != 0) { - context.setSessionData(CK.REQ_MONEY, reqs.getMoney()); + final Requirements requirements = q.getRequirements(); + if (requirements.getMoney() != 0) { + context.setSessionData(CK.REQ_MONEY, requirements.getMoney()); } - if (reqs.getQuestPoints() != 0) { - context.setSessionData(CK.REQ_QUEST_POINTS, reqs.getQuestPoints()); + if (requirements.getQuestPoints() != 0) { + context.setSessionData(CK.REQ_QUEST_POINTS, requirements.getQuestPoints()); } - if (!reqs.getItems().isEmpty()) { - context.setSessionData(CK.REQ_ITEMS, reqs.getItems()); - context.setSessionData(CK.REQ_ITEMS_REMOVE, reqs.getRemoveItems()); + if (!requirements.getItems().isEmpty()) { + context.setSessionData(CK.REQ_ITEMS, requirements.getItems()); + context.setSessionData(CK.REQ_ITEMS_REMOVE, requirements.getRemoveItems()); } - if (!reqs.getNeededQuests().isEmpty()) { - final List ids = reqs.getNeededQuests().stream().map(Quest::getId).collect(Collectors.toList()); + if (!requirements.getNeededQuests().isEmpty()) { + final List ids = requirements.getNeededQuests().stream().map(Quest::getId).collect(Collectors.toList()); context.setSessionData(CK.REQ_QUEST, ids); } - if (!reqs.getBlockQuests().isEmpty()) { - final List ids = reqs.getBlockQuests().stream().map(Quest::getId).collect(Collectors.toList()); + if (!requirements.getBlockQuests().isEmpty()) { + final List ids = requirements.getBlockQuests().stream().map(Quest::getId).collect(Collectors.toList()); context.setSessionData(CK.REQ_QUEST_BLOCK, ids); } - if (!reqs.getMcmmoSkills().isEmpty()) { - context.setSessionData(CK.REQ_MCMMO_SKILLS, reqs.getMcmmoAmounts()); - context.setSessionData(CK.REQ_MCMMO_SKILL_AMOUNTS, reqs.getMcmmoAmounts()); + if (!requirements.getMcmmoSkills().isEmpty()) { + context.setSessionData(CK.REQ_MCMMO_SKILLS, requirements.getMcmmoAmounts()); + context.setSessionData(CK.REQ_MCMMO_SKILL_AMOUNTS, requirements.getMcmmoAmounts()); } - if (!reqs.getPermissions().isEmpty()) { - context.setSessionData(CK.REQ_PERMISSION, reqs.getPermissions()); + if (!requirements.getPermissions().isEmpty()) { + context.setSessionData(CK.REQ_PERMISSION, requirements.getPermissions()); } - if (reqs.getHeroesPrimaryClass() != null) { - context.setSessionData(CK.REQ_HEROES_PRIMARY_CLASS, reqs.getHeroesPrimaryClass()); + if (requirements.getHeroesPrimaryClass() != null) { + context.setSessionData(CK.REQ_HEROES_PRIMARY_CLASS, requirements.getHeroesPrimaryClass()); } - if (reqs.getHeroesSecondaryClass() != null) { - context.setSessionData(CK.REQ_HEROES_SECONDARY_CLASS, reqs.getHeroesSecondaryClass()); + if (requirements.getHeroesSecondaryClass() != null) { + context.setSessionData(CK.REQ_HEROES_SECONDARY_CLASS, requirements.getHeroesSecondaryClass()); } - if (!reqs.getCustomRequirements().isEmpty()) { + if (!requirements.getCustomRequirements().isEmpty()) { final LinkedList list = new LinkedList<>(); - final LinkedList> datamapList = new LinkedList<>(); - for (final Entry> entry : reqs.getCustomRequirements().entrySet()) { + final LinkedList> dataMapList = new LinkedList<>(); + for (final Entry> entry : requirements.getCustomRequirements().entrySet()) { list.add(entry.getKey()); - datamapList.add(entry.getValue()); + dataMapList.add(entry.getValue()); } context.setSessionData(CK.REQ_CUSTOM, list); - context.setSessionData(CK.REQ_CUSTOM_DATA, datamapList); + context.setSessionData(CK.REQ_CUSTOM_DATA, dataMapList); } - if (!reqs.getDetailsOverride().isEmpty()) { - context.setSessionData(CK.REQ_FAIL_MESSAGE, reqs.getDetailsOverride()); + if (!requirements.getDetailsOverride().isEmpty()) { + context.setSessionData(CK.REQ_FAIL_MESSAGE, requirements.getDetailsOverride()); } - final Rewards rews = q.getRewards(); - if (rews.getMoney() != 0) { - context.setSessionData(CK.REW_MONEY, rews.getMoney()); + final Rewards rewards = q.getRewards(); + if (rewards.getMoney() != 0) { + context.setSessionData(CK.REW_MONEY, rewards.getMoney()); } - if (rews.getQuestPoints() != 0) { - context.setSessionData(CK.REW_QUEST_POINTS, rews.getQuestPoints()); + if (rewards.getQuestPoints() != 0) { + context.setSessionData(CK.REW_QUEST_POINTS, rewards.getQuestPoints()); } - if (rews.getExp() != 0) { - context.setSessionData(CK.REW_EXP, rews.getExp()); + if (rewards.getExp() != 0) { + context.setSessionData(CK.REW_EXP, rewards.getExp()); } - if (!rews.getItems().isEmpty()) { - context.setSessionData(CK.REW_ITEMS, rews.getItems()); + if (!rewards.getItems().isEmpty()) { + context.setSessionData(CK.REW_ITEMS, rewards.getItems()); } - if (!rews.getCommands().isEmpty()) { - context.setSessionData(CK.REW_COMMAND, rews.getCommands()); + if (!rewards.getCommands().isEmpty()) { + context.setSessionData(CK.REW_COMMAND, rewards.getCommands()); } - if (!rews.getCommandsOverrideDisplay().isEmpty()) { - context.setSessionData(CK.REW_COMMAND_OVERRIDE_DISPLAY, rews.getCommandsOverrideDisplay()); + if (!rewards.getCommandsOverrideDisplay().isEmpty()) { + context.setSessionData(CK.REW_COMMAND_OVERRIDE_DISPLAY, rewards.getCommandsOverrideDisplay()); } - if (!rews.getPermissions().isEmpty()) { - context.setSessionData(CK.REW_PERMISSION, rews.getPermissions()); + if (!rewards.getPermissions().isEmpty()) { + context.setSessionData(CK.REW_PERMISSION, rewards.getPermissions()); } - if (!rews.getPermissions().isEmpty()) { - context.setSessionData(CK.REW_PERMISSION_WORLDS, rews.getPermissionWorlds()); + if (!rewards.getPermissions().isEmpty()) { + context.setSessionData(CK.REW_PERMISSION_WORLDS, rewards.getPermissionWorlds()); } - if (!rews.getMcmmoSkills().isEmpty()) { - context.setSessionData(CK.REW_MCMMO_SKILLS, rews.getMcmmoSkills()); - context.setSessionData(CK.REW_MCMMO_AMOUNTS, rews.getMcmmoAmounts()); + if (!rewards.getMcmmoSkills().isEmpty()) { + context.setSessionData(CK.REW_MCMMO_SKILLS, rewards.getMcmmoSkills()); + context.setSessionData(CK.REW_MCMMO_AMOUNTS, rewards.getMcmmoAmounts()); } - if (!rews.getHeroesClasses().isEmpty()) { - context.setSessionData(CK.REW_HEROES_CLASSES, rews.getHeroesClasses()); - context.setSessionData(CK.REW_HEROES_AMOUNTS, rews.getHeroesAmounts()); + if (!rewards.getHeroesClasses().isEmpty()) { + context.setSessionData(CK.REW_HEROES_CLASSES, rewards.getHeroesClasses()); + context.setSessionData(CK.REW_HEROES_AMOUNTS, rewards.getHeroesAmounts()); } - if (rews.getPartiesExperience() != 0) { - context.setSessionData(CK.REW_PARTIES_EXPERIENCE, rews.getPartiesExperience()); + if (rewards.getPartiesExperience() != 0) { + context.setSessionData(CK.REW_PARTIES_EXPERIENCE, rewards.getPartiesExperience()); } - if (!rews.getPhatLoots().isEmpty()) { - context.setSessionData(CK.REW_PHAT_LOOTS, rews.getPhatLoots()); + if (!rewards.getPhatLoots().isEmpty()) { + context.setSessionData(CK.REW_PHAT_LOOTS, rewards.getPhatLoots()); } - if (!rews.getCustomRewards().isEmpty()) { - context.setSessionData(CK.REW_CUSTOM, new LinkedList<>(rews.getCustomRewards().keySet())); - context.setSessionData(CK.REW_CUSTOM_DATA, new LinkedList(rews.getCustomRewards().values())); + if (!rewards.getCustomRewards().isEmpty()) { + context.setSessionData(CK.REW_CUSTOM, new LinkedList<>(rewards.getCustomRewards().keySet())); + context.setSessionData(CK.REW_CUSTOM_DATA, new LinkedList(rewards.getCustomRewards().values())); } - if (!rews.getDetailsOverride().isEmpty()) { - context.setSessionData(CK.REW_DETAILS_OVERRIDE, rews.getDetailsOverride()); + if (!rewards.getDetailsOverride().isEmpty()) { + context.setSessionData(CK.REW_DETAILS_OVERRIDE, rewards.getDetailsOverride()); } final Planner pln = q.getPlanner(); if (pln.getStart() != null) { @@ -299,68 +299,68 @@ public class QuestFactory implements ConversationAbandonedListener { context.setSessionData(pref, Boolean.TRUE); if (!stage.getBlocksToBreak().isEmpty()) { final LinkedList names = new LinkedList<>(); - final LinkedList amnts = new LinkedList<>(); - final LinkedList durab = new LinkedList<>(); + final LinkedList amounts = new LinkedList<>(); + final LinkedList durability = new LinkedList<>(); for (final ItemStack e : stage.getBlocksToBreak()) { names.add(e.getType().name()); - amnts.add(e.getAmount()); - durab.add(e.getDurability()); + amounts.add(e.getAmount()); + durability.add(e.getDurability()); } context.setSessionData(pref + CK.S_BREAK_NAMES, names); - context.setSessionData(pref + CK.S_BREAK_AMOUNTS, amnts); - context.setSessionData(pref + CK.S_BREAK_DURABILITY, durab); + context.setSessionData(pref + CK.S_BREAK_AMOUNTS, amounts); + context.setSessionData(pref + CK.S_BREAK_DURABILITY, durability); } if (!stage.getBlocksToDamage().isEmpty()) { final LinkedList names = new LinkedList<>(); - final LinkedList amnts = new LinkedList<>(); - final LinkedList durab = new LinkedList<>(); + final LinkedList amounts = new LinkedList<>(); + final LinkedList durability = new LinkedList<>(); for (final ItemStack e : stage.getBlocksToDamage()) { names.add(e.getType().name()); - amnts.add(e.getAmount()); - durab.add(e.getDurability()); + amounts.add(e.getAmount()); + durability.add(e.getDurability()); } context.setSessionData(pref + CK.S_DAMAGE_NAMES, names); - context.setSessionData(pref + CK.S_DAMAGE_AMOUNTS, amnts); - context.setSessionData(pref + CK.S_DAMAGE_DURABILITY, durab); + context.setSessionData(pref + CK.S_DAMAGE_AMOUNTS, amounts); + context.setSessionData(pref + CK.S_DAMAGE_DURABILITY, durability); } if (!stage.getBlocksToPlace().isEmpty()) { final LinkedList names = new LinkedList<>(); - final LinkedList amnts = new LinkedList<>(); - final LinkedList durab = new LinkedList<>(); + final LinkedList amounts = new LinkedList<>(); + final LinkedList durability = new LinkedList<>(); for (final ItemStack e : stage.getBlocksToPlace()) { names.add(e.getType().name()); - amnts.add(e.getAmount()); - durab.add(e.getDurability()); + amounts.add(e.getAmount()); + durability.add(e.getDurability()); } context.setSessionData(pref + CK.S_PLACE_NAMES, names); - context.setSessionData(pref + CK.S_PLACE_AMOUNTS, amnts); - context.setSessionData(pref + CK.S_PLACE_DURABILITY, durab); + context.setSessionData(pref + CK.S_PLACE_AMOUNTS, amounts); + context.setSessionData(pref + CK.S_PLACE_DURABILITY, durability); } if (!stage.getBlocksToUse().isEmpty()) { final LinkedList names = new LinkedList<>(); - final LinkedList amnts = new LinkedList<>(); - final LinkedList durab = new LinkedList<>(); + final LinkedList amounts = new LinkedList<>(); + final LinkedList durability = new LinkedList<>(); for (final ItemStack e : stage.getBlocksToUse()) { names.add(e.getType().name()); - amnts.add(e.getAmount()); - durab.add(e.getDurability()); + amounts.add(e.getAmount()); + durability.add(e.getDurability()); } context.setSessionData(pref + CK.S_USE_NAMES, names); - context.setSessionData(pref + CK.S_USE_AMOUNTS, amnts); - context.setSessionData(pref + CK.S_USE_DURABILITY, durab); + context.setSessionData(pref + CK.S_USE_AMOUNTS, amounts); + context.setSessionData(pref + CK.S_USE_DURABILITY, durability); } if (!stage.getBlocksToCut().isEmpty()) { final LinkedList names = new LinkedList<>(); - final LinkedList amnts = new LinkedList<>(); - final LinkedList durab = new LinkedList<>(); + final LinkedList amounts = new LinkedList<>(); + final LinkedList durability = new LinkedList<>(); for (final ItemStack e : stage.getBlocksToCut()) { names.add(e.getType().name()); - amnts.add(e.getAmount()); - durab.add(e.getDurability()); + amounts.add(e.getAmount()); + durability.add(e.getDurability()); } context.setSessionData(pref + CK.S_CUT_NAMES, names); - context.setSessionData(pref + CK.S_CUT_AMOUNTS, amnts); - context.setSessionData(pref + CK.S_CUT_DURABILITY, durab); + context.setSessionData(pref + CK.S_CUT_AMOUNTS, amounts); + context.setSessionData(pref + CK.S_CUT_DURABILITY, durability); } if (!stage.getItemsToCraft().isEmpty()) { final LinkedList items = new LinkedList<>(stage.getItemsToCraft()); @@ -415,21 +415,21 @@ public class QuestFactory implements ConversationAbandonedListener { context.setSessionData(pref + CK.S_MOB_TYPES, mobs); context.setSessionData(pref + CK.S_MOB_AMOUNTS, stage.getMobNumToKill()); if (!stage.getLocationsToKillWithin().isEmpty()) { - final LinkedList locs = new LinkedList<>(); + final LinkedList locations = new LinkedList<>(); for (final Location l : stage.getLocationsToKillWithin()) { - locs.add(ConfigUtil.getLocationInfo(l)); + locations.add(ConfigUtil.getLocationInfo(l)); } - context.setSessionData(pref + CK.S_MOB_KILL_LOCATIONS, locs); + context.setSessionData(pref + CK.S_MOB_KILL_LOCATIONS, locations); context.setSessionData(pref + CK.S_MOB_KILL_LOCATIONS_RADIUS, stage.getRadiiToKillWithin()); context.setSessionData(pref + CK.S_MOB_KILL_LOCATIONS_NAMES, stage.getKillNames()); } } if (!stage.getLocationsToReach().isEmpty()) { - final LinkedList locs = new LinkedList<>(); + final LinkedList locations = new LinkedList<>(); for (final Location l : stage.getLocationsToReach()) { - locs.add(ConfigUtil.getLocationInfo(l)); + locations.add(ConfigUtil.getLocationInfo(l)); } - context.setSessionData(pref + CK.S_REACH_LOCATIONS, locs); + context.setSessionData(pref + CK.S_REACH_LOCATIONS, locations); context.setSessionData(pref + CK.S_REACH_LOCATIONS_RADIUS, stage.getRadiiToReachWithin()); context.setSessionData(pref + CK.S_REACH_LOCATIONS_NAMES, stage.getLocationNames()); } @@ -438,9 +438,9 @@ public class QuestFactory implements ConversationAbandonedListener { for (final EntityType e : stage.getMobsToTame()) { mobs.add(MiscUtil.getPrettyMobName(e)); } - final LinkedList amts = new LinkedList<>(stage.getMobNumToTame()); + final LinkedList amounts = new LinkedList<>(stage.getMobNumToTame()); context.setSessionData(pref + CK.S_TAME_TYPES, mobs); - context.setSessionData(pref + CK.S_TAME_AMOUNTS, amts); + context.setSessionData(pref + CK.S_TAME_AMOUNTS, amounts); } if (!stage.getSheepToShear().isEmpty()) { final LinkedList colors = new LinkedList<>(); @@ -448,9 +448,9 @@ public class QuestFactory implements ConversationAbandonedListener { colors.add(MiscUtil.getPrettyDyeColorName(d)); } - final LinkedList amts = new LinkedList<>(stage.sheepNumToShear); + final LinkedList amounts = new LinkedList<>(stage.sheepNumToShear); context.setSessionData(pref + CK.S_SHEAR_COLORS, colors); - context.setSessionData(pref + CK.S_SHEAR_AMOUNTS, amts); + context.setSessionData(pref + CK.S_SHEAR_AMOUNTS, amounts); } if (!stage.getPasswordDisplays().isEmpty()) { context.setSessionData(pref + CK.S_PASSWORD_DISPLAYS, stage.getPasswordDisplays()); @@ -463,10 +463,10 @@ public class QuestFactory implements ConversationAbandonedListener { list.add(stage.getCustomObjectives().get(i).getName()); countList.add(stage.getCustomObjectiveCounts().get(i)); } - final LinkedList> datamapList = new LinkedList<>(stage.getCustomObjectiveData()); + final LinkedList> dataMapList = new LinkedList<>(stage.getCustomObjectiveData()); context.setSessionData(pref + CK.S_CUSTOM_OBJECTIVES, list); context.setSessionData(pref + CK.S_CUSTOM_OBJECTIVES_COUNT, countList); - context.setSessionData(pref + CK.S_CUSTOM_OBJECTIVES_DATA, datamapList); + context.setSessionData(pref + CK.S_CUSTOM_OBJECTIVES_DATA, dataMapList); } if (stage.getStartAction() != null) { context.setSessionData(pref + CK.S_START_EVENT, stage.getStartAction().getName()); @@ -619,44 +619,44 @@ public class QuestFactory implements ConversationAbandonedListener { @SuppressWarnings("unchecked") private void saveRequirements(final ConversationContext context, final ConfigurationSection section) { - final ConfigurationSection reqs = section.createSection("requirements"); - reqs.set("money", context.getSessionData(CK.REQ_MONEY) != null + final ConfigurationSection requirements = section.createSection("requirements"); + requirements.set("money", context.getSessionData(CK.REQ_MONEY) != null ? context.getSessionData(CK.REQ_MONEY) : null); - reqs.set("quest-points", context.getSessionData(CK.REQ_QUEST_POINTS) != null + requirements.set("quest-points", context.getSessionData(CK.REQ_QUEST_POINTS) != null ? context.getSessionData(CK.REQ_QUEST_POINTS) : null); - reqs.set("items", context.getSessionData(CK.REQ_ITEMS) != null + requirements.set("items", context.getSessionData(CK.REQ_ITEMS) != null ? context.getSessionData(CK.REQ_ITEMS) : null); - reqs.set("remove-items", context.getSessionData(CK.REQ_ITEMS_REMOVE) != null + requirements.set("remove-items", context.getSessionData(CK.REQ_ITEMS_REMOVE) != null ? context.getSessionData(CK.REQ_ITEMS_REMOVE) : null); - reqs.set("permissions", context.getSessionData(CK.REQ_PERMISSION) != null + requirements.set("permissions", context.getSessionData(CK.REQ_PERMISSION) != null ? context.getSessionData(CK.REQ_PERMISSION) : null); - reqs.set("quests", context.getSessionData(CK.REQ_QUEST) != null + requirements.set("quests", context.getSessionData(CK.REQ_QUEST) != null ? context.getSessionData(CK.REQ_QUEST) : null); - reqs.set("quest-blocks", context.getSessionData(CK.REQ_QUEST_BLOCK) != null + requirements.set("quest-blocks", context.getSessionData(CK.REQ_QUEST_BLOCK) != null ? context.getSessionData(CK.REQ_QUEST_BLOCK) : null); - reqs.set("mcmmo-skills", context.getSessionData(CK.REQ_MCMMO_SKILLS) != null + requirements.set("mcmmo-skills", context.getSessionData(CK.REQ_MCMMO_SKILLS) != null ? context.getSessionData(CK.REQ_MCMMO_SKILLS) : null); - reqs.set("mcmmo-amounts", context.getSessionData(CK.REQ_MCMMO_SKILL_AMOUNTS) != null + requirements.set("mcmmo-amounts", context.getSessionData(CK.REQ_MCMMO_SKILL_AMOUNTS) != null ? context.getSessionData(CK.REQ_MCMMO_SKILL_AMOUNTS) : null); - reqs.set("heroes-primary-class", context.getSessionData(CK.REQ_HEROES_PRIMARY_CLASS) != null + requirements.set("heroes-primary-class", context.getSessionData(CK.REQ_HEROES_PRIMARY_CLASS) != null ? context.getSessionData(CK.REQ_HEROES_PRIMARY_CLASS) : null); - reqs.set("heroes-secondary-class", context.getSessionData(CK.REQ_HEROES_SECONDARY_CLASS) != null + requirements.set("heroes-secondary-class", context.getSessionData(CK.REQ_HEROES_SECONDARY_CLASS) != null ? context.getSessionData(CK.REQ_HEROES_SECONDARY_CLASS) : null); - final LinkedList customReqs = context.getSessionData(CK.REQ_CUSTOM) != null + final LinkedList customRequirements = context.getSessionData(CK.REQ_CUSTOM) != null ? (LinkedList) context.getSessionData(CK.REQ_CUSTOM) : null; - final LinkedList> customReqsData = context.getSessionData(CK.REQ_CUSTOM_DATA) != null + final LinkedList> customRequirementsData = context.getSessionData(CK.REQ_CUSTOM_DATA) != null ? (LinkedList>) context.getSessionData(CK.REQ_CUSTOM_DATA) : null; - if (customReqs != null && customReqsData != null) { - final ConfigurationSection customReqsSec = reqs.createSection("custom-requirements"); - for (int i = 0; i < customReqs.size(); i++) { - final ConfigurationSection customReqSec = customReqsSec.createSection("req" + (i + 1)); - customReqSec.set("name", customReqs.get(i)); - customReqSec.set("data", customReqsData.get(i)); + if (customRequirements != null && customRequirementsData != null) { + final ConfigurationSection customRequirementsSec = requirements.createSection("custom-requirements"); + for (int i = 0; i < customRequirements.size(); i++) { + final ConfigurationSection customReqSec = customRequirementsSec.createSection("req" + (i + 1)); + customReqSec.set("name", customRequirements.get(i)); + customReqSec.set("data", customRequirementsData.get(i)); } } - reqs.set("fail-requirement-message", context.getSessionData(CK.REQ_FAIL_MESSAGE) != null + requirements.set("fail-requirement-message", context.getSessionData(CK.REQ_FAIL_MESSAGE) != null ? context.getSessionData(CK.REQ_FAIL_MESSAGE) : null); - if (reqs.getKeys(false).isEmpty()) { + if (requirements.getKeys(false).isEmpty()) { section.set("requirements", null); } } @@ -755,23 +755,23 @@ public class QuestFactory implements ConversationAbandonedListener { ? context.getSessionData(pref + CK.S_PASSWORD_DISPLAYS) : null); stage.set("password-phrases", context.getSessionData(pref + CK.S_PASSWORD_PHRASES) != null ? context.getSessionData(pref + CK.S_PASSWORD_PHRASES) : null); - final LinkedList customObjs = (LinkedList) context.getSessionData(pref + CK.S_CUSTOM_OBJECTIVES); + final LinkedList customObj = (LinkedList) context.getSessionData(pref + CK.S_CUSTOM_OBJECTIVES); final LinkedList customObjCounts = (LinkedList) context.getSessionData(pref + CK.S_CUSTOM_OBJECTIVES_COUNT); - final LinkedList> customObjsData + final LinkedList> customObjData = (LinkedList>) context.getSessionData(pref + CK.S_CUSTOM_OBJECTIVES_DATA); if (context.getSessionData(pref + CK.S_CUSTOM_OBJECTIVES) != null) { final ConfigurationSection sec = stage.createSection("custom-objectives"); - if (customObjs == null || customObjCounts == null || customObjsData == null) { + if (customObj == null || customObjCounts == null || customObjData == null) { continue; } - for (int index = 0; index < customObjs.size(); index++) { + for (int index = 0; index < customObj.size(); index++) { final ConfigurationSection sec2 = sec.createSection("custom" + (index + 1)); - sec2.set("name", customObjs.get(index)); + sec2.set("name", customObj.get(index)); sec2.set("count", customObjCounts.get(index)); CustomObjective found = null; for (final CustomObjective co : plugin.getCustomObjectives()) { - if (co.getName().equals(customObjs.get(index))) { + if (co.getName().equals(customObj.get(index))) { found = co; break; } @@ -780,9 +780,9 @@ public class QuestFactory implements ConversationAbandonedListener { continue; } final ConfigurationSection sec3 = sec2.createSection("data"); - for (final Entry datamap : found.getData()) { - for (final Entry e : customObjsData) { - if (e.getKey().equals(datamap.getKey())) { + for (final Entry dataMap : found.getData()) { + for (final Entry e : customObjData) { + if (e.getKey().equals(dataMap.getKey())) { sec3.set(e.getKey(), e.getValue()); // if anything goes wrong it's probably here } } @@ -834,50 +834,50 @@ public class QuestFactory implements ConversationAbandonedListener { @SuppressWarnings("unchecked") private void saveRewards(final ConversationContext context, final ConfigurationSection section) { - final ConfigurationSection rews = section.createSection("rewards"); - rews.set("items", context.getSessionData(CK.REW_ITEMS) != null + final ConfigurationSection rewards = section.createSection("rewards"); + rewards.set("items", context.getSessionData(CK.REW_ITEMS) != null ? context.getSessionData(CK.REW_ITEMS) : null); - rews.set("money", context.getSessionData(CK.REW_MONEY) != null + rewards.set("money", context.getSessionData(CK.REW_MONEY) != null ? context.getSessionData(CK.REW_MONEY) : null); - rews.set("quest-points", context.getSessionData(CK.REW_QUEST_POINTS) != null + rewards.set("quest-points", context.getSessionData(CK.REW_QUEST_POINTS) != null ? context.getSessionData(CK.REW_QUEST_POINTS) : null); - rews.set("exp", context.getSessionData(CK.REW_EXP) != null + rewards.set("exp", context.getSessionData(CK.REW_EXP) != null ? context.getSessionData(CK.REW_EXP) : null); - rews.set("commands", context.getSessionData(CK.REW_COMMAND) != null + rewards.set("commands", context.getSessionData(CK.REW_COMMAND) != null ? context.getSessionData(CK.REW_COMMAND) : null); - rews.set("commands-override-display", context.getSessionData(CK.REW_COMMAND_OVERRIDE_DISPLAY) != null + rewards.set("commands-override-display", context.getSessionData(CK.REW_COMMAND_OVERRIDE_DISPLAY) != null ? context.getSessionData(CK.REW_COMMAND_OVERRIDE_DISPLAY) : null); - rews.set("permissions", context.getSessionData(CK.REW_PERMISSION) != null + rewards.set("permissions", context.getSessionData(CK.REW_PERMISSION) != null ? context.getSessionData(CK.REW_PERMISSION) : null); - rews.set("permission-worlds", context.getSessionData(CK.REW_PERMISSION_WORLDS) != null + rewards.set("permission-worlds", context.getSessionData(CK.REW_PERMISSION_WORLDS) != null ? context.getSessionData(CK.REW_PERMISSION_WORLDS) : null); - rews.set("mcmmo-skills", context.getSessionData(CK.REW_MCMMO_SKILLS) != null + rewards.set("mcmmo-skills", context.getSessionData(CK.REW_MCMMO_SKILLS) != null ? context.getSessionData(CK.REW_MCMMO_SKILLS) : null); - rews.set("mcmmo-levels", context.getSessionData(CK.REW_MCMMO_AMOUNTS) != null + rewards.set("mcmmo-levels", context.getSessionData(CK.REW_MCMMO_AMOUNTS) != null ? context.getSessionData(CK.REW_MCMMO_AMOUNTS) : null); - rews.set("heroes-exp-classes", context.getSessionData(CK.REW_HEROES_CLASSES) != null + rewards.set("heroes-exp-classes", context.getSessionData(CK.REW_HEROES_CLASSES) != null ? context.getSessionData(CK.REW_HEROES_CLASSES) : null); - rews.set("heroes-exp-amounts", context.getSessionData(CK.REW_HEROES_AMOUNTS) != null + rewards.set("heroes-exp-amounts", context.getSessionData(CK.REW_HEROES_AMOUNTS) != null ? context.getSessionData(CK.REW_HEROES_AMOUNTS) : null); - rews.set("parties-experience", context.getSessionData(CK.REW_PARTIES_EXPERIENCE) != null + rewards.set("parties-experience", context.getSessionData(CK.REW_PARTIES_EXPERIENCE) != null ? context.getSessionData(CK.REW_PARTIES_EXPERIENCE) : null); - rews.set("phat-loots", context.getSessionData(CK.REW_PHAT_LOOTS) != null + rewards.set("phat-loots", context.getSessionData(CK.REW_PHAT_LOOTS) != null ? context.getSessionData(CK.REW_PHAT_LOOTS) : null); - final LinkedList customRews = context.getSessionData(CK.REW_CUSTOM) != null + final LinkedList customRewards = context.getSessionData(CK.REW_CUSTOM) != null ? (LinkedList) context.getSessionData(CK.REW_CUSTOM) : null; - final LinkedList> customRewsData = context.getSessionData(CK.REW_CUSTOM_DATA) != null + final LinkedList> customRewardsData = context.getSessionData(CK.REW_CUSTOM_DATA) != null ? (LinkedList>) context.getSessionData(CK.REW_CUSTOM_DATA) : null; - if (customRews != null && customRewsData != null) { - final ConfigurationSection customRewsSec = rews.createSection("custom-rewards"); - for (int i = 0; i < customRews.size(); i++) { - final ConfigurationSection customRewSec = customRewsSec.createSection("req" + (i + 1)); - customRewSec.set("name", customRews.get(i)); - customRewSec.set("data", customRewsData.get(i)); + if (customRewards != null && customRewardsData != null) { + final ConfigurationSection customRewardsSec = rewards.createSection("custom-rewards"); + for (int i = 0; i < customRewards.size(); i++) { + final ConfigurationSection customRewSec = customRewardsSec.createSection("req" + (i + 1)); + customRewSec.set("name", customRewards.get(i)); + customRewSec.set("data", customRewardsData.get(i)); } } - rews.set("details-override", context.getSessionData(CK.REW_DETAILS_OVERRIDE) != null + rewards.set("details-override", context.getSessionData(CK.REW_DETAILS_OVERRIDE) != null ? context.getSessionData(CK.REW_DETAILS_OVERRIDE) : null); - if (rews.getKeys(false).isEmpty()) { + if (rewards.getKeys(false).isEmpty()) { section.set("rewards", null); } } diff --git a/main/src/main/java/me/blackvein/quests/Quester.java b/main/src/main/java/me/blackvein/quests/Quester.java index 41377223a..dc7af1f33 100644 --- a/main/src/main/java/me/blackvein/quests/Quester.java +++ b/main/src/main/java/me/blackvein/quests/Quester.java @@ -46,7 +46,6 @@ import org.bukkit.OfflinePlayer; import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.YamlConfiguration; -import org.bukkit.conversations.Conversable; import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; @@ -57,6 +56,7 @@ import org.bukkit.inventory.ItemFlag; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.material.Crops; +import org.jetbrains.annotations.NotNull; import java.util.ArrayList; import java.util.Collection; @@ -87,20 +87,20 @@ public class Quester implements Comparable { protected int questPoints = 0; private String compassTargetQuestId; private long lastNotifiedCondition = 0L; - protected ConcurrentHashMap timers = new ConcurrentHashMap(); + protected ConcurrentHashMap timers = new ConcurrentHashMap<>(); protected ConcurrentHashMap currentQuests = new ConcurrentHashMap() { private static final long serialVersionUID = 6361484975823846780L; @Override - public Integer put(final Quest key, final Integer val) { + public Integer put(final @NotNull Quest key, final @NotNull Integer val) { final Integer data = super.put(key, val); updateJournal(); return data; } @Override - public Integer remove(final Object key) { + public Integer remove(final @NotNull Object key) { final Integer i = super.remove(key); updateJournal(); return i; @@ -128,27 +128,14 @@ public class Quester implements Comparable { updateJournal(); return b; } - - /*@Override - public void add(final int index, final Quest element) { - super.add(index, element); - updateJournal(); - }*/ @Override - public boolean addAll(final Collection c) { + public boolean addAll(final @NotNull Collection c) { final boolean b = super.addAll(c); updateJournal(); return b; } - /*@Override - public boolean addAll(final int index, final Collection c) { - final boolean b = super.addAll(index, c); - updateJournal(); - return b; - }*/ - @Override public void clear() { super.clear(); @@ -168,35 +155,21 @@ public class Quester implements Comparable { updateJournal(); return b; } - - /*@Override - public Quest remove(final int index) { - final Quest s = super.remove(index); - updateJournal(); - return s; - } - - @Override - public Quest set(final int index, final Quest element) { - final Quest s = super.set(index, element); - updateJournal(); - return s; - }*/ }; - protected ConcurrentHashMap completedTimes = new ConcurrentHashMap(); + protected ConcurrentHashMap completedTimes = new ConcurrentHashMap<>(); protected ConcurrentHashMap amountsCompleted = new ConcurrentHashMap() { private static final long serialVersionUID = 5475202358792520975L; @Override - public Integer put(final Quest key, final Integer val) { + public Integer put(final @NotNull Quest key, final @NotNull Integer val) { final Integer data = super.put(key, val); updateJournal(); return data; } @Override - public Integer remove(final Object key) { + public Integer remove(final @NotNull Object key) { final Integer i = super.remove(key); updateJournal(); return i; @@ -219,14 +192,14 @@ public class Quester implements Comparable { private static final long serialVersionUID = -4607112433003926066L; @Override - public QuestData put(final Quest key, final QuestData val) { + public QuestData put(final @NotNull Quest key, final @NotNull QuestData val) { final QuestData data = super.put(key, val); updateJournal(); return data; } @Override - public QuestData remove(final Object key) { + public QuestData remove(final @NotNull Object key) { final QuestData data = super.remove(key); updateJournal(); return data; @@ -453,22 +426,22 @@ public class Quester implements Comparable { /** * Start a quest for this Quester * - * @param q The quest to start - * @param ignoreReqs Whether to ignore Requirements + * @param quest The quest to start + * @param ignoreRequirements Whether to ignore Requirements */ @SuppressWarnings("deprecation") - public void takeQuest(final Quest q, final boolean ignoreReqs) { - if (q == null) { + public void takeQuest(final Quest quest, final boolean ignoreRequirements) { + if (quest == null) { return; } - final QuesterPreStartQuestEvent preEvent = new QuesterPreStartQuestEvent(this, q); + final QuesterPreStartQuestEvent preEvent = new QuesterPreStartQuestEvent(this, quest); plugin.getServer().getPluginManager().callEvent(preEvent); if (preEvent.isCancelled()) { return; } final OfflinePlayer offlinePlayer = getOfflinePlayer(); if (offlinePlayer.isOnline()) { - final Planner pln = q.getPlanner(); + final Planner pln = quest.getPlanner(); final long currentTime = System.currentTimeMillis(); final long start = pln.getStartInMillis(); // Start time in milliseconds since UTC epoch final long end = pln.getEndInMillis(); // End time in milliseconds since UTC epoch @@ -477,7 +450,7 @@ public class Quester implements Comparable { if (start != -1) { if (currentTime < start) { String early = Lang.get("plnTooEarly"); - early = early.replace("", ChatColor.AQUA + q.getName() + ChatColor.YELLOW); + early = early.replace("", ChatColor.AQUA + quest.getName() + ChatColor.YELLOW); early = early.replace("