org.bukkit.Server.createInventory()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(7.9k)|赞(0)|评价(0)|浏览(98)

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

Server.createInventory介绍

[英]Creates an empty inventory of type InventoryType#CHEST with the specified size.
[中]创建具有指定大小的InventoryType#CHEST类型的空库存。

代码示例

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

/**
 * @see Server#createInventory(InventoryHolder owner, int size, String
 *     title)
 */
public static Inventory createInventory(InventoryHolder owner, int size, String title) throws IllegalArgumentException {
  return server.createInventory(owner, size, title);
}

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

/**
 * @see Server#createInventory(InventoryHolder owner, InventoryType type)
 */
public static Inventory createInventory(InventoryHolder owner, InventoryType type) {
  return server.createInventory(owner, type);
}

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

/**
 * @see Server#createInventory(InventoryHolder owner, InventoryType type, String title)
 */
public static Inventory createInventory(InventoryHolder owner, InventoryType type, String title) {
  return server.createInventory(owner, type, title);
}

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

/**
 * @see Server#createInventory(InventoryHolder owner, int size)
 */
public static Inventory createInventory(InventoryHolder owner, int size) throws IllegalArgumentException {
  return server.createInventory(owner, size);
}

代码示例来源:origin: SpigotMC/Spigot-API

/**
 * @see Server#createInventory(InventoryHolder owner, InventoryType type, String title)
 */
public static Inventory createInventory(InventoryHolder owner, InventoryType type, String title) {
  return server.createInventory(owner, type, title);
}

代码示例来源:origin: SpigotMC/Spigot-API

/**
 * @see Server#createInventory(InventoryHolder owner, int size, String
 *     title)
 */
public static Inventory createInventory(InventoryHolder owner, int size, String title) throws IllegalArgumentException {
  return server.createInventory(owner, size, title);
}

代码示例来源:origin: SpigotMC/Spigot-API

/**
 * @see Server#createInventory(InventoryHolder owner, int size)
 */
public static Inventory createInventory(InventoryHolder owner, int size) throws IllegalArgumentException {
  return server.createInventory(owner, size);
}

代码示例来源:origin: SpigotMC/Spigot-API

/**
 * @see Server#createInventory(InventoryHolder owner, InventoryType type)
 */
public static Inventory createInventory(InventoryHolder owner, InventoryType type) {
  return server.createInventory(owner, type);
}

代码示例来源:origin: me.lucko/helper

public static Inventory decodeInventory(byte[] buf, String title) {
  try (ByteArrayInputStream inputStream = new ByteArrayInputStream(buf)) {
    try (BukkitObjectInputStream dataInput = new BukkitObjectInputStream(inputStream)) {
      Inventory inventory = Bukkit.getServer().createInventory(null, dataInput.readInt(), title);
      for (int i = 0; i < inventory.getSize(); i++) {
        inventory.setItem(i, (ItemStack) dataInput.readObject());
      }
      return inventory;
    }
  } catch (ClassNotFoundException | IOException e) {
    throw new RuntimeException(e);
  }
}

代码示例来源:origin: lucko/helper

public static Inventory decodeInventory(byte[] buf, String title) {
  try (ByteArrayInputStream inputStream = new ByteArrayInputStream(buf)) {
    try (BukkitObjectInputStream dataInput = new BukkitObjectInputStream(inputStream)) {
      Inventory inventory = Bukkit.getServer().createInventory(null, dataInput.readInt(), title);
      for (int i = 0; i < inventory.getSize(); i++) {
        inventory.setItem(i, (ItemStack) dataInput.readObject());
      }
      return inventory;
    }
  } catch (ClassNotFoundException | IOException e) {
    throw new RuntimeException(e);
  }
}

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

private void openActivate(Player p) {
  ItemStack[] items = new TARDISSonicActivatorInventory(plugin).getActivator();
  Inventory sgc = plugin.getServer().createInventory(p, 9, ChatColor.DARK_RED + "Sonic Activator");
  sgc.setContents(items);
  p.openInventory(sgc);
}

代码示例来源:origin: ProSavage/SavageFactions

public static Inventory fromBase64(String data) {
  try {
    ByteArrayInputStream inputStream = new ByteArrayInputStream(Base64Coder.decodeLines(data));
    BukkitObjectInputStream dataInput = new BukkitObjectInputStream(inputStream);
    Inventory inventory = Bukkit.getServer().createInventory(null, dataInput.readInt());
    // Read the serialized inventory
    for (int i = 0; i < inventory.getSize(); i++) {
      inventory.setItem(i, (ItemStack) dataInput.readObject());
    }
    dataInput.close();
    return inventory;
  } catch (Exception e) {
  }
  return null;
}

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

private void list(Player player) {
  ResultSetTardisCompanions rs = new ResultSetTardisCompanions(plugin);
  if (rs.fromUUID(player.getUniqueId().toString())) {
    String comps = rs.getCompanions();
    close(player);
    plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, () -> {
      ItemStack[] items = new TARDISCompanionInventory(plugin, comps.split(":")).getSkulls();
      Inventory cominv = plugin.getServer().createInventory(player, 54, ChatColor.DARK_RED + "Companions");
      cominv.setContents(items);
      player.openInventory(cominv);
    }, 2L);
  }
}

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

boolean doAddGUI(Player player) {
  if (player.hasPermission("tardis.add")) {
    ItemStack[] items = new TARDISCompanionAddInventory(plugin, player.getUniqueId()).getPlayers();
    Inventory presetinv = plugin.getServer().createInventory(player, 54, ChatColor.DARK_RED + "Add Companion");
    presetinv.setContents(items);
    player.openInventory(presetinv);
  } else {
    TARDISMessage.send(player, "NO_PERMS");
  }
  return true;
}

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

@Override
  public void run() {
    TARDISRegulatorInventory reg = new TARDISRegulatorInventory();
    ItemStack[] items = reg.getRegulator();
    Inventory inv = plugin.getServer().createInventory(player, 54, "Helmic Regulator");
    inv.setContents(items);
    player.openInventory(inv);
    // play inflight sound
    if (!plugin.getTrackerKeeper().getDestinationVortex().containsKey(id)) {
      plugin.getServer().getScheduler().runTask(plugin, new TARDISLoopingFlightSound(plugin, player.getLocation(), id));
    }
  }
}

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

/**
 * Closes the inventory and opens the Wall block selector menu.
 *
 * @param p the player using the GUI
 */
private void floor(Player p) {
  plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, () -> {
    p.closeInventory();
    ItemStack[] wall_blocks = new TARDISWallsInventory(plugin).getMenu();
    Inventory wall = plugin.getServer().createInventory(p, 54, ChatColor.DARK_RED + "TARDIS Floor Menu");
    wall.setContents(wall_blocks);
    p.openInventory(wall);
  }, 1L);
}

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

/**
 * Closes the inventory and opens the archive consoles menu.
 *
 * @param p the player using the GUI
 */
private void archive(Player p) {
  plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, () -> {
    p.closeInventory();
    ItemStack[] archive = new TARDISArchiveInventory(plugin, p).getArchives();
    Inventory menu = plugin.getServer().createInventory(p, 27, ChatColor.DARK_RED + "TARDIS Archive");
    menu.setContents(archive);
    p.openInventory(menu);
  }, 1L);
}

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

/**
 * Goes back to the seeds menu.
 *
 * @param p the player using the GUI
 */
private void back(Player p) {
  close(p);
  plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, () -> {
    ItemStack[] seeds = new TARDISSeedsInventory(p).getMenu();
    Inventory gui = plugin.getServer().createInventory(p, 27, ChatColor.DARK_RED + "TARDIS Seeds Menu");
    gui.setContents(seeds);
    p.openInventory(gui);
  }, 2L);
}

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

/**
 * Closes the inventory and opens the Wall block selector menu.
 *
 * @param p the player using the GUI
 */
private void wall(Player p) {
  plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, () -> {
    p.closeInventory();
    ItemStack[] wall_blocks = new TARDISWallsInventory(plugin).getMenu();
    Inventory wall = plugin.getServer().createInventory(p, 54, ChatColor.DARK_RED + "TARDIS Wall Menu");
    wall.setContents(wall_blocks);
    p.openInventory(wall);
  }, 1L);
}

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

/**
 * Goes back to the seeds menu.
 *
 * @param p the player using the GUI
 */
private void back(Player p) {
  close(p);
  plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, () -> {
    ItemStack[] seeds = new TARDISSeedsInventory(p).getMenu();
    Inventory gui = plugin.getServer().createInventory(p, 27, ChatColor.DARK_RED + "TARDIS Seeds Menu");
    gui.setContents(seeds);
    p.openInventory(gui);
  }, 2L);
}

相关文章

微信公众号

最新文章

更多

Server类方法