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() {
|
public void loadQuests() {
|
||||||
|
|
||||||
FileConfiguration config = new YamlConfiguration();
|
FileConfiguration config = new YamlConfiguration();
|
||||||
|
File file = new File(this.getDataFolder(), "quests.yml");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
config.load(new File(this.getDataFolder(), "quests.yml"));
|
config.load(file);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@ -1711,7 +1713,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
|
|||||||
ConfigurationSection section1 = config.getConfigurationSection("quests");
|
ConfigurationSection section1 = config.getConfigurationSection("quests");
|
||||||
boolean failedToLoad = false;
|
boolean failedToLoad = false;
|
||||||
totalQuestPoints = 0;
|
totalQuestPoints = 0;
|
||||||
boolean firstStage = true;
|
boolean needsSaving = false;
|
||||||
for (String s : section1.getKeys(false)) {
|
for (String s : section1.getKeys(false)) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -2967,13 +2969,48 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
|
|||||||
if (evt != null) {
|
if (evt != null) {
|
||||||
stage.startEvent = evt;
|
stage.startEvent = evt;
|
||||||
} else {
|
} 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;
|
stageFailed = true;
|
||||||
break;
|
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")) {
|
if (config.contains("quests." + s + ".stages.ordered." + s2 + ".death-event")) {
|
||||||
|
|
||||||
Event evt = Event.loadEvent(config.getString("quests." + s + ".stages.ordered." + s2 + ".death-event"), this);
|
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) {
|
if (evt != null) {
|
||||||
stage.deathEvent = evt;
|
stage.deathEvent = evt;
|
||||||
} else {
|
} 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;
|
stageFailed = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -2995,7 +3032,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
|
|||||||
if (evt != null) {
|
if (evt != null) {
|
||||||
stage.disconnectEvent = evt;
|
stage.disconnectEvent = evt;
|
||||||
} else {
|
} 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;
|
stageFailed = true;
|
||||||
break;
|
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.contains("quests." + s + ".stages.ordered." + s2 + ".delay")) {
|
||||||
|
|
||||||
if (config.getLong("quests." + s + ".stages.ordered." + s2 + ".delay", -999) != -999) {
|
if (config.getLong("quests." + s + ".stages.ordered." + s2 + ".delay", -999) != -999) {
|
||||||
@ -3107,7 +3130,6 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
quest.stages.add(stage);
|
quest.stages.add(stage);
|
||||||
firstStage = false;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3245,6 +3267,10 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
|
|||||||
//
|
//
|
||||||
quests.add(quest);
|
quests.add(quest);
|
||||||
|
|
||||||
|
if(needsSaving){
|
||||||
|
config.save(file);
|
||||||
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
if (debug == false) {
|
if (debug == false) {
|
||||||
@ -4040,11 +4066,11 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String getNPCName(int id){
|
public String getNPCName(int id){
|
||||||
|
|
||||||
return citizens.getNPCRegistry().getById(id).getName();
|
return citizens.getNPCRegistry().getById(id).getName();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int countInv(Inventory inv, Material m, int subtract) {
|
public static int countInv(Inventory inv, Material m, int subtract) {
|
||||||
|
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user