本文整理汇总了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));
}
示例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;
}
}
}
}
示例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;
}
}
}
}
示例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);
}
}
}
示例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;
}
}
}
}
示例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;
}
}
}
}
示例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;
}
}
}
示例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;
}
}
}
}
示例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;
}
}
}
}
示例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;
}
}
}
}