Null check events.yml

This commit is contained in:
HappyPikachu 2017-07-25 21:30:04 -04:00
parent fef92e2b30
commit fc1455902f

View File

@ -3227,6 +3227,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
public void loadEvents() { public void loadEvents() {
YamlConfiguration config = new YamlConfiguration(); YamlConfiguration config = new YamlConfiguration();
File eventsFile = new File(this.getDataFolder(), "events.yml"); File eventsFile = new File(this.getDataFolder(), "events.yml");
if (eventsFile.length() != 0) {
try { try {
config.load(eventsFile); config.load(eventsFile);
} catch (IOException e) { } catch (IOException e) {
@ -3235,6 +3236,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
e.printStackTrace(); e.printStackTrace();
} }
ConfigurationSection sec = config.getConfigurationSection("events"); ConfigurationSection sec = config.getConfigurationSection("events");
if (sec != null) {
for (String s : sec.getKeys(false)) { for (String s : sec.getKeys(false)) {
Event event = Event.loadEvent(s, this); Event event = Event.loadEvent(s, this);
if (event != null) { if (event != null) {
@ -3243,6 +3245,12 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
getLogger().log(Level.SEVERE, "Failed to load Event \"" + s + "\". Skipping."); getLogger().log(Level.SEVERE, "Failed to load Event \"" + s + "\". Skipping.");
} }
} }
} else {
getLogger().log(Level.SEVERE, "Could not find section \"events\" from events.yml. Skipping.");
}
} else {
getLogger().log(Level.WARNING, "Unable to load events.yml as it was empty. Skipping.");
}
} }
public static String parseString(String s, Quest quest) { public static String parseString(String s, Quest quest) {