本文整理汇总了Java中org.bukkit.event.inventory.InventoryPickupItemEvent.isCancelled方法的典型用法代码示例。如果您正苦于以下问题:Java InventoryPickupItemEvent.isCancelled方法的具体用法?Java InventoryPickupItemEvent.isCancelled怎么用?Java InventoryPickupItemEvent.isCancelled使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.event.inventory.InventoryPickupItemEvent
的用法示例。
在下文中一共展示了InventoryPickupItemEvent.isCancelled方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onBlockPickupItem
import org.bukkit.event.inventory.InventoryPickupItemEvent; //导入方法依赖的package包/类
@EventHandler
public void onBlockPickupItem(InventoryPickupItemEvent event) {
int initialQuantity = getQuantityPlaceable(event.getItem().getItemStack(), event.getInventory());
ItemTransferEvent transferEvent = new ItemTransferEvent(
event, ItemTransferEvent.Type.PICKUP,
Optional.empty(),
Optional.of(new InventorySlot<>(event.getInventory())),
event.getItem().getItemStack(), event.getItem(), initialQuantity
);
this.callEvent(transferEvent);
if(initialQuantity != transferEvent.getQuantity() && !event.isCancelled()) {
event.setCancelled(true);
ItemStack stack = event.getItem().getItemStack();
stack.setAmount(stack.getAmount() - transferEvent.getQuantity());
stack = stack.clone();
stack.setAmount(transferEvent.getQuantity());
event.getInventory().addItem(stack);
}
}
示例2: a
import org.bukkit.event.inventory.InventoryPickupItemEvent; //导入方法依赖的package包/类
public static boolean a(IInventory iinventory, EntityItem entityitem) {
boolean flag = false;
if (entityitem == null) {
return false;
} else {
// CraftBukkit start
InventoryPickupItemEvent event = new InventoryPickupItemEvent(iinventory.getOwner().getInventory(), (org.bukkit.entity.Item) entityitem.getBukkitEntity());
entityitem.world.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) {
return false;
}
// CraftBukkit end
ItemStack itemstack = entityitem.getItemStack().cloneItemStack();
ItemStack itemstack1 = addItem(iinventory, itemstack, (EnumDirection) null);
if (itemstack1 != null && itemstack1.count != 0) {
entityitem.setItemStack(itemstack1);
} else {
flag = true;
entityitem.die();
}
return flag;
}
}
示例3: addEntityItem
import org.bukkit.event.inventory.InventoryPickupItemEvent; //导入方法依赖的package包/类
public static boolean addEntityItem(IInventory iinventory, EntityItem entityitem) {
boolean flag = false;
if (entityitem == null) {
return false;
} else {
// CraftBukkit start
InventoryPickupItemEvent event = new InventoryPickupItemEvent(iinventory.getOwner().getInventory(), (org.bukkit.entity.Item) entityitem.getBukkitEntity());
entityitem.world.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) {
return false;
}
// CraftBukkit end
ItemStack itemstack = entityitem.getItemStack().cloneItemStack();
ItemStack itemstack1 = addItem(iinventory, itemstack, -1);
if (itemstack1 != null && itemstack1.count != 0) {
entityitem.setItemStack(itemstack1);
} else {
flag = true;
entityitem.die();
}
return flag;
}
}
示例4: func_145898_a
import org.bukkit.event.inventory.InventoryPickupItemEvent; //导入方法依赖的package包/类
public static boolean func_145898_a(IInventory p_145898_0_, EntityItem p_145898_1_)
{
boolean flag = false;
if (p_145898_1_ == null)
{
return false;
}
else
{
// CraftBukkit start
// Cauldron start - vanilla compatibility
if (p_145898_0_.getOwner() != null && p_145898_1_.getBukkitEntity() != null)
{
InventoryPickupItemEvent event = new InventoryPickupItemEvent(p_145898_0_.getOwner().getInventory(), (org.bukkit.entity.Item) p_145898_1_.getBukkitEntity());
p_145898_1_.worldObj.getServer().getPluginManager().callEvent(event);
if (event.isCancelled())
{
return false;
}
}
// Cauldron end
// CraftBukkit end
ItemStack itemstack = p_145898_1_.getEntityItem().copy();
ItemStack itemstack1 = func_145889_a(p_145898_0_, itemstack, -1);
if (itemstack1 != null && itemstack1.stackSize != 0)
{
p_145898_1_.setEntityItemStack(itemstack1);
}
else
{
flag = true;
p_145898_1_.setDead();
}
return flag;
}
}
示例5: onInventoryPickup
import org.bukkit.event.inventory.InventoryPickupItemEvent; //导入方法依赖的package包/类
@EventHandler
public void onInventoryPickup(InventoryPickupItemEvent event) {
if (event.isCancelled() || !config.getBoolean("auto-import")) return;
InventoryHolder holder = event.getInventory().getHolder();
if (holder instanceof BlockState) {
Sign sign = null;
StorageSign storageSign = null;
boolean flag = false;
for (int i=0; i<5; i++) {
int[] x = {0, 0, 0,-1, 1};
int[] y = {1, 0, 0, 0, 0};
int[] z = {0,-1, 1, 0, 0};
Block block = ((BlockState)holder).getBlock().getRelative(x[i], y[i], z[i]);
if (i==0 && block.getType() == Material.SIGN_POST && isStorageSign(block)) {
sign = (Sign) block.getState();
storageSign = new StorageSign(sign);
if (storageSign.isSimilar(event.getItem().getItemStack())) {
flag = true;
break;
}
} else if (i != 0 && block.getType() == Material.WALL_SIGN && block.getData() == i+1 && isStorageSign(block)) {
sign = (Sign) block.getState();
storageSign = new StorageSign(sign);
if (storageSign.isSimilar(event.getItem().getItemStack())) {
flag = true;
break;
}
}
}
if (flag) importSign(sign, storageSign, event.getItem().getItemStack(), event.getInventory());
}
}