Java Code Examples for org.bukkit.Bukkit#createInventory()

The following examples show how to use org.bukkit.Bukkit#createInventory() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SetGui.java    From WildernessTp with MIT License 6 votes vote down vote up
public static void OpenSet(Player p) {

        ItemStack close = new ItemStack(Material.REDSTONE_BLOCK, 1);
        ItemMeta meta = close.getItemMeta();
        meta.setDisplayName("Close");
        ArrayList<String> lore = new ArrayList<>();
        lore.add("Click to close the inventory and return to normal gameplay");
        meta.setLore(lore);
        close.setItemMeta(meta);
        Inventory set = Bukkit.createInventory(p, 27, "WildTp");
        p.openInventory(set);
        set.setItem(0, MainGui.makeItem(Material.valueOf(MainGui.getMaterials().get("Book")), "MinX", Collections.singletonList("Click to set the minx")));
        set.setItem(2, MainGui.makeItem(Material.valueOf(MainGui.getMaterials().get("Book")), "MaxX", Collections.singletonList("Click to set the maxx")));
        set.setItem(4, MainGui.makeItem(Material.valueOf(MainGui.getMaterials().get("Book")), "MinZ", Collections.singletonList("Click to set the minz")));
        set.setItem(6, MainGui.makeItem(Material.valueOf(MainGui.getMaterials().get("Book")), "MaxZ", Collections.singletonList("Click to set the maxz")));
        set.setItem(8, MainGui.makeItem(Material.valueOf(MainGui.getMaterials().get("Watch")), "Cooldown", Collections.singletonList("Click me to set the cooldown for the command")));
        set.setItem(10, MainGui.makeItem(Material.GOLD_BLOCK, "Cost", Collections.singletonList("Click me to set the cost for the command")));
        set.setItem(12, MainGui.makeItem(Material.valueOf(MainGui.getMaterials().get("Watch")), "Wait", Collections.singletonList("Click to set the wait before telepoting happens")));
        set.setItem(14, MainGui.makeItem(Material.valueOf(MainGui.getMaterials().get("Watch")), "Retries", Collections.singletonList("Click to set the number of retries if a location is unsuitable")));
        set.setItem(16, MainGui.makeItem(Material.valueOf(MainGui.getMaterials().get("Watch")), "Do Retry", Collections.singletonList("Click to set true or false for doing retries")));
        set.setItem(18, MainGui.makeItem(Material.MAP, "Distance", Arrays.asList("Click to set the distance the plugin checks for a claim")));
        set.setItem(24, MainGui.backItem());
        set.setItem(26, close);
    }
 
Example 2
Source File: CreativeInventory.java    From Transport-Pipes with MIT License 6 votes vote down vote up
@Override
Inventory create(Player p){
    Inventory inv = Bukkit.createInventory(null, 9 * 3, LangConf.Key.DUCT_INVENTORY_CREATIVE_INVENTORY_TITLE.get());

    int i = 0;
    for (BaseDuctType<? extends Duct> bdt : ductRegister.baseDuctTypes()) {
        for (DuctType dt : bdt.ductTypes()) {
            ItemStack ductItem = bdt.getItemManager().getClonedItem(dt);
            ductItem.setAmount(16);
            inv.setItem(i++, ductItem);
        }
    }
    inv.setItem(i, itemService.getWrench().clone());

    return inv;
}
 
Example 3
Source File: ViewInventoryMatchModule.java    From ProjectAres with GNU Affero General Public License v3.0 6 votes vote down vote up
public void previewInventory(Player viewer, Inventory realInventory) {
    if(viewer == null) { return; }

    if(realInventory instanceof PlayerInventory) {
        previewPlayerInventory(viewer, (PlayerInventory) realInventory);
    }else {
        Inventory fakeInventory;
        if(realInventory instanceof DoubleChestInventory) {
            if(realInventory.hasCustomName()) {
                fakeInventory = Bukkit.createInventory(viewer, realInventory.getSize(), realInventory.getName());
            } else {
                fakeInventory = Bukkit.createInventory(viewer, realInventory.getSize());
            }
        } else {
            if(realInventory.hasCustomName()) {
                fakeInventory = Bukkit.createInventory(viewer, realInventory.getType(), realInventory.getName());
            } else {
                fakeInventory = Bukkit.createInventory(viewer, realInventory.getType());
            }
        }
        fakeInventory.setContents(realInventory.contents());

        this.showInventoryPreview(viewer, realInventory, fakeInventory);
    }
}
 
Example 4
Source File: LootGUI.java    From EliteMobs with GNU General Public License v3.0 5 votes vote down vote up
public void lootGUI(Player player) {

        Inventory fakeChestInventory = Bukkit.createInventory(null, 54, shopName);
        tierConstructor(fakeChestInventory);
        headerConstructor(fakeChestInventory);
        lootNavigationConstructor(fakeChestInventory);
        lootConstructor(fakeChestInventory);

        player.openInventory(fakeChestInventory);

    }
 
Example 5
Source File: ViewInventoryMatchModule.java    From PGM with GNU Affero General Public License v3.0 5 votes vote down vote up
public void previewInventory(Player viewer, Inventory realInventory) {
  if (viewer == null) {
    return;
  }

  if (realInventory instanceof PlayerInventory) {
    previewPlayerInventory(viewer, (PlayerInventory) realInventory);
  } else {
    Inventory fakeInventory;
    if (realInventory instanceof DoubleChestInventory) {
      if (realInventory.hasCustomName()) {
        fakeInventory =
            Bukkit.createInventory(viewer, realInventory.getSize(), realInventory.getName());
      } else {
        fakeInventory = Bukkit.createInventory(viewer, realInventory.getSize());
      }
    } else {
      if (realInventory.hasCustomName()) {
        fakeInventory =
            Bukkit.createInventory(viewer, realInventory.getType(), realInventory.getName());
      } else {
        fakeInventory = Bukkit.createInventory(viewer, realInventory.getType());
      }
    }
    fakeInventory.setContents(realInventory.getContents());

    this.showInventoryPreview(viewer, realInventory, fakeInventory);
  }
}
 
Example 6
Source File: Cosmic.java    From Crazy-Crates with MIT License 5 votes vote down vote up
public static void openCosmic(Player player, Crate crate, KeyType keyType, boolean checkHand) {
    Inventory inv = Bukkit.createInventory(null, 27, Methods.sanitizeColor(crate.getFile().getString("Crate.CrateName") + " - Choose"));
    setChests(inv, crate);
    cc.addPlayerKeyType(player, keyType);
    checkHands.put(player, checkHand);
    player.openInventory(inv);
}
 
Example 7
Source File: NewItemShop.java    From BedwarsRel with GNU General Public License v3.0 5 votes vote down vote up
private void openBuyInventory(MerchantCategory category, Player player, Game game) {
  List<VillagerTrade> offers = category.getOffers();
  int sizeCategories = this.getCategoriesSize(player);
  int sizeItems = offers.size();
  int invSize = this.getBuyInventorySize(sizeCategories, sizeItems);

  player.playSound(player.getLocation(), SoundMachine.get("CLICK", "UI_BUTTON_CLICK"),
      Float.valueOf("1.0"), Float.valueOf("1.0"));

  this.currentCategory = category;
  Inventory buyInventory = Bukkit
      .createInventory(player, invSize, BedwarsRel._l(player, "ingame.shop.name"));
  this.addCategoriesToInventory(buyInventory, player, game);

  for (int i = 0; i < offers.size(); i++) {
    VillagerTrade trade = offers.get(i);
    if (trade.getItem1().getType() == Material.AIR
        && trade.getRewardItem().getType() == Material.AIR) {
      continue;
    }

    int slot = (this.getInventorySize(sizeCategories)) + i;
    ItemStack tradeStack = this.toItemStack(trade, player, game);

    buyInventory.setItem(slot, tradeStack);
  }

  player.openInventory(buyInventory);
}
 
Example 8
Source File: Tools.java    From ce with GNU Lesser General Public License v3.0 5 votes vote down vote up
public static Inventory getItemMenu(Player p) {
    if (!p.isOp() && !p.hasPermission("ce.item.*")) {
        Inventory lInv = Main.CEItemMenu;
        Inventory items = Bukkit.createInventory(null, lInv.getSize(), lInv.getTitle());
        items.setContents(lInv.getContents());
        for (int i = 0; i < items.getSize() - 2; i++) {
            ItemStack item = items.getItem(i);
            if (item == null || item.getType().equals(Material.AIR))
                continue;
            ItemMeta im = item.getItemMeta();
            List<String> lore = new ArrayList<String>();
            if (im.hasLore())
                lore = im.getLore();
            for (CItem ci : Main.items)
                if (item.getItemMeta().getDisplayName().equals(ci.getDisplayName())) {
                    if (!checkPermission(ci, p)) {
                        lore.add(ChatColor.RED + "You are not permitted to use this");
                        break;
                    }
                }
            im.setLore(lore);
            item.setItemMeta(im);
        }
        return items;
    }

    return Main.CEItemMenu;
}
 
Example 9
Source File: ChestMenu.java    From CS-CoreLib with GNU General Public License v3.0 5 votes vote down vote up
private void setup() {
	if (this.inv != null) return;
	this.inv = Bukkit.createInventory(null, Calculator.formToLine(this.items.size()) * 9, title);
	for (int i = 0; i < this.items.size(); i++) {
		this.inv.setItem(i, this.items.get(i));
	}
}
 
Example 10
Source File: GUI.java    From Crazy-Auctions with MIT License 5 votes vote down vote up
public static void openBidding(Player player, String ID) {
    Methods.updateAuction();
    FileConfiguration config = Files.CONFIG.getFile();
    FileConfiguration data = Files.DATA.getFile();
    if (!data.contains("Items." + ID)) {
        openShop(player, ShopType.BID, shopCategory.get(player), 1);
        player.sendMessage(Messages.ITEM_DOESNT_EXIST.getMessage());
        return;
    }
    Inventory inv = Bukkit.createInventory(null, 27, Methods.color(config.getString("Settings.Bidding-On-Item")));
    if (!bidding.containsKey(player)) bidding.put(player, 0);
    if (Version.getCurrentVersion().isNewer(Version.v1_12_R1)) {
        inv.setItem(9, Methods.makeItem("LIME_STAINED_GLASS_PANE", 1, "&a+1"));
        inv.setItem(10, Methods.makeItem("LIME_STAINED_GLASS_PANE", 1, "&a+10"));
        inv.setItem(11, Methods.makeItem("LIME_STAINED_GLASS_PANE", 1, "&a+100"));
        inv.setItem(12, Methods.makeItem("LIME_STAINED_GLASS_PANE", 1, "&a+1000"));
        inv.setItem(14, Methods.makeItem("RED_STAINED_GLASS_PANE", 1, "&c-1000"));
        inv.setItem(15, Methods.makeItem("RED_STAINED_GLASS_PANE", 1, "&c-100"));
        inv.setItem(16, Methods.makeItem("RED_STAINED_GLASS_PANE", 1, "&c-10"));
        inv.setItem(17, Methods.makeItem("RED_STAINED_GLASS_PANE", 1, "&c-1"));
    } else {
        inv.setItem(9, Methods.makeItem("160:5", 1, "&a+1"));
        inv.setItem(10, Methods.makeItem("160:5", 1, "&a+10"));
        inv.setItem(11, Methods.makeItem("160:5", 1, "&a+100"));
        inv.setItem(12, Methods.makeItem("160:5", 1, "&a+1000"));
        inv.setItem(14, Methods.makeItem("160:14", 1, "&c-1000"));
        inv.setItem(15, Methods.makeItem("160:14", 1, "&c-100"));
        inv.setItem(16, Methods.makeItem("160:14", 1, "&c-10"));
        inv.setItem(17, Methods.makeItem("160:14", 1, "&c-1"));
    }
    inv.setItem(13, getBiddingGlass(player, ID));
    inv.setItem(22, Methods.makeItem(config.getString("Settings.GUISettings.OtherSettings.Bid.Item"), 1, config.getString("Settings.GUISettings.OtherSettings.Bid.Name"), config.getStringList("Settings.GUISettings.OtherSettings.Bid.Lore")));
    
    inv.setItem(4, getBiddingItem(player, ID));
    player.openInventory(inv);
}
 
Example 11
Source File: SkinsGUI.java    From SkinsRestorerX with GNU General Public License v3.0 4 votes vote down vote up
public Inventory getGUI(Player p, int page, Map<String, Object> skinsList) {
    Inventory inventory = Bukkit.createInventory(p, 54, Locale.SKINSMENU_TITLE.replace("&", "ยง") + page);

    inventory.setItem(36, new GuiGlass(GlassType.NONE).getItemStack());
    inventory.setItem(37, new GuiGlass(GlassType.NONE).getItemStack());
    inventory.setItem(38, new GuiGlass(GlassType.NONE).getItemStack());
    inventory.setItem(39, new GuiGlass(GlassType.NONE).getItemStack());
    inventory.setItem(40, new GuiGlass(GlassType.NONE).getItemStack());
    inventory.setItem(41, new GuiGlass(GlassType.NONE).getItemStack());
    inventory.setItem(42, new GuiGlass(GlassType.NONE).getItemStack());
    inventory.setItem(43, new GuiGlass(GlassType.NONE).getItemStack());
    inventory.setItem(44, new GuiGlass(GlassType.NONE).getItemStack());

    //Middle button //remove skin
    inventory.setItem(48, new GuiGlass(GlassType.DELETE).getItemStack());
    inventory.setItem(49, new GuiGlass(GlassType.DELETE).getItemStack());
    inventory.setItem(50, new GuiGlass(GlassType.DELETE).getItemStack());
    //button place next
    inventory.setItem(45, new GuiGlass(GlassType.NONE).getItemStack());
    inventory.setItem(46, new GuiGlass(GlassType.NONE).getItemStack());
    inventory.setItem(47, new GuiGlass(GlassType.NONE).getItemStack());

    //button place next
    inventory.setItem(53, new GuiGlass(GlassType.NONE).getItemStack());
    inventory.setItem(52, new GuiGlass(GlassType.NONE).getItemStack());
    inventory.setItem(51, new GuiGlass(GlassType.NONE).getItemStack());

    skinsList.forEach((name, property) -> {
        //if page is not 0, adding Previous Page button.
        if (page != 0) {
            inventory.setItem(45, new GuiGlass(GlassType.PREV).getItemStack());
            inventory.setItem(46, new GuiGlass(GlassType.PREV).getItemStack());
            inventory.setItem(47, new GuiGlass(GlassType.PREV).getItemStack());
        }

        inventory.addItem(createSkull(name, property));

        //if the page is full, adding Next Page button.
        if (inventory.firstEmpty() == -1 || inventory.getItem(26) != null) {
            inventory.setItem(53, new GuiGlass(GlassType.NEXT).getItemStack());
            inventory.setItem(52, new GuiGlass(GlassType.NEXT).getItemStack());
            inventory.setItem(51, new GuiGlass(GlassType.NEXT).getItemStack());
            return;
        }
    });

    return inventory;
}
 
Example 12
Source File: InventoryTypeAdapter.java    From IridiumSkyblock with GNU General Public License v2.0 4 votes vote down vote up
public static String toBase64(ItemStack[] is, int size) {
    Inventory inventory = Bukkit.createInventory(null, size);
    inventory.setContents(is);
    return toBase64(inventory);
}
 
Example 13
Source File: SkyBlockMenu.java    From uSkyBlock with GNU General Public License v3.0 4 votes vote down vote up
public Inventory displayChallengeGUI(final Player player, int page, String playerName) {
    int total = challengeLogic.getTotalPages();
    String title = "\u00a79" + pre("{0} ({1}/{2})", tr("Challenge Menu"), page, total);
    Inventory menu = Bukkit.createInventory(new UltimateHolder(player, title, MenuType.DEFAULT), CHALLENGE_PAGESIZE+COLS_PER_ROW, title);
    final PlayerInfo pi = playerName == null ? plugin.getPlayerInfo(player) : plugin.getPlayerInfo(playerName);
    challengeLogic.populateChallengeRank(menu, pi, page, playerName != null && player.hasPermission("usb.mod.bypassrestriction"));
    int[] pages = new int[9];
    pages[0] = 1;
    pages[8] = total;
    int startOffset = 2;
    if (page > 5) {
        startOffset = (int) ((Math.round(page/2d)) - 1);
        if (startOffset > total-7) {
            startOffset = total-7;
        }
    }
    for (int i = 0; i < 7; i++) {
        pages[i+1] = startOffset+i;
    }
    for (int i = 0; i < pages.length; i++) {
        int p = pages[i];
        if (p >= 1 && p <= total) {
            ItemStack pageItem;
            if (p == page) {
                pageItem = ItemStackUtil.createItemStack("WRITABLE_BOOK", tr("\u00a77Current page"), null);
            } else {
                pageItem = ItemStackUtil.createItemStack("BOOK", tr("\u00a77Page {0}", p), null);
            }
            if (i == 0) {
                pageItem = ItemStackUtil.builder(pageItem)
                        .displayName(tr("\u00a77First Page"))
                        .lore(playerName != null ? playerName : "")
                        .build();
            } else if (i == 8) {
                pageItem = ItemStackUtil.builder(pageItem).displayName(tr("\u00a77Last Page")).build();
            }
            pageItem.setAmount(p);
            menu.setItem(i + CHALLENGE_PAGESIZE, pageItem);
        }
    }
    return menu;
}
 
Example 14
Source File: GoldenPipeSettingsInventory.java    From Transport-Pipes with MIT License 4 votes vote down vote up
@Override
public void create() {
    scrollValues = new HashMap<>();
    inv = Bukkit.createInventory(null, 6 * 9, LangConf.Key.DUCT_INVENTORY_TITLE.get(duct.getDuctType().getFormattedTypeName()));
}
 
Example 15
Source File: Gui.java    From helper with MIT License 4 votes vote down vote up
public Gui(Player player, int lines, String title) {
    this.player = Objects.requireNonNull(player, "player");
    this.initialTitle = Text.colorize(Objects.requireNonNull(title, "title"));
    this.inventory = Bukkit.createInventory(player, lines * 9, this.initialTitle);
    this.slots = new HashMap<>();
}
 
Example 16
Source File: SkyBlockMenu.java    From uSkyBlock with GNU General Public License v3.0 4 votes vote down vote up
public Inventory displayBiomeGUI(final Player player) {
    List<String> lores = new ArrayList<>();
    String title = "\u00a79" + tr("Island Biome");
    Inventory menu = Bukkit.createInventory(new UltimateHolder(player, title, MenuType.DEFAULT), 27, title);
    ItemMeta meta4 = sign.getItemMeta();
    meta4.setDisplayName("\u00a7h" + tr("Island Biome"));
    addLore(lores, tr("\u00a7eClick here to return to\n\u00a7ethe main island screen."));
    meta4.setLore(lores);
    sign.setItemMeta(meta4);
    menu.addItem(new ItemStack[]{sign});
    lores.clear();
    String currentBiome = plugin.getIslandInfo(player).getBiome();
    for (BiomeMenuItem biomeMenu : biomeMenus) {
        if (!BiomeCommand.biomeExists(biomeMenu.getId())) {
            continue; // Skip it
        }
        ItemStack menuItem = biomeMenu.getIcon();
        meta4 = menuItem.getItemMeta();
        if (player.hasPermission("usb.biome." + biomeMenu.getId())) {
            meta4.setDisplayName("\u00a7a" + tr("Biome: {0}", biomeMenu.getTitle()));
            addLore(lores, "\u00a7f", biomeMenu.getDescription());
            if (biomeMenu.getId().equalsIgnoreCase(currentBiome)) {
                addLore(lores, tr("\u00a72\u00a7lThis is your current biome."));
            } else {
                addLore(lores, tr("\u00a7e\u00a7lClick to change to this biome."));
            }
        } else {
            meta4.setDisplayName("\u00a78" + tr("Biome: {0}", biomeMenu.getTitle()));
            lores.add("\u00a7c" + tr("You cannot use this biome."));
            addLore(lores, "\u00a77", biomeMenu.getDescription());
        }
        meta4.setLore(lores);
        menuItem.setItemMeta(meta4);
        menu.addItem(menuItem);
        lores.clear();
    }

    updateBiomeRadius(player, menu);


    return menu;
}
 
Example 17
Source File: SpectateTeamMenu.java    From SkyWarsReloaded with GNU General Public License v3.0 4 votes vote down vote up
public SpectateTeamMenu() {
    int menuSize = 45;
    Inventory menu = Bukkit.createInventory(null, menuSize + 9, menuName);
	ArrayList<Inventory> invs = new ArrayList<>();
	invs.add(menu);
	 
    SkyWarsReloaded.getIC().create("spectateteammenu", invs, event -> {
        Player player = event.getPlayer();
        GameMap gMap = MatchManager.get().getPlayerMap(player);
        if (gMap != null) {
            return;
        }
        String name = event.getName();
        if (name.equalsIgnoreCase(SkyWarsReloaded.getNMS().getItemName(SkyWarsReloaded.getIM().getItem("exitMenuItem")))) {
            player.closeInventory();
            return;
        }
        gMap = GameMap.getMapByDisplayName(ChatColor.stripColor(name));
        if (gMap == null) {
            return;
        }

        if (event.getClick() == ClickType.RIGHT) {
            final String n = gMap.getName();
            if (!SkyWarsReloaded.getIC().hasViewers(n + "teamspectate")) {
                new BukkitRunnable() {
                    @Override
                    public void run() {
                        SkyWarsReloaded.getIC().getMenu( n + "teamselect").update();
                    }
                }.runTaskLater(SkyWarsReloaded.get(), 5);
            }
            SkyWarsReloaded.getIC().show(player, n + "teamspectate");
        } else {
            if (player.hasPermission("sw.spectate")) {
                player.closeInventory();
                if (gMap.getMatchState() != MatchState.OFFLINE && gMap.getMatchState() != MatchState.ENDING) {
                    MatchManager.get().addSpectator(gMap, player);
                }
            }
        }
    });
}
 
Example 18
Source File: ObserverModule.java    From CardinalPGM with MIT License 4 votes vote down vote up
@EventHandler
public void onInteraction(PlayerInteractEvent event) {
    if (testObserver(event.getPlayer())) {
        event.setCancelled(true);
        if ((event.getAction().equals(Action.RIGHT_CLICK_AIR) || event.getAction().equals(Action.RIGHT_CLICK_BLOCK)) && (event.getPlayer().getInventory().getItemInMainHand() != null && event.getPlayer().getInventory().getItemInMainHand().getType().equals(Material.WRITTEN_BOOK))){
            event.setUseInteractedBlock(Event.Result.DENY);
            event.setUseItemInHand(Event.Result.ALLOW);
        }
        if (event.getClickedBlock() != null && !event.getPlayer().isSneaking() && event.getAction() == Action.RIGHT_CLICK_BLOCK) {
            if (event.getClickedBlock().getType().equals(Material.CHEST) || event.getClickedBlock().getType().equals(Material.TRAPPED_CHEST)) {
                Inventory chest = Bukkit.createInventory(null, ((Chest) event.getClickedBlock().getState()).getInventory().getSize());
                for (int i = 0; i < ((Chest) event.getClickedBlock().getState()).getInventory().getSize(); i++) {
                    chest.setItem(i, ((Chest) event.getClickedBlock().getState()).getInventory().getItem(i));
                }
                event.getPlayer().openInventory(chest);
            }
            if (event.getClickedBlock().getType().equals(Material.FURNACE) || event.getClickedBlock().getType().equals(Material.BURNING_FURNACE)) {
                Inventory furnace = Bukkit.createInventory(null, InventoryType.FURNACE);
                for (int i = 0; i < ((Furnace) event.getClickedBlock().getState()).getInventory().getSize(); i++) {
                    furnace.setItem(i, ((Furnace) event.getClickedBlock().getState()).getInventory().getItem(i));
                }
                event.getPlayer().openInventory(furnace);
            }
            if (event.getClickedBlock().getType().equals(Material.DISPENSER)) {
                Inventory dispenser = Bukkit.createInventory(null, InventoryType.DISPENSER);
                for (int i = 0; i < ((Dispenser) event.getClickedBlock().getState()).getInventory().getSize(); i++) {
                    dispenser.setItem(i, ((Dispenser) event.getClickedBlock().getState()).getInventory().getItem(i));
                }
                event.getPlayer().openInventory(dispenser);
            }
            if (event.getClickedBlock().getType().equals(Material.DROPPER)) {
                Inventory dropper = Bukkit.createInventory(null, InventoryType.DROPPER);
                for (int i = 0; i < ((Dropper) event.getClickedBlock().getState()).getInventory().getSize(); i++) {
                    dropper.setItem(i, ((Dropper) event.getClickedBlock().getState()).getInventory().getItem(i));
                }
                event.getPlayer().openInventory(dropper);
            }
            if (event.getClickedBlock().getType().equals(Material.HOPPER)) {
                Inventory hopper = Bukkit.createInventory(null, InventoryType.HOPPER);
                for (int i = 0; i < ((Hopper) event.getClickedBlock().getState()).getInventory().getSize(); i++) {
                    hopper.setItem(i, ((Hopper) event.getClickedBlock().getState()).getInventory().getItem(i));
                }
                event.getPlayer().openInventory(hopper);
            }
            if (event.getClickedBlock().getType().equals(Material.BREWING_STAND)) {
                Inventory brewingStand = Bukkit.createInventory(null, InventoryType.BREWING);
                for (int i = 0; i < ((BrewingStand) event.getClickedBlock().getState()).getInventory().getSize(); i++) {
                    brewingStand.setItem(i, ((BrewingStand) event.getClickedBlock().getState()).getInventory().getItem(i));
                }
                event.getPlayer().openInventory(brewingStand);
            }
            if (event.getClickedBlock().getType().equals(Material.BEACON)) {
                Inventory beacon = Bukkit.createInventory(null, InventoryType.BEACON);
                for (int i = 0; i < ((Beacon) event.getClickedBlock().getState()).getInventory().getSize(); i++) {
                    beacon.setItem(i, ((Beacon) event.getClickedBlock().getState()).getInventory().getItem(i));
                }
                event.getPlayer().openInventory(beacon);
            }
        }
    }
}
 
Example 19
Source File: GUI.java    From IridiumSkyblock with GNU General Public License v2.0 4 votes vote down vote up
public GUI(int size, String name) {
    this.inventory = Bukkit.createInventory(null, size, Utils.color(name));
    scheduler = Bukkit.getScheduler().scheduleAsyncRepeatingTask(IridiumSkyblock.getInstance(), this::addContent, 0, 2);
}
 
Example 20
Source File: ShopHandler.java    From EliteMobs with GNU General Public License v3.0 3 votes vote down vote up
public ShopHandler(Player player) {

        if (!ConfigValues.economyConfig.getBoolean(EconomySettingsConfig.ENABLE_ECONOMY)) return;

        Inventory shopInventory = Bukkit.createInventory(player, 54, SHOP_NAME);

        populateShop(shopInventory);

        player.openInventory(shopInventory);

    }