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:
    Code (Text):
    1. try{
    2.                         for(int i = 0; i <= 9; i++){
    3.                             if(item[i] == null || item[i] == ""){
    5.                             }else{
    6.                                 String [] split = item[i].split("x");
    7.                                 String itemid = split[0];
    8.                                 int itemamount = Integer.parseInt(split[1]);
    9.                                 Material itemname = Material.matchMaterial(itemid);
    10.                                 player.getInventory().addItem(new ItemStack(itemname, itemamount));
    11.                             }
    12.                         }
    13.                         MysqlHandler.finishOrder(id);                
    14.                     }catch(Exception e){
    15.                         System.out.println(e);
    16.                             sender.sendMessage(ChatColor.YELLOW + "[Shop] " + ChatColor.RED + "An error occured. Please contact server owner and note current date and time.");
    18.                     }
    Does anyone know a solution to this?

    Kind regards,
  2. 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