Solved switch case

Discussion in 'Plugin Development' started by x3G, Jun 11, 2018.

  1. Offline

    x3G

    Hi, i have a problem, on my code i do automatic shop seller, but on "dont sell nothing" i want say somthing, how i can do?

    my code:
    HTML:
                        for(ItemStack item : p.getInventory().getContents()) {
                            if(item == null)
                                continue;
                            switch(item.getType()){
                            case STONE:
                                if(getAmount(p, new ItemStack(Material.STONE)) >= 1) {
                                    p.sendMessage("§2Vendedor: §aVendeste §6"+getAmount(p, new ItemStack(Material.STONE))+" §2STONE(s)§a!");
                                    Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "eco give "+p.getName()+" "+getAmount(p, new ItemStack(Material.STONE))* preços(p, "stone"));
                                    removeitem(p, Material.STONE);
                                }
                                break;
                            case GOLD_ORE:
                                if(getAmount(p, new ItemStack(Material.GOLD_ORE)) >= 1) {
                                    p.sendMessage("§2Vendedor: §aVendeste §6"+getAmount(p, new ItemStack(Material.GOLD_ORE))+" §2GOLD_ORE(s)§a!");
                                    Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "eco give "+p.getName()+" "+getAmount(p, new ItemStack(Material.GOLD_ORE))* preços(p, "gold_ore"));
                                    removeitem(p, Material.GOLD_ORE);
                                }
                                break;
                            case DIAMOND_ORE:
                                if(getAmount(p, new ItemStack(Material.DIAMOND_ORE)) >= 1) {
                                    p.sendMessage("§2Vendedor: §aVendeste §6"+getAmount(p, new ItemStack(Material.DIAMOND_ORE))+" §2DIAMOND_ORE(s)§a!");
                                    Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "eco give "+p.getName()+" "+getAmount(p, new ItemStack(Material.DIAMOND_ORE))* preços(p, "diamond_ore"));
                                    removeitem(p, Material.DIAMOND_ORE);
                                }
                                break;
                            case EMERALD_ORE:
                                if(getAmount(p, new ItemStack(Material.EMERALD_ORE)) >= 1) {
                                    p.sendMessage("§2Vendedor: §aVendeste §6"+getAmount(p, new ItemStack(Material.EMERALD_ORE))+" §2EMERALD_ORE(s)§a!");
                                    Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "eco give "+p.getName()+" "+getAmount(p, new ItemStack(Material.EMERALD_ORE))* preços(p, "emerald_ore"));
                                    removeitem(p, Material.EMERALD_ORE);
                                }
                                break;
                            case COBBLESTONE:
                                if(getAmount(p, new ItemStack(Material.COBBLESTONE)) >= 1) {
                                    p.sendMessage("§2Vendedor: §aVendeste §6"+getAmount(p, new ItemStack(Material.COBBLESTONE))+" §2COBBLESTONE(s)§a!");
                                    Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "eco give "+p.getName()+" "+getAmount(p, new ItemStack(Material.COBBLESTONE))* preços(p, "cobblestone"));
                                    removeitem(p, Material.COBBLESTONE);
                                }
                                break;
                            case GOLD_INGOT:
                                if(getAmount(p, new ItemStack(Material.GOLD_INGOT)) >= 1) {
                                    p.sendMessage("§2Vendedor: §aVendeste §6"+getAmount(p, new ItemStack(Material.GOLD_INGOT))+" §2GOLD_INGOT(s)§a!");
                                    Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "eco give "+p.getName()+" "+getAmount(p, new ItemStack(Material.GOLD_INGOT))* preços(p, "gold_ingot"));
                                    removeitem(p, Material.GOLD_INGOT);
                                }
                                break;
                            case DIAMOND:
                                if(getAmount(p, new ItemStack(Material.DIAMOND)) >= 1) {
                                    p.sendMessage("§2Vendedor: §aVendeste §6"+getAmount(p, new ItemStack(Material.DIAMOND))+" §2DIAMOND(s)§a!");
                                    Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "eco give "+p.getName()+" "+getAmount(p, new ItemStack(Material.GOLD_INGOT))* preços(p, "diamond"));
                                    removeitem(p, Material.DIAMOND);
                                }
                                break;
                            case EMERALD:
                                if(getAmount(p, new ItemStack(Material.EMERALD)) >= 1) {
                                    p.sendMessage("§2Vendedor: §aVendeste §6"+getAmount(p, new ItemStack(Material.EMERALD))+" §2EMERALD(s)§a!");
                                    Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "eco give "+p.getName()+" "+getAmount(p, new ItemStack(Material.EMERALD))* preços(p, "emerald"));
                                    removeitem(p, Material.EMERALD);
                                }
                                break;
                            case GOLD_BLOCK:
                                if(getAmount(p, new ItemStack(Material.GOLD_BLOCK)) >= 1) {
                                    p.sendMessage("§2Vendedor: §aVendeste §6"+getAmount(p, new ItemStack(Material.GOLD_BLOCK))+" §2GOLD_BLOCK(s)§a!");
                                    Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "eco give "+p.getName()+" "+getAmount(p, new ItemStack(Material.GOLD_BLOCK))* preços(p, "gold_block"));
                                    removeitem(p, Material.GOLD_BLOCK);
                                }
                                break;
                            case DIAMOND_BLOCK:
                                if(getAmount(p, new ItemStack(Material.DIAMOND_BLOCK)) >= 1) {
                                    p.sendMessage("§2Vendedor: §aVendeste §6"+getAmount(p, new ItemStack(Material.DIAMOND_BLOCK))+" §2DIAMOND_BLOCK(s)§a!");
                                    Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "eco give "+p.getName()+" "+getAmount(p, new ItemStack(Material.DIAMOND_BLOCK))* preços(p, "diamond_block"));
                                    removeitem(p, Material.DIAMOND_BLOCK);
                                }
                                break;
                            case EMERALD_BLOCK:
                                if(getAmount(p, new ItemStack(Material.EMERALD_BLOCK)) >= 1) {
                                    p.sendMessage("§2Vendedor: §aVendeste §6"+getAmount(p, new ItemStack(Material.EMERALD_BLOCK))+" §2EMERALD_BLOCK(s)§a!");
                                    Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "eco give "+p.getName()+" "+getAmount(p, new ItemStack(Material.EMERALD_BLOCK))* preços(p, "emerald_block"));
                                    removeitem(p, Material.EMERALD_BLOCK);
                                }
                                break;
                            default:
                                break;
                            }
                        }
    i try do on default: but, on sell somthing, say what i put.

    Thanks for help, and sorry for my bad english
     
  2. Offline

    MightyOne

    It's not exactly clear what you mean. What is this action "don't sell anything", what do you want to say or to whom?
     
  3. Offline

    x3G

    Hi @MightyOne , i want on player dont have the items on this lists, say example: "u dont have items to sell".

    Thanks
     
  4. Offline

    MightyOne

    create a boolean, set it to false
    if the player has anything to sell set it to true (in your inventory loop)
    if it still false after the loop send the player your message
     
  5. Offline

    x3G

    @MightyOne hi, dam omg so easy, xD thanks for help
     

Share This Page