mirror of
https://github.com/PikaMug/Quests.git
synced 2024-11-15 07:05:51 +01:00
Refresh Quest objects on reload, fixes #811
This commit is contained in:
parent
ba6cf5f620
commit
aaecb130f2
@ -49,6 +49,7 @@ import net.citizensnpcs.api.npc.NPC;
|
||||
public class Quest {
|
||||
|
||||
protected Quests plugin;
|
||||
protected String id;
|
||||
private String name;
|
||||
protected String description;
|
||||
protected String finished;
|
||||
@ -63,20 +64,8 @@ public class Quest {
|
||||
private Rewards rews = new Rewards();
|
||||
private Options opts = new Options();
|
||||
|
||||
public Requirements getRequirements() {
|
||||
return reqs;
|
||||
}
|
||||
|
||||
public Planner getPlanner() {
|
||||
return pln;
|
||||
}
|
||||
|
||||
public Rewards getRewards() {
|
||||
return rews;
|
||||
}
|
||||
|
||||
public Options getOptions() {
|
||||
return opts;
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
@ -155,6 +144,22 @@ public class Quest {
|
||||
this.initialAction = initialAction;
|
||||
}
|
||||
|
||||
public Requirements getRequirements() {
|
||||
return reqs;
|
||||
}
|
||||
|
||||
public Planner getPlanner() {
|
||||
return pln;
|
||||
}
|
||||
|
||||
public Rewards getRewards() {
|
||||
return rews;
|
||||
}
|
||||
|
||||
public Options getOptions() {
|
||||
return opts;
|
||||
}
|
||||
|
||||
/**
|
||||
* Force player to proceed to the next ordered stage
|
||||
*
|
||||
|
@ -1339,9 +1339,12 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
||||
}
|
||||
|
||||
/**
|
||||
* Reload quests, player data, actions, config settings, lang and modules, in that order
|
||||
* Reload quests, actions, config settings, lang and modules, and player data
|
||||
*/
|
||||
public void reloadQuests() {
|
||||
for (Quester quester : questers) {
|
||||
quester.saveData();
|
||||
}
|
||||
quests.clear();
|
||||
events.clear();
|
||||
|
||||
@ -1360,6 +1363,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
||||
}
|
||||
loadModules();
|
||||
for (Quester quester : questers) {
|
||||
quester.loadData();
|
||||
for (Quest q : quester.currentQuests.keySet()) {
|
||||
quester.checkQuest(q);
|
||||
}
|
||||
@ -1465,6 +1469,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
||||
try { // main "skip quest" try/catch block
|
||||
Quest quest = new Quest();
|
||||
failedToLoad = false;
|
||||
quest.id = questKey;
|
||||
if (config.contains("quests." + questKey + ".name")) {
|
||||
quest.setName(parseString(config.getString("quests." + questKey + ".name"), quest));
|
||||
} else {
|
||||
|
@ -673,10 +673,16 @@ public class CmdExecutor implements CommandExecutor {
|
||||
if (args.length == 1) {
|
||||
player.sendMessage(ChatColor.YELLOW + Lang.get(player, "COMMAND_TAKE_USAGE"));
|
||||
} else {
|
||||
Quest questToFind = plugin.getQuest(concatArgArray(args, 1, args.length - 1, ' '));
|
||||
final Quest questToFind = plugin.getQuest(concatArgArray(args, 1, args.length - 1, ' '));
|
||||
final Quester quester = plugin.getQuester(player.getUniqueId());
|
||||
if (questToFind != null) {
|
||||
final Quest q = questToFind;
|
||||
plugin.getQuester(player.getUniqueId()).offerQuest(q, true);
|
||||
for (Quest q : quester.getCurrentQuests().keySet()) {
|
||||
if (q.getId().equals(questToFind.getId())) {
|
||||
player.sendMessage(ChatColor.RED + Lang.get(player, "questAlreadyOn"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
quester.offerQuest(questToFind, true);
|
||||
} else {
|
||||
player.sendMessage(ChatColor.YELLOW + Lang.get(player, "questNotFound"));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user