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


Java ItemSpawnEvent.setCancelled方法代码示例

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


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

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

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

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

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

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

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

示例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包/类
/**
 * Prevent items from spawning if they are in the item-remove tag in XML.
 *
 * @param event The event.
 */
@EventHandler(ignoreCancelled = true)
public void onItemSpawn(ItemSpawnEvent event) {
  Match match = Cardinal.getMatch(event.getWorld());
  MaterialData data = event.getEntity().getItemStack().getData();
  for (MaterialType type : materials.get(match)) {
    if (type.isType(data)) {
      event.setCancelled(true);
      break;
    }
  }
}
 
开发者ID:CardinalDevelopment,项目名称:Cardinal,代码行数:17,代码来源:ItemRemoveModule.java

示例10: onHelpItemDrop

import org.bukkit.event.entity.ItemSpawnEvent; //导入方法依赖的package包/类
/**
 * Removes the help item when dropped
 * @param e The event args
 */
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onHelpItemDrop(ItemSpawnEvent e) {
	if (isHelpItem(e.getEntity().getItemStack())) {
		e.setCancelled(true);
	}
}
 
开发者ID:DevotedMC,项目名称:ExilePearl,代码行数:11,代码来源:PlayerListener.java

示例11: onItemSpawn

import org.bukkit.event.entity.ItemSpawnEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.LOWEST)
public void onItemSpawn(ItemSpawnEvent event)
{
	//if in a creative world, cancel the event (don't drop items on the ground)
	if(GriefPrevention.instance.creativeRulesApply(event.getLocation()))
	{
		event.setCancelled(true);
	}
}
 
开发者ID:john01dav,项目名称:GriefPreventionPlus,代码行数:10,代码来源:EntityEventHandler.java

示例12: onItemSpawnEvent

import org.bukkit.event.entity.ItemSpawnEvent; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true)
public void onItemSpawnEvent(ItemSpawnEvent e) {
    plugin.tm.onArmourDrop(e);
    if (!e.isCancelled()) {
        if (plugin.rm.isInGame(e.getEntity().getWorld())) {
            if (plugin.rm.isProhibited(e.getEntity())) {
                e.setCancelled(true);
            }
        }
    }
}
 
开发者ID:ddonofrio,项目名称:libelula,代码行数:12,代码来源:EventManager.java

示例13: onArmourDrop

import org.bukkit.event.entity.ItemSpawnEvent; //导入方法依赖的package包/类
public void onArmourDrop(ItemSpawnEvent e) {
    List<String> lore = e.getEntity().getItemStack().getItemMeta().getLore();
    if (lore == null) {
        return;
    }
    if (lore.contains(armourBrandName)) {
        e.setCancelled(true);
    }
}
 
开发者ID:ddonofrio,项目名称:libelula,代码行数:10,代码来源:TeamManager.java

示例14: onItemSpawn

import org.bukkit.event.entity.ItemSpawnEvent; //导入方法依赖的package包/类
@EventHandler
public void onItemSpawn(ItemSpawnEvent event) {
	if ((event.getEntity().getItemStack().getType() == Material.SADDLE || event.getEntity().getItemStack().getType() == Material.IRON_BARDING || event.getEntity().getItemStack().getType() == Material.GOLD_BARDING || event.getEntity().getItemStack().getType() == Material.DIAMOND_BARDING) && this.DisableItemDrops == true) {
		// Workaround to prevent saddle/armor drops due to bukkit bug
		if (event.getEntity().getVelocity().getY() == 0.20000000298023224) {
			event.setCancelled(true);
		}
	}
}
 
开发者ID:ktross,项目名称:HorseMount,代码行数:10,代码来源:HorseMount.java

示例15: onItemSpawn

import org.bukkit.event.entity.ItemSpawnEvent; //导入方法依赖的package包/类
@EventHandler
public void onItemSpawn(ItemSpawnEvent event) {
    if (removed.contains(event.getEntity().getItemStack().getType())) {
        event.setCancelled(true);
    }
}
 
开发者ID:WarzoneMC,项目名称:Warzone,代码行数:7,代码来源:ItemRemoveModule.java


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