Get words from one line of lore in a custom item

Discussion in 'Programming' started by noob_joey, Jan 21, 2020.

  1. I want to ask how to get one line of the lore from a specific item, since i need to extract the word inside for SQL data as that string of word is fully random.
    Also, I want to specific the item in the inventory but not just item in hand.(Sorry for my bad grammar)
    Here is the code which doesn't work, is there any alt. way to do it?

    insert.setString(5, player.getPlayer().getItemInHand().getItemMeta().getLore().toString());
  2. Code (Text):
    List<String> lore = player.getPlayer().getItemInHand().getItemMeta().getLore().toString();
    something like this should work
  3. Work nicely, thank you very much
  4. no problem :)
  5. Strahan


    Just be aware that compounding methods like that can make the server puke if the person has no item in their hand, and if they do have an item the next line is assuming said item had a lore and again will puke if it does not. You should validate the steps as you go.

    Also in that example you are setting a List from a String, that shouldn't even compile.