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


Java ItemSpawnEvent.getEntity方法代码示例

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


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

示例1: onItemSpawn

import org.bukkit.event.entity.ItemSpawnEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.NORMAL)
public void onItemSpawn(final ItemSpawnEvent event) {
	if (event.isCancelled())
		return;

	final Entity item = event.getEntity();
	if (item.getType() != EntityType.DROPPED_ITEM || ((Item) item).getItemStack().getType() != Material.SUGAR_CANE)
		return;

	// Stop sugarcane block from decaying (workaround for lack of 1.7.2-R0.1 physics support)
	final WorldCoord coord = new WorldCoord((Item) item);
	final Gate nearestGate = Gates.gateFromPortal(coord);

	if (nearestGate != null) {
		if (nearestGate.getMaterial() != Material.SUGAR_CANE_BLOCK)
			return;

		event.getEntity().remove();
		plugin.getServer().getScheduler().scheduleSyncDelayedTask(Plugin.instance, new Runnable() {
			@Override
			public void run() {
				coord.getBlock().setType(Material.SUGAR_CANE_BLOCK);
			}
		}, 1);
	}
}
 
开发者ID:NoChanceSD,项目名称:AncientGates,代码行数:27,代码来源:PluginBlockListener.java

示例2: onItemSpawn

import org.bukkit.event.entity.ItemSpawnEvent; //导入方法依赖的package包/类
@EventHandler(priority=EventPriority.LOWEST)
public void onItemSpawn(ItemSpawnEvent event) {
    Item entity = event.getEntity();
    Chunk chunk = entity.getLocation().getChunk();
    if (chunk == lastChunk) {
        event.getEntity().remove();
        event.setCancelled(true);
        return;
    }
    if (!PlotSquared.isPlotWorld(chunk.getWorld().getName())) {
        return;
    }
    Entity[] entities = chunk.getEntities();
    if (entities.length > Settings.CHUNK_PROCESSOR_MAX_ENTITIES) {
        event.getEntity().remove();
        event.setCancelled(true);
        lastChunk = chunk;
    }
    else {
        lastChunk = null;
    }
}
 
开发者ID:Mayomi,项目名称:PlotSquared-Chinese,代码行数:23,代码来源:ChunkListener.java

示例3: OnItemSpawn

import org.bukkit.event.entity.ItemSpawnEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR) 
public void OnItemSpawn(ItemSpawnEvent event) {
	Item item = event.getEntity();
	
	BonusGoodie goodie = CivGlobal.getBonusGoodie(item.getItemStack());
	if (goodie == null) {
		return;
	}
	
	// Cant validate here, validate in drop item events...
	goodie.setItem(item);
	try {
		goodie.update(false);
		goodie.updateLore(item.getItemStack());
	} catch (CivException e) {
		e.printStackTrace();
	}
}
 
开发者ID:netizen539,项目名称:civcraft,代码行数:19,代码来源:BonusGoodieManager.java

示例4: onItemSpawn

import org.bukkit.event.entity.ItemSpawnEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.LOWEST)
public void onItemSpawn(ItemSpawnEvent event) {
    Item entity = event.getEntity();
    Chunk chunk = entity.getLocation().getChunk();
    if (chunk == this.lastChunk) {
        event.getEntity().remove();
        event.setCancelled(true);
        return;
    }
    if (!PS.get().hasPlotArea(chunk.getWorld().getName())) {
        return;
    }
    Entity[] entities = chunk.getEntities();
    if (entities.length > Settings.Chunk_Processor.MAX_ENTITIES) {
        event.getEntity().remove();
        event.setCancelled(true);
        this.lastChunk = chunk;
    } else {
        this.lastChunk = null;
    }
}
 
开发者ID:IntellectualSites,项目名称:PlotSquared,代码行数:22,代码来源:ChunkListener.java

示例5: onDrop

import org.bukkit.event.entity.ItemSpawnEvent; //导入方法依赖的package包/类
@EventHandler
public void onDrop(ItemSpawnEvent event)
{
	if(event.isCancelled()) return;
	final Item itemDrop = event.getEntity();
	if(itemDrop.getItemStack().getType() == Material.BOWL)
	{
	    final Runnable task = new Runnable()
	    {
	    	public void run()
	    	{
	    		if(itemDrop.getItemStack().getAmount() != 1) return;
	    		Location itemLocation = itemDrop.getLocation();
	    		if(itemLocation.getBlock().getType() == Material.WATER || itemLocation.getBlock().getType() == Material.STATIONARY_WATER)
	    		{
	    			itemDrop.remove();
	    			
	    	      	ItemStack i_beetroot = new ItemStack(Material.BEETROOT_SOUP, 1);
	    	      	ItemMeta beetrootMeta= i_beetroot.getItemMeta();
	    	      	beetrootMeta.setDisplayName(ChatColor.RESET + Survival.instance.Words.get("Water Bowl"));
	    	      	i_beetroot.setItemMeta(beetrootMeta);
	    	      	
	    			itemDrop.getWorld().dropItem(itemLocation, i_beetroot);
	    		}
            }
	    };
	    
	    Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(Survival.instance, task, 20L);
	}
}
 
开发者ID:FattyMieo,项目名称:SurvivalPlus,代码行数:31,代码来源:WaterBowl.java

示例6: onGhastTearSlimeBlock

import org.bukkit.event.entity.ItemSpawnEvent; //导入方法依赖的package包/类
@EventHandler
public void onGhastTearSlimeBlock(ItemSpawnEvent e)
{
	if(e.getEntityType() == EntityType.DROPPED_ITEM)
	{
		Item i = (Item)e.getEntity();
		switch(i.getItemStack().getType())
		{
			case GHAST_TEAR:
				Bukkit.getScheduler().runTaskLater(Survival.instance, initRunnable(i), 20);
				break;
			default:
		}
	}
}
 
开发者ID:FattyMieo,项目名称:SurvivalPlus,代码行数:16,代码来源:LivingSlime.java

示例7: onItemSpawn

import org.bukkit.event.entity.ItemSpawnEvent; //导入方法依赖的package包/类
@EventHandler
public void onItemSpawn(ItemSpawnEvent event) {
	Item item = event.getEntity();
	ItemStack stack = item.getItemStack();
	World world = item.getWorld();
	
	if (world.getEnvironment() != Environment.THE_END || stack.getType() != Material.DRAGON_EGG
			|| stack.hasItemMeta()) return;
	
	DragonTemplate dragon = plugin.getDEDManager().getWorldWrapper(world).getActiveBattle();
	DragonLoot loot = dragon.getLoot();
	
	String eggName = loot.getEggName().replace("%dragon%", dragon.getName());
	List<String> eggLore = loot.getEggLore().stream()
			.map(s -> s.replace("%dragon%", dragon.getName()))
			.collect(Collectors.toList());

	ItemMeta eggMeta = stack.getItemMeta();
	
	if (eggName != null && !eggName.isEmpty()) {
		eggMeta.setDisplayName(eggName);
	}
	if (eggLore != null && !eggLore.isEmpty()) {
		eggMeta.setLore(eggLore);
	}
	
	stack.setItemMeta(eggMeta);
}
 
开发者ID:2008Choco,项目名称:DragonEggDrop,代码行数:29,代码来源:LootListeners.java

示例8: onItemSpawn

import org.bukkit.event.entity.ItemSpawnEvent; //导入方法依赖的package包/类
@EventHandler
public void onItemSpawn(ItemSpawnEvent e) {
    if (e.isCancelled()) {
        return;
    }

    Item item = e.getEntity();
    ItemStack is = item.getItemStack();

    if (isMoneyItem(is)) {
        item.setCustomName(is.getItemMeta().getDisplayName());
        item.setCustomNameVisible(true);
    }
}
 
开发者ID:diecode,项目名称:KillerMoney,代码行数:15,代码来源:MoneyHandler.java

示例9: onItemSpawn

import org.bukkit.event.entity.ItemSpawnEvent; //导入方法依赖的package包/类
/**
 * Track the location of a pearl if it spawns as an item for any reason
 * @param e The event args
 */
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onItemSpawn(ItemSpawnEvent e) {
	Item item = e.getEntity();

	ExilePearl pearl = pearlApi.getPearlFromItemStack(item.getItemStack());
	if (pearl == null) {
		return;
	}

	pearl.setHolder(item);
}
 
开发者ID:DevotedMC,项目名称:ExilePearl,代码行数:16,代码来源:PlayerListener.java

示例10: onItemSpawn

import org.bukkit.event.entity.ItemSpawnEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR)
public void onItemSpawn(ItemSpawnEvent event)
{
    if (!data.getChestCache().isChestListEmpty() && event.getEntity() instanceof Item )//&& plugin.worldSet.contains(event.getEntity().getWorld().getName()))
    {
        for (Loc loc : data.getChestCache().getChestList())
        {
            Location l = loc.toLocation();
            if (event.getEntity().getLocation().getWorld().getName().equals(l.getWorld().getName()) && l.distanceSquared(event.getEntity().getLocation()) < 4)
            {
                ((Item) event.getEntity()).setPickupDelay(20);
            }
        }
    }
}
 
开发者ID:Vanillacraft,项目名称:vanillacraft,代码行数:16,代码来源:GriefProtectListeners.java

示例11: onItemSpawn

import org.bukkit.event.entity.ItemSpawnEvent; //导入方法依赖的package包/类
/**
 * Concentrate stacks
 *
 * @param event Event
 */
@EventHandler
public void onItemSpawn(ItemSpawnEvent event)
{
    if (event.getEntityType() != EntityType.DROPPED_ITEM)
        return;

    Item newEntity = event.getEntity();
    List<Entity> entityList = newEntity.getNearbyEntities(this.radius, 1, this.radius);
    int maxSize = newEntity.getItemStack().getMaxStackSize();

    for (Entity anEntityList : entityList)
    {
        if (anEntityList instanceof Item)
        {
            Item curEntity = (Item) anEntityList;

            if (!curEntity.isDead()
                    && curEntity.getItemStack().getType().equals(newEntity.getItemStack().getType())
                    && curEntity.getItemStack().getData().getData() == newEntity.getItemStack().getData().getData()
                    && curEntity.getItemStack().getDurability() == newEntity.getItemStack().getDurability()
                    && Math.abs(curEntity.getLocation().getX() - newEntity.getLocation().getX()) <= this.radius
                    && Math.abs(curEntity.getLocation().getY() - newEntity.getLocation().getY()) <= this.radius
                    && Math.abs(curEntity.getLocation().getZ() - newEntity.getLocation().getZ()) <= this.radius)
            {
                int newAmount = newEntity.getItemStack().getAmount();
                int curAmount = curEntity.getItemStack().getAmount();
                int more = Math.min(newAmount, maxSize - curAmount);

                curAmount += more;
                newAmount -= more;
                curEntity.getItemStack().setAmount(curAmount);
                newEntity.getItemStack().setAmount(newAmount);

                if (newAmount <= 0)
                    event.setCancelled(true);

                return;
            }
        }
    }
}
 
开发者ID:SamaGames,项目名称:SurvivalAPI,代码行数:47,代码来源:OptimizationListener.java

示例12: onSpawn

import org.bukkit.event.entity.ItemSpawnEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onSpawn(ItemSpawnEvent e) {
	if (cm.isAntiNegativeItemDupe && e.getEntity() != null && e.getEntity().getItemStack() != null && e.getEntity().getItemStack().getAmount() <= 0) {
		e.setCancelled(true);
	}
}
 
开发者ID:jiongjionger,项目名称:NeverLag,代码行数:7,代码来源:AntiNegativeItemDupe.java


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