本文整理匯總了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();
}
}