当前位置: 首页>>代码示例>>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;未经允许,请勿转载。