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


Java InventoryDragEvent.getRawSlots方法代碼示例

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


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

示例1: onInventoryDrag

import org.bukkit.event.inventory.InventoryDragEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.LOW)
public void onInventoryDrag(InventoryDragEvent e) {
    Player p = (Player) e.getWhoClicked();

    if(!inventories.containsKey(p))
        return;

    SmartInventory inv = inventories.get(p);

    for(int slot : e.getRawSlots()) {
        if(slot >= p.getOpenInventory().getTopInventory().getSize())
            continue;

        e.setCancelled(true);
        break;
    }

    inv.getListeners().stream()
            .filter(listener -> listener.getType() == InventoryDragEvent.class)
            .forEach(listener -> ((InventoryListener<InventoryDragEvent>) listener).accept(e));
}
 
開發者ID:MinusKube,項目名稱:SmartInvs,代碼行數:22,代碼來源:InventoryManager.java

示例2: onEvent

import org.bukkit.event.inventory.InventoryDragEvent; //導入方法依賴的package包/類
@Override
public void onEvent(InventoryEvent event) {
    if (event instanceof InventoryClickEvent) {
        InventoryClickEvent clickEvent = ((InventoryClickEvent) event);
        if (isTop(event, clickEvent.getRawSlot())) {
            notify(event);
        }
    } else if (event instanceof InventoryDragEvent) {
        InventoryDragEvent dragEvent = ((InventoryDragEvent) event);
        for (int slot : dragEvent.getRawSlots()) {
            if (isTop(event, slot)) {
                notify(event);
                break;
            }
        }
    }
}
 
開發者ID:EntryPointKR,項目名稱:MCLibrary,代碼行數:18,代碼來源:TopHandler.java

示例3: handle

import org.bukkit.event.inventory.InventoryDragEvent; //導入方法依賴的package包/類
@Override
public void handle(GUIEvent<InventoryEvent> event) {
    InventoryEvent nativeEvent = event.getEvent();
    if (nativeEvent instanceof InventoryClickEvent) {
        InventoryClickEvent clickEvent = (InventoryClickEvent) nativeEvent;
        if (clickEvent.getRawSlot() < clickEvent.getInventory().getSize())
            receive(event);
    } else if (nativeEvent instanceof InventoryDragEvent) {
        InventoryDragEvent dragEvent = (InventoryDragEvent) nativeEvent;
        for (int slot : dragEvent.getRawSlots()) {
            if (slot < dragEvent.getInventory().getSize()) {
                receive(event);
                break;
            }
        }
    }
}
 
開發者ID:EntryPointKR,項目名稱:MCLibrary,代碼行數:18,代碼來源:TopInventoryHandler.java

示例4: onInventoryDrag

import org.bukkit.event.inventory.InventoryDragEvent; //導入方法依賴的package包/類
@EventHandler
public void onInventoryDrag(InventoryDragEvent event) {
    if(!event.getInventory().equals(i) || !(event.getWhoClicked() instanceof Player)) return;
    Player p = (Player) event.getWhoClicked();
    boolean invModified = false;
    for(int slot : event.getRawSlots()) {
        if(slot < i.getSize()) {
            if(invSlots.contains(slot)) {
                invModified = true;
            } else {
                event.setCancelled(true);
                return;
            }
        }
    }
    if(invModified) {
        if(plugin.checkBlockPermission(p, as.getLocation().getBlock())) {
            updateInventory();
        } else {
            event.setCancelled(true);
            p.sendMessage(ChatColor.RED + Config.wgNoPerm);
        }
    }
}
 
開發者ID:St3venAU,項目名稱:ArmorStandTools,代碼行數:25,代碼來源:ArmorStandGUI.java

示例5: OnInventoryDragEvent

import org.bukkit.event.inventory.InventoryDragEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.LOW) 
public void OnInventoryDragEvent(InventoryDragEvent event) {
	if (event.isCancelled()) {
		return;
	}
	
	for (int slot : event.getRawSlots()) {
		if (slot < event.getView().getTopInventory().getSize()) {
			if (guiInventories.containsKey(event.getView().getTopInventory().getName())) {
				event.setCancelled(true);
				return;
			}
		}
	}
	
}
 
開發者ID:netizen539,項目名稱:civcraft,代碼行數:17,代碼來源:LoreGuiItemListener.java

示例6: 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

示例7: onInventoryDragEvent

import org.bukkit.event.inventory.InventoryDragEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.LOW)
public void onInventoryDragEvent(InventoryDragEvent event) {
	if (!(event.getWhoClicked() instanceof Player)) {
		return;
	}
	Player player = (Player)event.getWhoClicked();
	Resident resident = CivGlobal.getResident(player);
	TradeInventoryPair pair = tradeInventories.get(getTradeInventoryKey(resident));
	if (pair == null) {
		return;
	}
	
	Inventory savedTradeInventory = pair.inv;
	if (savedTradeInventory == null) {
		return;
	}
	
	if (!savedTradeInventory.getName().equals(event.getInventory().getName())) {
		return;
	}
	
	for (int slot : event.getRawSlots()) {
		if (!handleSlotChange(slot, pair)) {
			event.setCancelled(true);
			return;
		}
	}
}
 
開發者ID:netizen539,項目名稱:civcraft,代碼行數:29,代碼來源:TradeInventoryListener.java

示例8: onInventoryDrag

import org.bukkit.event.inventory.InventoryDragEvent; //導入方法依賴的package包/類
/**
 * Cancel inventory drags in Auction Houses.
 * 
 * @param evt
 *            the evt
 */
@EventHandler
public void onInventoryDrag(final InventoryDragEvent evt) {
	if (inventoryManager.isAuctionInventory(evt.getInventory())) {
		for (int slot : evt.getRawSlots()) {
			if (slot < evt.getView().getTopInventory().getSize()) {
				evt.setCancelled(true);
				return;
			}
		}
	}
}
 
開發者ID:ngasull,項目名稱:well-auction,代碼行數:18,代碼來源:AuctionShopInventoryListener.java

示例9: onInventoryDrag

import org.bukkit.event.inventory.InventoryDragEvent; //導入方法依賴的package包/類
@EventHandler
public void onInventoryDrag(InventoryDragEvent e) {
	if(controller.isPlaying()
			&& e.getOldCursor().getType() == Material.EYE_OF_ENDER) {
		int size = e.getInventory().getSize();
		for(int slot : e.getRawSlots()) {
			if(slot < size) {
				e.setResult(Result.DENY);
				break;
			}
		}
	}
}
 
開發者ID:kyriog,項目名稱:rftd,代碼行數:14,代碼來源:InventoryListener.java

示例10: 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


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