Search in sources :

Example 1 with ChunkUnloadEvent

use of org.bukkit.event.world.ChunkUnloadEvent in project BKCommonLib by bergerhealer.

the class EntityAddRemoveHandler_1_8_to_1_13_2 method onEnabled.

@Override
public void onEnabled(CommonPlugin plugin) {
    super.onEnabled(plugin);
    plugin.register(new Listener() {

        @EventHandler(priority = EventPriority.LOWEST)
        public void onChunkLoad(ChunkLoadEvent event) {
            notifyChunkEntitiesLoaded(event.getChunk());
        }

        @EventHandler(priority = EventPriority.LOWEST)
        public void onChunkUnload(ChunkUnloadEvent event) {
            notifyChunkEntitiesUnloaded(event.getChunk());
        }
    });
}
Also used : ChunkUnloadEvent(org.bukkit.event.world.ChunkUnloadEvent) ChunkLoadEvent(org.bukkit.event.world.ChunkLoadEvent) Listener(org.bukkit.event.Listener) EventHandler(org.bukkit.event.EventHandler)

Example 2 with ChunkUnloadEvent

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

the class GlowChunk method unload.

@Deprecated
public boolean unload(boolean save, boolean safe) {
    safe = false;
    if (!isLoaded()) {
        return true;
    }
    if (safe && world.isChunkInUse(x, z)) {
        return false;
    }
    if (save && !world.getChunkManager().performSave(this)) {
        return false;
    }
    EventFactory.getInstance().callEvent(new ChunkUnloadEvent(this));
    sections = null;
    biomes = null;
    heightMap = null;
    blockEntities.clear();
    if (save) {
        for (GlowEntity entity : entities) {
            entity.remove();
        }
        entities.clear();
    }
    return true;
}
Also used : ChunkUnloadEvent(org.bukkit.event.world.ChunkUnloadEvent) GlowEntity(net.glowstone.entity.GlowEntity)

Example 3 with ChunkUnloadEvent

use of org.bukkit.event.world.ChunkUnloadEvent in project BKCommonLib by bergerhealer.

the class EntityAddRemoveHandler_1_14_to_1_16_5 method onEnabled.

@Override
public void onEnabled(CommonPlugin plugin) {
    super.onEnabled(plugin);
    plugin.register(new Listener() {

        @EventHandler(priority = EventPriority.LOWEST)
        public void onChunkLoad(ChunkLoadEvent event) {
            notifyChunkEntitiesLoaded(event.getChunk());
        }

        @EventHandler(priority = EventPriority.LOWEST)
        public void onChunkUnload(ChunkUnloadEvent event) {
            notifyChunkEntitiesUnloaded(event.getChunk());
        }
    });
}
Also used : ChunkUnloadEvent(org.bukkit.event.world.ChunkUnloadEvent) ChunkLoadEvent(org.bukkit.event.world.ChunkLoadEvent) Listener(org.bukkit.event.Listener) EventHandler(org.bukkit.event.EventHandler)

Aggregations

ChunkUnloadEvent (org.bukkit.event.world.ChunkUnloadEvent)3 EventHandler (org.bukkit.event.EventHandler)2 Listener (org.bukkit.event.Listener)2 ChunkLoadEvent (org.bukkit.event.world.ChunkLoadEvent)2 GlowEntity (net.glowstone.entity.GlowEntity)1