ShopGUIPlus Multiple Pages

Discussion in 'Spigot Plugin Help' started by SeePeeDee, Jun 14, 2016.

  1. i want to make a colored blocks section and want to make a section in the shop "coloredblocks" with page 1 colored wools, page 2 colored glass, page 3 carpets, page 4 clay
    How do I do this? Can someone just make me an example config with like 4 pages of just plain wool, glass, carpet, and clay? Thanks.
     
  2. nobody will make for you a 'free-code' lol
     
  3. what? Nah, he mean like provide an example. In tutorial videos, I've seen people with this kind of stuff but they never show it. I am having this issue too... Can you please help out? Provide maybe assistance with creating a multi-paged shop?
     
  4. You can make multiple inventories, and in each inventory add an 'button' item to the next inventory :p

    Code (Text):
    package ro.nicuch.example;

    import org.bukkit.Material;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    import org.bukkit.event.Event.Result;
    import org.bukkit.event.Listener;
    import org.bukkit.event.inventory.InventoryClickEvent;
    import org.bukkit.event.inventory.InventoryType;
    import org.bukkit.inventory.Inventory;
    import org.bukkit.inventory.ItemStack;
    import org.bukkit.plugin.java.JavaPlugin;

    public class Start extends JavaPlugin implements Listener {
        // Create GUIs
        private Inventory inv1 = this.getServer().createInventory(null, InventoryType.CHEST, "Carpet Shop");
        private Inventory inv2 = this.getServer().createInventory(null, InventoryType.CHEST, "Glass Shop");

        @SuppressWarnings("deprecation")
        @Override
        public void onEnable() {
            // Fill GUIs with what items you want
            this.inv1.setItem(0, new ItemStack(Material.CARPET, 1, (short) 0, (byte) 0));
            this.inv1.setItem(1, new ItemStack(Material.CARPET, 1, (short) 0, (byte) 1));
            this.inv1.setItem(2, new ItemStack(Material.CARPET, 1, (short) 0, (byte) 2));
            this.inv1.setItem(3, new ItemStack(Material.ANVIL));
            this.inv2.setItem(0, new ItemStack(Material.STAINED_GLASS, 1, (short) 0, (byte) 0));
            this.inv2.setItem(1, new ItemStack(Material.STAINED_GLASS, 1, (short) 0, (byte) 1));
            this.inv2.setItem(2, new ItemStack(Material.STAINED_GLASS, 1, (short) 0, (byte) 2));
            this.inv2.setItem(3, new ItemStack(Material.ANVIL));
        }

        public void event(InventoryClickEvent event) {
            if (event.getClickedInventory().getName().equals("Carpet Shop")) {
                // Check for every item by rawslot int
                switch (event.getRawSlot()) {
                case 0:
                    event.getWhoClicked().sendMessage("You clicked on carpet!");
                    break;
                case 1:
                    event.getWhoClicked().sendMessage("You clicked on carpet!");
                    break;
                case 2:
                    event.getWhoClicked().sendMessage("You clicked on carpet!");
                    break;
                // When the player click on anvil, it will open another GUI.
                case 3:
                    event.getWhoClicked().openInventory(this.inv1);
                    break;
                default:
                    break;
                }
                event.setResult(Result.DENY);
            } else if (event.getClickedInventory().getName().equals("Glass Shop")) {
                switch (event.getRawSlot()) {
                case 0:
                    event.getWhoClicked().sendMessage("You clicked on glass!");
                    break;
                case 1:
                    event.getWhoClicked().sendMessage("You clicked on glass!");
                    break;
                case 2:
                    event.getWhoClicked().sendMessage("You clicked on glass!");
                    break;
                // When the player click on anvil, it will open another GUI.
                case 3:
                    event.getWhoClicked().openInventory(this.inv2);
                    break;
                default:
                    break;
                }
                event.setResult(Result.DENY);
            }
        }

        @Override
        public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
            // Console can't open GUIs!
            if (!(sender instanceof Player)) {
                sender.sendMessage("Only players can open GUIs!");
            }
            // Run command "menu" for open first GUI!
            if (command.getName().equals("menu")) {
                ((Player) sender).openInventory(this.inv1);
            }
            return true;
        }
    }
     
    PS: I didn't make a test on this, and is very possible to have bugs!
     
  5. No, like.... Somehow in the config you can make certain items on certain pages. Without coding a whole different part.
     
  6. BUMP
    AND HU1K you are correct with what you are saying. Those are my intentions.