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