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


Java InventoryPickupItemEvent.setCancelled方法代码示例

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


在下文中一共展示了InventoryPickupItemEvent.setCancelled方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
    }
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:22,代码来源:ItemTransferListener.java

示例2: onHopperPickup

import org.bukkit.event.inventory.InventoryPickupItemEvent; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true) // Handles special items entering hoppers.
public void onHopperPickup(InventoryPickupItemEvent evt) {
    if (!(evt.getInventory().getHolder() instanceof Hopper))
        return; // Verify the inventory the item is going to enter is a hopper.

    Hopper hp = (Hopper) evt.getInventory().getHolder();
    Matcher mName = Pattern.compile("<Custom ID: (\\w+)>").matcher(hp.getInventory().getName());
    if (!mName.find())
        return; // If it doesn't have a Custom item ID defined, don't handle it.

    ItemWrapper iw = ItemManager.constructItem(evt.getItem().getItemStack());
    evt.setCancelled(true);

    if (mName.group(1).equalsIgnoreCase(iw.getTagString("id"))) { // We've found the right item! Consume it.
        evt.getItem().remove();
        hp.getBlock().getRelative(BlockFace.DOWN).setType(Material.REDSTONE_BLOCK);
    } else { // This item isn't acceptable, spit it back out.
        evt.getItem().setVelocity(new Vector(0, .15F, 0));
    }
}
 
开发者ID:Kneesnap,项目名称:Kineticraft,代码行数:21,代码来源:Dungeons.java

示例3: onInventoryPickup

import org.bukkit.event.inventory.InventoryPickupItemEvent; //导入方法依赖的package包/类
@EventHandler
public void onInventoryPickup(InventoryPickupItemEvent event) {
    if (!cratesPlus.getConfigHandler().isDisableKeySwapping())
        return;
    if (event.getItem().getItemStack() != null) {
        String title;
        ItemStack item = event.getItem().getItemStack();
        for (Map.Entry<String, Crate> crate : cratesPlus.getConfigHandler().getCrates().entrySet()) {
            if (!(crate.getValue() instanceof KeyCrate)) {
                continue;
            }
            KeyCrate keyCrate = (KeyCrate) crate.getValue();
            Key key = keyCrate.getKey();
            if (key == null)
                continue;
            title = key.getName();

            if (item.hasItemMeta() && item.getItemMeta().hasDisplayName() && item.getItemMeta().getDisplayName().contains(title)) {
                // Send message?
                event.setCancelled(true);
                return;
            }
        }
    }
}
 
开发者ID:ConnorLinfoot,项目名称:CratesPlus,代码行数:26,代码来源:BlockListeners.java

示例4: onInventoryPickupItem

import org.bukkit.event.inventory.InventoryPickupItemEvent; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true)
public void onInventoryPickupItem(InventoryPickupItemEvent event) {
	if(event.getInventory().getType() != InventoryType.HOPPER) {
		return;
	}
	
	ItemStack item = event.getItem().getItemStack();
	
	try {
		ExchangeRule.parseRuleBlock(item);
	}
	catch(ExchangeRuleParseException e) {
		try {
			ExchangeRule.parseBulkRuleBlock(item);
		}
		catch(ExchangeRuleParseException e2) {
			return;
		}
	}
	
	event.setCancelled(true);
}
 
开发者ID:gmlaxfanatic,项目名称:ItemExchange,代码行数:23,代码来源:ItemExchangeListener.java

示例5: onMinecartPickup

import org.bukkit.event.inventory.InventoryPickupItemEvent; //导入方法依赖的package包/类
@EventHandler
public void onMinecartPickup(InventoryPickupItemEvent e) {
    if (e.getItem().hasMetadata("no_pickup")) e.setCancelled(true);
    else if (!e.getItem().hasMetadata("no_pickup") && e.getItem().getItemStack().hasItemMeta() && e.getItem().getItemStack().getItemMeta().hasDisplayName() && e.getItem().getItemStack().getItemMeta().getDisplayName().startsWith("&5&dALTAR &3Probe - &e")) {
        e.setCancelled(true);
        e.getItem().remove();
    }
}
 
开发者ID:StarWishsama,项目名称:Slimefun4-Chinese-Version,代码行数:9,代码来源:ItemPickupListener_1_12.java

示例6: onHopperPickUp

import org.bukkit.event.inventory.InventoryPickupItemEvent; //导入方法依赖的package包/类
@EventHandler
public void onHopperPickUp(InventoryPickupItemEvent e) {
    if (!DefaultConfig.isMoneyItemDropEnabled()) {
        return;
    }

    if (e.getInventory().getType() != InventoryType.HOPPER) {
        return;
    }

    if (isMoneyItem(e.getItem().getItemStack())) {
        e.setCancelled(true);
    }
}
 
开发者ID:diecode,项目名称:KillerMoney,代码行数:15,代码来源:MoneyHandler.java

示例7: onPickup

import org.bukkit.event.inventory.InventoryPickupItemEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.LOW)
public void onPickup(InventoryPickupItemEvent event) {
    if (event.getInventory().getHolder() instanceof Player) {
        Player player = (Player) event.getInventory().getHolder();
        Optional<Session> opSession = INST.getSessionRegistry().getSession(player);
        if (opSession.isPresent()) {
            Session session = opSession.get();
            if (session.getGame().isPresent() && !session.getGame().get().canDrop()) {
                event.setCancelled(true);
            }
        }
    }
}
 
开发者ID:DemigodsRPG,项目名称:demigames,代码行数:14,代码来源:GameListener.java

示例8: onPickup

import org.bukkit.event.inventory.InventoryPickupItemEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.LOWEST)
public void onPickup(InventoryPickupItemEvent event) {
    if (event.getInventory().getHolder() instanceof Player &&
            ((Player) event.getInventory().getHolder()).getGameMode() != GameMode.CREATIVE) {
        Profile profile = INST.getProfileRegistry().fromPlayer(INST, (Player) event.getInventory().getHolder());
        if (profile.getKit().isPresent() && profile.getKit().get() instanceof ImmutableKit) {
            event.setCancelled(true);
            ((Player) event.getInventory().getHolder()).updateInventory();
        }
    }
}
 
开发者ID:DemigodsRPG,项目名称:demigames,代码行数:12,代码来源:KitListener.java

示例9: onInventoryPickupEvent

import org.bukkit.event.inventory.InventoryPickupItemEvent; //导入方法依赖的package包/类
@EventHandler
public void onInventoryPickupEvent(InventoryPickupItemEvent event) {

    if(plugin.checkNames(event.getInventory().getName())) {
        event.setCancelled(true);
    }
}
 
开发者ID:poiNt3D,项目名称:SortingHopper,代码行数:8,代码来源:PickupListener.java

示例10: onInventoryPickup

import org.bukkit.event.inventory.InventoryPickupItemEvent; //导入方法依赖的package包/类
@EventHandler
public void onInventoryPickup(InventoryPickupItemEvent event) {
    if (event.getInventory().getType() == InventoryType.HOPPER) {
        if (ItemSpray.UUID_LIST.contains(event.getItem().getUniqueId())) {
            event.setCancelled(true);
        }
    }
}
 
开发者ID:DSH105,项目名称:SparkTrail,代码行数:9,代码来源:PlayerListener.java

示例11: onHopper

import org.bukkit.event.inventory.InventoryPickupItemEvent; //导入方法依赖的package包/类
@EventHandler
public void onHopper(InventoryPickupItemEvent event) {
    event.setCancelled(true);
}
 
开发者ID:edasaki,项目名称:ZentrelaRPG,代码行数:5,代码来源:EnvironmentManager.java

示例12: onHopper

import org.bukkit.event.inventory.InventoryPickupItemEvent; //导入方法依赖的package包/类
@EventHandler
public void onHopper(InventoryPickupItemEvent e){
    if(e.getInventory().getType().toString().equalsIgnoreCase("hopper") && e.getItem().getCustomName()!=null){
        e.setCancelled(true);
    }
}
 
开发者ID:KickVN,项目名称:PickupMoney,代码行数:7,代码来源:MainListener.java

示例13: onItem

import org.bukkit.event.inventory.InventoryPickupItemEvent; //导入方法依赖的package包/类
@EventHandler
public void onItem(InventoryPickupItemEvent e) {
	if(e.getItem().hasMetadata("fakefish")) {
		e.setCancelled(true);
	}
}
 
开发者ID:xEssentials,项目名称:xEssentials-deprecated-bukkit,代码行数:7,代码来源:RealisticWaterEvent.java

示例14: onDropperPickup

import org.bukkit.event.inventory.InventoryPickupItemEvent; //导入方法依赖的package包/类
@Override
public void onDropperPickup(InventoryPickupItemEvent event) {
	if (event.getItem().hasMetadata("is-active")) {
		event.setCancelled(true);
	}
}
 
开发者ID:goncalomb,项目名称:NBTEditor,代码行数:7,代码来源:BatBomb.java


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