mirror of
https://github.com/PikaMug/Quests.git
synced 2024-12-22 09:08:05 +01:00
Added legacy support for Stage event loading
This commit is contained in:
parent
8cb9ea0963
commit
ec48680b3a
@ -1700,9 +1700,11 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
|
||||
public void loadQuests() {
|
||||
|
||||
FileConfiguration config = new YamlConfiguration();
|
||||
File file = new File(this.getDataFolder(), "quests.yml");
|
||||
|
||||
try {
|
||||
|
||||
config.load(new File(this.getDataFolder(), "quests.yml"));
|
||||
config.load(file);
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@ -1711,7 +1713,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
|
||||
ConfigurationSection section1 = config.getConfigurationSection("quests");
|
||||
boolean failedToLoad = false;
|
||||
totalQuestPoints = 0;
|
||||
boolean firstStage = true;
|
||||
boolean needsSaving = false;
|
||||
for (String s : section1.getKeys(false)) {
|
||||
|
||||
try {
|
||||
@ -2967,13 +2969,48 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
|
||||
if (evt != null) {
|
||||
stage.startEvent = evt;
|
||||
} else {
|
||||
printSevere("[Quests] start-event in Stage " + s2 + " of Quest " + quest.name + " failed to load.");
|
||||
printSevere("[Quests] start-event: in Stage " + s2 + " of Quest " + quest.name + " failed to load.");
|
||||
stageFailed = true;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (config.contains("quests." + s + ".stages.ordered." + s2 + ".finish-event")) {
|
||||
|
||||
Event evt = Event.loadEvent(config.getString("quests." + s + ".stages.ordered." + s2 + ".finish-event"), this);
|
||||
|
||||
if (evt != null) {
|
||||
stage.finishEvent = evt;
|
||||
} else {
|
||||
printSevere("[Quests] finish-event: in Stage " + s2 + " of Quest " + quest.name + " failed to load.");
|
||||
stageFailed = true;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//Legacy support
|
||||
if (config.contains("quests." + s + ".stages.ordered." + s2 + ".event")) {
|
||||
|
||||
Event evt = Event.loadEvent(config.getString("quests." + s + ".stages.ordered." + s2 + ".event"), this);
|
||||
|
||||
if (evt != null) {
|
||||
stage.finishEvent = evt;
|
||||
printInfo("[Quests] Converting event: in Stage " + s2 + " of Quest " + quest.name + " to finish-event:");
|
||||
String old = config.getString("quests." + s + ".stages.ordered." + s2 + ".event");
|
||||
config.set("quests." + s + ".stages.ordered." + s2 + ".finish-event", old);
|
||||
config.set("quests." + s + ".stages.ordered." + s2 + ".event", null);
|
||||
needsSaving = true;
|
||||
} else {
|
||||
printSevere("[Quests] event: in Stage " + s2 + " of Quest " + quest.name + " failed to load.");
|
||||
stageFailed = true;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
//
|
||||
|
||||
if (config.contains("quests." + s + ".stages.ordered." + s2 + ".death-event")) {
|
||||
|
||||
Event evt = Event.loadEvent(config.getString("quests." + s + ".stages.ordered." + s2 + ".death-event"), this);
|
||||
@ -2981,7 +3018,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
|
||||
if (evt != null) {
|
||||
stage.deathEvent = evt;
|
||||
} else {
|
||||
printSevere("[Quests] death-event in Stage " + s2 + " of Quest " + quest.name + " failed to load.");
|
||||
printSevere("[Quests] death-event: in Stage " + s2 + " of Quest " + quest.name + " failed to load.");
|
||||
stageFailed = true;
|
||||
break;
|
||||
}
|
||||
@ -2995,7 +3032,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
|
||||
if (evt != null) {
|
||||
stage.disconnectEvent = evt;
|
||||
} else {
|
||||
printSevere("[Quests] disconnect-event in Stage " + s2 + " of Quest " + quest.name + " failed to load.");
|
||||
printSevere("[Quests] disconnect-event: in Stage " + s2 + " of Quest " + quest.name + " failed to load.");
|
||||
stageFailed = true;
|
||||
break;
|
||||
}
|
||||
@ -3053,20 +3090,6 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
|
||||
|
||||
}
|
||||
|
||||
if (config.contains("quests." + s + ".stages.ordered." + s2 + ".finish-event")) {
|
||||
|
||||
Event evt = Event.loadEvent(config.getString("quests." + s + ".stages.ordered." + s2 + ".finish-event"), this);
|
||||
|
||||
if (evt != null) {
|
||||
stage.finishEvent = evt;
|
||||
} else {
|
||||
printSevere("[Quests] finish-event in Stage " + s2 + " of Quest " + quest.name + " failed to load.");
|
||||
stageFailed = true;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (config.contains("quests." + s + ".stages.ordered." + s2 + ".delay")) {
|
||||
|
||||
if (config.getLong("quests." + s + ".stages.ordered." + s2 + ".delay", -999) != -999) {
|
||||
@ -3107,7 +3130,6 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
|
||||
break;
|
||||
}
|
||||
quest.stages.add(stage);
|
||||
firstStage = false;
|
||||
|
||||
}
|
||||
|
||||
@ -3245,6 +3267,10 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
|
||||
//
|
||||
quests.add(quest);
|
||||
|
||||
if(needsSaving){
|
||||
config.save(file);
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
|
||||
if (debug == false) {
|
||||
|
Loading…
Reference in New Issue
Block a user