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


Java ChunkUnloadEvent.getChunk方法代码示例

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


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

示例1: onChunkUnload

import org.bukkit.event.world.ChunkUnloadEvent; //导入方法依赖的package包/类
/**
 * Prevent chunk that contain pearls from unloading
 * @param e The event args
 */
@EventHandler(priority=EventPriority.HIGH, ignoreCancelled = true)
public void onChunkUnload(ChunkUnloadEvent e) {
	Chunk chunk = e.getChunk();
	for (Entity entity : chunk.getEntities()) {
		if (!(entity instanceof Item)) {
			continue;
		}
		
		Item item = (Item)entity;
		ExilePearl pearl = pearlApi.getPearlFromItemStack(item.getItemStack());
		
		if (pearl != null) {
			e.setCancelled(true);
			pearlApi.log("Prevented chunk (%d, %d) from unloading because it contained an exile pearl for player %s.", chunk.getX(), chunk.getZ(), pearl.getPlayerName());
		}
	}
}
 
开发者ID:DevotedMC,项目名称:ExilePearl,代码行数:22,代码来源:PlayerListener.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() instanceof Harvester)
			{
				if(machine.getGUIBlock().getLocation().getChunk() == chunk)
				{
					main.setInactive(machine);
					machine.data.put("blocked", false);
				}
			}
		}
	}
}
 
开发者ID:StarQuestMinecraft,项目名称:StarQuestCode,代码行数:21,代码来源:Events.java

示例3: 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

示例4: onChunkUnloaded

import org.bukkit.event.world.ChunkUnloadEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.NORMAL)
public void onChunkUnloaded(ChunkUnloadEvent event) {
    Chunk c = event.getChunk();
    
    Entity[] entities = c.getEntities();
    
    for(Entity e: entities){
    	if (this.manager.isHorse(e))
    	{
    		if (this.manager.isOwned(e.getUniqueId()))
    		{
    			// We save horse location
    			Location loc = e.getLocation();
    			this.data.getHorsesData().set("horses."+e.getUniqueId()+".lastpos",loc.getWorld().getName()+":"+loc.getX()+":"+loc.getY()+":"+loc.getZ()+":"+loc.getYaw()+":"+loc.getPitch());
    			
    			this.data.save();
    		}
    	}
    }
}
 
开发者ID:vikicraft,项目名称:horsekeep,代码行数:21,代码来源:HorseKeep.java

示例5: onChunkUnload

import org.bukkit.event.world.ChunkUnloadEvent; //导入方法依赖的package包/类
@EventHandler
public void onChunkUnload(ChunkUnloadEvent event) {
    if (ignoreUnload) {
        return;
    }
    if (Settings.Chunk_Processor.AUTO_TRIM) {
        Chunk chunk = event.getChunk();
        String world = chunk.getWorld().getName();
        if (PS.get().hasPlotArea(world)) {
            if (unloadChunk(world, chunk, true)) {
                return;
            }
        }
    }
    if (processChunk(event.getChunk(), true)) {
        event.setCancelled(true);
    }
}
 
开发者ID:IntellectualSites,项目名称:PlotSquared,代码行数:19,代码来源:ChunkListener.java

示例6: onChunkUnload

import org.bukkit.event.world.ChunkUnloadEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onChunkUnload(ChunkUnloadEvent event)
{
	final Chunk c = event.getChunk();
	for(Entity entity : c.getEntities())
	{
		if(!(entity instanceof LivingEntity))
			continue;

		RemoteEntity rentity = RemoteEntities.getRemoteEntityFromEntity((LivingEntity)entity);
		if(rentity != null && rentity.isSpawned())
		{
			m_toSpawn.add(new EntityLoadData(rentity, entity.getLocation()));
			rentity.despawn(DespawnReason.CHUNK_UNLOAD);
		}
	}
}
 
开发者ID:MeRPG2,项目名称:EndHQ-Libraries,代码行数:18,代码来源:ChunkEntityLoader.java

示例7: onChunkUnload

import org.bukkit.event.world.ChunkUnloadEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR)
private void onChunkUnload(ChunkUnloadEvent cue) {
  Chunk chunk = cue.getChunk();
  ConfigurationSection config = configs.get(cue.getChunk());
  if(config != null && config.isConfigurationSection("blocks")) {
    ConfigurationSection blocks = config.getConfigurationSection("blocks");
    for(Map.Entry<String, Object> entry : blocks.getValues(false).entrySet()) {
      ConfigurationSection section = (ConfigurationSection) entry.getValue();
      String[] locationParts = entry.getKey().split(" ");
      int[] locationValues = new int[3];
      for(int i = 0; i < 3; i++) {
        locationValues[i] = Integer.parseInt(locationParts[i]);
      }
      BlockConfigUnloadEvent event = new BlockConfigUnloadEvent(plugin, section, cue.getChunk().getBlock(locationValues[0], locationValues[2], locationValues[2]));
      Bukkit.getPluginManager().callEvent(event);
    }
  }
  saveConfig(cue.getChunk());
  configs.remove(chunk);
  blockConfigs.remove(chunk);
}
 
开发者ID:Dykam,项目名称:ReadySetJump,代码行数:22,代码来源:BlockConfig.java

示例8: onUnload

import org.bukkit.event.world.ChunkUnloadEvent; //导入方法依赖的package包/类
@EventHandler
public void onUnload(ChunkUnloadEvent event) {
    Chunk unloadedChunk = event.getChunk();
    for (Entity entity : unloadedChunk.getEntities()) {
        if (entity instanceof LivingEntity) {
            Object handle = BukkitUnwrapper.getInstance().unwrap(entity);
            if (handle instanceof ControllableEntityHandle) {
                ControllableEntity controllableEntity = ((ControllableEntityHandle) handle).getControllableEntity();
                if (controllableEntity != null && controllableEntity.isSpawned()) {
                    this.SPAWN_QUEUE.add(new EntityChunkData(controllableEntity, entity.getLocation()));
                    controllableEntity.despawn(DespawnReason.CHUNK_UNLOAD);
                }
            }
        }
    }
}
 
开发者ID:EntityAPIDev,项目名称:EntityAPI,代码行数:17,代码来源:SimpleChunkManager.java

示例9: onChunkUnload

import org.bukkit.event.world.ChunkUnloadEvent; //导入方法依赖的package包/类
/**
 * Marks a loaded chunk as pending unload. It'll be unloaded later en-masse.
 * 
 * @param e The chunk to unload.
 */
@EventHandler(ignoreCancelled = true)
public void onChunkUnload(ChunkUnloadEvent e) {
	Chunk chunk = e.getChunk();
	
	CropControl.getDAO().unloadChunk(chunk);
}
 
开发者ID:DevotedMC,项目名称:CropControl,代码行数:12,代码来源:CropControlEventHandler.java

示例10: onChunkUnload

import org.bukkit.event.world.ChunkUnloadEvent; //导入方法依赖的package包/类
@EventHandler(priority=EventPriority.MONITOR, ignoreCancelled = true)
public void onChunkUnload(ChunkUnloadEvent event) {
    Chunk chunk = event.getChunk();
    ChunkReloader.addUnloadedChunk(event.getWorld(), chunk.getX(), chunk.getZ());

    //Orebfuscator.log("Chunk x = " + chunk.getX() + ", z = " + chunk.getZ() + " is unloaded");/*debug*/
}
 
开发者ID:SamaGames,项目名称:AntiCheat,代码行数:8,代码来源:OrebfuscatorChunkListener.java

示例11: ChunkloadClear

import org.bukkit.event.world.ChunkUnloadEvent; //导入方法依赖的package包/类
@EventHandler
public void ChunkloadClear(ChunkUnloadEvent event) {
	if (ConfigOptimize.UnloadClearenable != true) {
		return;
	}
	Chunk chunk = event.getChunk();
	boolean noclearitemchunk = false;
	int dcs = DeathChunk.size();
	for (int i = 0; i < dcs; i++) {
		Chunk deathchunk = DeathChunk.get(i);
		if (Utils.isSameChunk(chunk, deathchunk)) {
			DeathChunk.remove(chunk);
			noclearitemchunk = true;
			break;
		}
	}
	Entity[] entities = chunk.getEntities();
	for (int i = 0; i < entities.length; i++) {
		Entity ent = entities[i];
		if (ent.getType() == EntityType.DROPPED_ITEM && noclearitemchunk == false && ConfigOptimize.UnloadClearDROPPED_ITEMenable) {
			ent.remove();
		}
		if(ConfigOptimize.UnloadCleartype.contains(ent.getType().name())||ConfigOptimize.UnloadCleartype.contains("*")) {
			ent.remove();
		}
	}
}
 
开发者ID:GelandiAssociation,项目名称:EscapeLag,代码行数:28,代码来源:UnloadClear.java

示例12: chunkUnloadClearBullets

import org.bukkit.event.world.ChunkUnloadEvent; //导入方法依赖的package包/类
/**
 * This eliminates pending bullets on chunk unload
 * 
 * @param event
 */
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void chunkUnloadClearBullets(ChunkUnloadEvent event) {
	if (event.getChunk() == null) return;
	Entity[] entities = event.getChunk().getEntities();
	for (Entity e : entities) {
		if (inFlightBullets.containsKey(e.getUniqueId())) {
			inFlightBullets.remove(e.getUniqueId());
			travelPaths.remove(e.getUniqueId());
			e.remove();
		}
	}
}
 
开发者ID:ProgrammerDan,项目名称:AddGun,代码行数:18,代码来源:Guns.java

示例13: onUnloadChunk

import org.bukkit.event.world.ChunkUnloadEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onUnloadChunk(ChunkUnloadEvent e) {
	if (!cm.hotChunkEnabled || NeverLag.getTpsWatcher().getAverageTPS() < cm.hotChunkTpsThreshold) {
		return;
	}
	ChunkInfo chunkInfo = new ChunkInfo(e.getChunk());
	if (hotChunkRecord.contains(chunkInfo)) {
		e.setCancelled(true);
		this.addHotChunkUnloadCount(chunkInfo);
	}
}
 
开发者ID:jiongjionger,项目名称:NeverLag,代码行数:12,代码来源:HotChunkHolder.java

示例14: onUnloadChunkMonitor

import org.bukkit.event.world.ChunkUnloadEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onUnloadChunkMonitor(ChunkUnloadEvent e) {
	if (!cm.hotChunkEnabled || NeverLag.getTpsWatcher().getAverageTPS() < cm.hotChunkTpsThreshold) {
		return;
	}
	ChunkInfo chunkInfo = new ChunkInfo(e.getChunk());
	chunkUnLoadTime.put(chunkInfo, System.currentTimeMillis());
}
 
开发者ID:jiongjionger,项目名称:NeverLag,代码行数:9,代码来源:HotChunkHolder.java

示例15: onChunkUnload

import org.bukkit.event.world.ChunkUnloadEvent; //导入方法依赖的package包/类
@EventHandler
public static void onChunkUnload(ChunkUnloadEvent event) {
    Chunk chunk = event.getChunk();
    long pair = MathMan.pairInt(chunk.getX(), chunk.getZ());
    Long lastLoad = keepLoaded.get(pair);
    if (lastLoad != null) {
        if (Fawe.get().getTimer().getTickStart() - lastLoad < 10000) {
            event.setCancelled(true);
        } else {
            keepLoaded.remove(pair);
        }
    }
}
 
开发者ID:boy0001,项目名称:FastAsyncWorldedit,代码行数:14,代码来源:BukkitQueue_0.java


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