Improve code syntax, part 6

This commit is contained in:
PikaMug 2021-09-09 01:01:41 -04:00
parent 3cf7ad2719
commit 3f7e920043
14 changed files with 824 additions and 878 deletions

View File

@ -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<String, Short> items = new HashMap<String, Short>();
private final Map<String, Object> data = new HashMap<String, Object>();
private final Map<String, String> descriptions = new HashMap<String, String>();
private final Map<String, Short> items = new HashMap<>();
private final Map<String, Object> data = new HashMap<>();
private final Map<String, String> descriptions = new HashMap<>();
public abstract boolean testRequirement(Player p, Map<String, Object> m);

View File

@ -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<String, Short> items = new HashMap<String, Short>();
private final Map<String, Object> data = new HashMap<String, Object>();
private final Map<String, String> descriptions = new HashMap<String, String>();
private final Map<String, Short> items = new HashMap<>();
private final Map<String, Object> data = new HashMap<>();
private final Map<String, String> descriptions = new HashMap<>();
public abstract void giveReward(Player p, Map<String, Object> m);

View File

@ -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();

View File

@ -69,10 +69,10 @@ public class Quest implements Comparable<Quest> {
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<Quest> {
}
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<Quest> {
}
// Multiplayer
if (allowSharedProgress && opts.getShareProgressLevel() == 3) {
if (allowSharedProgress && options.getShareProgressLevel() == 3) {
final List<Quester> mq = quester.getMultiplayerQuesters(this);
for (final Quester qq : mq) {
if (currentStage.equals(qq.getCurrentStage(this))) {
@ -441,36 +441,36 @@ public class Quest implements Comparable<Quest> {
*/
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<Quest> {
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<Quest> {
}
}
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<Quest> {
+ 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<Quest> {
// 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<Quest> {
}
}
}
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<Quest> {
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<Quest> {
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<Quest> {
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<Quest> {
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<Quest> {
final LinkedList<ItemStack> phatLootItems = new LinkedList<>();
int phatLootExp = 0;
final LinkedList<String> 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<Quest> {
}
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<Quest> {
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<Quest> {
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<Quest> {
}
}
}
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<Quest> {
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<Quest> {
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<Quest> {
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<Quest> {
}
}
if (found != null) {
final Map<String, Object> datamap = rews.getCustomRewards().get(found.getName());
final Map<String, Object> 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<Quest> {
}
// Multiplayer
if (allowMultiplayer && opts.getShareProgressLevel() == 4) {
if (allowMultiplayer && options.getShareProgressLevel() == 4) {
final List<Quester> mq = quester.getMultiplayerQuesters(this);
for (final Quester qq : mq) {
if (qq.getQuestData(this) != null) {
@ -999,7 +999,7 @@ public class Quest implements Comparable<Quest> {
* 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) {

View File

@ -1403,7 +1403,7 @@ public class QuestData {
return sheepSheared;
}
public void setSheepSheared(LinkedList<Integer> sheepSheared) {
public void setSheepSheared(final LinkedList<Integer> sheepSheared) {
this.sheepSheared = sheepSheared;
if (doJournalUpdate) {
quester.updateJournal();

View File

@ -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<String> ids = reqs.getNeededQuests().stream().map(Quest::getId).collect(Collectors.toList());
if (!requirements.getNeededQuests().isEmpty()) {
final List<String> ids = requirements.getNeededQuests().stream().map(Quest::getId).collect(Collectors.toList());
context.setSessionData(CK.REQ_QUEST, ids);
}
if (!reqs.getBlockQuests().isEmpty()) {
final List<String> ids = reqs.getBlockQuests().stream().map(Quest::getId).collect(Collectors.toList());
if (!requirements.getBlockQuests().isEmpty()) {
final List<String> 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<String> list = new LinkedList<>();
final LinkedList<Map<String, Object>> datamapList = new LinkedList<>();
for (final Entry<String, Map<String, Object>> entry : reqs.getCustomRequirements().entrySet()) {
final LinkedList<Map<String, Object>> dataMapList = new LinkedList<>();
for (final Entry<String, Map<String, Object>> 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<Object>(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<Object>(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<String> names = new LinkedList<>();
final LinkedList<Integer> amnts = new LinkedList<>();
final LinkedList<Short> durab = new LinkedList<>();
final LinkedList<Integer> amounts = new LinkedList<>();
final LinkedList<Short> 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<String> names = new LinkedList<>();
final LinkedList<Integer> amnts = new LinkedList<>();
final LinkedList<Short> durab = new LinkedList<>();
final LinkedList<Integer> amounts = new LinkedList<>();
final LinkedList<Short> 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<String> names = new LinkedList<>();
final LinkedList<Integer> amnts = new LinkedList<>();
final LinkedList<Short> durab = new LinkedList<>();
final LinkedList<Integer> amounts = new LinkedList<>();
final LinkedList<Short> 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<String> names = new LinkedList<>();
final LinkedList<Integer> amnts = new LinkedList<>();
final LinkedList<Short> durab = new LinkedList<>();
final LinkedList<Integer> amounts = new LinkedList<>();
final LinkedList<Short> 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<String> names = new LinkedList<>();
final LinkedList<Integer> amnts = new LinkedList<>();
final LinkedList<Short> durab = new LinkedList<>();
final LinkedList<Integer> amounts = new LinkedList<>();
final LinkedList<Short> 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<ItemStack> 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<String> locs = new LinkedList<>();
final LinkedList<String> 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<String> locs = new LinkedList<>();
final LinkedList<String> 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<Integer> amts = new LinkedList<>(stage.getMobNumToTame());
final LinkedList<Integer> 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<String> colors = new LinkedList<>();
@ -448,9 +448,9 @@ public class QuestFactory implements ConversationAbandonedListener {
colors.add(MiscUtil.getPrettyDyeColorName(d));
}
final LinkedList<Integer> amts = new LinkedList<>(stage.sheepNumToShear);
final LinkedList<Integer> 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<Entry<String, Object>> datamapList = new LinkedList<>(stage.getCustomObjectiveData());
final LinkedList<Entry<String, Object>> 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<String> customReqs = context.getSessionData(CK.REQ_CUSTOM) != null
final LinkedList<String> customRequirements = context.getSessionData(CK.REQ_CUSTOM) != null
? (LinkedList<String>) context.getSessionData(CK.REQ_CUSTOM) : null;
final LinkedList<Map<String, Object>> customReqsData = context.getSessionData(CK.REQ_CUSTOM_DATA) != null
final LinkedList<Map<String, Object>> customRequirementsData = context.getSessionData(CK.REQ_CUSTOM_DATA) != null
? (LinkedList<Map<String, Object>>) 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<String> customObjs = (LinkedList<String>) context.getSessionData(pref + CK.S_CUSTOM_OBJECTIVES);
final LinkedList<String> customObj = (LinkedList<String>) context.getSessionData(pref + CK.S_CUSTOM_OBJECTIVES);
final LinkedList<Integer> customObjCounts
= (LinkedList<Integer>) context.getSessionData(pref + CK.S_CUSTOM_OBJECTIVES_COUNT);
final LinkedList<Entry<String, Object>> customObjsData
final LinkedList<Entry<String, Object>> customObjData
= (LinkedList<Entry<String, Object>>) 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<String, Object> datamap : found.getData()) {
for (final Entry<String, Object> e : customObjsData) {
if (e.getKey().equals(datamap.getKey())) {
for (final Entry<String, Object> dataMap : found.getData()) {
for (final Entry<String, Object> 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<String> customRews = context.getSessionData(CK.REW_CUSTOM) != null
final LinkedList<String> customRewards = context.getSessionData(CK.REW_CUSTOM) != null
? (LinkedList<String>) context.getSessionData(CK.REW_CUSTOM) : null;
final LinkedList<Map<String, Object>> customRewsData = context.getSessionData(CK.REW_CUSTOM_DATA) != null
final LinkedList<Map<String, Object>> customRewardsData = context.getSessionData(CK.REW_CUSTOM_DATA) != null
? (LinkedList<Map<String, Object>>) 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);
}
}

File diff suppressed because it is too large Load Diff

View File

@ -12,27 +12,27 @@
package me.blackvein.quests;
import org.bukkit.inventory.ItemStack;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import org.bukkit.inventory.ItemStack;
public class Requirements {
private int money = 0;
private int questPoints = 0;
private List<ItemStack> items = new LinkedList<ItemStack>();
private List<Boolean> removeItems = new LinkedList<Boolean>();
private List<Quest> neededQuests = new LinkedList<Quest>();
private List<Quest> blockQuests = new LinkedList<Quest>();
private List<String> permissions = new LinkedList<String>();
private List<String> mcmmoSkills = new LinkedList<String>();
private List<Integer> mcmmoAmounts = new LinkedList<Integer>();
private List<ItemStack> items = new LinkedList<>();
private List<Boolean> removeItems = new LinkedList<>();
private List<Quest> neededQuests = new LinkedList<>();
private List<Quest> blockQuests = new LinkedList<>();
private List<String> permissions = new LinkedList<>();
private List<String> mcmmoSkills = new LinkedList<>();
private List<Integer> mcmmoAmounts = new LinkedList<>();
private String heroesPrimaryClass = null;
private String heroesSecondaryClass = null;
private Map<String, Map<String, Object>> customRequirements = new HashMap<String, Map<String, Object>>();
private List<String> detailsOverride = new LinkedList<String>();
private Map<String, Map<String, Object>> customRequirements = new HashMap<>();
private List<String> detailsOverride = new LinkedList<>();
public int getMoney() {
return money;

View File

@ -12,30 +12,30 @@
package me.blackvein.quests;
import org.bukkit.inventory.ItemStack;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import org.bukkit.inventory.ItemStack;
public class Rewards {
private int money = 0;
private int questPoints = 0;
private int exp = 0;
private List<String> commands = new LinkedList<String>();
private List<String> commandsOverrideDisplay = new LinkedList<String>();
private List<String> permissions = new LinkedList<String>();
private List<String> permissionWorlds = new LinkedList<String>();
private List<ItemStack> items = new LinkedList<ItemStack>();
private List<String> mcmmoSkills = new LinkedList<String>();
private List<Integer> mcmmoAmounts = new LinkedList<Integer>();
private List<String> heroesClasses = new LinkedList<String>();
private List<Double> heroesAmounts = new LinkedList<Double>();
private List<String> commands = new LinkedList<>();
private List<String> commandsOverrideDisplay = new LinkedList<>();
private List<String> permissions = new LinkedList<>();
private List<String> permissionWorlds = new LinkedList<>();
private List<ItemStack> items = new LinkedList<>();
private List<String> mcmmoSkills = new LinkedList<>();
private List<Integer> mcmmoAmounts = new LinkedList<>();
private List<String> heroesClasses = new LinkedList<>();
private List<Double> heroesAmounts = new LinkedList<>();
private int partiesExperience = 0;
private List<String> phatLoots = new LinkedList<String>();
private Map<String, Map<String, Object>> customRewards = new HashMap<String, Map<String, Object>>();
private List<String> detailsOverride = new LinkedList<String>();
private List<String> phatLoots = new LinkedList<>();
private Map<String, Map<String, Object>> customRewards = new HashMap<>();
private List<String> detailsOverride = new LinkedList<>();
public int getMoney() {
return money;

View File

@ -17,6 +17,7 @@ import org.bukkit.configuration.file.FileConfiguration;
import java.io.File;
import java.io.IOException;
import java.util.Objects;
public class Settings {
@ -186,7 +187,7 @@ public class Settings {
genFilesOnJoin = config.getBoolean("generate-files-on-join", true);
ignoreLockedQuests = config.getBoolean("ignore-locked-quests", false);
killDelay = config.getInt("kill-delay", 600);
if (config.getString("language").equalsIgnoreCase("en")) {
if (Objects.requireNonNull(config.getString("language")).equalsIgnoreCase("en")) {
//Legacy
Lang.setISO("en-US");
} else {

View File

@ -28,17 +28,17 @@ import java.util.Map.Entry;
public class Stage {
protected LinkedList<ItemStack> blocksToBreak = new LinkedList<ItemStack>();
protected LinkedList<ItemStack> blocksToDamage = new LinkedList<ItemStack>();
protected LinkedList<ItemStack> blocksToPlace = new LinkedList<ItemStack>();
protected LinkedList<ItemStack> blocksToUse = new LinkedList<ItemStack>();
protected LinkedList<ItemStack> blocksToCut = new LinkedList<ItemStack>();
protected LinkedList<ItemStack> itemsToCraft = new LinkedList<ItemStack>();
protected LinkedList<ItemStack> itemsToSmelt = new LinkedList<ItemStack>();
protected LinkedList<ItemStack> itemsToEnchant = new LinkedList<ItemStack>();
protected LinkedList<ItemStack> itemsToBrew = new LinkedList<ItemStack>();
protected LinkedList<ItemStack> itemsToConsume = new LinkedList<ItemStack>();
protected LinkedList<ItemStack> itemsToDeliver = new LinkedList<ItemStack>();
protected LinkedList<ItemStack> blocksToBreak = new LinkedList<>();
protected LinkedList<ItemStack> blocksToDamage = new LinkedList<>();
protected LinkedList<ItemStack> blocksToPlace = new LinkedList<>();
protected LinkedList<ItemStack> blocksToUse = new LinkedList<>();
protected LinkedList<ItemStack> blocksToCut = new LinkedList<>();
protected LinkedList<ItemStack> itemsToCraft = new LinkedList<>();
protected LinkedList<ItemStack> itemsToSmelt = new LinkedList<>();
protected LinkedList<ItemStack> itemsToEnchant = new LinkedList<>();
protected LinkedList<ItemStack> itemsToBrew = new LinkedList<>();
protected LinkedList<ItemStack> itemsToConsume = new LinkedList<>();
protected LinkedList<ItemStack> itemsToDeliver = new LinkedList<>();
protected LinkedList<Integer> itemDeliveryTargets = new LinkedList<Integer>() {
private static final long serialVersionUID = -2774443496142382127L;
@ -59,7 +59,7 @@ public class Stage {
return true;
}
};
protected LinkedList<String> deliverMessages = new LinkedList<String>();
protected LinkedList<String> deliverMessages = new LinkedList<>();
protected LinkedList<Integer> citizensToInteract = new LinkedList<Integer>() {
private static final long serialVersionUID = -4086855121042524435L;
@ -100,43 +100,43 @@ public class Stage {
return true;
}
};
protected LinkedList<Integer> citizenNumToKill = new LinkedList<Integer>();
protected LinkedList<EntityType> mobsToKill = new LinkedList<EntityType>();
protected LinkedList<Integer> mobNumToKill = new LinkedList<Integer>();
protected LinkedList<Location> locationsToKillWithin = new LinkedList<Location>();
protected LinkedList<Integer> radiiToKillWithin = new LinkedList<Integer>();
protected LinkedList<String> killNames = new LinkedList<String>();
protected LinkedList<EntityType> mobsToTame = new LinkedList<EntityType>();
protected LinkedList<Integer> mobNumToTame = new LinkedList<Integer>();
protected LinkedList<Integer> citizenNumToKill = new LinkedList<>();
protected LinkedList<EntityType> mobsToKill = new LinkedList<>();
protected LinkedList<Integer> mobNumToKill = new LinkedList<>();
protected LinkedList<Location> locationsToKillWithin = new LinkedList<>();
protected LinkedList<Integer> radiiToKillWithin = new LinkedList<>();
protected LinkedList<String> killNames = new LinkedList<>();
protected LinkedList<EntityType> mobsToTame = new LinkedList<>();
protected LinkedList<Integer> mobNumToTame = new LinkedList<>();
protected Integer fishToCatch;
protected Integer cowsToMilk;
protected LinkedList<DyeColor> sheepToShear = new LinkedList<DyeColor>();
protected LinkedList<Integer> sheepNumToShear = new LinkedList<Integer>();
protected LinkedList<DyeColor> sheepToShear = new LinkedList<>();
protected LinkedList<Integer> sheepNumToShear = new LinkedList<>();
protected Integer playersToKill;
protected LinkedList<Location> locationsToReach = new LinkedList<Location>();
protected LinkedList<Integer> radiiToReachWithin = new LinkedList<Integer>();
protected LinkedList<World> worldsToReachWithin = new LinkedList<World>();
protected LinkedList<String> locationNames = new LinkedList<String>();
protected LinkedList<String> passwordDisplays = new LinkedList<String>();
protected LinkedList<String> passwordPhrases = new LinkedList<String>();
protected LinkedList<Location> locationsToReach = new LinkedList<>();
protected LinkedList<Integer> radiiToReachWithin = new LinkedList<>();
protected LinkedList<World> worldsToReachWithin = new LinkedList<>();
protected LinkedList<String> locationNames = new LinkedList<>();
protected LinkedList<String> passwordDisplays = new LinkedList<>();
protected LinkedList<String> passwordPhrases = new LinkedList<>();
protected String script;
protected Action startAction = null;
protected Action finishAction = null;
protected Action failAction = null;
protected Action deathAction = null;
protected Map<String, Action> chatActions = new HashMap<String, Action>();
protected Map<String, Action> commandActions = new HashMap<String, Action>();
protected Map<String, Action> chatActions = new HashMap<>();
protected Map<String, Action> commandActions = new HashMap<>();
protected Action disconnectAction = null;
protected Condition condition = null;
protected long delay = -1;
protected String delayMessage = null;
protected String completeMessage = null;
protected String startMessage = null;
protected LinkedList<String> objectiveOverrides = new LinkedList<String>();
protected LinkedList<CustomObjective> customObjectives = new LinkedList<CustomObjective>();
protected LinkedList<Integer> customObjectiveCounts = new LinkedList<Integer>();
protected LinkedList<String> customObjectiveDisplays = new LinkedList<String>();
protected LinkedList<Entry<String, Object>> customObjectiveData = new LinkedList<Entry<String, Object>>();
protected LinkedList<String> objectiveOverrides = new LinkedList<>();
protected LinkedList<CustomObjective> customObjectives = new LinkedList<>();
protected LinkedList<Integer> customObjectiveCounts = new LinkedList<>();
protected LinkedList<String> customObjectiveDisplays = new LinkedList<>();
protected LinkedList<Entry<String, Object>> customObjectiveData = new LinkedList<>();
public LinkedList<ItemStack> getBlocksToBreak() {
return blocksToBreak;
@ -566,8 +566,7 @@ public class Stage {
if (!mobsToTame.isEmpty()) { return true; }
if (!sheepToShear.isEmpty()) { return true; }
if (!passwordDisplays.isEmpty()) { return true; }
if (!customObjectives.isEmpty()) { return true; }
return false;
return !customObjectives.isEmpty();
}
/**

View File

@ -23,7 +23,7 @@ import java.util.Map;
public class ParticleProvider_v1_8_R1 extends ParticleProvider {
private static Map<PreBuiltParticle, Object> PARTICLES = new HashMap<>();
private static final Map<PreBuiltParticle, Object> PARTICLES = new HashMap<>();
static {
PARTICLES.put(PreBuiltParticle.ENCHANT, EnumParticle.ENCHANTMENT_TABLE);

View File

@ -12,19 +12,18 @@
package me.blackvein.quests.particle;
import java.util.HashMap;
import java.util.Map;
import net.minecraft.server.v1_8_R2.EnumParticle;
import net.minecraft.server.v1_8_R2.PacketPlayOutWorldParticles;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_8_R2.entity.CraftPlayer;
import org.bukkit.entity.Player;
import net.minecraft.server.v1_8_R2.EnumParticle;
import net.minecraft.server.v1_8_R2.PacketPlayOutWorldParticles;
import java.util.HashMap;
import java.util.Map;
public class ParticleProvider_v1_8_R2 extends ParticleProvider {
private static Map<PreBuiltParticle, Object> PARTICLES = new HashMap<>();
private static final Map<PreBuiltParticle, Object> PARTICLES = new HashMap<>();
static {
PARTICLES.put(PreBuiltParticle.ENCHANT, EnumParticle.ENCHANTMENT_TABLE);

View File

@ -12,19 +12,18 @@
package me.blackvein.quests.particle;
import java.util.HashMap;
import java.util.Map;
import net.minecraft.server.v1_8_R3.EnumParticle;
import net.minecraft.server.v1_8_R3.PacketPlayOutWorldParticles;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
import org.bukkit.entity.Player;
import net.minecraft.server.v1_8_R3.EnumParticle;
import net.minecraft.server.v1_8_R3.PacketPlayOutWorldParticles;
import java.util.HashMap;
import java.util.Map;
public class ParticleProvider_v1_8_R3 extends ParticleProvider {
private static Map<PreBuiltParticle, Object> PARTICLES = new HashMap<>();
private static final Map<PreBuiltParticle, Object> PARTICLES = new HashMap<>();
static {
PARTICLES.put(PreBuiltParticle.ENCHANT, EnumParticle.ENCHANTMENT_TABLE);