Solved Going from one GUI to another

Discussion in 'Plugin Development' started by iClipse, Oct 1, 2016.

Thread Status:
Not open for further replies.
  1. Offline

    iClipse

    So im making a shop which is already said in my previous thread, and in it all I got is the menu. I wanna make it so that when you click an item it goes to a new GUI. I have part of what I want done at the end (Its the last chunk of code, starts with @Event handler)).
    Code:
    import org.bukkit.Bukkit;
    import org.bukkit.ChatColor;
    import org.bukkit.Material;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    import org.bukkit.event.inventory.InventoryClickEvent;
    import org.bukkit.inventory.Inventory;
    import org.bukkit.inventory.ItemStack;
    import org.bukkit.inventory.meta.ItemMeta;
    import org.bukkit.plugin.java.JavaPlugin;
    
    public class OpenShop extends JavaPlugin
    {
    public boolean onCommand(CommandSender theSender, Command cmd, String commandLabel, String[] args)
    {
        if(commandLabel.equalsIgnoreCase("shop"))
        {
            Player player = (Player) theSender;
            {
            private void openGUI (Player player)
            {
                Inventory inv = Bukkit.createInventory(null, 18, ChatColor.GOLD + "Shop");
              
                ItemStack ores = new ItemStack(Material.IRON_INGOT);
                ItemMeta oresMeta = ores.getItemMeta();
                ItemStack raw_blocks = new ItemStack (Material.STONE);
                ItemMeta raw_blocksMeta = raw_blocks.getItemMeta();
                ItemStack crafted_blocks = new ItemStack (Material.SMOOTH_BRICK);
                ItemMeta crafted_blocksMeta = crafted_blocks.getItemMeta();
                ItemStack wood_and_plants = new ItemStack(Material.SAPLING);
                ItemMeta wood_and_plantsMeta = wood_and_plants.getItemMeta();
                ItemStack food_and_farming = new ItemStack (Material.GRILLED_PORK);
                ItemMeta food_and_farmingMeta = wood_and_plants.getItemMeta();
                ItemStack drops = new ItemStack (Material.SULPHUR);
                ItemMeta dropsMeta = drops.getItemMeta();
                ItemStack decorative = new ItemStack (Material.BOOKSHELF);
                ItemMeta decorativeMeta = decorative.getItemMeta();
                ItemStack mechanisms = new ItemStack(Material.REDSTONE_LAMP_ON);
                ItemMeta mechanismsMeta = mechanisms.getItemMeta();
                ItemStack misk = new ItemStack(Material.SADDLE);
                ItemMeta miskMeta = misk.getItemMeta();
                ItemStack dyes = new ItemStack (Material.YELLOW_FLOWER);
                ItemMeta dyesMeta = dyes.getItemMeta();
                ItemStack tools_and_combat = new ItemStack (Material.IRON_PICKAXE);
                ItemMeta tools_and_combatMeta = tools_and_combat.getItemMeta();
                ItemStack brewing = new ItemStack (Material.BREWING_STAND);
                ItemMeta brewingMeta = brewing.getItemMeta();
                ItemStack enchanting = new ItemStack (Material.ENCHANTED_BOOK);
                ItemMeta enchantingMeta = enchanting.getItemMeta();
              
                oresMeta.setDisplayName(ChatColor.GRAY + "Ores");
                ores.setItemMeta(oresMeta);
              
                raw_blocksMeta.setDisplayName(ChatColor.DARK_GREEN + "Raw Blocks");
                raw_blocks.setItemMeta (raw_blocksMeta);
              
                crafted_blocksMeta.setDisplayName(ChatColor.DARK_RED + "Crafted Blocks");
                crafted_blocks.setItemMeta(crafted_blocksMeta);
              
                wood_and_plantsMeta.setDisplayName(ChatColor.GREEN + "Wood and Plants");
                wood_and_plants.setItemMeta(wood_and_plantsMeta);
              
                food_and_farmingMeta.setDisplayName(ChatColor.RED + "Food and Farming");
                food_and_farming.setItemMeta(food_and_farmingMeta);
              
                dropsMeta.setDisplayName(ChatColor.DARK_PURPLE + "Drops");
                drops.setItemMeta(dropsMeta);
              
                decorativeMeta.setDisplayName(ChatColor.AQUA + "Decorative");
                decorative.setItemMeta(decorativeMeta);
              
                mechanismsMeta.setDisplayName(ChatColor.YELLOW + "Mehcanisms");
                mechanisms.setItemMeta(mechanismsMeta);
              
                miskMeta.setDisplayName(ChatColor.WHITE + "Misk");
                misk.setItemMeta(miskMeta);
              
                dyesMeta.setDisplayName (ChatColor.BLUE + "D" + ChatColor.GREEN + "y" + ChatColor.YELLOW + "e" + ChatColor.DARK_RED + "s");
                dyes.setItemMeta(dyesMeta);
              
                tools_and_combatMeta.setDisplayName(ChatColor.DARK_GRAY + "Tools and Combat");
                tools_and_combat.setItemMeta(tools_and_combatMeta);
              
                brewingMeta.setDisplayName(ChatColor.GOLD + "Brewing");
                brewing.setItemMeta (brewingMeta);
              
                enchantingMeta.setDisplayName(ChatColor.MAGIC + "Enchanting");
                enchanting.setItemMeta (enchantingMeta);
              
                inv.setItem(2, ores);
                inv.setItem(3, raw_blocks);
                inv.setItem(4, crafted_blocks);
                inv.setItem(5, food_and_farming);
                inv.setItem(6, wood_and_plants);
                inv.setItem(7, drops);
                inv.setItem(8, decorative);
                inv.setItem(11, mechanisms);
                inv.setItem(12, misk);
                inv.setItem(13, dyes);
                inv.setItem(15, tools_and_combat);
                inv.setItem(16, brewing);
                inv.setItem(17, enchanting);
              
                player.openInventory(inv);
              
            }
            @EventHandler
            public void onInventoryClick(InventoryClickEvent event) {
                if (!ChatColor.stripColor(event.getInventory().getName())
                        .equalsIgnoreCase("Shop"))
                    if (getClickedItem.equalsIgnoreCase("Ores"));
                      
                  
            }
            }
        }
    return true;
    }
    }
          
    
     
  2. Offline

    Zombie_Striker

    First, remove the semicolon. This means this if statement does nothing.

    Second: You cannot have methods inside of other methods. Move the event out of the onCommand.

    Finally: You never state what is currently happening and what is not working.
     
  3. Offline

    iClipse

    First, im a finicky writer. I write and then proof read/fix my mistakes.

    Second: thanks, didnt know that.

    Third: Nothings necessarily wrong, I just want to know how to continue to a new GUI

    Actually, nvm. I figured it out

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Oct 1, 2016
Thread Status:
Not open for further replies.

Share This Page