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


Java InventoryClickEvent.getSlot方法代码示例

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


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

示例1: call

import org.bukkit.event.inventory.InventoryClickEvent; //导入方法依赖的package包/类
@Override
public void call(Event event) {
	if (event instanceof InventoryClickEvent) {
		final InventoryClickEvent ice = (InventoryClickEvent) event;

		if (ice.getCurrentItem().getType() == Material.BOWL) {

			final int slot = ice.getSlot();

			if (!slotsChosen.containsKey(slot)) {
				slotsChosen.put(slot, 1);
			} else {
				slotsChosen.put(slot, slotsChosen.get(slot) + 1);
			}

			if (getStackChance() >= 100.0) {
				callback(true);
			}
		}
	}
}
 
开发者ID:davidm98,项目名称:Crescent,代码行数:22,代码来源:InventoryTweaksB.java

示例2: handleInventoryClick

import org.bukkit.event.inventory.InventoryClickEvent; //导入方法依赖的package包/类
@EventHandler
public void handleInventoryClick(InventoryClickEvent e)
{
    if (!(e.getWhoClicked() instanceof Player)) return;

    if (inventories().contains(e.getInventory()) && e.getCurrentItem() != null && e.getSlot() == e.getRawSlot())
    {
        e.setCancelled(true);
        if (mobConfig.getItemLayout().getItemId() == e.getCurrentItem().getTypeId())
        {
            MobImpl mob = find(e.getInventory());
            if (mob.getServerPosition().containsKey(e.getSlot()))
            {
                if (CloudAPI.getInstance().getServerId().equalsIgnoreCase(mob.getServerPosition().get(e.getSlot()))) return;
                ByteArrayDataOutput byteArrayDataOutput = ByteStreams.newDataOutput();
                byteArrayDataOutput.writeUTF("Connect");
                byteArrayDataOutput.writeUTF(mob.getServerPosition().get(e.getSlot()));
                ((Player) e.getWhoClicked()).sendPluginMessage(CloudServer.getInstance().getPlugin(), "BungeeCord", byteArrayDataOutput.toByteArray());
            }
        }
    }
}
 
开发者ID:Dytanic,项目名称:CloudNet,代码行数:23,代码来源:MobSelector.java

示例3: onClick

import org.bukkit.event.inventory.InventoryClickEvent; //导入方法依赖的package包/类
@Override
public void onClick(InventoryClickEvent event) {
    int slot = event.getSlot();
    if(slot < 0)
        return;
    Player clicker = (Player) event.getWhoClicked();
    int page = pageRegistry.getOrDefault(clicker, 0);
    Icon clicked = getIcon(page, slot);
    if(clicked != null)
        clicked.getClick().run(clicker);
}
 
开发者ID:upperlevel,项目名称:uppercore,代码行数:12,代码来源:MenuGui.java

示例4: playSound

import org.bukkit.event.inventory.InventoryClickEvent; //导入方法依赖的package包/类
public static void playSound(InventoryClickEvent event) {
    if (event.getSlot() == -999) {
        return;
    }

    HumanEntity human = event.getWhoClicked();
    if (!(human instanceof Player)) {
        return;
    }

    ItemStack clicked = event.getCurrentItem();
    if (clicked == null || clicked.getType() == Material.AIR) {
        return;
    }

    if (clicked.getType() == Material.BARRIER) {
        ((Player) human).playSound(human.getLocation(), Sound.BLOCK_ANVIL_PLACE, 1, 1);
    } else if (clicked != null && !clicked.equals(PLACEHOLDER)) {
        ((Player) human).playSound(human.getLocation(), Sound.UI_BUTTON_CLICK, 1, 1);
    }
}
 
开发者ID:DRE2N,项目名称:FactionsXL,代码行数:22,代码来源:PageGUI.java

示例5: onClickChooseExport

import org.bukkit.event.inventory.InventoryClickEvent; //导入方法依赖的package包/类
private void onClickChooseExport(InventoryClickEvent event) {
    TradeOffer offer = creatingOffer.get(event.getWhoClicked());
    if (offer == null) {
        return;
    }
    Faction creator = offer.getImporter();
    Faction partner = offer.getExporter();
    String exImport = null;
    if (event.getSlot() == 3) {
        exImport = "export";
        offer.setExporter(creator);
        offer.setImporter(partner);
        offer.setExporterAccepted(true);
        offer.setImporterAccepted(false);
    } else if (event.getSlot() == 5) {
        exImport = "import";
        offer.setExporter(partner);
        offer.setImporter(creator);
        offer.setExporterAccepted(false);
        offer.setImporterAccepted(true);
    }
    performCommand(event.getWhoClicked(), creator.getName() + " " + partner.getName() + " " + exImport);
}
 
开发者ID:DRE2N,项目名称:FactionsXL,代码行数:24,代码来源:TradeOfferCommand.java

示例6: onInventoryClick

import org.bukkit.event.inventory.InventoryClickEvent; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onInventoryClick(InventoryClickEvent event) {
    HumanEntity humanEntity = event.getWhoClicked();
    if (humanEntity instanceof Player) {
        Player player = (Player) humanEntity;
        PearlNameFaker pearlNameFaker = itemNameFakes.get(player.getUniqueId());
        if (pearlNameFaker == null)
            return;

        // Required to prevent ghost items.
        int heldSlot = player.getInventory().getHeldItemSlot();
        if (event.getSlot() == heldSlot) {
            pearlNameFaker.setFakeItem(CraftItemStack.asNMSCopy(player.getItemInHand()), heldSlot);
        } else if (event.getHotbarButton() == heldSlot) {
            pearlNameFaker.setFakeItem(CraftItemStack.asNMSCopy(event.getCurrentItem()), event.getSlot());
            new BukkitRunnable() {
                @Override
                public void run() {
                    player.updateInventory();
                }
            }.runTask(plugin);
        }
    }
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:25,代码来源:EnderPearlTimer.java

示例7: onInventoryClick

import org.bukkit.event.inventory.InventoryClickEvent; //导入方法依赖的package包/类
@EventHandler (priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onInventoryClick(InventoryClickEvent event) {
	Menu menu = null;
	MenuLink ml = null;
	if(event.getInventory().getHolder() instanceof MenuLink)
		ml = (MenuLink) event.getInventory().getHolder();
	int slot = event.getSlot();
	slot = slot == -999 ? 0 : slot+1;
	VPPlayer clicker = VanillaPlusCore.getPlayerManager().getPlayer((Player) event.getWhoClicked());
	if(slot == 0){
		menu =  ml != null ? ml.getIconMenu() : clicker.getMenu();
	}else if (event.getClickedInventory() == event.getWhoClicked().getOpenInventory().getTopInventory()){
		if(ml != null)
			menu = ml.getIconMenu();
	}else if(clicker.getMenu() != null){
		menu = clicker.getMenu();
	}
	if(menu == null){
		VPPInventoryClicEvent clickEvent = new VPPInventoryClicEvent(clicker, event);
		Bukkit.getServer().getPluginManager().callEvent(clickEvent);
		if(clickEvent.isCancelled())
			event.setCancelled(true);
		return;
	}
	VPPMenuClicEvent e = new VPPMenuClicEvent(clicker, menu, event);
	Bukkit.getServer().getPluginManager().callEvent(e);
	if(e.isCancelled()) {
		event.setCancelled(true);
		return;
	}
	Long cooldownUntil = antiClickSpam.get(clicker);
	if(menu.onClick(clicker, slot, cooldownUntil, ml, event)){
		antiClickSpam.put(clicker, System.currentTimeMillis() + anti_click_spam_delay);
	}
}
 
开发者ID:dracnis,项目名称:VanillaPlus,代码行数:36,代码来源:MenuManager.java

示例8: GUIClickEvent

import org.bukkit.event.inventory.InventoryClickEvent; //导入方法依赖的package包/类
public GUIClickEvent(InventoryClickEvent delegate, GUI gui) {
    super(delegate.getView(), delegate.getSlotType(), delegate.getRawSlot(), delegate.getClick(), delegate.getAction(), delegate.getHotbarButton());
    this.delegate = delegate;
    this.gui = gui;
    this.rawSlot = delegate.getRawSlot();
    this.slot = delegate.getSlot();
}
 
开发者ID:EntryPointKR,项目名称:MCLibrary,代码行数:8,代码来源:GUIClickEvent.java

示例9: onEvent

import org.bukkit.event.inventory.InventoryClickEvent; //导入方法依赖的package包/类
@Override
public void onEvent(InventoryClickEvent event) {
    super.onEvent(event);
    if(this.isCarrier(event.getWhoClicked()) && event.getSlot() == ArmorType.HELMET.inventorySlot()) {
        event.setCancelled(true);
        event.getView().setCursor(null);
        event.setCurrentItem(null);
        this.flag.getMatch().getScheduler(MatchScope.RUNNING).createTask(() -> {
            if(isCurrent()) {
                dropFlag();
            }
        });
    }
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:15,代码来源:Carried.java

示例10: onInventoryClick

import org.bukkit.event.inventory.InventoryClickEvent; //导入方法依赖的package包/类
@EventHandler
public void onInventoryClick(InventoryClickEvent event) {
    if (event.getSlot() == 8) {
        event.setCurrentItem(null);
        try {
            ScrapsUtil.setScraps((Player) event.getWhoClicked(), ScrapsUtil.getScraps((Player) event.getWhoClicked()));
        } catch (SQLException e) {
            e.printStackTrace();
        }
        event.setCancelled(true);
    }
}
 
开发者ID:Warvale,项目名称:Locked,代码行数:13,代码来源:PlayerListener.java

示例11: onClickChooseResource

import org.bukkit.event.inventory.InventoryClickEvent; //导入方法依赖的package包/类
private void onClickChooseResource(InventoryClickEvent event) {
    if (event.getSlot() > 44 && event.getSlot() < 54) {
        return;
    }

    TradeOffer offer = creatingOffer.get(event.getWhoClicked());
    if (offer == null) {
        return;
    }
    if (event.getCurrentItem() == null) {
        return;
    }
    ItemStack button = event.getCurrentItem();
    if (button == null) {
        return;
    }
    Resource resource = Resource.getByIcon(button);
    if (resource == null) {
        return;
    }
    offer.setGood(resource);

    Faction creator = offer.hasExporterAccepted() ? offer.getExporter() : offer.getImporter();
    Faction partner = offer.hasExporterAccepted() ? offer.getImporter() : offer.getExporter();
    String exImport = offer.hasExporterAccepted() ? "export" : "import";
    performCommand(event.getWhoClicked(), creator.getName() + " " + partner.getName() + " " + exImport + " " + resource.name());
}
 
开发者ID:DRE2N,项目名称:FactionsXL,代码行数:28,代码来源:TradeOfferCommand.java

示例12: onInventoryClick

import org.bukkit.event.inventory.InventoryClickEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.LOW)
public void onInventoryClick(InventoryClickEvent e) {
    Player p = (Player) e.getWhoClicked();

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

    if(e.getAction() == InventoryAction.COLLECT_TO_CURSOR ||
            e.getAction() == InventoryAction.MOVE_TO_OTHER_INVENTORY) {
        e.setCancelled(true);
        return;
    }

    if(e.getClickedInventory() == p.getOpenInventory().getTopInventory()) {
        e.setCancelled(true);

        int row = e.getSlot() / 9;
        int column = e.getSlot() % 9;

        if(row < 0 || column < 0)
            return;

        SmartInventory inv = inventories.get(p);

        if(row >= inv.getRows() || column >= inv.getColumns())
            return;

        inv.getListeners().stream()
                .filter(listener -> listener.getType() == InventoryClickEvent.class)
                .forEach(listener -> ((InventoryListener<InventoryClickEvent>) listener).accept(e));

        contents.get(p).get(row, column).ifPresent(item -> item.run(e));
    }
}
 
开发者ID:MinusKube,项目名称:SmartInvs,代码行数:35,代码来源:InventoryManager.java

示例13: onInventoryClick

import org.bukkit.event.inventory.InventoryClickEvent; //导入方法依赖的package包/类
/**
 * Cancel the click on the lapis lazuli (duplication catch)
 *
 * @param event Event
 */
@EventHandler
public void onInventoryClick(InventoryClickEvent event)
{
    if (event.getClickedInventory() != null && event.getClickedInventory().getType() == InventoryType.ENCHANTING && event.getSlot() == 1)
        event.setCancelled(true);
}
 
开发者ID:SamaGames,项目名称:SurvivalAPI,代码行数:12,代码来源:AutomaticLapisModule.java

示例14: accept

import org.bukkit.event.inventory.InventoryClickEvent; //导入方法依赖的package包/类
@Override
public void accept(InventoryClickEvent event) {
    Objects.requireNonNull(event);
    for (int x = 0; isWithinBounds(x, 0); x++) {
        for (int y = 0; isWithinBounds(x, y); y++) {
            if ((locX + x) + (locY + y) * 9 == event.getSlot()) {
                elements[x][y].accept(event);
            }
        }
    }
}
 
开发者ID:Personinblack,项目名称:black,代码行数:12,代码来源:BasicPane.java

示例15: onBackpackClick

import org.bukkit.event.inventory.InventoryClickEvent; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
public void onBackpackClick(final InventoryClickEvent event) {
    final Inventory inventory = event.getInventory();
    final Player player = (Player) event.getWhoClicked();

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

    if (inventory.getHolder() instanceof BackpackHolder) {
        // Click inside backpack
        if (BackpackManager.isBackpack(event.getCurrentItem())
                || BackpackManager.isBackpack(event.getCursor())
                || InventoryManager.isFilledSlot(event.getCurrentItem())
                || InventoryManager.isFilledSlot(event.getCursor())) {
            event.setCancelled(true);
            return;
        }

        // Save changes
        if (event.getAction() == InventoryAction.NOTHING) {
            return;
        }

        BackpackUpdater.update(inventory, InventoryManager.get(player).getBackpack());
    } else if ((event.getRawSlot() >= event.getView().getTopInventory().getSize()
            || event.getSlot() == SlotManager.instance().getBackpackSlot().getSlotId()
                    && InventoryAPI.isRPGInventory(event.getInventory()))
            && !BackpackManager.playerCanTakeBackpack(player)
            && BackpackManager.isBackpack(event.getCursor())
            && ActionType.getTypeOfAction(event.getAction()) == ActionType.SET) {
        // Prevent placing new backpack in bottom inventory if player can't take backpack
        int limit = BackpackManager.getLimit();
        String message = RPGInventory.getLanguage().getMessage("backpack.limit", limit);
        PlayerUtils.sendMessage(player, message);
        event.setCancelled(true);
    }
}
 
开发者ID:EndlessCodeGroup,项目名称:RPGInventory,代码行数:39,代码来源:BackpackListener.java


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