mirror of
https://github.com/PikaMug/Quests.git
synced 2024-11-13 22:25:50 +01:00
Null check events.yml
This commit is contained in:
parent
fef92e2b30
commit
fc1455902f
@ -3227,21 +3227,29 @@ 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");
|
||||||
try {
|
if (eventsFile.length() != 0) {
|
||||||
config.load(eventsFile);
|
try {
|
||||||
} catch (IOException e) {
|
config.load(eventsFile);
|
||||||
e.printStackTrace();
|
} catch (IOException e) {
|
||||||
} catch (InvalidConfigurationException e) {
|
e.printStackTrace();
|
||||||
e.printStackTrace();
|
} catch (InvalidConfigurationException e) {
|
||||||
}
|
e.printStackTrace();
|
||||||
ConfigurationSection sec = config.getConfigurationSection("events");
|
|
||||||
for (String s : sec.getKeys(false)) {
|
|
||||||
Event event = Event.loadEvent(s, this);
|
|
||||||
if (event != null) {
|
|
||||||
events.add(event);
|
|
||||||
} else {
|
|
||||||
getLogger().log(Level.SEVERE, "Failed to load Event \"" + s + "\". Skipping.");
|
|
||||||
}
|
}
|
||||||
|
ConfigurationSection sec = config.getConfigurationSection("events");
|
||||||
|
if (sec != null) {
|
||||||
|
for (String s : sec.getKeys(false)) {
|
||||||
|
Event event = Event.loadEvent(s, this);
|
||||||
|
if (event != null) {
|
||||||
|
events.add(event);
|
||||||
|
} else {
|
||||||
|
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.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user