use of com.elmakers.mine.bukkit.api.event.SaveEvent in project MagicPlugin by elBukkit.
the class MagicController method save.
public void save(boolean asynchronous) {
if (!initialized)
return;
maps.save(asynchronous);
final List<YamlDataFile> saveData = new ArrayList<>();
final List<MageData> saveMages = new ArrayList<>();
if (savePlayerData && mageDataStore != null) {
savePlayerData(saveMages);
}
info("Saving " + saveMages.size() + " players");
saveSpellData(saveData);
saveLostWands(saveData);
if (mageDataStore != null) {
if (asynchronous) {
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
@Override
public void run() {
synchronized (saveLock) {
for (MageData mageData : saveMages) {
mageDataStore.save(mageData, null);
}
for (YamlDataFile config : saveData) {
config.save();
}
info("Finished saving");
}
}
});
} else {
synchronized (saveLock) {
for (MageData mageData : saveMages) {
mageDataStore.save(mageData, null);
}
for (YamlDataFile config : saveData) {
config.save();
}
info("Finished saving");
}
}
}
SaveEvent saveEvent = new SaveEvent(asynchronous);
Bukkit.getPluginManager().callEvent(saveEvent);
}
Aggregations