Refactoring for getter/setter methods, part 2

This commit is contained in:
BuildTools 2019-01-03 16:31:34 -05:00
parent 3d2c9b1e9d
commit 8a3b67d735
10 changed files with 284 additions and 175 deletions

View File

@ -0,0 +1,33 @@
package me.blackvein.quests;
public class Planner {
public String start = null;
public String end = null;
public long repeat = -1;
public long cooldown = -1;
public String getStart() {
return start;
}
public void setStart(String start) {
this.start = start;
}
public String getEnd() {
return end;
}
public void setEnd(String end) {
this.end = end;
}
public long getRepeat() {
return repeat;
}
public void setRepeat(long repeat) {
this.repeat = repeat;
}
public long getCooldown() {
return cooldown;
}
public void setCooldown(long cooldown) {
this.cooldown = cooldown;
}
}

View File

@ -12,10 +12,8 @@
package me.blackvein.quests; package me.blackvein.quests;
import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
@ -56,31 +54,22 @@ public class Quest {
protected NPC npcStart; protected NPC npcStart;
protected Location blockStart; protected Location blockStart;
protected Event initialEvent; protected Event initialEvent;
// Planner
public String startPlanner = null;
public String endPlanner = null;
public long repeatPlanner = -1;
public long cooldownPlanner = -1;
// Rewards
int moneyReward = 0;
int questPoints = 0;
int exp = 0;
List<String> commands = new LinkedList<String>();
List<String> permissions = new LinkedList<String>();
LinkedList<ItemStack> itemRewards = new LinkedList<ItemStack>();
List<String> mcmmoSkills = new LinkedList<String>();
List<Integer> mcmmoAmounts = new LinkedList<Integer>();
List<String> heroesClasses = new LinkedList<String>();
List<Double> heroesAmounts = new LinkedList<Double>();
List<String> phatLootRewards = new LinkedList<String>();
Map<String, Map<String, Object>> customRewards = new HashMap<String, Map<String, Object>>();
private Requirements reqs = new Requirements(); private Requirements reqs = new Requirements();
private Planner pln = new Planner();
private Rewards rews = new Rewards();
public Requirements getRequirements() { public Requirements getRequirements() {
return reqs; return reqs;
} }
public Planner getPlanner() {
return pln;
}
public Rewards getRewards() {
return rews;
}
public String getName() { public String getName() {
return name; return name;
} }
@ -413,11 +402,11 @@ public class Quest {
} }
} }
}, 40); }, 40);
if (moneyReward > 0 && Quests.economy != null) { if (rews.getMoney() > 0 && Quests.economy != null) {
Quests.economy.depositPlayer(q.getOfflinePlayer(), moneyReward); Quests.economy.depositPlayer(q.getOfflinePlayer(), rews.getMoney());
none = null; none = null;
} }
if (cooldownPlanner > -1) { if (pln.getCooldown() > -1) {
q.completedTimes.put(this.name, System.currentTimeMillis()); q.completedTimes.put(this.name, System.currentTimeMillis());
if (q.amountsCompleted.containsKey(this.name)) { if (q.amountsCompleted.containsKey(this.name)) {
q.amountsCompleted.put(this.name, q.amountsCompleted.get(this.name) + 1); q.amountsCompleted.put(this.name, q.amountsCompleted.get(this.name) + 1);
@ -425,7 +414,7 @@ public class Quest {
q.amountsCompleted.put(this.name, 1); q.amountsCompleted.put(this.name, 1);
} }
} }
for (ItemStack i : itemRewards) { for (ItemStack i : rews.getItems()) {
try { try {
Quests.addItem(player, i); Quests.addItem(player, i);
} catch (Exception e) { } catch (Exception e) {
@ -436,7 +425,7 @@ public class Quest {
} }
none = null; none = null;
} }
for (String s : commands) { for (String s : rews.getCommands()) {
final String command = s.replace("<player>", player.getName()); final String command = s.replace("<player>", player.getName());
if (Bukkit.isPrimaryThread()) { if (Bukkit.isPrimaryThread()) {
Bukkit.getServer().dispatchCommand(plugin.getServer().getConsoleSender(), command); Bukkit.getServer().dispatchCommand(plugin.getServer().getConsoleSender(), command);
@ -451,25 +440,25 @@ public class Quest {
} }
none = null; none = null;
} }
for (String s : permissions) { for (String s : rews.getPermissions()) {
if (Quests.permission != null) { if (Quests.permission != null) {
Quests.permission.playerAdd(player, s); Quests.permission.playerAdd(player, s);
} }
none = null; none = null;
} }
for (String s : mcmmoSkills) { for (String s : rews.getMcmmoSkills()) {
UserManager.getPlayer(player).getProfile().addLevels(Quests.getMcMMOSkill(s), mcmmoAmounts.get(mcmmoSkills.indexOf(s))); UserManager.getPlayer(player).getProfile().addLevels(Quests.getMcMMOSkill(s), rews.getMcmmoAmounts().get(rews.getMcmmoSkills().indexOf(s)));
none = null; none = null;
} }
for (String s : heroesClasses) { for (String s : rews.getHeroesClasses()) {
Hero hero = plugin.getHero(player.getUniqueId()); Hero hero = plugin.getHero(player.getUniqueId());
hero.addExp(heroesAmounts.get(heroesClasses.indexOf(s)), Quests.heroes.getClassManager().getClass(s), player.getLocation()); hero.addExp(rews.getHeroesAmounts().get(rews.getHeroesClasses().indexOf(s)), Quests.heroes.getClassManager().getClass(s), player.getLocation());
none = null; none = null;
} }
LinkedList<ItemStack> phatLootItems = new LinkedList<ItemStack>(); LinkedList<ItemStack> phatLootItems = new LinkedList<ItemStack>();
int phatLootExp = 0; int phatLootExp = 0;
LinkedList<String> phatLootMessages = new LinkedList<String>(); LinkedList<String> phatLootMessages = new LinkedList<String>();
for (String s : phatLootRewards) { for (String s : rews.getPhatLoots()) {
LootBundle lb = PhatLootsAPI.getPhatLoot(s).rollForLoot(); LootBundle lb = PhatLootsAPI.getPhatLoot(s).rollForLoot();
if (lb.getExp() > 0) { if (lb.getExp() > 0) {
phatLootExp += lb.getExp(); phatLootExp += lb.getExp();
@ -502,8 +491,8 @@ public class Quest {
phatLootMessages.addAll(lb.getMessageList()); phatLootMessages.addAll(lb.getMessageList());
} }
} }
if (exp > 0) { if (rews.getExp() > 0) {
player.giveExp(exp); player.giveExp(rews.getExp());
none = null; none = null;
} }
String complete = Lang.get(player, "questCompleteTitle"); String complete = Lang.get(player, "questCompleteTitle");
@ -516,12 +505,12 @@ public class Quest {
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "title " + player.getName() Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "title " + player.getName()
+ " subtitle " + "{\"text\":\"" + name + "\",\"color\":\"yellow\"}"); + " subtitle " + "{\"text\":\"" + name + "\",\"color\":\"yellow\"}");
} }
if (questPoints > 0) { if (rews.getQuestPoints() > 0) {
player.sendMessage("- " + ChatColor.DARK_GREEN + questPoints + " " + Lang.get(player, "questPoints")); player.sendMessage("- " + ChatColor.DARK_GREEN + rews.getQuestPoints() + " " + Lang.get(player, "questPoints"));
q.questPoints += questPoints; q.questPoints += rews.getQuestPoints();
none = null; none = null;
} }
for (ItemStack i : itemRewards) { for (ItemStack i : rews.getItems()) {
String text = "error"; String text = "error";
if (i.hasItemMeta() && i.getItemMeta().hasDisplayName()) { if (i.hasItemMeta() && i.getItemMeta().hasDisplayName()) {
if (i.getEnchantments().isEmpty()) { if (i.getEnchantments().isEmpty()) {
@ -585,27 +574,27 @@ public class Quest {
} }
none = null; none = null;
} }
if (moneyReward > 1) { if (rews.getMoney() > 1) {
player.sendMessage("- " + ChatColor.DARK_GREEN + moneyReward + " " + ChatColor.DARK_PURPLE + Quests.getCurrency(true)); player.sendMessage("- " + ChatColor.DARK_GREEN + rews.getMoney() + " " + ChatColor.DARK_PURPLE + Quests.getCurrency(true));
none = null; none = null;
} else if (moneyReward == 1) { } else if (rews.getMoney() == 1) {
player.sendMessage("- " + ChatColor.DARK_GREEN + moneyReward + " " + ChatColor.DARK_PURPLE + Quests.getCurrency(false)); player.sendMessage("- " + ChatColor.DARK_GREEN + rews.getMoney() + " " + ChatColor.DARK_PURPLE + Quests.getCurrency(false));
none = null; none = null;
} }
if (exp > 0 || phatLootExp > 0) { if (rews.getExp() > 0 || phatLootExp > 0) {
int tot = exp + phatLootExp; int tot = rews.getExp() + phatLootExp;
player.sendMessage("- " + ChatColor.DARK_GREEN + tot + ChatColor.DARK_PURPLE + " " + Lang.get(player, "experience")); player.sendMessage("- " + ChatColor.DARK_GREEN + tot + ChatColor.DARK_PURPLE + " " + Lang.get(player, "experience"));
none = null; none = null;
} }
if (mcmmoSkills.isEmpty() == false) { if (rews.getMcmmoSkills().isEmpty() == false) {
for (String s : mcmmoSkills) { for (String s : rews.getMcmmoSkills()) {
player.sendMessage("- " + ChatColor.DARK_GREEN + mcmmoAmounts.get(mcmmoSkills.indexOf(s)) + " " + ChatColor.DARK_PURPLE + s + " " + Lang.get(player, "experience")); player.sendMessage("- " + ChatColor.DARK_GREEN + rews.getMcmmoAmounts().get(rews.getMcmmoSkills().indexOf(s)) + " " + ChatColor.DARK_PURPLE + s + " " + Lang.get(player, "experience"));
} }
none = null; none = null;
} }
if (heroesClasses.isEmpty() == false) { if (rews.getHeroesClasses().isEmpty() == false) {
for (String s : heroesClasses) { for (String s : rews.getHeroesClasses()) {
player.sendMessage("- " + ChatColor.AQUA + heroesAmounts.get(heroesClasses.indexOf(s)) + " " + ChatColor.BLUE + s + " " + Lang.get(player, "experience")); player.sendMessage("- " + ChatColor.AQUA + rews.getHeroesAmounts().get(rews.getHeroesClasses().indexOf(s)) + " " + ChatColor.BLUE + s + " " + Lang.get(player, "experience"));
} }
none = null; none = null;
} }
@ -615,7 +604,7 @@ public class Quest {
} }
none = null; none = null;
} }
for (String s : customRewards.keySet()) { for (String s : rews.getCustomRewards().keySet()) {
CustomReward found = null; CustomReward found = null;
for (CustomReward cr : plugin.customRewards) { for (CustomReward cr : plugin.customRewards) {
if (cr.getName().equalsIgnoreCase(s)) { if (cr.getName().equalsIgnoreCase(s)) {
@ -624,7 +613,7 @@ public class Quest {
} }
} }
if (found != null) { if (found != null) {
Map<String, Object> datamap = customRewards.get(found.getName()); Map<String, Object> datamap = rews.getCustomRewards().get(found.getName());
String message = found.getRewardName(); String message = found.getRewardName();
if (message != null) { if (message != null) {
for (String key : datamap.keySet()) { for (String key : datamap.keySet()) {
@ -634,7 +623,7 @@ public class Quest {
} else { } else {
plugin.getLogger().warning("Failed to notify player: Custom Reward does not have an assigned name"); plugin.getLogger().warning("Failed to notify player: Custom Reward does not have an assigned name");
} }
found.giveReward(player, customRewards.get(s)); found.giveReward(player, rews.getCustomRewards().get(s));
} else { } else {
plugin.getLogger().warning("Quester \"" + player.getName() + "\" completed the Quest \"" + name + "\", but the Custom Reward \"" + s + "\" could not be found. Does it still exist?"); plugin.getLogger().warning("Quester \"" + player.getName() + "\" completed the Quest \"" + name + "\", but the Custom Reward \"" + s + "\" could not be found. Does it still exist?");
} }

View File

@ -1312,7 +1312,6 @@ public class QuestFactory implements ConversationAbandonedListener {
if (q.guiDisplay != null) { if (q.guiDisplay != null) {
cc.setSessionData(CK.Q_GUIDISPLAY, q.guiDisplay); cc.setSessionData(CK.Q_GUIDISPLAY, q.guiDisplay);
} }
// Requirements
Requirements reqs = q.getRequirements(); Requirements reqs = q.getRequirements();
if (reqs.getMoney() != 0) { if (reqs.getMoney() != 0) {
cc.setSessionData(CK.REQ_MONEY, reqs.getMoney()); cc.setSessionData(CK.REQ_MONEY, reqs.getMoney());
@ -1356,58 +1355,52 @@ public class QuestFactory implements ConversationAbandonedListener {
cc.setSessionData(CK.REQ_CUSTOM, list); cc.setSessionData(CK.REQ_CUSTOM, list);
cc.setSessionData(CK.REQ_CUSTOM_DATA, datamapList); cc.setSessionData(CK.REQ_CUSTOM_DATA, datamapList);
} }
// Rewards rews = q.getRewards();
// Rewards if (rews.getMoney() != 0) {
if (q.moneyReward != 0) { cc.setSessionData(CK.REW_MONEY, rews.getMoney());
cc.setSessionData(CK.REW_MONEY, q.moneyReward);
} }
if (q.questPoints != 0) { if (rews.getQuestPoints() != 0) {
cc.setSessionData(CK.REW_QUEST_POINTS, q.questPoints); cc.setSessionData(CK.REW_QUEST_POINTS, rews.getQuestPoints());
} }
if (q.exp != 0) { if (rews.getExp() != 0) {
cc.setSessionData(CK.REW_EXP, q.exp); cc.setSessionData(CK.REW_EXP, rews.getExp());
} }
if (q.itemRewards.isEmpty() == false) { if (rews.getItems().isEmpty() == false) {
cc.setSessionData(CK.REW_ITEMS, q.itemRewards); cc.setSessionData(CK.REW_ITEMS, reqs.getItems());
} }
if (q.commands.isEmpty() == false) { if (rews.getCommands().isEmpty() == false) {
cc.setSessionData(CK.REW_COMMAND, q.commands); cc.setSessionData(CK.REW_COMMAND, rews.getCommands());
} }
if (q.permissions.isEmpty() == false) { if (rews.getPermissions().isEmpty() == false) {
cc.setSessionData(CK.REW_PERMISSION, q.permissions); cc.setSessionData(CK.REW_PERMISSION, rews.getPermissions());
} }
if (q.mcmmoSkills.isEmpty() == false) { if (rews.getMcmmoSkills().isEmpty() == false) {
cc.setSessionData(CK.REW_MCMMO_SKILLS, q.mcmmoSkills); cc.setSessionData(CK.REW_MCMMO_SKILLS, rews.getMcmmoSkills());
cc.setSessionData(CK.REW_MCMMO_AMOUNTS, q.mcmmoAmounts); cc.setSessionData(CK.REW_MCMMO_AMOUNTS, rews.getMcmmoAmounts());
} }
if (q.heroesClasses.isEmpty() == false) { if (rews.getHeroesClasses().isEmpty() == false) {
cc.setSessionData(CK.REW_HEROES_CLASSES, q.heroesClasses); cc.setSessionData(CK.REW_HEROES_CLASSES, rews.getHeroesClasses());
cc.setSessionData(CK.REW_HEROES_AMOUNTS, q.heroesAmounts); cc.setSessionData(CK.REW_HEROES_AMOUNTS, rews.getHeroesAmounts());
} }
if (q.heroesClasses.isEmpty() == false) { if (rews.getPhatLoots().isEmpty() == false) {
cc.setSessionData(CK.REW_HEROES_CLASSES, q.heroesClasses); cc.setSessionData(CK.REW_PHAT_LOOTS, rews.getPhatLoots());
cc.setSessionData(CK.REW_HEROES_AMOUNTS, q.heroesAmounts);
} }
if (q.phatLootRewards.isEmpty() == false) { if (rews.getCustomRewards().isEmpty() == false) {
cc.setSessionData(CK.REW_PHAT_LOOTS, q.phatLootRewards); cc.setSessionData(CK.REW_CUSTOM, new LinkedList<String>(rews.getCustomRewards().keySet()));
cc.setSessionData(CK.REW_CUSTOM_DATA, new LinkedList<Object>(rews.getCustomRewards().values()));
} }
if (q.customRewards.isEmpty() == false) { Planner pln = q.getPlanner();
cc.setSessionData(CK.REW_CUSTOM, new LinkedList<String>(q.customRewards.keySet())); if (pln.getStart() != null) {
cc.setSessionData(CK.REW_CUSTOM_DATA, new LinkedList<Object>(q.customRewards.values())); cc.setSessionData(CK.PLN_START_DATE, pln.getStart());
} }
// if (pln.getEnd() != null) {
//Planner cc.setSessionData(CK.PLN_END_DATE, pln.getEnd());
if (q.startPlanner != null) {
cc.setSessionData(CK.PLN_START_DATE, q.startPlanner);
} }
if (q.endPlanner != null) { if (pln.getRepeat() != -1) {
cc.setSessionData(CK.PLN_END_DATE, q.endPlanner); cc.setSessionData(CK.PLN_REPEAT_CYCLE, pln.getRepeat());
} }
if (q.repeatPlanner != -1) { if (pln.getCooldown() != -1) {
cc.setSessionData(CK.PLN_REPEAT_CYCLE, q.repeatPlanner); cc.setSessionData(CK.PLN_COOLDOWN, pln.getCooldown());
}
if (q.cooldownPlanner != -1) {
cc.setSessionData(CK.PLN_COOLDOWN, q.cooldownPlanner);
} }
// //
// Stages // Stages

View File

@ -315,28 +315,29 @@ public class Quester {
return; return;
} }
Player player = getPlayer(); Player player = getPlayer();
Planner pln = q.getPlanner();
long start = -1; long start = -1;
long end = -1; long end = -1;
if (q.startPlanner != null) { if (pln.getStart() != null) {
Calendar cal = Calendar.getInstance(); Calendar cal = Calendar.getInstance();
String[] s = q.startPlanner.split(":"); String[] s = pln.getStart().split(":");
cal.set(Integer.valueOf(s[2]), Integer.valueOf(s[1]), Integer.valueOf(s[0]), 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])); Integer.valueOf(s[3]), Integer.valueOf(s[4]), Integer.valueOf(s[5]));
start = cal.getTimeInMillis(); start = cal.getTimeInMillis();
} }
if (q.endPlanner != null) { if (pln.getEnd() != null) {
Calendar cal = Calendar.getInstance(); Calendar cal = Calendar.getInstance();
String[] s = q.endPlanner.split(":"); String[] s = pln.getEnd().split(":");
cal.set(Integer.valueOf(s[2]), Integer.valueOf(s[1]), Integer.valueOf(s[0]), 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])); Integer.valueOf(s[3]), Integer.valueOf(s[4]), Integer.valueOf(s[5]));
end = cal.getTimeInMillis(); end = cal.getTimeInMillis();
} }
if (start > -1 && end > -1) { if (start > -1 && end > -1) {
if (q.repeatPlanner > -1) { if (pln.getRepeat() > -1) {
long questLength = end - start; long questLength = end - start;
long nextStart = start; long nextStart = start;
while (System.currentTimeMillis() >= nextStart) { while (System.currentTimeMillis() >= nextStart) {
nextStart += questLength + q.repeatPlanner; nextStart += questLength + pln.getRepeat();
} }
long nextEnd = nextStart + questLength; long nextEnd = nextStart + questLength;
if (System.currentTimeMillis() < nextStart) { if (System.currentTimeMillis() < nextStart) {
@ -361,7 +362,7 @@ public class Quester {
} }
} }
} }
if (q.startPlanner != null) { if (pln.getStart() != null) {
if (System.currentTimeMillis() < start) { if (System.currentTimeMillis() < start) {
String early = Lang.get("plnTooEarly"); String early = Lang.get("plnTooEarly");
early = early.replace("<quest>", ChatColor.AQUA + q.getName() + ChatColor.YELLOW); early = early.replace("<quest>", ChatColor.AQUA + q.getName() + ChatColor.YELLOW);
@ -372,7 +373,7 @@ public class Quester {
} }
} }
//TODO - should this even be reported? //TODO - should this even be reported?
if (q.endPlanner != null) { if (pln.getEnd() != null) {
if (System.currentTimeMillis() > end) { if (System.currentTimeMillis() > end) {
String late = Lang.get("plnTooLate"); String late = Lang.get("plnTooLate");
late = late.replace("<quest>", ChatColor.AQUA + q.getName() + ChatColor.RED); late = late.replace("<quest>", ChatColor.AQUA + q.getName() + ChatColor.RED);
@ -1761,7 +1762,7 @@ public class Quester {
} }
} }
public long getDifference(Quest q) { public long getCooldownDifference(Quest q) {
long currentTime = System.currentTimeMillis(); long currentTime = System.currentTimeMillis();
long lastTime; long lastTime;
if (completedTimes.containsKey(q.getName()) == false) { if (completedTimes.containsKey(q.getName()) == false) {
@ -1770,7 +1771,7 @@ public class Quester {
} else { } else {
lastTime = completedTimes.get(q.getName()); lastTime = completedTimes.get(q.getName());
} }
long comparator = q.cooldownPlanner; long comparator = q.getPlanner().getCooldown();
long difference = (comparator - (currentTime - lastTime)); long difference = (comparator - (currentTime - lastTime));
return difference; return difference;
} }

View File

@ -93,9 +93,9 @@ import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
import com.sk89q.worldguard.protection.managers.RegionManager; import com.sk89q.worldguard.protection.managers.RegionManager;
import com.sk89q.worldguard.protection.regions.ProtectedRegion; import com.sk89q.worldguard.protection.regions.ProtectedRegion;
import me.blackvein.listeners.NpcListener;
import me.blackvein.listeners.PlayerListener;
import me.blackvein.quests.exceptions.InvalidStageException; import me.blackvein.quests.exceptions.InvalidStageException;
import me.blackvein.quests.listeners.NpcListener;
import me.blackvein.quests.listeners.PlayerListener;
import me.blackvein.quests.prompts.QuestAcceptPrompt; import me.blackvein.quests.prompts.QuestAcceptPrompt;
import me.blackvein.quests.util.ItemUtil; import me.blackvein.quests.util.ItemUtil;
import me.blackvein.quests.util.Lang; import me.blackvein.quests.util.Lang;
@ -1617,7 +1617,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
} else if (quester.currentQuests.containsKey(q)) { } else if (quester.currentQuests.containsKey(q)) {
String msg = Lang.get(player, "questAlreadyOn"); String msg = Lang.get(player, "questAlreadyOn");
player.sendMessage(ChatColor.YELLOW + msg); player.sendMessage(ChatColor.YELLOW + msg);
} else if (quester.completedQuests.contains(q.getName()) && q.cooldownPlanner < 0) { } else if (quester.completedQuests.contains(q.getName()) && q.getPlanner().getCooldown() < 0) {
String msg = Lang.get(player, "questAlreadyCompleted"); String msg = Lang.get(player, "questAlreadyCompleted");
msg = msg.replace("<quest>", ChatColor.DARK_PURPLE + q.getName() + ChatColor.YELLOW); msg = msg.replace("<quest>", ChatColor.DARK_PURPLE + q.getName() + ChatColor.YELLOW);
player.sendMessage(ChatColor.YELLOW + msg); player.sendMessage(ChatColor.YELLOW + msg);
@ -1632,10 +1632,10 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
} else { } else {
boolean takeable = true; boolean takeable = true;
if (quester.completedQuests.contains(q.getName())) { if (quester.completedQuests.contains(q.getName())) {
if (quester.getDifference(q) > 0) { if (quester.getCooldownDifference(q) > 0) {
String early = Lang.get(player, "questTooEarly"); String early = Lang.get(player, "questTooEarly");
early = early.replace("<quest>", ChatColor.AQUA + q.getName() + ChatColor.YELLOW); early = early.replace("<quest>", ChatColor.AQUA + q.getName() + ChatColor.YELLOW);
early = early.replace("<time>", ChatColor.DARK_PURPLE + Quests.getTime(quester.getDifference(q)) + ChatColor.YELLOW); early = early.replace("<time>", ChatColor.DARK_PURPLE + Quests.getTime(quester.getCooldownDifference(q)) + ChatColor.YELLOW);
player.sendMessage(ChatColor.YELLOW + early); player.sendMessage(ChatColor.YELLOW + early);
takeable = false; takeable = false;
} }
@ -2289,7 +2289,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
if (config.contains("quests." + questName + ".redo-delay")) { if (config.contains("quests." + questName + ".redo-delay")) {
//Legacy //Legacy
if (config.getInt("quests." + questName + ".redo-delay", -999) != -999) { if (config.getInt("quests." + questName + ".redo-delay", -999) != -999) {
quest.cooldownPlanner = config.getInt("quests." + questName + ".redo-delay") * 1000; quest.getPlanner().setCooldown(config.getInt("quests." + questName + ".redo-delay") * 1000);
} else { } else {
skipQuestProcess("redo-delay: for Quest " + quest.getName() + " is not a number!"); skipQuestProcess("redo-delay: for Quest " + quest.getName() + " is not a number!");
} }
@ -2320,7 +2320,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
} }
quest.plugin = this; quest.plugin = this;
processStages(quest, config, questName); // needsSaving may be modified as a side-effect processStages(quest, config, questName); // needsSaving may be modified as a side-effect
loadRewards(config); loadQuestRewards(config);
quests.add(quest); quests.add(quest);
if (needsSaving) { if (needsSaving) {
try { try {
@ -2344,56 +2344,57 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
} }
} }
private void loadRewards(FileConfiguration config) throws SkipQuest { private void loadQuestRewards(FileConfiguration config) throws SkipQuest {
Rewards rews = quest.getRewards();
if (config.contains("quests." + questName + ".rewards.items")) { if (config.contains("quests." + questName + ".rewards.items")) {
if (Quests.checkList(config.getList("quests." + questName + ".rewards.items"), String.class)) { if (Quests.checkList(config.getList("quests." + questName + ".rewards.items"), String.class)) {
LinkedList<ItemStack> temp = new LinkedList<ItemStack>();
for (String item : config.getStringList("quests." + questName + ".rewards.items")) { for (String item : config.getStringList("quests." + questName + ".rewards.items")) {
try { try {
ItemStack stack = ItemUtil.readItemStack(item); ItemStack stack = ItemUtil.readItemStack(item);
if (stack != null) { if (stack != null) {
quest.itemRewards.add(stack); temp.add(stack);
} }
} catch (Exception e) { } catch (Exception e) {
skipQuestProcess("" + item + " in items: Reward in Quest " + quest.getName() + " is not properly formatted!"); skipQuestProcess("" + item + " in items: Reward in Quest " + quest.getName() + " is not properly formatted!");
} }
} }
rews.setItems(temp);
} else { } else {
skipQuestProcess("items: Reward in Quest " + quest.getName() + " is not a list of strings!"); skipQuestProcess("items: Reward in Quest " + quest.getName() + " is not a list of strings!");
} }
} }
if (config.contains("quests." + questName + ".rewards.money")) { if (config.contains("quests." + questName + ".rewards.money")) {
if (config.getInt("quests." + questName + ".rewards.money", -999) != -999) { if (config.getInt("quests." + questName + ".rewards.money", -999) != -999) {
quest.moneyReward = config.getInt("quests." + questName + ".rewards.money"); rews.setMoney(config.getInt("quests." + questName + ".rewards.money"));
} else { } else {
skipQuestProcess("money: Reward in Quest " + quest.getName() + " is not a number!"); skipQuestProcess("money: Reward in Quest " + quest.getName() + " is not a number!");
} }
} }
if (config.contains("quests." + questName + ".rewards.exp")) { if (config.contains("quests." + questName + ".rewards.exp")) {
if (config.getInt("quests." + questName + ".rewards.exp", -999) != -999) { if (config.getInt("quests." + questName + ".rewards.exp", -999) != -999) {
quest.exp = config.getInt("quests." + questName + ".rewards.exp"); rews.setExp(config.getInt("quests." + questName + ".rewards.exp"));
} else { } else {
skipQuestProcess("exp: Reward in Quest " + quest.getName() + " is not a number!"); skipQuestProcess("exp: Reward in Quest " + quest.getName() + " is not a number!");
} }
} }
if (config.contains("quests." + questName + ".rewards.commands")) { if (config.contains("quests." + questName + ".rewards.commands")) {
if (Quests.checkList(config.getList("quests." + questName + ".rewards.commands"), String.class)) { if (Quests.checkList(config.getList("quests." + questName + ".rewards.commands"), String.class)) {
quest.commands.clear(); rews.setCommands(config.getStringList("quests." + questName + ".rewards.commands"));
quest.commands.addAll(config.getStringList("quests." + questName + ".rewards.commands"));
} else { } else {
skipQuestProcess("commands: Reward in Quest " + quest.getName() + " is not a list of commands!"); skipQuestProcess("commands: Reward in Quest " + quest.getName() + " is not a list of commands!");
} }
} }
if (config.contains("quests." + questName + ".rewards.permissions")) { if (config.contains("quests." + questName + ".rewards.permissions")) {
if (Quests.checkList(config.getList("quests." + questName + ".rewards.permissions"), String.class)) { if (Quests.checkList(config.getList("quests." + questName + ".rewards.permissions"), String.class)) {
quest.permissions.clear(); rews.setPermissions(config.getStringList("quests." + questName + ".rewards.permissions"));
quest.permissions.addAll(config.getStringList("quests." + questName + ".rewards.permissions"));
} else { } else {
skipQuestProcess("permissions: Reward in Quest " + quest.getName() + " is not a list of permissions!"); skipQuestProcess("permissions: Reward in Quest " + quest.getName() + " is not a list of permissions!");
} }
} }
if (config.contains("quests." + questName + ".rewards.quest-points")) { if (config.contains("quests." + questName + ".rewards.quest-points")) {
if (config.getInt("quests." + questName + ".rewards.quest-points", -999) != -999) { if (config.getInt("quests." + questName + ".rewards.quest-points", -999) != -999) {
quest.questPoints = config.getInt("quests." + questName + ".rewards.quest-points"); rews.setQuestPoints(config.getInt("quests." + questName + ".rewards.quest-points"));
} else { } else {
skipQuestProcess("quest-points: Reward in Quest " + quest.getName() + " is not a number!"); skipQuestProcess("quest-points: Reward in Quest " + quest.getName() + " is not a number!");
} }
@ -2410,10 +2411,8 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
skipQuestProcess("" + skill + " in mcmmo-skills: Reward in Quest " + quest.getName() + " is not a valid mcMMO skill name!"); skipQuestProcess("" + skill + " in mcmmo-skills: Reward in Quest " + quest.getName() + " is not a valid mcMMO skill name!");
} }
} }
quest.mcmmoSkills.clear(); rews.setMcmmoSkills(config.getStringList("quests." + questName + ".rewards.mcmmo-skills"));
quest.mcmmoAmounts.clear(); rews.setMcmmoAmounts(config.getIntegerList("quests." + questName + ".rewards.mcmmo-levels"));
quest.mcmmoSkills.addAll(config.getStringList("quests." + questName + ".rewards.mcmmo-skills"));
quest.mcmmoAmounts.addAll(config.getIntegerList("quests." + questName + ".rewards.mcmmo-levels"));
} else { } else {
skipQuestProcess("mcmmo-levels: Reward in Quest " + quest.getName() + " is not a list of numbers!"); skipQuestProcess("mcmmo-levels: Reward in Quest " + quest.getName() + " is not a list of numbers!");
} }
@ -2437,10 +2436,8 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
skipQuestProcess("" + heroClass + " in heroes-exp-classes: Reward in Quest " + quest.getName() + " is not a valid Heroes class name!"); skipQuestProcess("" + heroClass + " in heroes-exp-classes: Reward in Quest " + quest.getName() + " is not a valid Heroes class name!");
} }
} }
quest.heroesClasses.clear(); rews.setHeroesClasses(config.getStringList("quests." + questName + ".rewards.heroes-exp-classes"));
quest.heroesAmounts.clear(); rews.setHeroesAmounts(config.getDoubleList("quests." + questName + ".rewards.heroes-exp-amounts"));
quest.heroesClasses.addAll(config.getStringList("quests." + questName + ".rewards.heroes-exp-classes"));
quest.heroesAmounts.addAll(config.getDoubleList("quests." + questName + ".rewards.heroes-exp-amounts"));
} else { } else {
skipQuestProcess("heroes-exp-amounts: Reward in Quest " + quest.getName() + " is not a list of experience amounts (decimal numbers)!"); skipQuestProcess("heroes-exp-amounts: Reward in Quest " + quest.getName() + " is not a list of experience amounts (decimal numbers)!");
} }
@ -2462,15 +2459,34 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
skipQuestProcess("" + loot + " in phat-loots: Reward in Quest " + quest.getName() + " is not a valid PhatLoot name!"); skipQuestProcess("" + loot + " in phat-loots: Reward in Quest " + quest.getName() + " is not a valid PhatLoot name!");
} }
} }
quest.phatLootRewards.clear(); rews.setPhatLoots(config.getStringList("quests." + questName + ".rewards.phat-loots"));
quest.phatLootRewards.addAll(config.getStringList("quests." + questName + ".rewards.phat-loots"));
} else { } else {
skipQuestProcess("phat-loots: Reward in Quest " + quest.getName() + " is not a list of PhatLoots!"); skipQuestProcess("phat-loots: Reward in Quest " + quest.getName() + " is not a list of PhatLoots!");
} }
} }
} }
if (config.contains("quests." + questName + ".rewards.custom-rewards")) { if (config.contains("quests." + questName + ".rewards.custom-rewards")) {
populateCustomRewards(config); ConfigurationSection sec = config.getConfigurationSection("quests." + questName + ".rewards.custom-rewards");
Map<String, Map<String, Object>> temp = new HashMap<String, Map<String, Object>>();
for (String path : sec.getKeys(false)) {
String name = sec.getString(path + ".name");
Optional<CustomReward>found = Optional.empty();
for (CustomReward cr : customRewards) {
if (cr.getName().equalsIgnoreCase(name)) {
found=Optional.of(cr);
break;
}
}
if (!found.isPresent()) {
getLogger().warning("Custom reward \"" + name + "\" for Quest \"" + quest.getName() + "\" could not be found!");
continue;
} else {
ConfigurationSection sec2 = sec.getConfigurationSection(path + ".data");
Map<String, Object> data=populateCustoms(sec2,found.get().datamap);
temp.put(name, data);
}
}
rews.setCustomRewards(temp);
} }
} }
@ -2651,7 +2667,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
if (!found.isPresent()) { if (!found.isPresent()) {
getLogger().warning("Custom requirement \"" + name + "\" for Quest \"" + quest.getName() + "\" could not be found!"); getLogger().warning("Custom requirement \"" + name + "\" for Quest \"" + quest.getName() + "\" could not be found!");
skipQuestProcess((String) null); // null bc we warn, not severe for this one skipQuestProcess((String) null); // null bc we warn, not severe for this one
}else { } else {
ConfigurationSection sec2 = sec.getConfigurationSection(path + ".data"); ConfigurationSection sec2 = sec.getConfigurationSection(path + ".data");
Map<String, Object> data=populateCustoms(sec2,found.get().datamap); Map<String, Object> data=populateCustoms(sec2,found.get().datamap);
temp.put(name, data); temp.put(name, data);
@ -2662,26 +2678,27 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
} }
private void loadQuestPlanner(FileConfiguration config, ConfigurationSection questsSection) throws SkipQuest { private void loadQuestPlanner(FileConfiguration config, ConfigurationSection questsSection) throws SkipQuest {
Planner pln = quest.getPlanner();
if (config.contains("quests." + questName + ".planner.start")) { if (config.contains("quests." + questName + ".planner.start")) {
quest.startPlanner = config.getString("quests." + questName + ".planner.start"); pln.setStart(config.getString("quests." + questName + ".planner.start"));
} /*else { } /*else {
skipQuestProcess("Planner for Quest " + quest.getName() + " is missing start:"); skipQuestProcess("Planner for Quest " + quest.getName() + " is missing start:");
}*/ }*/
if (config.contains("quests." + questName + ".planner.end")) { if (config.contains("quests." + questName + ".planner.end")) {
quest.endPlanner = config.getString("quests." + questName + ".planner.end"); pln.setEnd(config.getString("quests." + questName + ".planner.end"));
} /*else { } /*else {
skipQuestProcess("Planner for Quest " + quest.getName() + " is missing end:"); skipQuestProcess("Planner for Quest " + quest.getName() + " is missing end:");
}*/ }*/
if (config.contains("quests." + questName + ".planner.repeat")) { if (config.contains("quests." + questName + ".planner.repeat")) {
if (config.getInt("quests." + questName + ".planner.repeat", -999) != -999) { if (config.getInt("quests." + questName + ".planner.repeat", -999) != -999) {
quest.repeatPlanner = config.getInt("quests." + questName + ".planner.repeat") * 1000; pln.setRepeat(config.getInt("quests." + questName + ".planner.repeat") * 1000);
} else { } else {
skipQuestProcess("repeat: for Quest " + quest.getName() + " is not a number!"); skipQuestProcess("repeat: for Quest " + quest.getName() + " is not a number!");
} }
} }
if (config.contains("quests." + questName + ".planner.cooldown")) { if (config.contains("quests." + questName + ".planner.cooldown")) {
if (config.getInt("quests." + questName + ".planner.cooldown", -999) != -999) { if (config.getInt("quests." + questName + ".planner.cooldown", -999) != -999) {
quest.cooldownPlanner = config.getInt("quests." + questName + ".planner.cooldown") * 1000; pln.setCooldown(config.getInt("quests." + questName + ".planner.cooldown") * 1000);
} else { } else {
skipQuestProcess("cooldown: for Quest " + quest.getName() + " is not a number!"); skipQuestProcess("cooldown: for Quest " + quest.getName() + " is not a number!");
} }
@ -2701,27 +2718,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
skipQuestProcess(new String[] { msg }); skipQuestProcess(new String[] { msg });
} }
private void populateCustomRewards(FileConfiguration config) {
ConfigurationSection sec = config.getConfigurationSection("quests." + questName + ".rewards.custom-rewards");
for (String path : sec.getKeys(false)) {
String name = sec.getString(path + ".name");
Optional<CustomReward>found = Optional.empty();
for (CustomReward cr : customRewards) {
if (cr.getName().equalsIgnoreCase(name)) {
found=Optional.of(cr);
break;
}
}
if (!found.isPresent()) {
getLogger().warning("Custom reward \"" + name + "\" for Quest \"" + quest.getName() + "\" could not be found!");
continue;
} else {
ConfigurationSection sec2 = sec.getConfigurationSection(path + ".data");
Map<String, Object> data=populateCustoms(sec2,found.get().datamap);
quest.customRewards.put(name, data);
}
}
}
private boolean regionFound(Quest quest, String region) { private boolean regionFound(Quest quest, String region) {
boolean exists = false; boolean exists = false;
@ -4180,7 +4177,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
public boolean hasCompletedRedoableQuest(NPC npc, Quester quester) { public boolean hasCompletedRedoableQuest(NPC npc, Quester quester) {
for (Quest q : quests) { for (Quest q : quests) {
if (q.npcStart != null && quester.completedQuests.contains(q.getName()) == true && q.cooldownPlanner > -1) { if (q.npcStart != null && quester.completedQuests.contains(q.getName()) == true && q.getPlanner().getCooldown() > -1) {
if (q.npcStart.getId() == npc.getId()) { if (q.npcStart.getId() == npc.getId()) {
if (ignoreLockedQuests == false || ignoreLockedQuests == true && q.testRequirements(quester) == true) { if (ignoreLockedQuests == false || ignoreLockedQuests == true && q.testRequirements(quester) == true) {
return true; return true;

View File

@ -101,4 +101,4 @@ public class Requirements {
public void setFailRequirements(String failRequirements) { public void setFailRequirements(String failRequirements) {
this.failRequirements = failRequirements; this.failRequirements = failRequirements;
} }
} }

View File

@ -0,0 +1,96 @@
package me.blackvein.quests;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import org.bukkit.inventory.ItemStack;
public class Rewards {
int money = 0;
int questPoints = 0;
int exp = 0;
List<String> commands = new LinkedList<String>();
List<String> permissions = new LinkedList<String>();
LinkedList<ItemStack> items = new LinkedList<ItemStack>();
List<String> mcmmoSkills = new LinkedList<String>();
List<Integer> mcmmoAmounts = new LinkedList<Integer>();
List<String> heroesClasses = new LinkedList<String>();
List<Double> heroesAmounts = new LinkedList<Double>();
List<String> phatLoots = new LinkedList<String>();
private Map<String, Map<String, Object>> customRewards = new HashMap<String, Map<String, Object>>();
public int getMoney() {
return money;
}
public void setMoney(int money) {
this.money = money;
}
public int getQuestPoints() {
return questPoints;
}
public void setQuestPoints(int questPoints) {
this.questPoints = questPoints;
}
public int getExp() {
return exp;
}
public void setExp(int exp) {
this.exp = exp;
}
public List<String> getCommands() {
return commands;
}
public void setCommands(List<String> commands) {
this.commands = commands;
}
public List<String> getPermissions() {
return permissions;
}
public void setPermissions(List<String> permissions) {
this.permissions = permissions;
}
public LinkedList<ItemStack> getItems() {
return items;
}
public void setItems(LinkedList<ItemStack> items) {
this.items = items;
}
public List<String> getMcmmoSkills() {
return mcmmoSkills;
}
public void setMcmmoSkills(List<String> mcmmoSkills) {
this.mcmmoSkills = mcmmoSkills;
}
public List<Integer> getMcmmoAmounts() {
return mcmmoAmounts;
}
public void setMcmmoAmounts(List<Integer> mcmmoAmounts) {
this.mcmmoAmounts = mcmmoAmounts;
}
public List<String> getHeroesClasses() {
return heroesClasses;
}
public void setHeroesClasses(List<String> heroesClasses) {
this.heroesClasses = heroesClasses;
}
public List<Double> getHeroesAmounts() {
return heroesAmounts;
}
public void setHeroesAmounts(List<Double> heroesAmounts) {
this.heroesAmounts = heroesAmounts;
}
public List<String> getPhatLoots() {
return phatLoots;
}
public void setPhatLoots(List<String> phatLoots) {
this.phatLoots = phatLoots;
}
public Map<String, Map<String, Object>> getCustomRewards() {
return customRewards;
}
protected void setCustomRewards(Map<String, Map<String, Object>> customRewards) {
this.customRewards = customRewards;
}
}

View File

@ -10,7 +10,7 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*******************************************************************************************************/ *******************************************************************************************************/
package me.blackvein.listeners; package me.blackvein.quests.listeners;
import java.text.MessageFormat; import java.text.MessageFormat;
import java.util.LinkedList; import java.util.LinkedList;
@ -162,11 +162,11 @@ public class NpcListener implements Listener {
if (quester.currentQuests.containsKey(q)) if (quester.currentQuests.containsKey(q))
continue; continue;
if (q.getNpcStart() != null && q.getNpcStart().getId() == evt.getNPC().getId()) { if (q.getNpcStart() != null && q.getNpcStart().getId() == evt.getNPC().getId()) {
if (plugin.ignoreLockedQuests && (quester.completedQuests.contains(q.getName()) == false || q.cooldownPlanner > -1)) { if (plugin.ignoreLockedQuests && (quester.completedQuests.contains(q.getName()) == false || q.getPlanner().getCooldown() > -1)) {
if (q.testRequirements(quester)) { if (q.testRequirements(quester)) {
npcQuests.add(q); npcQuests.add(q);
} }
} else if (quester.completedQuests.contains(q.getName()) == false || q.cooldownPlanner > -1) { } else if (quester.completedQuests.contains(q.getName()) == false || q.getPlanner().getCooldown() > -1) {
npcQuests.add(q); npcQuests.add(q);
} }
} }
@ -196,12 +196,12 @@ public class NpcListener implements Listener {
player.sendMessage(ChatColor.YELLOW + msg); player.sendMessage(ChatColor.YELLOW + msg);
} }
} else if (quester.currentQuests.size() < plugin.maxQuests || plugin.maxQuests < 1) { } else if (quester.currentQuests.size() < plugin.maxQuests || plugin.maxQuests < 1) {
if (quester.getDifference(q) > 0) { if (quester.getCooldownDifference(q) > 0) {
String early = Lang.get(player, "questTooEarly"); String early = Lang.get(player, "questTooEarly");
early = early.replaceAll("<quest>", ChatColor.AQUA + q.getName() + ChatColor.YELLOW); early = early.replaceAll("<quest>", ChatColor.AQUA + q.getName() + ChatColor.YELLOW);
early = early.replaceAll("<time>", ChatColor.DARK_PURPLE + Quests.getTime(quester.getDifference(q)) + ChatColor.YELLOW); early = early.replaceAll("<time>", ChatColor.DARK_PURPLE + Quests.getTime(quester.getCooldownDifference(q)) + ChatColor.YELLOW);
player.sendMessage(ChatColor.YELLOW + early); player.sendMessage(ChatColor.YELLOW + early);
} else if (q.cooldownPlanner < 0) { } else if (q.getPlanner().getCooldown() < 0) {
String completed = Lang.get(player, "questAlreadyCompleted"); String completed = Lang.get(player, "questAlreadyCompleted");
completed = completed.replaceAll("<quest>", ChatColor.AQUA + q.getName() + ChatColor.YELLOW); completed = completed.replaceAll("<quest>", ChatColor.AQUA + q.getName() + ChatColor.YELLOW);
player.sendMessage(ChatColor.YELLOW + completed); player.sendMessage(ChatColor.YELLOW + completed);

View File

@ -10,7 +10,7 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*******************************************************************************************************/ *******************************************************************************************************/
package me.blackvein.listeners; package me.blackvein.quests.listeners;
import java.io.File; import java.io.File;
import java.util.Iterator; import java.util.Iterator;
@ -117,17 +117,17 @@ public class PlayerListener implements Listener {
String msg = Lang.get(player, "questMaxAllowed"); String msg = Lang.get(player, "questMaxAllowed");
msg = msg.replace("<number>", String.valueOf(plugin.maxQuests)); msg = msg.replace("<number>", String.valueOf(plugin.maxQuests));
player.sendMessage(ChatColor.YELLOW + msg); player.sendMessage(ChatColor.YELLOW + msg);
} else if (quester.completedQuests.contains(quest.getName()) && quest.cooldownPlanner < 0) { } else if (quester.completedQuests.contains(quest.getName()) && quest.getPlanner().getCooldown() < 0) {
String completed = Lang.get(player, "questAlreadyCompleted"); String completed = Lang.get(player, "questAlreadyCompleted");
completed = completed.replace("<quest>", ChatColor.AQUA + quest.getName() + ChatColor.YELLOW); completed = completed.replace("<quest>", ChatColor.AQUA + quest.getName() + ChatColor.YELLOW);
player.sendMessage(ChatColor.YELLOW + completed); player.sendMessage(ChatColor.YELLOW + completed);
} else { } else {
boolean takeable = true; boolean takeable = true;
if (quester.completedQuests.contains(quest.getName())) { if (quester.completedQuests.contains(quest.getName())) {
if (quester.getDifference(quest) > 0) { if (quester.getCooldownDifference(quest) > 0) {
String early = Lang.get(player, "questTooEarly"); String early = Lang.get(player, "questTooEarly");
early = early.replace("<quest>", ChatColor.AQUA + quest.getName() + ChatColor.YELLOW); early = early.replace("<quest>", ChatColor.AQUA + quest.getName() + ChatColor.YELLOW);
early = early.replace("<time>", ChatColor.DARK_PURPLE + Quests.getTime(quester.getDifference(quest)) + ChatColor.YELLOW); early = early.replace("<time>", ChatColor.DARK_PURPLE + Quests.getTime(quester.getCooldownDifference(quest)) + ChatColor.YELLOW);
player.sendMessage(ChatColor.YELLOW + early); player.sendMessage(ChatColor.YELLOW + early);
takeable = false; takeable = false;
} }
@ -264,13 +264,13 @@ public class PlayerListener implements Listener {
player.sendMessage(ChatColor.YELLOW + msg); player.sendMessage(ChatColor.YELLOW + msg);
} else { } else {
if (quester.completedQuests.contains(q.getName())) { if (quester.completedQuests.contains(q.getName())) {
if (q.cooldownPlanner > -1 && (quester.getDifference(q)) > 0) { if (q.getPlanner().getCooldown() > -1 && (quester.getCooldownDifference(q)) > 0) {
String early = Lang.get(player, "questTooEarly"); String early = Lang.get(player, "questTooEarly");
early = early.replace("<quest>", ChatColor.AQUA + q.getName() + ChatColor.YELLOW); early = early.replace("<quest>", ChatColor.AQUA + q.getName() + ChatColor.YELLOW);
early = early.replace("<time>", ChatColor.DARK_PURPLE + Quests.getTime(quester.getDifference(q)) + ChatColor.YELLOW); early = early.replace("<time>", ChatColor.DARK_PURPLE + Quests.getTime(quester.getCooldownDifference(q)) + ChatColor.YELLOW);
player.sendMessage(ChatColor.YELLOW + early); player.sendMessage(ChatColor.YELLOW + early);
return; return;
} else if (quester.completedQuests.contains(q.getName()) && q.cooldownPlanner < 0) { } else if (quester.completedQuests.contains(q.getName()) && q.getPlanner().getCooldown() < 0) {
String completed = Lang.get(player, "questAlreadyCompleted"); String completed = Lang.get(player, "questAlreadyCompleted");
completed = completed.replace("<quest>", ChatColor.AQUA + q.getName() + ChatColor.YELLOW); completed = completed.replace("<quest>", ChatColor.AQUA + q.getName() + ChatColor.YELLOW);
player.sendMessage(ChatColor.YELLOW + completed); player.sendMessage(ChatColor.YELLOW + completed);
@ -674,7 +674,7 @@ public class PlayerListener implements Listener {
for (String s : quester.completedQuests) { for (String s : quester.completedQuests) {
Quest q = plugin.getQuest(s); Quest q = plugin.getQuest(s);
if (q != null) { if (q != null) {
if (quester.completedTimes.containsKey(q.getName()) == false && q.cooldownPlanner > -1) { if (quester.completedTimes.containsKey(q.getName()) == false && q.getPlanner().getCooldown() > -1) {
quester.completedTimes.put(q.getName(), System.currentTimeMillis()); quester.completedTimes.put(q.getName(), System.currentTimeMillis());
} }
} }

View File

@ -123,12 +123,12 @@ public class QuestAcceptPrompt extends StringPrompt {
} }
} else if (quester.completedQuests.contains(q.getName())) { } else if (quester.completedQuests.contains(q.getName())) {
if (quester.currentQuests.size() < plugin.maxQuests || plugin.maxQuests < 1) { if (quester.currentQuests.size() < plugin.maxQuests || plugin.maxQuests < 1) {
if (quester.getDifference(q) > 0) { if (quester.getCooldownDifference(q) > 0) {
String early = Lang.get("questTooEarly"); String early = Lang.get("questTooEarly");
early = early.replaceAll("<quest>", ChatColor.AQUA + q.getName() + ChatColor.YELLOW); early = early.replaceAll("<quest>", ChatColor.AQUA + q.getName() + ChatColor.YELLOW);
early = early.replaceAll("<time>", ChatColor.DARK_PURPLE + Quests.getTime(quester.getDifference(q)) + ChatColor.YELLOW); early = early.replaceAll("<time>", ChatColor.DARK_PURPLE + Quests.getTime(quester.getCooldownDifference(q)) + ChatColor.YELLOW);
player.sendMessage(ChatColor.YELLOW + early); player.sendMessage(ChatColor.YELLOW + early);
} else if (q.cooldownPlanner < 0) { } else if (q.getPlanner().getCooldown() < 0) {
String completed = Lang.get("questAlreadyCompleted"); String completed = Lang.get("questAlreadyCompleted");
completed = completed.replaceAll("<quest>", ChatColor.AQUA + q.getName() + ChatColor.YELLOW); completed = completed.replaceAll("<quest>", ChatColor.AQUA + q.getName() + ChatColor.YELLOW);
player.sendMessage(ChatColor.YELLOW + completed); player.sendMessage(ChatColor.YELLOW + completed);