当前位置: 首页>>代码示例>>Java>>正文


Java InventoryDragEvent.setCancelled方法代码示例

本文整理汇总了Java中org.bukkit.event.inventory.InventoryDragEvent.setCancelled方法的典型用法代码示例。如果您正苦于以下问题:Java InventoryDragEvent.setCancelled方法的具体用法?Java InventoryDragEvent.setCancelled怎么用?Java InventoryDragEvent.setCancelled使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.bukkit.event.inventory.InventoryDragEvent的用法示例。


在下文中一共展示了InventoryDragEvent.setCancelled方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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

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

示例4: onPlayerClickTrinket2

import org.bukkit.event.inventory.InventoryDragEvent; //导入方法依赖的package包/类
@EventHandler
public void onPlayerClickTrinket2(InventoryDragEvent event) {
    if (event.getRawSlots().contains(45)) {
        event.setCancelled(true);
        if (event.getWhoClicked().getGameMode() != GameMode.ADVENTURE && event.getWhoClicked().getGameMode() != GameMode.SURVIVAL) {
            event.getWhoClicked().getInventory().setItemInOffHand(null);
        }
        if (event.getWhoClicked() instanceof Player)
            ((Player) event.getWhoClicked()).updateInventory();
    }
}
 
开发者ID:edasaki,项目名称:ZentrelaRPG,代码行数:12,代码来源:TrinketManager.java

示例5: onPlayerDragInventory

import org.bukkit.event.inventory.InventoryDragEvent; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true)
public void onPlayerDragInventory(InventoryDragEvent event) {
    // This is when you spread items evenly across slots by dragging
    if(!(event.getWhoClicked() instanceof Player)) {
        return;
    }
    Player player = (Player) event.getWhoClicked();

    ItemStack transferred = event.getOldCursor().clone();
    transferred.setAmount(0);
    Inventory externalInventory = null;

    for(Map.Entry<Integer, ItemStack> entry : event.getNewItems().entrySet()) {
        Inventory inventory = getLocalInventory(event.getView(), entry.getKey());
        if(inventory.getHolder() != player) {
            // Add stacks to the total if they are dragged over an external inventory
            externalInventory = inventory;
            transferred.setAmount(transferred.getAmount() + entry.getValue().getAmount());
        }
    }

    if(externalInventory != null) {
        int initialQuantity = transferred.getAmount();
        PlayerItemTransferEvent transferEvent = new PlayerItemTransferEvent(
            event, ItemTransferEvent.Type.PLACE, player,
            Optional.empty(),
            Optional.of(new InventorySlot<>(externalInventory)),
            transferred, null, initialQuantity,
            event.getOldCursor()
        );

        this.callEvent(transferEvent);

        if(initialQuantity != transferEvent.getQuantity()) {
            // If the quantity changes, we have to cancel the entire drag,
            // because bukkit does not let us modify the dragged stacks.
            event.setCancelled(true);
        }
    }
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:41,代码来源:ItemTransferListener.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: onDragEquip

import org.bukkit.event.inventory.InventoryDragEvent; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true)
public void onDragEquip(InventoryDragEvent event) {
    Player player = (Player) event.getWhoClicked();
    if (!InventoryManager.playerIsLoaded(player) || InventoryAPI.isRPGInventory(event.getInventory())) {
        return;
    }

    if (event.getRawSlots().size() == 1) {
        int slot = (int) event.getRawSlots().toArray()[0];

        event.setCancelled(slot >= 5 && slot <= 8 && event.getInventory().getType() == InventoryType.CRAFTING);
    }
}
 
开发者ID:EndlessCodeGroup,项目名称:RPGInventory,代码行数:14,代码来源:ArmorEquipListener.java

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

示例9: onInventoryDrag

import org.bukkit.event.inventory.InventoryDragEvent; //导入方法依赖的package包/类
@EventHandler
public void onInventoryDrag(InventoryDragEvent event) {
    UUID uuid = event.getWhoClicked().getUniqueId();
    if (invClickables.containsKey(uuid)) {
        HashMap<String, HashMap<String, Runnable>> invs = invClickables.get(uuid);
        if (event.getInventory().getName() != null && invs.containsKey(event.getInventory().getName())) {
            event.setCancelled(true);
            ((Player) event.getWhoClicked()).updateInventory();
        }
    }
}
 
开发者ID:edasaki,项目名称:ZentrelaCore,代码行数:12,代码来源:MenuManager.java

示例10: onInventoryDrag

import org.bukkit.event.inventory.InventoryDragEvent; //导入方法依赖的package包/类
@EventHandler (priority = EventPriority.HIGHEST)
public void onInventoryDrag(InventoryDragEvent e){
	if(!isEnabled(e.getWhoClicked().getWorld()) || 
			e.getInventory().getType() != InventoryType.CRAFTING ||
			!e.getInventorySlots().contains(40)) return;

	if(shouldWeCancel(e.getOldCursor())){
		e.setResult(Event.Result.DENY);
		e.setCancelled(true);
	}
}
 
开发者ID:gvlfm78,项目名称:BukkitOldCombatMechanics,代码行数:12,代码来源:ModuleDisableOffHand.java

示例11: on

import org.bukkit.event.inventory.InventoryDragEvent; //导入方法依赖的package包/类
@EventHandler
public void on(InventoryDragEvent event) {
    Player player = (Player) event.getWhoClicked();

    if (!isSpectating(player)) {
        return;
    }

    event.setCancelled(true);
}
 
开发者ID:RealizedMC,项目名称:Duels,代码行数:11,代码来源:SpectatorManager.java

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

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

示例14: playerDragInventoryEvent

import org.bukkit.event.inventory.InventoryDragEvent; //导入方法依赖的package包/类
@EventHandler
public void playerDragInventoryEvent(InventoryDragEvent e) {
	ArmorType newArmorType = ArmorType.matchType(e.getOldCursor());
	if (newArmorType == null)
		return;
	ArmorEquipEvent armorEquipEvent = new ArmorEquipEvent((Player) e.getWhoClicked(), EquipMethod.DRAG,
			newArmorType, e.getOldCursor());
	if (!e.getRawSlots().contains(newArmorType.getSlot()))
		return;
	Bukkit.getServer().getPluginManager().callEvent(armorEquipEvent);
	if (armorEquipEvent.isCancelled()) {
		e.setCancelled(true);
	}
}
 
开发者ID:Sharpjaws,项目名称:SharpSK,代码行数:15,代码来源:ArmorEquipListener.java

示例15: onDrag

import org.bukkit.event.inventory.InventoryDragEvent; //导入方法依赖的package包/类
@EventHandler
public void onDrag(InventoryDragEvent e) {
    Player p = (Player) e.getWhoClicked();
    if (this.guiManager.containsPlayer(p.getUniqueId()) && p.getOpenInventory().getTopInventory().equals(e.getInventory())) {
        e.setCancelled(true);
    }
}
 
开发者ID:7rory768,项目名称:SimpleFreeze,代码行数:8,代码来源:InventoryDragListener.java


注:本文中的org.bukkit.event.inventory.InventoryDragEvent.setCancelled方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。