當前位置: 首頁>>代碼示例>>Java>>正文


Java InventoryMoveItemEvent.getItem方法代碼示例

本文整理匯總了Java中org.bukkit.event.inventory.InventoryMoveItemEvent.getItem方法的典型用法代碼示例。如果您正苦於以下問題:Java InventoryMoveItemEvent.getItem方法的具體用法?Java InventoryMoveItemEvent.getItem怎麽用?Java InventoryMoveItemEvent.getItem使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.bukkit.event.inventory.InventoryMoveItemEvent的用法示例。


在下文中一共展示了InventoryMoveItemEvent.getItem方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onInventoryMove

import org.bukkit.event.inventory.InventoryMoveItemEvent; //導入方法依賴的package包/類
@EventHandler
public void onInventoryMove(InventoryMoveItemEvent event) {
    if (!cratesPlus.getConfigHandler().isDisableKeySwapping())
        return;
    String title;
    ItemStack item = event.getItem();

    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,代碼行數:25,代碼來源:BlockListeners.java

示例2: onInventoryMove

import org.bukkit.event.inventory.InventoryMoveItemEvent; //導入方法依賴的package包/類
@EventHandler(ignoreCancelled = true)
public void onInventoryMove(InventoryMoveItemEvent event) {
	ItemStack item = event.getItem();
	
	try {
		ExchangeRule.parseRuleBlock(item);
	}
	catch(ExchangeRuleParseException e) {
		try {
			ExchangeRule.parseBulkRuleBlock(item);
		}
		catch(ExchangeRuleParseException e2) {
			return;
		}
	}
	
	event.setCancelled(true);
}
 
開發者ID:gmlaxfanatic,項目名稱:ItemExchange,代碼行數:19,代碼來源:ItemExchangeListener.java

示例3: onInventoryMoveItemEvent

import org.bukkit.event.inventory.InventoryMoveItemEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onInventoryMoveItemEvent(InventoryMoveItemEvent event) {
    Inventory inventory = event.getDestination();

    if (!(inventory instanceof BrewerInventory)) {
        return;
    }

    InventoryHolder holder = inventory.getHolder();

    if (!(holder instanceof BrewingStand)) {
        return;
    }

    ItemStack item = event.getItem();

    if (Config.getInstance().getPreventHopperTransferIngredients() && item.getType() != Material.POTION) {
        event.setCancelled(true);
        return;
    }

    if (Config.getInstance().getPreventHopperTransferBottles() && item.getType() == Material.POTION) {
        event.setCancelled(true);
        return;
    }

    if (Config.getInstance().getEnabledForHoppers() && AlchemyPotionBrewer.isValidIngredient(null, item)) {
        AlchemyPotionBrewer.scheduleCheck(null, (BrewingStand) holder);
    }
}
 
開發者ID:Pershonkey,項目名稱:McMMOPlus,代碼行數:31,代碼來源:InventoryListener.java

示例4: onItemMove

import org.bukkit.event.inventory.InventoryMoveItemEvent; //導入方法依賴的package包/類
@EventHandler
public void onItemMove(InventoryMoveItemEvent event)
{
    Inventory source = event.getSource();
    Inventory target = event.getDestination();

    if (target == null || source == null)
    {
        this.module.getLog().warn("InventoryMoveItem has null {} -> {} This should never happen!", source, target);
        return;
    }
    Location sourceLocation = this.getLocationForHolder(source.getHolder());
    if (sourceLocation == null)
    {
        return;
    }
    Location targetLocation = this.getLocationForHolder(target.getHolder());
    if (targetLocation == null)
    {
        return;
    }
    ItemMove action = this.newAction(ItemMove.class, targetLocation.getWorld());
    if (action != null)
    {
        LoggingConfiguration config = this.getConfig(targetLocation.getWorld());
        if (config.container.moveIgnore.contains(event.getItem().getType()))
        {
            return;
        }
        action.item = event.getItem();
        action.setLocation(sourceLocation);
        action.direction = sourceLocation.getBlock().getFace(targetLocation.getBlock());
        action.fromContainer = new ContainerType(source.getHolder());
        action.toContainer = new ContainerType(target.getHolder());
        this.logAction(action);
    }
}
 
開發者ID:CubeEngine,項目名稱:modules-extra,代碼行數:38,代碼來源:ListenerItemMove.java


注:本文中的org.bukkit.event.inventory.InventoryMoveItemEvent.getItem方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。