當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。