org.bukkit.event.world.WorldSaveEvent Java Examples

The following examples show how to use org.bukkit.event.world.WorldSaveEvent. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WorldEventHandler.java    From GriefDefender with MIT License 6 votes vote down vote up
@EventHandler(priority = EventPriority.LOWEST)
public void onWorldSave(WorldSaveEvent event) {
    if (!GriefDefenderPlugin.getInstance().claimsEnabledForWorld(event.getWorld().getUID())) {
        return;
    }

    GDTimings.WORLD_SAVE_EVENT.startTiming();
    GDClaimManager claimWorldManager = GriefDefenderPlugin.getInstance().dataStore.getClaimWorldManager(event.getWorld().getUID());
    if (claimWorldManager == null) {
        GDTimings.WORLD_SAVE_EVENT.stopTiming();
        return;
    }

    claimWorldManager.save();

    GDTimings.WORLD_SAVE_EVENT.stopTiming();
}
 
Example #2
Source File: CraftServer.java    From Thermos with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean unloadWorld(World world, boolean save) {
    if (world == null) {
        return false;
    }

    net.minecraft.world.WorldServer handle = ((CraftWorld) world).getHandle();

    if (!(console.worlds.contains(handle))) {
        return false;
    }

    if (handle.playerEntities.size() > 0) {
        return false;
    }

    WorldUnloadEvent e = new WorldUnloadEvent(handle.getWorld());
    pluginManager.callEvent(e);

    if (e.isCancelled()) {
        return false;
    }

    if (save) {
        try {
            handle.saveAllChunks(true, null);
            handle.flush();
            WorldSaveEvent event = new WorldSaveEvent(handle.getWorld());
            getPluginManager().callEvent(event);
        } catch (net.minecraft.world.MinecraftException ex) {
            getLogger().log(Level.SEVERE, null, ex);
            FMLLog.log(org.apache.logging.log4j.Level.ERROR, ex, "Failed to save world " + handle.getWorld().getName() + " while unloading it.");
        }
    }
    MinecraftForge.EVENT_BUS.post(new WorldEvent.Unload(handle)); // Cauldron - fire unload event before removing world
    worlds.remove(world.getName().toLowerCase());
    DimensionManager.setWorld(handle.provider.dimensionId, null); // Cauldron - remove world from DimensionManager
    return true;
}
 
Example #3
Source File: EventForwarder.java    From BlueMap with MIT License 4 votes vote down vote up
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public synchronized void onWorldSaveToDisk(WorldSaveEvent evt) {
	listeners.forEach(l -> l.onWorldSaveToDisk(evt.getWorld().getUID()));		
}
 
Example #4
Source File: WorldListener.java    From Transport-Pipes with MIT License 4 votes vote down vote up
@EventHandler
public void onWorldSave(WorldSaveEvent e) {
    plugin.saveWorld(e.getWorld());
}
 
Example #5
Source File: ThreadSafetyListener.java    From LagMonitor with MIT License 4 votes vote down vote up
@EventHandler
public void onWorldSave(WorldSaveEvent worldSaveEvent) {
    checkSafety(worldSaveEvent);
}
 
Example #6
Source File: ThreadSafetyListener.java    From LagMonitor with MIT License 4 votes vote down vote up
@EventHandler
public void onWorldSave(WorldSaveEvent worldSaveEvent) {
    checkSafety(worldSaveEvent);
}