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


Java InventoryDragEvent.getWhoClicked方法代碼示例

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


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

示例4: afterEquipChange

import org.bukkit.event.inventory.InventoryDragEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.MONITOR)
public void afterEquipChange(final InventoryDragEvent event) {
    final Player player = (Player) event.getWhoClicked();

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

    new BukkitRunnable() {
        @Override
        public void run() {
            InventoryView inventoryView = event.getView();
            for (int slot : event.getRawSlots()) {
                ItemStack item = inventoryView.getItem(slot);
                if (CustomItem.isCustomItem(item)) {
                    ItemManager.updateStats((Player) event.getWhoClicked());
                }
            }
        }
    }.runTaskLater(RPGInventory.getInstance(), 1);
}
 
開發者ID:EndlessCodeGroup,項目名稱:RPGInventory,代碼行數:22,代碼來源:ItemListener.java

示例5: onInventoryDrag

import org.bukkit.event.inventory.InventoryDragEvent; //導入方法依賴的package包/類
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onInventoryDrag(InventoryDragEvent event) {
    HumanEntity humanEntity = event.getWhoClicked();
    if (humanEntity instanceof Player) {
        Player player = (Player) humanEntity;
        PearlNameFaker pearlNameFaker = itemNameFakes.get(player.getUniqueId());
        if (pearlNameFaker == null)
            return;
        for (Map.Entry<Integer, ItemStack> entry : event.getNewItems().entrySet()) {
            if (entry.getKey() == player.getInventory().getHeldItemSlot()) {
                pearlNameFaker.setFakeItem(CraftItemStack.asNMSCopy(player.getItemInHand()), player.getInventory().getHeldItemSlot());
                break;
            }
        }
    }
}
 
開發者ID:funkemunky,項目名稱:HCFCore,代碼行數:17,代碼來源:EnderPearlTimer.java

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

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

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

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

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

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

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

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

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

示例15: onInventoryDrag

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

    TradePlayer tradePlayer = initiator.getPlayer() == player ? initiator : partner.getPlayer() == player ? partner : null;
    if (tradePlayer == null) {
        //This event does not belong to this trade
        return;
    }

    event.setCancelled(true);
}
 
開發者ID:xaniox,項目名稱:simple-trading,代碼行數:13,代碼來源:DefaultTrade.java


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