本文整理汇总了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);
}
示例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;
}
}
示例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;
}
}
示例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();
}
}
}
示例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;
}
}
示例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);
}
}
示例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;
}
}
}
}
示例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);
}
示例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;
}
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
}
}
示例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);
}
}
示例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);
}
}
}
示例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);
}
}