當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。