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


Java ItemSpawnEvent.getEntityType方法代码示例

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


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

示例1: onItemSpawn

import org.bukkit.event.entity.ItemSpawnEvent; //导入方法依赖的package包/类
/**
 * Add ore to chest on drop
 *
 * @param event Item spawn event instance
 */
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
public void onItemSpawn(ItemSpawnEvent event)
{
    if (event.getEntityType() != EntityType.DROPPED_ITEM
            || Meta.hasMeta(event.getEntity().getItemStack())
            || event.getEntity().hasMetadata("playerDrop"))
        return;

    for (int i = 0; i < MATERIALS.length; i++)
    {
        ItemStack stack = event.getEntity().getItemStack();

        if (MATERIALS[i] != stack.getType())
            continue;

        ItemStack newStack = stack.clone();
        this.inventory.addItem(Meta.addMeta(newStack));
        event.getEntity().setItemStack(Meta.addMeta(event.getEntity().getItemStack()));
    }
}
 
开发者ID:SamaGames,项目名称:SurvivalAPI,代码行数:26,代码来源:RiskyRetrievalModule.java

示例2: onItemSpawn

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

    if (event.getEntity().hasMetadata("playerDrop"))
        return;

    Material material = event.getEntity().getItemStack().getType();

    if (material == Material.LOG || material == Material.LOG_2)
        event.getEntity().setItemStack(new ItemStack(Material.LOG, event.getEntity().getItemStack().getAmount()));
    else if (material == Material.COBBLESTONE)
        event.getEntity().setItemStack(new ItemStack(Material.COBBLESTONE, event.getEntity().getItemStack().getAmount()));
    else if (material == Material.STONE)
        event.getEntity().setItemStack(new ItemStack(Material.COBBLESTONE, event.getEntity().getItemStack().getAmount()));
}
 
开发者ID:SamaGames,项目名称:SurvivalAPI,代码行数:24,代码来源:RapidStackingModule.java

示例3: onItemSpawn

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

    if (event.getEntity().hasMetadata("playerDrop"))
        return;

    Material material = event.getEntity().getItemStack().getType();

    if (material == Material.BROWN_MUSHROOM || material == Material.RED_MUSHROOM)
        event.getEntity().setItemStack(new ItemStack(Material.MUSHROOM_SOUP, 2));
    else if (material == Material.POTATO_ITEM)
        event.getEntity().setItemStack(new ItemStack(Material.BAKED_POTATO, 1));
    else if (material == Material.CARROT_ITEM)
        event.getEntity().setItemStack(new ItemStack(Material.GOLDEN_CARROT, 1));
    else if (material == Material.WHEAT)
        event.getEntity().setItemStack(new ItemStack(Material.BREAD, 1));
    else if (material == Material.PUMPKIN)
        event.getEntity().setItemStack(new ItemStack(Material.PUMPKIN_PIE, 1));
}
 
开发者ID:SamaGames,项目名称:SurvivalAPI,代码行数:28,代码来源:RapidFoodModule.java

示例4: onItemSpawn

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

    if(Meta.hasMeta(event.getEntity().getItemStack()))
        return;

    ItemStack stack = event.getEntity().getItemStack();

    if (this.drops.containsKey(stack))
    {
        ItemStack newStack = this.drops.get(stack).getDrop(stack, this.random);

        if (newStack != null)
        {
            event.getEntity().setItemStack(Meta.addMeta(newStack));
            this.spawnXP(event.getEntity(), this.drops.get(stack).getExperienceModifier(this.random));
        }
    }
}
 
开发者ID:SamaGames,项目名称:SurvivalAPI,代码行数:28,代码来源:RapidOresModule.java

示例5: onItemSpawn

import org.bukkit.event.entity.ItemSpawnEvent; //导入方法依赖的package包/类
/**
 * Chance to drop a diamond when a player breaks a flower
 *
 * @param event Event
 */
@EventHandler
public void onItemSpawn(ItemSpawnEvent event)
{
    if (event.getEntityType() != EntityType.DROPPED_ITEM)
        return;

    if (event.getEntity().hasMetadata("playerDrop"))
        return;

    if (event.getEntity().getItemStack().getType() != Material.YELLOW_FLOWER
            && event.getEntity().getItemStack().getType() != Material.RED_ROSE
            && (event.getEntity().getItemStack().getType() != Material.DOUBLE_PLANT
                || (event.getEntity().getItemStack().getDurability() > 1 && event.getEntity().getItemStack().getDurability() < 4)))
        return;

    if (this.random.nextDouble() <= (double) this.moduleConfiguration.get("chance"))
        event.getEntity().getWorld().dropItemNaturally(event.getLocation(), Meta.addMeta(new ItemStack(Material.DIAMOND, (int) this.moduleConfiguration.get("diamonds"))));

    event.setCancelled(true);
}
 
开发者ID:SamaGames,项目名称:SurvivalAPI,代码行数:26,代码来源:DiamondFlowerModule.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包/类
/**
 * Drop some utilities
 *
 * @param event Event
 */
@EventHandler
public void onItemSpawn(ItemSpawnEvent event)
{
    if (event.getEntityType() != EntityType.DROPPED_ITEM)
        return;

    if (Meta.hasMeta(event.getEntity().getItemStack()))
        return;

    ItemStack stack = event.getEntity().getItemStack();

    for (ItemStack drop : this.drops.keySet())
    {
        if (drop.getType() == stack.getType())
        {
            if (drop.getDurability() == -1 || (drop.getDurability() == stack.getDurability()))
            {
                ItemStack finalDrop = this.drops.get(drop).getDrop(stack, this.random);

                if (finalDrop == null)
                    event.setCancelled(true);
                else
                    event.getEntity().setItemStack(finalDrop);

                break;
            }
        }
    }
}
 
开发者ID:SamaGames,项目名称:SurvivalAPI,代码行数:35,代码来源:RapidUsefulModule.java

示例8: onItemSpawn

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

    if (event.getEntity().getItemStack().getType() == Material.BARRIER)
        event.setCancelled(true);
}
 
开发者ID:SamaGames,项目名称:SurvivalAPI,代码行数:15,代码来源:NineSlotsModule.java

示例9: onItemSpawn

import org.bukkit.event.entity.ItemSpawnEvent; //导入方法依赖的package包/类
/**
 * Replace world's drop by custom ones
 *
 * @param event Event
 */
@EventHandler
public void onItemSpawn(ItemSpawnEvent event)
{
    if (event.getEntityType() != EntityType.DROPPED_ITEM)
        return;

    if (Meta.hasMeta(event.getEntity().getItemStack()))
        return;

    if (!this.drops.containsKey(event.getEntity().getItemStack().getType()))
        return;

    event.getEntity().setItemStack(Meta.addMeta(this.drops.get(event.getEntity().getItemStack().getType())));
}
 
开发者ID:SamaGames,项目名称:SurvivalAPI,代码行数:20,代码来源:WorldDropModule.java

示例10: onItemSpawn

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

    if (event.getEntity().hasMetadata("playerDrop"))
        return;

    if (event.getEntity().getItemStack().getType() == Material.COAL)
        event.getEntity().setItemStack(new ItemStack(Material.TORCH, (int) this.moduleConfiguration.get("torch")));
}
 
开发者ID:SamaGames,项目名称:SurvivalAPI,代码行数:18,代码来源:TorchThanCoalModule.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


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