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


Java InventoryClickEvent.getRawSlot方法代码示例

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


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

示例1: onClick

import org.bukkit.event.inventory.InventoryClickEvent; //导入方法依赖的package包/类
@Override
protected void onClick(InventoryClickEvent event) {
    Player player = (Player) event.getWhoClicked();
    int rawSlot = event.getRawSlot();
    boolean isFrame = isFrame(rawSlot);
    if (isFrame) {
        event.setCancelled(true);
    }
    if (rawSlot == prevPageBtnIndex) {
        prevPage(player);
    } else if (rawSlot == nextPageBtnIndex) {
        nextPage(player);
    } else if (!isFrame) {
        InventoryClickEvent converted = convert(event);
        getHandlers().notify(converted);
        event.setCancelled(converted.isCancelled());
        return;
    }
    open(event.getWhoClicked());
}
 
开发者ID:EntryPointKR,项目名称:MCLibrary,代码行数:21,代码来源:PageGUI.java

示例2: onInventoryClick

import org.bukkit.event.inventory.InventoryClickEvent; //导入方法依赖的package包/类
public void onInventoryClick(InventoryClickEvent event) {
    event.setCancelled(true);
    Player player = (Player) event.getWhoClicked();
    int slot = event.getRawSlot();
    if (event.getInventory().getSize() == 54 && slot >= 0 && slot < 54) {
        ItemStack item = event.getInventory().getItem(slot);
        if (slot >= 0 && slot < 45 && item != null && !item.getType().equals(Material.AIR)) {
            this.clickItem(player, event.getRawSlot(), event.isShiftClick());
            return;
        }
        if (event.getRawSlot() == 45 && event.getCurrentItem().getType() != Material.AIR) {
            this.openGUI(player, this.getCurrentPage() - 1);
        } else if (event.getRawSlot() == 53 && event.getCurrentItem().getType() != Material.AIR) {
            this.openGUI(player, this.getCurrentPage() + 1);
        } else {
            this.closeGUI(player);
        }
    } else {
        this.closeGUI(player);
    }
}
 
开发者ID:NyaaCat,项目名称:Ourtown,代码行数:22,代码来源:SpawnGUI.java

示例3: onInventoryClick

import org.bukkit.event.inventory.InventoryClickEvent; //导入方法依赖的package包/类
@EventHandler
public void onInventoryClick(InventoryClickEvent event) {
    UUID uuid = event.getWhoClicked().getUniqueId();
    if (invClickables.containsKey(uuid)) {
        HashMap<String, HashMap<String, Runnable>> invs = invClickables.get(uuid);
        String invName = event.getInventory().getName();
        if (invName != null && invs.containsKey(invName) && event.getCurrentItem() != null) {
            event.setCancelled(true);
            ((Player) event.getWhoClicked()).updateInventory();
            ItemStack item = event.getCurrentItem();
            String serialized = serializeForMenu(item);
            //                System.out.println("checking " + invs.get(invName) + " for " + serialized);
            if (invs.get(invName).containsKey(serialized)) {
                Runnable r = invs.get(invName).get(serialized);
                r.run();
            }
        }
    }
    if (event.getView() != null && event.getView().getBottomInventory() != null && event.getView().getBottomInventory() instanceof CraftInventoryPlayer) {
        if (event.getRawSlot() >= event.getView().getTopInventory().getSize() && generalClickables.containsKey(uuid)) {
            Player p = (Player) event.getWhoClicked();
            generalClickables.get(uuid).onClick(p, event.getCurrentItem(), event.getSlot());
        }
    }
}
 
开发者ID:edasaki,项目名称:ZentrelaCore,代码行数:26,代码来源:MenuManager.java

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

示例5: onClickGUI

import org.bukkit.event.inventory.InventoryClickEvent; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
public void onClickGUI(InventoryClickEvent e) {
	Inventory inv = e.getInventory();
	if (inv == null) {
		return;
	}
	if (i18n.tr("title").equals(inv.getTitle())) {
		e.setCancelled(true);
	}
	if (e.getWhoClicked() instanceof Player) {
		Player p = (Player) e.getWhoClicked();
		int slot = e.getRawSlot();
		if (slot < 0 || slot > inv.getSize()) {
			return;
		}
		GUISortPing guiSortPing = GUISortPingHolder.get(p);
		if (guiSortPing != null) {
			if (slot == 44) {
				p.openInventory(guiSortPing.getPreviousPage());
			} else if (slot == 53) {
				p.openInventory(guiSortPing.getNextPage());
			}
		}
	}
}
 
开发者ID:jiongjionger,项目名称:NeverLag,代码行数:26,代码来源:GUISortPingListener.java

示例6: onInvClick

import org.bukkit.event.inventory.InventoryClickEvent; //导入方法依赖的package包/类
@EventHandler
public void onInvClick(InventoryClickEvent event) {
    HumanEntity human = event.getWhoClicked();
    if (human instanceof Player) {
        Player player = (Player) human;
        Inventory inv = event.getView().getTopInventory();
        if (inv.getHolder() != null && inv.getHolder() instanceof InventoryMenu && event.getRawSlot() >= 0 && event.getRawSlot() < size) {
            event.setCancelled(true);
            MenuIcon icon = slots.get(event.getSlot());
            if (icon != null) {
                icon.onClick(player);
                player.closeInventory();
            }
        }
    }
}
 
开发者ID:Borlea,项目名称:EchoPet,代码行数:17,代码来源:InventoryMenu.java

示例7: onInventoryClick

import org.bukkit.event.inventory.InventoryClickEvent; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGH)
public void onInventoryClick(InventoryClickEvent event) {
    final Player player = (Player) event.getWhoClicked();
    //noinspection ConstantConditions
    if (!InventoryManager.playerIsLoaded(player)
            || event.getInventory().getType() != InventoryType.WORKBENCH
            || isNotNeededHere(player)) {
        return;
    }

    List<CraftExtension> extensions = CraftManager.getExtensions(player);
    for (CraftExtension extension : extensions) {
        for (int slot : extension.getSlots()) {
            if (slot == event.getRawSlot()) {
                event.setCancelled(true);
                PlayerUtils.updateInventory(player);
                return;
            }
        }
    }
}
 
开发者ID:EndlessCodeGroup,项目名称:RPGInventory,代码行数:22,代码来源:CraftListener.java

示例8: onInventoryClick

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

	if (p.getGameMode() != GameMode.CREATIVE)
		event.setCancelled(true);
	
	if (Chat.stripColor(inv.getTitle()).equalsIgnoreCase("MC Zone Games")) {
		if (event.getRawSlot() > 9 || event.getCurrentItem() == null || event.getCurrentItem().getType() == Material.AIR)
			return;
		GameIcon game = GameIcon.get(event.getCurrentItem());
		if (game != null) {
			p.teleport(game.getTo());
			p.closeInventory();
		}
	}
}
 
开发者ID:thekeenant,项目名称:mczone,代码行数:19,代码来源:CompassEvents.java

示例9: onClick

import org.bukkit.event.inventory.InventoryClickEvent; //导入方法依赖的package包/类
@EventHandler // Prevents players from selling custom items and crafting with them.
public void onClick(InventoryClickEvent evt) {
    if (!(evt.getInventory() instanceof MerchantInventory) || evt.getRawSlot() != 2)
        return;

    MerchantInventory mi = (MerchantInventory) evt.getInventory();
    List<ItemStack> ig = new ArrayList<>();
    try {
        ig = mi.getSelectedRecipe().getIngredients();
    } catch (Exception e) {
        for (int i = 0; i < 3; i++) // Interal CraftBukkit throws an error, this avoids it.
            ig.add(new ItemStack(Material.DIRT));
    }

    for (int i = 0; i < evt.getInventory().getSize() - 1; i++)
        if (ItemWrapper.isCustom(evt.getInventory().getItem(i)) && !ItemWrapper.isCustom(ig.get(i)))
            evt.setCancelled(true); // Don't allow the trade to go through if it's using a custom item where none is needed.
}
 
开发者ID:Kneesnap,项目名称:Kineticraft,代码行数:19,代码来源:Items.java

示例10: onInventoryClick

import org.bukkit.event.inventory.InventoryClickEvent; //导入方法依赖的package包/类
@EventHandler
public void onInventoryClick(InventoryClickEvent event) {
	for (RawItemPosition p : this.layout.getItems()) {
		if (event.getRawSlot() == p.calculatePosition() && this.compiles.contains(event.getInventory()) && p.getComponent() != null) {
			p.getComponent().onClick(this, event);
		}
	}
}
 
开发者ID:GigaGamma,项目名称:McLink,代码行数:9,代码来源:Page.java

示例11: onAnvil

import org.bukkit.event.inventory.InventoryClickEvent; //导入方法依赖的package包/类
@EventHandler
  public void onAnvil(InventoryClickEvent e) {
      if (e.getRawSlot() == 2 && e.getWhoClicked() instanceof Player && e.getInventory().getType() == InventoryType.ANVIL) {
if (SlimefunManager.isItemSimiliar(e.getInventory().getContents()[0], SlimefunItems.ELYTRA, true)) return;

      	if (SlimefunItem.getByItem(e.getInventory().getContents()[0]) != null && !SlimefunItem.isDisabled(e.getInventory().getContents()[0])) {
          	e.setCancelled(true);
              Messages.local.sendTranslation((Player) e.getWhoClicked(), "anvil.not-working", true);
          }
      }
  }
 
开发者ID:StarWishsama,项目名称:Slimefun4-Chinese-Version,代码行数:12,代码来源:ItemListener.java

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

示例13: convert

import org.bukkit.event.inventory.InventoryClickEvent; //导入方法依赖的package包/类
private InventoryClickEvent convert(InventoryClickEvent event) {
    int rawSlot = event.getRawSlot();
    int convertedSlot = rawSlot - 9 + (currPage * spaceSize);
    return new InventoryClickEvent(
            event.getView(), event.getSlotType(), convertedSlot,
            event.getClick(), event.getAction(), event.getHotbarButton()
    );
}
 
开发者ID:EntryPointKR,项目名称:MCLibrary,代码行数:9,代码来源:PageGUI.java

示例14: onClick

import org.bukkit.event.inventory.InventoryClickEvent; //导入方法依赖的package包/类
@EventHandler
public void onClick(InventoryClickEvent e) {
    if (ChatColor.stripColor(e.getInventory().getTitle()).equals("장신구 장착")) {
        if (e.getSlotType() != InventoryType.SlotType.OUTSIDE) {
            if ((e.getClick() == ClickType.RIGHT) || (e.getClick() == ClickType.LEFT)) {
                if ((e.getRawSlot() == 20) || (e.getRawSlot() == 21) || (e.getRawSlot() == 22) || (e.getRawSlot() == 23) || (e.getRawSlot() == 24)) {

                } else if (e.getRawSlot() <= e.getInventory().getSize()) {
                    e.setCancelled(true);
                }

            } else e.setCancelled(true);
        }
    }
}
 
开发者ID:SkyLightQP,项目名称:ArmorPlus,代码行数:16,代码来源:GUIEvent.java

示例15: handleCategoryInventoryClick

import org.bukkit.event.inventory.InventoryClickEvent; //导入方法依赖的package包/类
private void handleCategoryInventoryClick(InventoryClickEvent ice,
		Game game, Player player) {
	int catSize = getCategoriesSize(player);
	int sizeCategories = getInventorySize(catSize) + 9;
	int rawSlot = ice.getRawSlot();

	if ((rawSlot >= getInventorySize(catSize))
			&& (rawSlot < sizeCategories)) {
		ice.setCancelled(true);

		if (ice.getCurrentItem().getType() == Material.BUCKET) {
			game.getPlayerSettings(player).setOneStackPerShift(false);
			player.playSound(player.getLocation(),
					SoundMachine.get("CLICK", "UI_BUTTON_CLICK"), 10.0F,
					1.0F);
			openCategoryInventory(player);
			return;
		}
		if (ice.getCurrentItem().getType() == Material.LAVA_BUCKET) {
			game.getPlayerSettings(player).setOneStackPerShift(true);
			player.playSound(player.getLocation(),
					SoundMachine.get("CLICK", "UI_BUTTON_CLICK"), 10.0F,
					1.0F);
			openCategoryInventory(player);
			return;
		}

	}

	if (rawSlot >= sizeCategories) {
		if (ice.isShiftClick()) {
			ice.setCancelled(true);
			return;
		}

		ice.setCancelled(false);
		return;
	}

	MerchantCategory clickedCategory = getCategoryByMaterial(ice
			.getCurrentItem().getType());
	if (clickedCategory == null) {
		if (ice.isShiftClick()) {
			ice.setCancelled(true);
			return;
		}

		ice.setCancelled(false);
		return;
	}

	openBuyInventory(clickedCategory, player, game);
}
 
开发者ID:Ldcr993519867,项目名称:BedwarsXP,代码行数:54,代码来源:XPItemShop.java


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