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