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


Java ItemSpawnEvent类代码示例

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


ItemSpawnEvent类属于org.bukkit.event.entity包,在下文中一共展示了ItemSpawnEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: onItemSpawn

import org.bukkit.event.entity.ItemSpawnEvent; //导入依赖的package包/类
@EventHandler(priority = EventPriority.LOWEST)
public void onItemSpawn(ItemSpawnEvent event) {
    if (physicsFreeze) {
        event.setCancelled(true);
        return;
    }
    Location loc = event.getLocation();
    int cx = loc.getBlockX() >> 4;
    int cz = loc.getBlockZ() >> 4;
    int[] count = getCount(cx, cz);
    if (count[2] >= Settings.IMP.TICK_LIMITER.ITEMS) {
        event.setCancelled(true);
        return;
    }
    if (++count[2] >= Settings.IMP.TICK_LIMITER.ITEMS) {
        cleanup(loc.getChunk());
        cancelNearby(cx, cz);
        if (rateLimit <= 0) {
            rateLimit = 20;
            Fawe.debug("[FAWE `tick-limiter`] Detected and cancelled item lag source at " + loc);
        }
        event.setCancelled(true);
        return;
    }
}
 
开发者ID:boy0001,项目名称:FastAsyncWorldedit,代码行数:26,代码来源:ChunkListener.java

示例7: itemSpawn

import org.bukkit.event.entity.ItemSpawnEvent; //导入依赖的package包/类
@EventHandler
public void itemSpawn(ItemSpawnEvent event) {
	ItemStack stack = event.getEntity().getItemStack();
	if (stack == null || isMarked(stack))
		return;

	Material material = stack.getType();
	LootRule rule = LootRule.getRule(material);
	if (rule == null)
		return;

	if (rule.getProbability() < 1 && new Random().nextDouble() > rule.getProbability())
		return;

	MaterialData target = rule.getTarget();
	ItemStack replace = new ItemStack(target.getItemType(), stack.getAmount() * rule.getMultiplier());
	replace.setData(target);

	event.getEntity().setItemStack(mark(replace));
}
 
开发者ID:zyuiop,项目名称:FastSurvival,代码行数:21,代码来源:LootReplacer.java

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

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

示例10: OnItemSpawn

import org.bukkit.event.entity.ItemSpawnEvent; //导入依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST)
public void OnItemSpawn(ItemSpawnEvent event) {
	ItemStack stack = event.getEntity().getItemStack();

	if (LoreMaterial.isCustom(stack)) {
		LoreMaterial.getMaterial(stack).onItemSpawn(event);
	}
	
	if (isUnwantedVanillaItem(stack)) {
		if (!stack.getType().equals(Material.HOPPER) && 
				!stack.getType().equals(Material.HOPPER_MINECART)) {		
			event.setCancelled(true);
			event.getEntity().remove();
		}
	}
}
 
开发者ID:netizen539,项目名称:civcraft,代码行数:17,代码来源:CustomItemManager.java

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

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

示例13: onItemSpawn

import org.bukkit.event.entity.ItemSpawnEvent; //导入依赖的package包/类
@EventHandler
public void onItemSpawn(ItemSpawnEvent e) {
    if (e.getEntity().getItemStack().getType() == Material.EGG) {
        if (e.getEntity().getVelocity().getY() * 10 == 2) {
            e.getEntity().remove();
        }
    }
}
 
开发者ID:edasaki,项目名称:ZentrelaRPG,代码行数:9,代码来源:EnvironmentManager.java

示例14: processItemRemoval

import org.bukkit.event.entity.ItemSpawnEvent; //导入依赖的package包/类
@SuppressWarnings("deprecation")
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void processItemRemoval(ItemSpawnEvent event) {
    final ItemStack item = event.getEntity().getItemStack();
    if(patterns.stream().anyMatch(pattern -> pattern.matches(item))) {
        event.setCancelled(true);
    }
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:9,代码来源:ItemDestroyMatchModule.java

示例15: onItemSpawn

import org.bukkit.event.entity.ItemSpawnEvent; //导入依赖的package包/类
@EventHandler
public void onItemSpawn(ItemSpawnEvent event) {
    ItemStack stack = event.getEntity().getItemStack();
    if(applyRules(stack)) {
        event.getEntity().setItemStack(stack);
    }
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:8,代码来源:ItemModifyMatchModule.java


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