org.bukkit.inventory.Inventory.getType()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(7.3k)|赞(0)|评价(0)|浏览(145)

本文整理了Java中org.bukkit.inventory.Inventory.getType()方法的一些代码示例,展示了Inventory.getType()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Inventory.getType()方法的具体详情如下:
包路径:org.bukkit.inventory.Inventory
类名称:Inventory
方法名:getType

Inventory.getType介绍

[英]Returns what type of inventory this is.
[中]返回这是什么类型的库存。

代码示例

代码示例来源:origin: GlowstoneMC/Glowstone

/**
 * Create an inventory view for this player looking at a given top inventory.
 *
 * @param player The player.
 * @param topInventory The top inventory.
 */
public GlowInventoryView(HumanEntity player, Inventory topInventory) {
  this(player, topInventory.getType(), topInventory, player.getInventory());
}

代码示例来源:origin: GlowstoneMC/Glowstone

/**
 * Create a new monitor for the given inventory view.
 *
 * @param view The view to monitor.
 */
public InventoryMonitor(InventoryView view) {
  this.view = view;
  if (view.getTopInventory().getType() != InventoryType.CRAFTING
    && view.getBottomInventory().getType() == InventoryType.PLAYER) {
    // Don't send armor/shield slots when looking in an inventory
    size = view.countSlots() - 5;
  } else {
    size = view.countSlots();
  }
  slots = new ItemStack[size];
  // determine id and type id
  if (GlowInventoryView.isDefault(view)) {
    id = 0;
  } else {
    id = nextId;
    nextId = nextId % 100 + 1;
  }
  type = getTypeId(view.getType());
  // set initial contents
  for (int i = 0; i < size; ++i) {
    updateItem(i);
  }
}

代码示例来源:origin: GlowstoneMC/Glowstone

if (view.getTopInventory().getType() != InventoryType.CRAFTING || viewSlot >= view
    .getTopInventory().getSize()
    || ((GlowInventory) view.getTopInventory()).getSlot(viewSlot).getType()

代码示例来源:origin: bergerkiller/BKCommonLib

@Override
public InventoryType getType() {
  return base.getType();
}

代码示例来源:origin: bergerkiller/BKCommonLib

@Override
public InventoryType getType() {
  return base.getType();
}

代码示例来源:origin: seeseemelk/MockBukkit

public PlayerInventoryViewMock(HumanEntity player, Inventory top)
{
  super(player, top, player.getInventory(), top.getType());
}

代码示例来源:origin: EngineHub/CommandHelper

@Override
public MCInventoryType getType() {
  return MCInventoryType.valueOf(this.i.getType().name());
}

代码示例来源:origin: jiongjionger/NeverLag

public GUIMaker(Inventory inv) {
  if (inv.getType() == InventoryType.CHEST) { // 自定义大小的 Inventory
    this.inv = Bukkit.createInventory(inv.getHolder(), inv.getSize(), inv.getTitle());
  } else { // 自定义类型的 Inventory
    this.inv = Bukkit.createInventory(inv.getHolder(), inv.getType(), inv.getTitle());
  }
  this.inv.setContents(inv.getContents());
}

代码示例来源:origin: eccentricdevotion/TARDIS

@EventHandler(ignoreCancelled = true)
public void onRecipeClick(InventoryClickEvent event) {
  Inventory top = event.getView().getTopInventory();
  InventoryType type = top.getType();
  if (type == InventoryType.CHEST) {
    Player player = (Player) event.getWhoClicked();
    if (plugin.getTrackerKeeper().getRecipeView().contains(player.getUniqueId())) {
      event.setCancelled(true);
    }
  }
}

代码示例来源:origin: gvlfm78/BukkitOldCombatMechanics

@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);
  }
}

代码示例来源:origin: FunnyGuilds/FunnyGuilds

@EventHandler
  public void onInteract(final InventoryInteractEvent e) {
    if (GuiWindow.getWindow(e.getInventory().getTitle()) != null) {
      if (e.getInventory().getType().equals(InventoryType.CHEST)) {
        e.setResult(Event.Result.DENY);
        e.setCancelled(true);
      }
    }
  }
}

代码示例来源:origin: Co0sh/BetonQuest

@EventHandler
public void onIngredientPut(InventoryClickEvent event) {
  if (event.getInventory().getType() != InventoryType.BREWING)
    return;
  if (event.getRawSlot() == 3 || event.getClick().equals(ClickType.SHIFT_LEFT)) {
    String playerID = PlayerConverter.getID((Player) event.getWhoClicked());
    if (!containsPlayer(playerID))
      return;
    locations.put(((BrewingStand) event.getInventory().getHolder()).getLocation(), playerID);
  }
}

代码示例来源:origin: eccentricdevotion/TARDIS

@EventHandler(ignoreCancelled = true)
  public void onRecipeClose(InventoryCloseEvent event) {
    Inventory top = event.getView().getTopInventory();
    InventoryType type = top.getType();
    if (type == InventoryType.CHEST) {
      Player p = (Player) event.getPlayer();
      UUID uuid = p.getUniqueId();
      if (plugin.getTrackerKeeper().getRecipeView().contains(uuid)) {
        plugin.getTrackerKeeper().getRecipeView().remove(uuid);
        event.getView().getTopInventory().clear();
        p.updateInventory();
      }
    }
  }
}

代码示例来源:origin: elBukkit/MagicPlugin

@EventHandler
public void onInventoryClick(InventoryClickEvent event) {
  if (!(event.getWhoClicked() instanceof Player)) return;
  if (event.isCancelled()) return;
  InventoryType inventoryType = event.getInventory().getType();
  SlotType slotType = event.getSlotType();
  // Check for wand clicks to prevent grinding them to dust, or whatever.
  if (slotType == SlotType.CRAFTING && (inventoryType == InventoryType.CRAFTING || inventoryType == InventoryType.WORKBENCH)) {
    ItemStack cursor = event.getCursor();
    if (Wand.isSpecial(cursor)) {
      event.setCancelled(true);
      return;
    }
  }
}

代码示例来源:origin: gvlfm78/BukkitOldCombatMechanics

@EventHandler
public void onInventoryOpen(InventoryOpenEvent e){
  if(!isEnabled(e.getPlayer().getWorld())) return;
  Inventory inv = e.getInventory();
  if(inv == null || inv.getType() != InventoryType.ENCHANTING || !hasPermission(e.getPlayer())) return;
  ((EnchantingInventory) inv).setSecondary(getLapis());
}

代码示例来源:origin: gvlfm78/BukkitOldCombatMechanics

@EventHandler
public void onInventoryClose(InventoryCloseEvent e){
  if(!isEnabled(e.getPlayer().getWorld())) return;
  Inventory inv = e.getInventory();
  if(inv == null || inv.getType() != InventoryType.ENCHANTING || !hasPermission(e.getPlayer())) return;
  ((EnchantingInventory) inv).setSecondary(new ItemStack(Material.AIR));
}

代码示例来源:origin: Co0sh/BetonQuest

@EventHandler
public void onShiftSmelting(InventoryClickEvent event) {
  if (event.getInventory().getType().equals(InventoryType.FURNACE) && event.getRawSlot() == 2
      && event.getClick().equals(ClickType.SHIFT_LEFT) && event.getWhoClicked() instanceof Player) {
    String playerID = PlayerConverter.getID((Player) event.getWhoClicked());
    if (containsPlayer(playerID))
      event.setCancelled(true);
  }
}

代码示例来源:origin: gvlfm78/BukkitOldCombatMechanics

@EventHandler(priority = EventPriority.HIGHEST)
public void onInventoryClick(InventoryClickEvent e){
  if(!isEnabled(e.getWhoClicked().getWorld()) ||
      e.getInventory().getType() != InventoryType.CRAFTING || //Making sure it's a survival player's inventory
      e.getSlot() != 40) return; // If they didn't click into the offhand slot, return
  if(e.getClick().equals(ClickType.NUMBER_KEY) || shouldWeCancel(e.getCursor())){
    e.setResult(Event.Result.DENY);
    e.setCancelled(true);
  }
}

代码示例来源:origin: FunnyGuilds/FunnyGuilds

@EventHandler
public void onClick(final InventoryClickEvent e) {
  if (e.getInventory() != null && e.getInventory().getType().equals(InventoryType.CHEST)) {
    GuiWindow window = GuiWindow.getWindow(e.getInventory().getTitle());
    if (window != null) {
      GuiItem item = window.getItem(e.getSlot());
      if (item != null) {
        item.handleClick(e);
      }
      
      e.setResult(Event.Result.DENY);
      e.setCancelled(true);
    }
  }
}

代码示例来源:origin: TheBusyBiscuit/Slimefun4

@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);
    }
  }
}

相关文章