Search in sources :

Example 1 with WorldSaveEvent

use of org.bukkit.event.world.WorldSaveEvent in project Glowstone by GlowstoneMC.

the class GlowWorld method save.

/**
 * Saves world to disk synchronously or asynchronously.
 *
 * @param async if true, save asynchronously
 */
public void save(boolean async) {
    EventFactory.getInstance().callEvent(new WorldSaveEvent(this));
    // save metadata
    writeWorldData(async);
    // save chunkManager
    maybeAsync(async, () -> {
        for (GlowChunk chunk : chunkManager.getLoadedChunks()) {
            chunkManager.performSave(chunk);
        }
    });
    // save players
    for (GlowPlayer player : getRawPlayers()) {
        player.saveData(async);
    }
}
Also used : GlowPlayer(net.glowstone.entity.GlowPlayer) WorldSaveEvent(org.bukkit.event.world.WorldSaveEvent) GlowChunk(net.glowstone.chunk.GlowChunk)

Aggregations

GlowChunk (net.glowstone.chunk.GlowChunk)1 GlowPlayer (net.glowstone.entity.GlowPlayer)1 WorldSaveEvent (org.bukkit.event.world.WorldSaveEvent)1