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


Java PlayerItemConsumeEvent.isCancelled方法代码示例

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


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

示例1: onConsume

import org.bukkit.event.player.PlayerItemConsumeEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST)
public void onConsume(PlayerItemConsumeEvent event)
{
	if(event.isCancelled()) return;
	Player player = event.getPlayer();
	if(event.getItem().getType() == Material.POISONOUS_POTATO)
	{
		for (PotionEffect effect : player.getActivePotionEffects())
	        player.removePotionEffect(effect.getType());

		Random rand = new Random();
		if(rand.nextInt(10) + 1 <= 6)
		{
			player.addPotionEffect(new PotionEffect(PotionEffectType.POISON, 100, 0), true);
			player.addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION, 200, 0), true);
		}
	}
}
 
开发者ID:FattyMieo,项目名称:SurvivalPlus,代码行数:19,代码来源:PoisonousPotato.java

示例2: onConsume

import org.bukkit.event.player.PlayerItemConsumeEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST)
public void onConsume(PlayerItemConsumeEvent event)
{
	if(event.isCancelled()) return;
	Player player = event.getPlayer();
	if(event.getItem().getType() == Material.BEETROOT)
	{
		int amp = 0;
		int dur = 200;
		for (PotionEffect effect : player.getActivePotionEffects())
		{
			if(effect.getType().equals(PotionEffectType.INCREASE_DAMAGE))
			{
				dur += effect.getDuration();
				if(dur > 600) dur = 600;
				player.removePotionEffect(effect.getType());
			}
		}
		player.addPotionEffect(new PotionEffect(PotionEffectType.INCREASE_DAMAGE, dur, amp));
	}
}
 
开发者ID:FattyMieo,项目名称:SurvivalPlus,代码行数:22,代码来源:BeetrootStrength.java

示例3: onConsume

import org.bukkit.event.player.PlayerItemConsumeEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST)
public void onConsume(PlayerItemConsumeEvent event)
{
	if(!Survival.settings.getBoolean("Mechanics.Thirst.Enabled"))
	{
		if(event.isCancelled()) return;
		Player player = event.getPlayer();
		if(event.getItem().getType() == Material.BEETROOT_SOUP)
		{
			event.setCancelled(true);
		}
	}
}
 
开发者ID:FattyMieo,项目名称:SurvivalPlus,代码行数:14,代码来源:WaterBowl.java

示例4: onConsume

import org.bukkit.event.player.PlayerItemConsumeEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST)
public void onConsume(PlayerItemConsumeEvent event)
{
	if(event.isCancelled()) return;
	Random rand = new Random();
	Player player = event.getPlayer();
	switch(event.getItem().getType())
	{
		case RAW_BEEF:
		case PORK:
		case MUTTON:
		case RAW_FISH:
		case RAW_CHICKEN:
		case ROTTEN_FLESH:
			int hungerChance = rand.nextInt(10) + 1;
			if(hungerChance >= 1 && hungerChance <= 8)
			{
				int dur = 600;
				for (PotionEffect effect : player.getActivePotionEffects())
				{
					if(effect.getType().equals(PotionEffectType.HUNGER))
					{
						dur += effect.getDuration();
				        player.removePotionEffect(effect.getType());
					}
				}
				player.addPotionEffect(new PotionEffect(PotionEffectType.HUNGER, dur, 0, false));
			}
			break;
		default:
	}
}
 
开发者ID:FattyMieo,项目名称:SurvivalPlus,代码行数:33,代码来源:RawMeatHunger.java

示例5: onConsume

import org.bukkit.event.player.PlayerItemConsumeEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST)
public void onConsume(PlayerItemConsumeEvent event)
{
	if(event.isCancelled()) return;
	Player player = event.getPlayer();
	if(event.getItem().getType() == Material.COOKIE)
	{
		int amp = -1;
		int dur = 600;
		for (PotionEffect effect : player.getActivePotionEffects())
		{
			if(effect.getType().equals(PotionEffectType.HEALTH_BOOST))
			{
				dur += effect.getDuration();
				if(effect.getDuration() >= 300)
					amp++;
				if(effect.getDuration() >= 1200)
					amp++;
				if(effect.getDuration() >= 3600)
					amp++;
		        player.removePotionEffect(effect.getType());
			}
		}
		player.addPotionEffect(new PotionEffect(PotionEffectType.HEALTH_BOOST, dur, amp));
		player.setSaturation(player.getSaturation() + 4.6f);
	}
}
 
开发者ID:FattyMieo,项目名称:SurvivalPlus,代码行数:28,代码来源:CookieHealthBoost.java

示例6: v

import org.bukkit.event.player.PlayerItemConsumeEvent; //导入方法依赖的package包/类
protected void v() {
    if (this.bn != null && this.ct()) {
        this.a(this.bn, 16);
        // CraftBukkit start - fire PlayerItemConsumeEvent
        org.bukkit.inventory.ItemStack craftItem = CraftItemStack.asBukkitCopy(this.bn); // PAIL: rename
        PlayerItemConsumeEvent event = new PlayerItemConsumeEvent((Player) this.getBukkitEntity(), craftItem);
        world.getServer().getPluginManager().callEvent(event);

        if (event.isCancelled()) {
            // Update client
            if (this instanceof EntityPlayer) {
                ((EntityPlayer) this).getBukkitEntity().updateInventory();
                ((EntityPlayer) this).getBukkitEntity().updateScaledHealth();
            }
            return;
        }

        ItemStack itemstack = (craftItem.equals(event.getItem())) ? this.bn.a(this.world, this) : CraftItemStack.asNMSCopy(event.getItem()).a(world, this);
        // CraftBukkit end

        if (itemstack != null && itemstack.count == 0) {
            itemstack = null;
        }

        this.a(this.cu(), itemstack);
        this.cA();
    }

}
 
开发者ID:bergerkiller,项目名称:SpigotSource,代码行数:30,代码来源:EntityLiving.java

示例7: p

import org.bukkit.event.player.PlayerItemConsumeEvent; //导入方法依赖的package包/类
protected void p() {
    if (this.f != null) {
        this.c(this.f, 16);
        int i = this.f.count;

        // CraftBukkit start - fire PlayerItemConsumeEvent
        org.bukkit.inventory.ItemStack craftItem = CraftItemStack.asBukkitCopy(this.f);
        PlayerItemConsumeEvent event = new PlayerItemConsumeEvent((Player) this.getBukkitEntity(), craftItem);
        world.getServer().getPluginManager().callEvent(event);

        if (event.isCancelled()) {
            // Update client
            if (this instanceof EntityPlayer) {
                ((EntityPlayer) this).playerConnection.sendPacket(new PacketPlayOutSetSlot((byte) 0, activeContainer.getSlot((IInventory) this.inventory, this.inventory.itemInHandIndex).index, this.f));
            }
            return;
        }

        // Plugin modified the item, process it but don't remove it
        if (!craftItem.equals(event.getItem())) {
            CraftItemStack.asNMSCopy(event.getItem()).b(this.world, this);

            // Update client
            if (this instanceof EntityPlayer) {
                ((EntityPlayer) this).playerConnection.sendPacket(new PacketPlayOutSetSlot((byte) 0, activeContainer.getSlot((IInventory) this.inventory, this.inventory.itemInHandIndex).index, this.f));
            }
            return;
        }
        // CraftBukkit end

        ItemStack itemstack = this.f.b(this.world, this);

        if (itemstack != this.f || itemstack != null && itemstack.count != i) {
            this.inventory.items[this.inventory.itemInHandIndex] = itemstack;
            if (itemstack.count == 0) {
                this.inventory.items[this.inventory.itemInHandIndex] = null;
            }
        }

        this.bB();
    }
}
 
开发者ID:OvercastNetwork,项目名称:CraftBukkit,代码行数:43,代码来源:EntityHuman.java

示例8: n

import org.bukkit.event.player.PlayerItemConsumeEvent; //导入方法依赖的package包/类
protected void n() {
    if (this.f != null) {
        this.c(this.f, 16);
        int i = this.f.count;

        // CraftBukkit start
        org.bukkit.inventory.ItemStack craftItem = CraftItemStack.asBukkitCopy(this.f);
        PlayerItemConsumeEvent event = new PlayerItemConsumeEvent((Player) this.getBukkitEntity(), craftItem);
        world.getServer().getPluginManager().callEvent(event);

        if (event.isCancelled()) {
            // Update client
            if (this instanceof EntityPlayer) {
                ((EntityPlayer) this).playerConnection.sendPacket(new Packet103SetSlot((byte) 0, activeContainer.a((IInventory) this.inventory, this.inventory.itemInHandIndex).index, this.f));
                // Spigot Start
                ((EntityPlayer) this).getBukkitEntity().updateInventory();
                ((EntityPlayer) this).getBukkitEntity().updateScaledHealth();
                // Spigot End
            }
            return;
        }

        // Plugin modified the item, process it but don't remove it
        if (!craftItem.equals(event.getItem())) {
            CraftItemStack.asNMSCopy(event.getItem()).b(this.world, this);

            // Update client
            if (this instanceof EntityPlayer) {
                ((EntityPlayer) this).playerConnection.sendPacket(new Packet103SetSlot((byte) 0, activeContainer.a((IInventory) this.inventory, this.inventory.itemInHandIndex).index, this.f));
            }
            return;
        }
        // CraftBukkit end

        ItemStack itemstack = this.f.b(this.world, this);

        if (itemstack != this.f || itemstack != null && itemstack.count != i) {
            this.inventory.items[this.inventory.itemInHandIndex] = itemstack;
            if (itemstack.count == 0) {
                this.inventory.items[this.inventory.itemInHandIndex] = null;
            }
        }

        this.bu();
    }
}
 
开发者ID:AlmuraDev,项目名称:Almura-Server,代码行数:47,代码来源:EntityHuman.java

示例9: p

import org.bukkit.event.player.PlayerItemConsumeEvent; //导入方法依赖的package包/类
protected void p() {
    if (this.f != null) {
        this.c(this.f, 16);
        int i = this.f.count;

        // CraftBukkit start - fire PlayerItemConsumeEvent
        org.bukkit.inventory.ItemStack craftItem = CraftItemStack.asBukkitCopy(this.f);
        PlayerItemConsumeEvent event = new PlayerItemConsumeEvent((Player) this.getBukkitEntity(), craftItem);
        world.getServer().getPluginManager().callEvent(event);

        if (event.isCancelled()) {
            // Update client
            if (this instanceof EntityPlayer) {
                ((EntityPlayer) this).playerConnection.sendPacket(new PacketPlayOutSetSlot((byte) 0, activeContainer.getSlot((IInventory) this.inventory, this.inventory.itemInHandIndex).index, this.f));
                // Spigot Start
                ((EntityPlayer) this).getBukkitEntity().updateInventory();
                ((EntityPlayer) this).getBukkitEntity().updateScaledHealth();
                // Spigot End
            }
            return;
        }

        // Plugin modified the item, process it but don't remove it
        if (!craftItem.equals(event.getItem())) {
            CraftItemStack.asNMSCopy(event.getItem()).b(this.world, this);

            // Update client
            if (this instanceof EntityPlayer) {
                ((EntityPlayer) this).playerConnection.sendPacket(new PacketPlayOutSetSlot((byte) 0, activeContainer.getSlot((IInventory) this.inventory, this.inventory.itemInHandIndex).index, this.f));
            }
            return;
        }
        // CraftBukkit end

        ItemStack itemstack = this.f.b(this.world, this);

        if (itemstack != this.f || itemstack != null && itemstack.count != i) {
            this.inventory.items[this.inventory.itemInHandIndex] = itemstack;
            if (itemstack.count == 0) {
                this.inventory.items[this.inventory.itemInHandIndex] = null;
            }
        }

        this.bB();
    }
}
 
开发者ID:pvginkel,项目名称:Tweakkit-Server,代码行数:47,代码来源:EntityHuman.java

示例10: onItemUseFinish

import org.bukkit.event.player.PlayerItemConsumeEvent; //导入方法依赖的package包/类
protected void onItemUseFinish()
{
    if (this.itemInUse != null)
    {
        this.updateItemUse(this.itemInUse, 16);
        int i = this.itemInUse.stackSize;
        // CraftBukkit start
        org.bukkit.inventory.ItemStack craftItem = CraftItemStack.asBukkitCopy(this.itemInUse);
        PlayerItemConsumeEvent event = new PlayerItemConsumeEvent((Player) this.getBukkitEntity(), craftItem);
        worldObj.getServer().getPluginManager().callEvent(event);

        if (event.isCancelled())
        {
            // Update client
            if (this instanceof EntityPlayerMP)
            {
                ((EntityPlayerMP) this).playerNetServerHandler.sendPacket(new S2FPacketSetSlot((byte) 0, openContainer.getSlotFromInventory((IInventory) this.inventory, this.inventory.currentItem).slotIndex, this.itemInUse));
                // Spigot Start
                ((EntityPlayerMP) this).getBukkitEntity().updateInventory();
                ((EntityPlayerMP) this).getBukkitEntity().updateScaledHealth();
                // Spigot End
            }

            return;
        }

        // Plugin modified the item, process it but don't remove it
        if (!craftItem.equals(event.getItem()))
        {
            CraftItemStack.asNMSCopy(event.getItem()).onFoodEaten(this.worldObj, this);

            // Update client
            if (this instanceof EntityPlayerMP)
            {
                ((EntityPlayerMP) this).playerNetServerHandler.sendPacket(new S2FPacketSetSlot((byte) 0, openContainer.getSlotFromInventory((IInventory) this.inventory, this.inventory.currentItem).slotIndex, this.itemInUse));
            }

            return;
        }

        // CraftBukkit end
        ItemStack itemstack = this.itemInUse.onFoodEaten(this.worldObj, this);

        itemstack = ForgeEventFactory.onItemUseFinish(this, itemInUse, itemInUseCount, itemstack);

        if (itemstack != this.itemInUse || itemstack != null && itemstack.stackSize != i)
        {
            this.inventory.mainInventory[this.inventory.currentItem] = itemstack;

            if (itemstack != null && itemstack.stackSize == 0)
            {
                this.inventory.mainInventory[this.inventory.currentItem] = null;
            }
        }

        this.clearItemInUse();
    }
}
 
开发者ID:xtrafrancyz,项目名称:Cauldron,代码行数:59,代码来源:EntityPlayer.java

示例11: m

import org.bukkit.event.player.PlayerItemConsumeEvent; //导入方法依赖的package包/类
protected void m() {
    if (this.f != null) {
        this.c(this.f, 16);
        int i = this.f.count;

        // CraftBukkit start
        org.bukkit.inventory.ItemStack craftItem = CraftItemStack.asBukkitCopy(this.f);
        PlayerItemConsumeEvent event = new PlayerItemConsumeEvent((Player) this.getBukkitEntity(), craftItem);
        world.getServer().getPluginManager().callEvent(event);

        if (event.isCancelled()) {
            // Update client
            if (this instanceof EntityPlayer) {
                ((EntityPlayer) this).playerConnection.sendPacket(new Packet103SetSlot((byte) 0, activeContainer.a((IInventory) this.inventory, this.inventory.itemInHandIndex).index, this.f));
            }
            return;
        }

        // Plugin modified the item, process it but don't remove it
        if (!craftItem.equals(event.getItem())) {
            CraftItemStack.asNMSCopy(event.getItem()).b(this.world, this);

            // Update client
            if (this instanceof EntityPlayer) {
                ((EntityPlayer) this).playerConnection.sendPacket(new Packet103SetSlot((byte) 0, activeContainer.a((IInventory) this.inventory, this.inventory.itemInHandIndex).index, this.f));
            }
            return;
        }
        // CraftBukkit end

        ItemStack itemstack = this.f.b(this.world, this);

        if (itemstack != this.f || itemstack != null && itemstack.count != i) {
            this.inventory.items[this.inventory.itemInHandIndex] = itemstack;
            if (itemstack.count == 0) {
                this.inventory.items[this.inventory.itemInHandIndex] = null;
            }
        }

        this.bY();
    }
}
 
开发者ID:didoupimpon,项目名称:Craft-city,代码行数:43,代码来源:EntityHuman.java


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