Item shop

Discussion in 'Plugin Development' started by djmaster329, Apr 20, 2013.

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



    For my new server I build an online webshop for players to buy items with iConomy money. The orders get saved into the MySQL database in the following format:
    So far so good. I am trying to make it possible for players to receive the items with a command (/getorder [id]). It works when you use item ids without damage value. The image above shows a working order. But when I try to deliver 'Spruce Wood Planks' with item id '5:1' it resolved the item name to 'null'.

    This is the code I use to deliver the orders:
                            for(int i = 0; i <= 9; i++){
                                if(item[i] == null || item[i] == ""){
                                    String [] split = item[i].split("x");
                                    String itemid = split[0];
                                    int itemamount = Integer.parseInt(split[1]);
                                    Material itemname = Material.matchMaterial(itemid);
                                    player.getInventory().addItem(new ItemStack(itemname, itemamount));
                        }catch(Exception e){
                                sender.sendMessage(ChatColor.YELLOW + "[Shop] " + ChatColor.RED + "An error occured. Please contact server owner and note current date and time.");
    Does anyone know a solution to this?

    Kind regards,
  2. Offline


    Save the durability in a format something like this: "<id>:<durability>x<amount>" so for spruce wood planks it would be like this: "5:1x4", 4 being the amount.
  3. Offline


    Yes, that is exactly the way I save the items:
Thread Status:
Not open for further replies.

Share This Page