当前位置: 首页>>代码示例>>Java>>正文


Java ChunkUnloadEvent.isCancelled方法代码示例

本文整理汇总了Java中org.bukkit.event.world.ChunkUnloadEvent.isCancelled方法的典型用法代码示例。如果您正苦于以下问题:Java ChunkUnloadEvent.isCancelled方法的具体用法?Java ChunkUnloadEvent.isCancelled怎么用?Java ChunkUnloadEvent.isCancelled使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.bukkit.event.world.ChunkUnloadEvent的用法示例。


在下文中一共展示了ChunkUnloadEvent.isCancelled方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onChunkUnload

import org.bukkit.event.world.ChunkUnloadEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST)
public void onChunkUnload(ChunkUnloadEvent event)
{
	if(!event.isCancelled())
	{
		Chunk chunk = event.getChunk();
		
		for(Machine machine : SQTechBase.machines)
		{
			if(machine.getMachineType() instanceof Harvester)
			{
				if(machine.getGUIBlock().getLocation().getChunk() == chunk)
				{
					main.setInactive(machine);
					machine.data.put("blocked", false);
				}
			}
		}
	}
}
 
开发者ID:StarQuestMinecraft,项目名称:StarQuestCode,代码行数:21,代码来源:Events.java

示例2: onChunkUnload

import org.bukkit.event.world.ChunkUnloadEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST)
public void onChunkUnload(ChunkUnloadEvent event)
{
	if(!event.isCancelled())
	{
		Chunk chunk = event.getChunk();
		
		for(Machine machine : SQTechBase.machines)
		{
			if(machine.getMachineType().name == "Drill")
			{
				if(machine.getGUIBlock().getLocation().getChunk() == chunk)
				{
					machine.data.put("isActive", false);
					machine.data.put("blocked", false);
				}
			}
		}
	}
}
 
开发者ID:StarQuestMinecraft,项目名称:StarQuestCode,代码行数:21,代码来源:Events.java

示例3: onChunkUnload

import org.bukkit.event.world.ChunkUnloadEvent; //导入方法依赖的package包/类
@HookHandler(priority = Priority.CRITICAL, ignoreCanceled = true)
public void onChunkUnload(final ChunkUnloadHook hook) {
    ChunkUnloadEvent event =
            new ChunkUnloadEvent(new CanaryChunk(hook.getChunk(), new CanaryWorld(hook.getWorld())));
    event.setCancelled(hook.isCanceled());
    server.getPluginManager().callEvent(event);
    if (event.isCancelled()) {
        hook.setCanceled();
    }
}
 
开发者ID:CanaryBukkitTeam,项目名称:CanaryBukkit,代码行数:11,代码来源:CanaryWorldListener.java

示例4: unloadChunks

import org.bukkit.event.world.ChunkUnloadEvent; //导入方法依赖的package包/类
public boolean unloadChunks() {
    if (!this.world.savingDisabled) {
        // CraftBukkit start
        Server server = this.world.getServer();
        for (int i = 0; i < 100 && !this.unloadQueue.isEmpty(); i++) {
            long chunkcoordinates = this.unloadQueue.popFirst();
            Chunk chunk = this.chunks.get(chunkcoordinates);
            if (chunk == null) continue;
            // Almura - Remove the chunk from cache if it is unloaded
            Chunk result = world.lastChunkAccessed;
            if (result != null && result.x == chunk.x && result.z == chunk.z) {
                world.lastChunkAccessed = null;
            }
            // Almura end

            ChunkUnloadEvent event = new ChunkUnloadEvent(chunk.bukkitChunk);
            server.getPluginManager().callEvent(event);
            if (!event.isCancelled()) {
                chunk.removeEntities();
                this.saveChunk(chunk);
                this.saveChunkNOP(chunk);
                // this.unloadQueue.remove(integer);
                this.chunks.remove(chunkcoordinates); // CraftBukkit
            }
        }
        // CraftBukkit end

        if (this.e != null) {
            this.e.a();
        }
    }

    return this.chunkProvider.unloadChunks();
}
 
开发者ID:AlmuraDev,项目名称:Almura-Server,代码行数:35,代码来源:ChunkProviderServer.java

示例5: unloadChunks

import org.bukkit.event.world.ChunkUnloadEvent; //导入方法依赖的package包/类
public boolean unloadChunks() {
    if (!this.world.savingDisabled) {
        // CraftBukkit start
        Server server = this.world.getServer();
        for (int i = 0; i < 100 && !this.unloadQueue.isEmpty(); i++) {
            long chunkcoordinates = this.unloadQueue.popFirst();
            Chunk chunk = this.chunks.get(chunkcoordinates);
            if (chunk == null) continue;

            ChunkUnloadEvent event = new ChunkUnloadEvent(chunk.bukkitChunk);
            server.getPluginManager().callEvent(event);
            if (!event.isCancelled()) {
                chunk.removeEntities();
                this.saveChunk(chunk);
                this.saveChunkNOP(chunk);
                // this.unloadQueue.remove(integer);
                this.chunks.remove(chunkcoordinates); // CraftBukkit
            }
        }
        // CraftBukkit end

        if (this.e != null) {
            this.e.a();
        }
    }

    return this.chunkProvider.unloadChunks();
}
 
开发者ID:didoupimpon,项目名称:Craft-city,代码行数:29,代码来源:ChunkProviderServer.java

示例6: onChunkUnload

import org.bukkit.event.world.ChunkUnloadEvent; //导入方法依赖的package包/类
@EventHandler
public void onChunkUnload(ChunkUnloadEvent event) {
	if (event.isCancelled()) return;
	Chunk chunk = event.getChunk();
	List<Frame> frames = this.manager.getFramesInChunk(chunk.getWorld().getName(), chunk.getX(), chunk.getZ());
	
	for (Frame frame : frames) {
		frame.setEntity(null);
	}
}
 
开发者ID:Howaner,项目名称:FramePicture,代码行数:11,代码来源:ChunkListener.java

示例7: unloadChunks

import org.bukkit.event.world.ChunkUnloadEvent; //导入方法依赖的package包/类
public boolean unloadChunks() {
    if (!this.world.savingDisabled) {
        // CraftBukkit start
        Server server = this.world.getServer();
        for (int i = 0; i < 100 && !this.unloadQueue.isEmpty(); i++) {
            long chunkcoordinates = this.unloadQueue.popFirst();
            Chunk chunk = this.chunks.get(chunkcoordinates);
            if (chunk == null) continue;

            ChunkUnloadEvent event = new ChunkUnloadEvent(chunk.bukkitChunk);
            server.getPluginManager().callEvent(event);
            if (!event.isCancelled()) {
                if (chunk != null) {
                    chunk.removeEntities();
                    this.saveChunk(chunk);
                    this.saveChunkNOP(chunk);
                    this.chunks.remove(chunkcoordinates); // CraftBukkit
                }

                // this.unloadQueue.remove(olong);
                // this.chunks.remove(olong.longValue());

                // Update neighbor counts
                for (int x = -2; x < 3; x++) {
                    for (int z = -2; z < 3; z++) {
                        if (x == 0 && z == 0) {
                            continue;
                        }

                        Chunk neighbor = this.getChunkIfLoaded(chunk.locX + x, chunk.locZ + z);
                        if (neighbor != null) {
                            neighbor.setNeighborUnloaded(-x, -z);
                            chunk.setNeighborUnloaded(x, z);
                        }
                    }
                }
            }
        }
        // CraftBukkit end

        if (this.f != null) {
            this.f.a();
        }
    }

    return this.chunkProvider.unloadChunks();
}
 
开发者ID:OvercastNetwork,项目名称:CraftBukkit,代码行数:48,代码来源:ChunkProviderServer.java

示例8: unloadQueuedChunks

import org.bukkit.event.world.ChunkUnloadEvent; //导入方法依赖的package包/类
public boolean unloadQueuedChunks()
{
    if (!this.worldObj.levelSaving)
    {
        // Cauldron start - remove any chunk that has a ticket associated with it
        if (!this.chunksToUnload.isEmpty())
        {
            for (ChunkCoordIntPair forcedChunk : this.worldObj.getPersistentChunks().keys())
            {
                this.chunksToUnload.remove(forcedChunk.chunkXPos, forcedChunk.chunkZPos);
            }
        }
        // Cauldron end
        // CraftBukkit start
        Server server = this.worldObj.getServer();

        for (int i = 0; i < 100 && !this.chunksToUnload.isEmpty(); i++)
        {
            long chunkcoordinates = this.chunksToUnload.popFirst();
            Chunk chunk = this.loadedChunkHashMap.get(chunkcoordinates);

            if (chunk == null)
            {
                continue;
            }

            // Cauldron static - check if the chunk was accessed recently and keep it loaded if there are players in world
            /*if (!shouldUnloadChunk(chunk) && this.worldObj.playerEntities.size() > 0)
            {
                CauldronHooks.logChunkUnload(this, chunk.xPosition, chunk.zPosition, "** Chunk kept from unloading due to recent activity");
                continue;
            }*/
            // Cauldron end


            ChunkUnloadEvent event = new ChunkUnloadEvent(chunk.bukkitChunk);
            server.getPluginManager().callEvent(event);

            if (!event.isCancelled())
            {
                CauldronHooks.logChunkUnload(this, chunk.xPosition, chunk.zPosition, "Unloading Chunk at");

                chunk.onChunkUnload();
                this.safeSaveChunk(chunk);
                this.safeSaveExtraChunkData(chunk);
                // this.unloadQueue.remove(olong);
                this.loadedChunkHashMap.remove(chunkcoordinates); // CraftBukkit
                this.loadedChunks.remove(chunk); // Cauldron - vanilla compatibility
                ForgeChunkManager.putDormantChunk(chunkcoordinates, chunk);
                if(this.loadedChunkHashMap.size() == 0 && ForgeChunkManager.getPersistentChunksFor(this.worldObj).size() == 0 && !DimensionManager.shouldLoadSpawn(this.worldObj.provider.dimensionId)){
                    DimensionManager.unloadWorld(this.worldObj.provider.dimensionId);
                    return currentChunkProvider.unloadQueuedChunks();
                }
            }
        }

        // CraftBukkit end

        if (this.currentChunkLoader != null)
        {
            this.currentChunkLoader.chunkTick();
        }
    }

    return this.currentChunkProvider.unloadQueuedChunks();
}
 
开发者ID:xtrafrancyz,项目名称:Cauldron,代码行数:67,代码来源:ChunkProviderServer.java

示例9: unloadChunks

import org.bukkit.event.world.ChunkUnloadEvent; //导入方法依赖的package包/类
public boolean unloadChunks() {
    if (!this.world.savingDisabled) {
        if (!this.unloadQueue.isEmpty()) {
            Iterator iterator = this.unloadQueue.iterator();

            for (int i = 0; i < 100 && iterator.hasNext(); iterator.remove()) {
                Long olong = (Long) iterator.next();
                Chunk chunk = (Chunk) this.chunks.get(olong);

                if (chunk != null && chunk.d) {
                    // CraftBukkit start
                    ChunkUnloadEvent event = new ChunkUnloadEvent(chunk.bukkitChunk);
                    this.world.getServer().getPluginManager().callEvent(event);
                    if (event.isCancelled()) {
                        continue;
                    }

                    // Update neighbor counts
                    for (int x = -2; x < 3; x++) {
                        for (int z = -2; z < 3; z++) {
                            if (x == 0 && z == 0) {
                                continue;
                            }

                            Chunk neighbor = this.getChunkIfLoaded(chunk.locX + x, chunk.locZ + z);
                            if (neighbor != null) {
                                neighbor.setNeighborUnloaded(-x, -z);
                                chunk.setNeighborUnloaded(x, z);
                            }
                        }
                    }
                    // CraftBukkit end

                    chunk.removeEntities();
                    this.saveChunk(chunk);
                    this.saveChunkNOP(chunk);
                    this.chunks.remove(olong);
                    ++i;
                }
            }
        }

        this.chunkLoader.a();
    }

    return false;
}
 
开发者ID:bergerkiller,项目名称:SpigotSource,代码行数:48,代码来源:ChunkProviderServer.java


注:本文中的org.bukkit.event.world.ChunkUnloadEvent.isCancelled方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。