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


Java InventoryDragEvent.getInventory方法代碼示例

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


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

示例1: equipWeaponEvent

import org.bukkit.event.inventory.InventoryDragEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void equipWeaponEvent(InventoryDragEvent event) {
	if (Result.DENY.equals(event.getResult())) return;
	HumanEntity human = event.getWhoClicked();
	
	Inventory inv = event.getInventory();
	ItemStack prior = event.getOldCursor();
	StandardGun priorGun = findGun(prior); 
	
	// Don't really care what sort of drag, if we have a gun in inv and this was a gun, deny.
	if (priorGun != null && inv != null && !InventoryType.PLAYER.equals(inv.getType()) && priorGun.isLimitToOne() && priorGun.hasGun(human)) {
		event.setResult(Result.DENY);
		// yes this will prevent drag style of weapon in chest invs. Oh well.
	}
	
}
 
開發者ID:ProgrammerDan,項目名稱:AddGun,代碼行數:17,代碼來源:Guns.java

示例2: equipWeaponEvent

import org.bukkit.event.inventory.InventoryDragEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void equipWeaponEvent(InventoryDragEvent event) {
	if (!enabled) return;
	HumanEntity human = event.getWhoClicked();
	boolean alreadyHasGun = hasGun(human);
	
	Inventory inv = event.getInventory();
	ItemStack prior = event.getOldCursor();
	
	// Don't really care what sort of drag, if we have a gun in inv and this was a gun, deny.
	if (alreadyHasGun && (inv != null && !InventoryType.PLAYER.equals(inv.getType()))
			&& (prior != null && isGun(prior))) {
		event.setResult(Result.DENY);
		// yes this will prevent drag style of weapon in chest invs. Oh well.
	}
	
}
 
開發者ID:ProgrammerDan,項目名稱:AddGun,代碼行數:18,代碼來源:RailGun.java

示例3: onInventoryDrag

import org.bukkit.event.inventory.InventoryDragEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onInventoryDrag(InventoryDragEvent event)
{
    if (event.getWhoClicked() instanceof Player)
    {
        if (!this.inventoryChanges.containsKey(event.getWhoClicked().getUniqueId()))
        {
            return;
        }
        Inventory inventory = event.getInventory();
        int amount = 0;
        for (Entry<Integer, ItemStack> entry : event.getNewItems().entrySet())
        {
            if (entry.getKey() < inventory.getSize())
            {
                amount += entry.getValue().getAmount();
            }
        }
        this.prepareForLogging((Player)event.getWhoClicked(), new ItemData(event.getOldCursor()), amount);
    }
}
 
開發者ID:CubeEngine,項目名稱:modules-extra,代碼行數:22,代碼來源:ListenerContainerItem.java

示例4: onInventoryDrag

import org.bukkit.event.inventory.InventoryDragEvent; //導入方法依賴的package包/類
@EventHandler(ignoreCancelled = true)
public void onInventoryDrag(InventoryDragEvent event) {
    Player player = (Player) event.getWhoClicked();

    if (!InventoryManager.playerIsLoaded(player)) {
        return;
    }

    for (Integer rawSlotId : event.getRawSlots()) {
        ItemStack cursor = event.getOldCursor();
        Inventory inventory = event.getInventory();

        if (PetManager.isPetItem(cursor)) {
            event.setCancelled(true);
            return;
        }

        if (inventory.getType() == InventoryType.CRAFTING) {
            if (InventoryManager.get(player).isOpened()) {
                return;
            }

            // Shield slot is QUICKBAR and has rawId - 45 o.O
            if (rawSlotId >= 1 && rawSlotId <= 8 || rawSlotId == 45) {
                event.setCancelled(true);
                return;
            }
        } else if (InventoryAPI.isRPGInventory(inventory)) {
            if (rawSlotId < 54) {
                event.setCancelled(true);
                return;
            }
        }
    }
}
 
開發者ID:EndlessCodeGroup,項目名稱:RPGInventory,代碼行數:36,代碼來源:InventoryListener.java

示例5: onInventoryDrag

import org.bukkit.event.inventory.InventoryDragEvent; //導入方法依賴的package包/類
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGH)
public void onInventoryDrag(InventoryDragEvent event) {
    Inventory inventory = event.getInventory();
    Inventory topInventory = event.getView().getTopInventory();
    if (inventory != null && topInventory != null && topInventory.equals(inventory) && topInventory.getTitle().endsWith(" Key Reward")) { // TODO: More reliable
        event.setCancelled(true);
    }
}
 
開發者ID:funkemunky,項目名稱:HCFCore,代碼行數:9,代碼來源:KeyListener.java

示例6: InventoryDrag

import org.bukkit.event.inventory.InventoryDragEvent; //導入方法依賴的package包/類
public static void InventoryDrag(InventoryDragEvent event)
{
	Inventory inventory = event.getInventory();
	if ( inventory.getName().contains("SkullInventory"))
	{
		event.setCancelled(true);
		return;
	}
}
 
開發者ID:HinyariGohan,項目名稱:SkullGetter,代碼行數:10,代碼來源:SkullEventer.java

示例7: inventoryDragEvent

import org.bukkit.event.inventory.InventoryDragEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.MONITOR)
public void inventoryDragEvent(InventoryDragEvent e) {
    if (e.getInventory() == null)
        return;
    
    if (check(e.getInventory().getType(), e.getOldCursor()))
        e.setCancelled(true);
}
 
開發者ID:Explodncheez,項目名稱:MysteryBags,代碼行數:9,代碼來源:MysteryBagsListener.java

示例8: onDrag

import org.bukkit.event.inventory.InventoryDragEvent; //導入方法依賴的package包/類
@EventHandler
public void onDrag(InventoryDragEvent event) {
    if (users.contains(event.getWhoClicked().getUniqueId())) {
        event.getInventory().setItem(31, new ItemStack(Material.AIR));
        final Inventory inv = event.getInventory();
        plugin.getServer().getScheduler().runTaskLater(plugin, () -> updateEmeraldIcon(inv), 1L);
    }
}
 
開發者ID:elsiff,項目名稱:MoreFish,代碼行數:9,代碼來源:FishShopGUI.java

示例9: onInventoryDrag

import org.bukkit.event.inventory.InventoryDragEvent; //導入方法依賴的package包/類
@EventHandler
public void onInventoryDrag(InventoryDragEvent e) {
	if (e == null) return;
	if (e.getInventory() == null) return;
	if (e.getInventory().getTitle() == null) return;
	if (e.getInventory().getTitle().equals(CC(Main.finalconfig.getString("atm_title")))) {
		e.setResult(Result.DENY);
	}
}
 
開發者ID:mastercake10,項目名稱:TimeIsMoney,代碼行數:10,代碼來源:ATM.java

示例10: onInventoryDrag

import org.bukkit.event.inventory.InventoryDragEvent; //導入方法依賴的package包/類
@EventHandler(ignoreCancelled = true)
public void onInventoryDrag(InventoryDragEvent event)
{
    Inventory inventory = event.getInventory();

    if(isInventoryGui(HiddenId.grabId(inventory.getTitle())))
    {
        event.setCancelled(true);
    }

}
 
開發者ID:robzen,項目名稱:ProSpam,代碼行數:12,代碼來源:GuiManager.java

示例11: onInventoryDragEvent

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

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

    InventoryHolder holder = inventory.getHolder();

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

    HumanEntity whoClicked = event.getWhoClicked();

    if (!UserManager.hasPlayerDataKey(event.getWhoClicked()) || !Permissions.secondaryAbilityEnabled(whoClicked, SecondaryAbility.CONCOCTIONS)) {
        return;
    }

    if (!event.getInventorySlots().contains(Alchemy.INGREDIENT_SLOT)) {
        return;
    }

    ItemStack cursor = event.getCursor();
    ItemStack ingredient = ((BrewerInventory) inventory).getIngredient();

    if (AlchemyPotionBrewer.isEmpty(ingredient) || ingredient.isSimilar(cursor)) {
        Player player = (Player) whoClicked;

        if (AlchemyPotionBrewer.isValidIngredient(player, cursor)) {
            // Not handled: dragging custom ingredients over ingredient slot (does not trigger any event)
            AlchemyPotionBrewer.scheduleCheck(player, (BrewingStand) holder);
            return;
        }

        event.setCancelled(true);
        AlchemyPotionBrewer.scheduleUpdate(inventory);
    }
}
 
開發者ID:Pershonkey,項目名稱:McMMOPlus,代碼行數:41,代碼來源:InventoryListener.java

示例12: onInventoryDragEvent

import org.bukkit.event.inventory.InventoryDragEvent; //導入方法依賴的package包/類
/**
 * Prevent placing items in death chests if configured
 * @param event
 */
@EventHandler
public void onInventoryDragEvent(InventoryDragEvent event) {
	
	Inventory inventory = event.getInventory();
	
	// if inventory is a death chest inventory
    if (inventoryIsDeathChest(inventory)) {

		// if prevent-item-placement is configured false, do nothing and return
		if (!plugin.getConfig().getBoolean("prevent-item-placement")) {
			return;
		}
		
		// get set of slots dragged over
		Set<Integer> rawSlots = event.getRawSlots();
		
		// if single chest set max slot to 27
		int maxSlot = 27;
		
		// if double chest set max slot to 54
		if (inventory.getHolder() instanceof DoubleChest) {
			maxSlot = 54;
		}
		
		// iterate over dragged slots and if any are above max slot, cancel event
		for (int slot : rawSlots) {
			if (slot < maxSlot) {
				
				// if player does not have allow-place permission, cancel event
				if (!event.getWhoClicked().hasPermission("deathchest.allow-place")) {
					event.setCancelled(true);
				}
				break;
			}
		}
    }
}
 
開發者ID:tim-savage,項目名稱:SavageDeathChest,代碼行數:42,代碼來源:InventoryEventListener.java

示例13: onItemDrag

import org.bukkit.event.inventory.InventoryDragEvent; //導入方法依賴的package包/類
@EventHandler
public void onItemDrag(final InventoryDragEvent event) {
	if (event.getInventory() != null && event.getInventory().equals(this.inventory) && event.getWhoClicked() instanceof Player) {
		event.setCancelled(true);
		event.setResult(Result.DENY);
	}
}
 
開發者ID:Craftolution,項目名稱:CraftoPlugin,代碼行數:8,代碼來源:Menu.java

示例14: onDrag

import org.bukkit.event.inventory.InventoryDragEvent; //導入方法依賴的package包/類
@EventHandler(ignoreCancelled = true)
public void onDrag(InventoryDragEvent event) {
    if (!(event.getWhoClicked() instanceof Player)) {
        return;
    }

    Player player = (Player) event.getWhoClicked();
    if (player.hasPermission("playervaults.bypassblockeditems")) {
        return;
    }

    Inventory clickedInventory = event.getInventory();
    if (clickedInventory != null) {
        VaultViewInfo info = PlayerVaults.getInstance().getInVault().get(player.getUniqueId().toString());
        if (info != null) {
            int num = info.getNumber();
            String inventoryTitle = clickedInventory.getTitle();
            String title = Lang.VAULT_TITLE.toString().replace("%number", String.valueOf(num)).replace("%p", info.getHolder());
            if ((inventoryTitle != null && inventoryTitle.equalsIgnoreCase(title)) && event.getNewItems() != null) {
                for (ItemStack item : event.getNewItems().values()) {
                    if (PlayerVaults.getInstance().isBlockedMaterial(item.getType())) {
                        event.setCancelled(true);
                        player.sendMessage(Lang.TITLE.toString() + Lang.BLOCKED_ITEM.toString().replace("%m", item.getType().name()));
                        return;
                    }
                }
            }
        }
    }
}
 
開發者ID:drtshock,項目名稱:PlayerVaults,代碼行數:31,代碼來源:Listeners.java


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