Solved Way to take specific parts of an items lore?

Discussion in 'Plugin Development' started by man_in_matrix, Sep 12, 2021.

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


    SO I'm making a plugin that uses custom item stats to deal damage to entities. I have the damage calculation done the only thing I'm trying to figure out is if/how I can use the stats in the lore in the calculation.

    Basically, the item's lore states ChatColor.GRAY + "Damage: " + ChatColor.RED + "+50", as one of the lines
    is there a way I can transform the "+50" into a useable number in my calculation?

    I've researched this before writing and people seem to use HashMaps a lot but is there a way for me to create a hashmap on the craft of the specific item or not? Like put it in the ShapedRecipe method and access it elsewhere?
  2. Offline


    @man_in_matrix Just get the item's lore, find the line you want and then parse it to an integer.
  3. Offline


    ok thanks Ill try it

    ok so I've been trying for a while and can't seem to find a way to grab the lore and parse it.

    The string is always on the same line and I'm trying to do this inside of a PlayerItemHeldEvent any help?

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

Share This Page