mirror of
https://github.com/PikaMug/Quests.git
synced 2024-11-15 15:16:41 +01:00
Refactoring for getter/setter methods, part 2
This commit is contained in:
parent
3d2c9b1e9d
commit
8a3b67d735
33
src/main/java/me/blackvein/quests/Planner.java
Normal file
33
src/main/java/me/blackvein/quests/Planner.java
Normal 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;
|
||||
}
|
||||
}
|
@ -12,10 +12,8 @@
|
||||
|
||||
package me.blackvein.quests;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
@ -56,31 +54,22 @@ public class Quest {
|
||||
protected NPC npcStart;
|
||||
protected Location blockStart;
|
||||
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 Planner pln = new Planner();
|
||||
private Rewards rews = new Rewards();
|
||||
|
||||
public Requirements getRequirements() {
|
||||
return reqs;
|
||||
}
|
||||
|
||||
public Planner getPlanner() {
|
||||
return pln;
|
||||
}
|
||||
|
||||
public Rewards getRewards() {
|
||||
return rews;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
@ -413,11 +402,11 @@ public class Quest {
|
||||
}
|
||||
}
|
||||
}, 40);
|
||||
if (moneyReward > 0 && Quests.economy != null) {
|
||||
Quests.economy.depositPlayer(q.getOfflinePlayer(), moneyReward);
|
||||
if (rews.getMoney() > 0 && Quests.economy != null) {
|
||||
Quests.economy.depositPlayer(q.getOfflinePlayer(), rews.getMoney());
|
||||
none = null;
|
||||
}
|
||||
if (cooldownPlanner > -1) {
|
||||
if (pln.getCooldown() > -1) {
|
||||
q.completedTimes.put(this.name, System.currentTimeMillis());
|
||||
if (q.amountsCompleted.containsKey(this.name)) {
|
||||
q.amountsCompleted.put(this.name, q.amountsCompleted.get(this.name) + 1);
|
||||
@ -425,7 +414,7 @@ public class Quest {
|
||||
q.amountsCompleted.put(this.name, 1);
|
||||
}
|
||||
}
|
||||
for (ItemStack i : itemRewards) {
|
||||
for (ItemStack i : rews.getItems()) {
|
||||
try {
|
||||
Quests.addItem(player, i);
|
||||
} catch (Exception e) {
|
||||
@ -436,7 +425,7 @@ public class Quest {
|
||||
}
|
||||
none = null;
|
||||
}
|
||||
for (String s : commands) {
|
||||
for (String s : rews.getCommands()) {
|
||||
final String command = s.replace("<player>", player.getName());
|
||||
if (Bukkit.isPrimaryThread()) {
|
||||
Bukkit.getServer().dispatchCommand(plugin.getServer().getConsoleSender(), command);
|
||||
@ -451,25 +440,25 @@ public class Quest {
|
||||
}
|
||||
none = null;
|
||||
}
|
||||
for (String s : permissions) {
|
||||
for (String s : rews.getPermissions()) {
|
||||
if (Quests.permission != null) {
|
||||
Quests.permission.playerAdd(player, s);
|
||||
}
|
||||
none = null;
|
||||
}
|
||||
for (String s : mcmmoSkills) {
|
||||
UserManager.getPlayer(player).getProfile().addLevels(Quests.getMcMMOSkill(s), mcmmoAmounts.get(mcmmoSkills.indexOf(s)));
|
||||
for (String s : rews.getMcmmoSkills()) {
|
||||
UserManager.getPlayer(player).getProfile().addLevels(Quests.getMcMMOSkill(s), rews.getMcmmoAmounts().get(rews.getMcmmoSkills().indexOf(s)));
|
||||
none = null;
|
||||
}
|
||||
for (String s : heroesClasses) {
|
||||
for (String s : rews.getHeroesClasses()) {
|
||||
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;
|
||||
}
|
||||
LinkedList<ItemStack> phatLootItems = new LinkedList<ItemStack>();
|
||||
int phatLootExp = 0;
|
||||
LinkedList<String> phatLootMessages = new LinkedList<String>();
|
||||
for (String s : phatLootRewards) {
|
||||
for (String s : rews.getPhatLoots()) {
|
||||
LootBundle lb = PhatLootsAPI.getPhatLoot(s).rollForLoot();
|
||||
if (lb.getExp() > 0) {
|
||||
phatLootExp += lb.getExp();
|
||||
@ -502,8 +491,8 @@ public class Quest {
|
||||
phatLootMessages.addAll(lb.getMessageList());
|
||||
}
|
||||
}
|
||||
if (exp > 0) {
|
||||
player.giveExp(exp);
|
||||
if (rews.getExp() > 0) {
|
||||
player.giveExp(rews.getExp());
|
||||
none = null;
|
||||
}
|
||||
String complete = Lang.get(player, "questCompleteTitle");
|
||||
@ -516,12 +505,12 @@ public class Quest {
|
||||
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "title " + player.getName()
|
||||
+ " subtitle " + "{\"text\":\"" + name + "\",\"color\":\"yellow\"}");
|
||||
}
|
||||
if (questPoints > 0) {
|
||||
player.sendMessage("- " + ChatColor.DARK_GREEN + questPoints + " " + Lang.get(player, "questPoints"));
|
||||
q.questPoints += questPoints;
|
||||
if (rews.getQuestPoints() > 0) {
|
||||
player.sendMessage("- " + ChatColor.DARK_GREEN + rews.getQuestPoints() + " " + Lang.get(player, "questPoints"));
|
||||
q.questPoints += rews.getQuestPoints();
|
||||
none = null;
|
||||
}
|
||||
for (ItemStack i : itemRewards) {
|
||||
for (ItemStack i : rews.getItems()) {
|
||||
String text = "error";
|
||||
if (i.hasItemMeta() && i.getItemMeta().hasDisplayName()) {
|
||||
if (i.getEnchantments().isEmpty()) {
|
||||
@ -585,27 +574,27 @@ public class Quest {
|
||||
}
|
||||
none = null;
|
||||
}
|
||||
if (moneyReward > 1) {
|
||||
player.sendMessage("- " + ChatColor.DARK_GREEN + moneyReward + " " + ChatColor.DARK_PURPLE + Quests.getCurrency(true));
|
||||
if (rews.getMoney() > 1) {
|
||||
player.sendMessage("- " + ChatColor.DARK_GREEN + rews.getMoney() + " " + ChatColor.DARK_PURPLE + Quests.getCurrency(true));
|
||||
none = null;
|
||||
} else if (moneyReward == 1) {
|
||||
player.sendMessage("- " + ChatColor.DARK_GREEN + moneyReward + " " + ChatColor.DARK_PURPLE + Quests.getCurrency(false));
|
||||
} else if (rews.getMoney() == 1) {
|
||||
player.sendMessage("- " + ChatColor.DARK_GREEN + rews.getMoney() + " " + ChatColor.DARK_PURPLE + Quests.getCurrency(false));
|
||||
none = null;
|
||||
}
|
||||
if (exp > 0 || phatLootExp > 0) {
|
||||
int tot = exp + phatLootExp;
|
||||
if (rews.getExp() > 0 || phatLootExp > 0) {
|
||||
int tot = rews.getExp() + phatLootExp;
|
||||
player.sendMessage("- " + ChatColor.DARK_GREEN + tot + ChatColor.DARK_PURPLE + " " + Lang.get(player, "experience"));
|
||||
none = null;
|
||||
}
|
||||
if (mcmmoSkills.isEmpty() == false) {
|
||||
for (String s : mcmmoSkills) {
|
||||
player.sendMessage("- " + ChatColor.DARK_GREEN + mcmmoAmounts.get(mcmmoSkills.indexOf(s)) + " " + ChatColor.DARK_PURPLE + s + " " + Lang.get(player, "experience"));
|
||||
if (rews.getMcmmoSkills().isEmpty() == false) {
|
||||
for (String s : rews.getMcmmoSkills()) {
|
||||
player.sendMessage("- " + ChatColor.DARK_GREEN + rews.getMcmmoAmounts().get(rews.getMcmmoSkills().indexOf(s)) + " " + ChatColor.DARK_PURPLE + s + " " + Lang.get(player, "experience"));
|
||||
}
|
||||
none = null;
|
||||
}
|
||||
if (heroesClasses.isEmpty() == false) {
|
||||
for (String s : heroesClasses) {
|
||||
player.sendMessage("- " + ChatColor.AQUA + heroesAmounts.get(heroesClasses.indexOf(s)) + " " + ChatColor.BLUE + s + " " + Lang.get(player, "experience"));
|
||||
if (rews.getHeroesClasses().isEmpty() == false) {
|
||||
for (String s : rews.getHeroesClasses()) {
|
||||
player.sendMessage("- " + ChatColor.AQUA + rews.getHeroesAmounts().get(rews.getHeroesClasses().indexOf(s)) + " " + ChatColor.BLUE + s + " " + Lang.get(player, "experience"));
|
||||
}
|
||||
none = null;
|
||||
}
|
||||
@ -615,7 +604,7 @@ public class Quest {
|
||||
}
|
||||
none = null;
|
||||
}
|
||||
for (String s : customRewards.keySet()) {
|
||||
for (String s : rews.getCustomRewards().keySet()) {
|
||||
CustomReward found = null;
|
||||
for (CustomReward cr : plugin.customRewards) {
|
||||
if (cr.getName().equalsIgnoreCase(s)) {
|
||||
@ -624,7 +613,7 @@ public class Quest {
|
||||
}
|
||||
}
|
||||
if (found != null) {
|
||||
Map<String, Object> datamap = customRewards.get(found.getName());
|
||||
Map<String, Object> datamap = rews.getCustomRewards().get(found.getName());
|
||||
String message = found.getRewardName();
|
||||
if (message != null) {
|
||||
for (String key : datamap.keySet()) {
|
||||
@ -634,7 +623,7 @@ public class Quest {
|
||||
} else {
|
||||
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 {
|
||||
plugin.getLogger().warning("Quester \"" + player.getName() + "\" completed the Quest \"" + name + "\", but the Custom Reward \"" + s + "\" could not be found. Does it still exist?");
|
||||
}
|
||||
|
@ -1312,7 +1312,6 @@ public class QuestFactory implements ConversationAbandonedListener {
|
||||
if (q.guiDisplay != null) {
|
||||
cc.setSessionData(CK.Q_GUIDISPLAY, q.guiDisplay);
|
||||
}
|
||||
// Requirements
|
||||
Requirements reqs = q.getRequirements();
|
||||
if (reqs.getMoney() != 0) {
|
||||
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_DATA, datamapList);
|
||||
}
|
||||
//
|
||||
// Rewards
|
||||
if (q.moneyReward != 0) {
|
||||
cc.setSessionData(CK.REW_MONEY, q.moneyReward);
|
||||
Rewards rews = q.getRewards();
|
||||
if (rews.getMoney() != 0) {
|
||||
cc.setSessionData(CK.REW_MONEY, rews.getMoney());
|
||||
}
|
||||
if (q.questPoints != 0) {
|
||||
cc.setSessionData(CK.REW_QUEST_POINTS, q.questPoints);
|
||||
if (rews.getQuestPoints() != 0) {
|
||||
cc.setSessionData(CK.REW_QUEST_POINTS, rews.getQuestPoints());
|
||||
}
|
||||
if (q.exp != 0) {
|
||||
cc.setSessionData(CK.REW_EXP, q.exp);
|
||||
if (rews.getExp() != 0) {
|
||||
cc.setSessionData(CK.REW_EXP, rews.getExp());
|
||||
}
|
||||
if (q.itemRewards.isEmpty() == false) {
|
||||
cc.setSessionData(CK.REW_ITEMS, q.itemRewards);
|
||||
if (rews.getItems().isEmpty() == false) {
|
||||
cc.setSessionData(CK.REW_ITEMS, reqs.getItems());
|
||||
}
|
||||
if (q.commands.isEmpty() == false) {
|
||||
cc.setSessionData(CK.REW_COMMAND, q.commands);
|
||||
if (rews.getCommands().isEmpty() == false) {
|
||||
cc.setSessionData(CK.REW_COMMAND, rews.getCommands());
|
||||
}
|
||||
if (q.permissions.isEmpty() == false) {
|
||||
cc.setSessionData(CK.REW_PERMISSION, q.permissions);
|
||||
if (rews.getPermissions().isEmpty() == false) {
|
||||
cc.setSessionData(CK.REW_PERMISSION, rews.getPermissions());
|
||||
}
|
||||
if (q.mcmmoSkills.isEmpty() == false) {
|
||||
cc.setSessionData(CK.REW_MCMMO_SKILLS, q.mcmmoSkills);
|
||||
cc.setSessionData(CK.REW_MCMMO_AMOUNTS, q.mcmmoAmounts);
|
||||
if (rews.getMcmmoSkills().isEmpty() == false) {
|
||||
cc.setSessionData(CK.REW_MCMMO_SKILLS, rews.getMcmmoSkills());
|
||||
cc.setSessionData(CK.REW_MCMMO_AMOUNTS, rews.getMcmmoAmounts());
|
||||
}
|
||||
if (q.heroesClasses.isEmpty() == false) {
|
||||
cc.setSessionData(CK.REW_HEROES_CLASSES, q.heroesClasses);
|
||||
cc.setSessionData(CK.REW_HEROES_AMOUNTS, q.heroesAmounts);
|
||||
if (rews.getHeroesClasses().isEmpty() == false) {
|
||||
cc.setSessionData(CK.REW_HEROES_CLASSES, rews.getHeroesClasses());
|
||||
cc.setSessionData(CK.REW_HEROES_AMOUNTS, rews.getHeroesAmounts());
|
||||
}
|
||||
if (q.heroesClasses.isEmpty() == false) {
|
||||
cc.setSessionData(CK.REW_HEROES_CLASSES, q.heroesClasses);
|
||||
cc.setSessionData(CK.REW_HEROES_AMOUNTS, q.heroesAmounts);
|
||||
if (rews.getPhatLoots().isEmpty() == false) {
|
||||
cc.setSessionData(CK.REW_PHAT_LOOTS, rews.getPhatLoots());
|
||||
}
|
||||
if (q.phatLootRewards.isEmpty() == false) {
|
||||
cc.setSessionData(CK.REW_PHAT_LOOTS, q.phatLootRewards);
|
||||
if (rews.getCustomRewards().isEmpty() == false) {
|
||||
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) {
|
||||
cc.setSessionData(CK.REW_CUSTOM, new LinkedList<String>(q.customRewards.keySet()));
|
||||
cc.setSessionData(CK.REW_CUSTOM_DATA, new LinkedList<Object>(q.customRewards.values()));
|
||||
Planner pln = q.getPlanner();
|
||||
if (pln.getStart() != null) {
|
||||
cc.setSessionData(CK.PLN_START_DATE, pln.getStart());
|
||||
}
|
||||
//
|
||||
//Planner
|
||||
if (q.startPlanner != null) {
|
||||
cc.setSessionData(CK.PLN_START_DATE, q.startPlanner);
|
||||
if (pln.getEnd() != null) {
|
||||
cc.setSessionData(CK.PLN_END_DATE, pln.getEnd());
|
||||
}
|
||||
if (q.endPlanner != null) {
|
||||
cc.setSessionData(CK.PLN_END_DATE, q.endPlanner);
|
||||
if (pln.getRepeat() != -1) {
|
||||
cc.setSessionData(CK.PLN_REPEAT_CYCLE, pln.getRepeat());
|
||||
}
|
||||
if (q.repeatPlanner != -1) {
|
||||
cc.setSessionData(CK.PLN_REPEAT_CYCLE, q.repeatPlanner);
|
||||
}
|
||||
if (q.cooldownPlanner != -1) {
|
||||
cc.setSessionData(CK.PLN_COOLDOWN, q.cooldownPlanner);
|
||||
if (pln.getCooldown() != -1) {
|
||||
cc.setSessionData(CK.PLN_COOLDOWN, pln.getCooldown());
|
||||
}
|
||||
//
|
||||
// Stages
|
||||
|
@ -315,28 +315,29 @@ public class Quester {
|
||||
return;
|
||||
}
|
||||
Player player = getPlayer();
|
||||
Planner pln = q.getPlanner();
|
||||
long start = -1;
|
||||
long end = -1;
|
||||
if (q.startPlanner != null) {
|
||||
if (pln.getStart() != null) {
|
||||
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]),
|
||||
Integer.valueOf(s[3]), Integer.valueOf(s[4]), Integer.valueOf(s[5]));
|
||||
start = cal.getTimeInMillis();
|
||||
}
|
||||
if (q.endPlanner != null) {
|
||||
if (pln.getEnd() != null) {
|
||||
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]),
|
||||
Integer.valueOf(s[3]), Integer.valueOf(s[4]), Integer.valueOf(s[5]));
|
||||
end = cal.getTimeInMillis();
|
||||
}
|
||||
if (start > -1 && end > -1) {
|
||||
if (q.repeatPlanner > -1) {
|
||||
if (pln.getRepeat() > -1) {
|
||||
long questLength = end - start;
|
||||
long nextStart = start;
|
||||
while (System.currentTimeMillis() >= nextStart) {
|
||||
nextStart += questLength + q.repeatPlanner;
|
||||
nextStart += questLength + pln.getRepeat();
|
||||
}
|
||||
long nextEnd = nextStart + questLength;
|
||||
if (System.currentTimeMillis() < nextStart) {
|
||||
@ -361,7 +362,7 @@ public class Quester {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (q.startPlanner != null) {
|
||||
if (pln.getStart() != null) {
|
||||
if (System.currentTimeMillis() < start) {
|
||||
String early = Lang.get("plnTooEarly");
|
||||
early = early.replace("<quest>", ChatColor.AQUA + q.getName() + ChatColor.YELLOW);
|
||||
@ -372,7 +373,7 @@ public class Quester {
|
||||
}
|
||||
}
|
||||
//TODO - should this even be reported?
|
||||
if (q.endPlanner != null) {
|
||||
if (pln.getEnd() != null) {
|
||||
if (System.currentTimeMillis() > end) {
|
||||
String late = Lang.get("plnTooLate");
|
||||
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 lastTime;
|
||||
if (completedTimes.containsKey(q.getName()) == false) {
|
||||
@ -1770,7 +1771,7 @@ public class Quester {
|
||||
} else {
|
||||
lastTime = completedTimes.get(q.getName());
|
||||
}
|
||||
long comparator = q.cooldownPlanner;
|
||||
long comparator = q.getPlanner().getCooldown();
|
||||
long difference = (comparator - (currentTime - lastTime));
|
||||
return difference;
|
||||
}
|
||||
|
@ -93,9 +93,9 @@ import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||
import com.sk89q.worldguard.protection.managers.RegionManager;
|
||||
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.listeners.NpcListener;
|
||||
import me.blackvein.quests.listeners.PlayerListener;
|
||||
import me.blackvein.quests.prompts.QuestAcceptPrompt;
|
||||
import me.blackvein.quests.util.ItemUtil;
|
||||
import me.blackvein.quests.util.Lang;
|
||||
@ -1617,7 +1617,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
||||
} else if (quester.currentQuests.containsKey(q)) {
|
||||
String msg = Lang.get(player, "questAlreadyOn");
|
||||
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");
|
||||
msg = msg.replace("<quest>", ChatColor.DARK_PURPLE + q.getName() + ChatColor.YELLOW);
|
||||
player.sendMessage(ChatColor.YELLOW + msg);
|
||||
@ -1632,10 +1632,10 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
||||
} else {
|
||||
boolean takeable = true;
|
||||
if (quester.completedQuests.contains(q.getName())) {
|
||||
if (quester.getDifference(q) > 0) {
|
||||
if (quester.getCooldownDifference(q) > 0) {
|
||||
String early = Lang.get(player, "questTooEarly");
|
||||
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);
|
||||
takeable = false;
|
||||
}
|
||||
@ -2289,7 +2289,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
||||
if (config.contains("quests." + questName + ".redo-delay")) {
|
||||
//Legacy
|
||||
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 {
|
||||
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;
|
||||
processStages(quest, config, questName); // needsSaving may be modified as a side-effect
|
||||
loadRewards(config);
|
||||
loadQuestRewards(config);
|
||||
quests.add(quest);
|
||||
if (needsSaving) {
|
||||
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 (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")) {
|
||||
try {
|
||||
ItemStack stack = ItemUtil.readItemStack(item);
|
||||
if (stack != null) {
|
||||
quest.itemRewards.add(stack);
|
||||
temp.add(stack);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
skipQuestProcess("" + item + " in items: Reward in Quest " + quest.getName() + " is not properly formatted!");
|
||||
}
|
||||
}
|
||||
rews.setItems(temp);
|
||||
} else {
|
||||
skipQuestProcess("items: Reward in Quest " + quest.getName() + " is not a list of strings!");
|
||||
}
|
||||
}
|
||||
if (config.contains("quests." + questName + ".rewards.money")) {
|
||||
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 {
|
||||
skipQuestProcess("money: Reward in Quest " + quest.getName() + " is not a number!");
|
||||
}
|
||||
}
|
||||
if (config.contains("quests." + questName + ".rewards.exp")) {
|
||||
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 {
|
||||
skipQuestProcess("exp: Reward in Quest " + quest.getName() + " is not a number!");
|
||||
}
|
||||
}
|
||||
if (config.contains("quests." + questName + ".rewards.commands")) {
|
||||
if (Quests.checkList(config.getList("quests." + questName + ".rewards.commands"), String.class)) {
|
||||
quest.commands.clear();
|
||||
quest.commands.addAll(config.getStringList("quests." + questName + ".rewards.commands"));
|
||||
rews.setCommands(config.getStringList("quests." + questName + ".rewards.commands"));
|
||||
} else {
|
||||
skipQuestProcess("commands: Reward in Quest " + quest.getName() + " is not a list of commands!");
|
||||
}
|
||||
}
|
||||
if (config.contains("quests." + questName + ".rewards.permissions")) {
|
||||
if (Quests.checkList(config.getList("quests." + questName + ".rewards.permissions"), String.class)) {
|
||||
quest.permissions.clear();
|
||||
quest.permissions.addAll(config.getStringList("quests." + questName + ".rewards.permissions"));
|
||||
rews.setPermissions(config.getStringList("quests." + questName + ".rewards.permissions"));
|
||||
} else {
|
||||
skipQuestProcess("permissions: Reward in Quest " + quest.getName() + " is not a list of permissions!");
|
||||
}
|
||||
}
|
||||
if (config.contains("quests." + questName + ".rewards.quest-points")) {
|
||||
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 {
|
||||
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!");
|
||||
}
|
||||
}
|
||||
quest.mcmmoSkills.clear();
|
||||
quest.mcmmoAmounts.clear();
|
||||
quest.mcmmoSkills.addAll(config.getStringList("quests." + questName + ".rewards.mcmmo-skills"));
|
||||
quest.mcmmoAmounts.addAll(config.getIntegerList("quests." + questName + ".rewards.mcmmo-levels"));
|
||||
rews.setMcmmoSkills(config.getStringList("quests." + questName + ".rewards.mcmmo-skills"));
|
||||
rews.setMcmmoAmounts(config.getIntegerList("quests." + questName + ".rewards.mcmmo-levels"));
|
||||
} else {
|
||||
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!");
|
||||
}
|
||||
}
|
||||
quest.heroesClasses.clear();
|
||||
quest.heroesAmounts.clear();
|
||||
quest.heroesClasses.addAll(config.getStringList("quests." + questName + ".rewards.heroes-exp-classes"));
|
||||
quest.heroesAmounts.addAll(config.getDoubleList("quests." + questName + ".rewards.heroes-exp-amounts"));
|
||||
rews.setHeroesClasses(config.getStringList("quests." + questName + ".rewards.heroes-exp-classes"));
|
||||
rews.setHeroesAmounts(config.getDoubleList("quests." + questName + ".rewards.heroes-exp-amounts"));
|
||||
} else {
|
||||
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!");
|
||||
}
|
||||
}
|
||||
quest.phatLootRewards.clear();
|
||||
quest.phatLootRewards.addAll(config.getStringList("quests." + questName + ".rewards.phat-loots"));
|
||||
rews.setPhatLoots(config.getStringList("quests." + questName + ".rewards.phat-loots"));
|
||||
} else {
|
||||
skipQuestProcess("phat-loots: Reward in Quest " + quest.getName() + " is not a list of PhatLoots!");
|
||||
}
|
||||
}
|
||||
}
|
||||
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()) {
|
||||
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
|
||||
}else {
|
||||
} else {
|
||||
ConfigurationSection sec2 = sec.getConfigurationSection(path + ".data");
|
||||
Map<String, Object> data=populateCustoms(sec2,found.get().datamap);
|
||||
temp.put(name, data);
|
||||
@ -2662,26 +2678,27 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
||||
}
|
||||
|
||||
private void loadQuestPlanner(FileConfiguration config, ConfigurationSection questsSection) throws SkipQuest {
|
||||
Planner pln = quest.getPlanner();
|
||||
if (config.contains("quests." + questName + ".planner.start")) {
|
||||
quest.startPlanner = config.getString("quests." + questName + ".planner.start");
|
||||
pln.setStart(config.getString("quests." + questName + ".planner.start"));
|
||||
} /*else {
|
||||
skipQuestProcess("Planner for Quest " + quest.getName() + " is missing start:");
|
||||
}*/
|
||||
if (config.contains("quests." + questName + ".planner.end")) {
|
||||
quest.endPlanner = config.getString("quests." + questName + ".planner.end");
|
||||
pln.setEnd(config.getString("quests." + questName + ".planner.end"));
|
||||
} /*else {
|
||||
skipQuestProcess("Planner for Quest " + quest.getName() + " is missing end:");
|
||||
}*/
|
||||
if (config.contains("quests." + questName + ".planner.repeat")) {
|
||||
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 {
|
||||
skipQuestProcess("repeat: for Quest " + quest.getName() + " is not a number!");
|
||||
}
|
||||
}
|
||||
if (config.contains("quests." + questName + ".planner.cooldown")) {
|
||||
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 {
|
||||
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 });
|
||||
}
|
||||
|
||||
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) {
|
||||
boolean exists = false;
|
||||
@ -4180,7 +4177,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
||||
|
||||
public boolean hasCompletedRedoableQuest(NPC npc, Quester quester) {
|
||||
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 (ignoreLockedQuests == false || ignoreLockedQuests == true && q.testRequirements(quester) == true) {
|
||||
return true;
|
||||
|
96
src/main/java/me/blackvein/quests/Rewards.java
Normal file
96
src/main/java/me/blackvein/quests/Rewards.java
Normal 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;
|
||||
}
|
||||
}
|
@ -10,7 +10,7 @@
|
||||
* 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.util.LinkedList;
|
||||
@ -162,11 +162,11 @@ public class NpcListener implements Listener {
|
||||
if (quester.currentQuests.containsKey(q))
|
||||
continue;
|
||||
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)) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
@ -196,12 +196,12 @@ public class NpcListener implements Listener {
|
||||
player.sendMessage(ChatColor.YELLOW + msg);
|
||||
}
|
||||
} 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");
|
||||
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);
|
||||
} else if (q.cooldownPlanner < 0) {
|
||||
} else if (q.getPlanner().getCooldown() < 0) {
|
||||
String completed = Lang.get(player, "questAlreadyCompleted");
|
||||
completed = completed.replaceAll("<quest>", ChatColor.AQUA + q.getName() + ChatColor.YELLOW);
|
||||
player.sendMessage(ChatColor.YELLOW + completed);
|
@ -10,7 +10,7 @@
|
||||
* 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.util.Iterator;
|
||||
@ -117,17 +117,17 @@ public class PlayerListener implements Listener {
|
||||
String msg = Lang.get(player, "questMaxAllowed");
|
||||
msg = msg.replace("<number>", String.valueOf(plugin.maxQuests));
|
||||
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");
|
||||
completed = completed.replace("<quest>", ChatColor.AQUA + quest.getName() + ChatColor.YELLOW);
|
||||
player.sendMessage(ChatColor.YELLOW + completed);
|
||||
} else {
|
||||
boolean takeable = true;
|
||||
if (quester.completedQuests.contains(quest.getName())) {
|
||||
if (quester.getDifference(quest) > 0) {
|
||||
if (quester.getCooldownDifference(quest) > 0) {
|
||||
String early = Lang.get(player, "questTooEarly");
|
||||
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);
|
||||
takeable = false;
|
||||
}
|
||||
@ -264,13 +264,13 @@ public class PlayerListener implements Listener {
|
||||
player.sendMessage(ChatColor.YELLOW + msg);
|
||||
} else {
|
||||
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");
|
||||
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);
|
||||
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");
|
||||
completed = completed.replace("<quest>", ChatColor.AQUA + q.getName() + ChatColor.YELLOW);
|
||||
player.sendMessage(ChatColor.YELLOW + completed);
|
||||
@ -674,7 +674,7 @@ public class PlayerListener implements Listener {
|
||||
for (String s : quester.completedQuests) {
|
||||
Quest q = plugin.getQuest(s);
|
||||
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());
|
||||
}
|
||||
}
|
@ -123,12 +123,12 @@ public class QuestAcceptPrompt extends StringPrompt {
|
||||
}
|
||||
} else if (quester.completedQuests.contains(q.getName())) {
|
||||
if (quester.currentQuests.size() < plugin.maxQuests || plugin.maxQuests < 1) {
|
||||
if (quester.getDifference(q) > 0) {
|
||||
if (quester.getCooldownDifference(q) > 0) {
|
||||
String early = Lang.get("questTooEarly");
|
||||
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);
|
||||
} else if (q.cooldownPlanner < 0) {
|
||||
} else if (q.getPlanner().getCooldown() < 0) {
|
||||
String completed = Lang.get("questAlreadyCompleted");
|
||||
completed = completed.replaceAll("<quest>", ChatColor.AQUA + q.getName() + ChatColor.YELLOW);
|
||||
player.sendMessage(ChatColor.YELLOW + completed);
|
||||
|
Loading…
Reference in New Issue
Block a user