counting up

Discussion in 'Plugin Development' started by greaperc4, Sep 2, 2013.

Thread Status:
Not open for further replies.
  1. Hello,
    I have made a little plugin what can change the Lore on a item.. and I want to make it count up everyime you click in the Air

    This is the Lore:
    "- 0x clicked"
     
  2. Offline

    sharp237

    Use PlayerInteractEvent to get when a player clicks the air. Then see if the player's item in their hand is the item you want to do this to. Then change the item's lore.
     
  3. That's what I have.. but how do I get the int in the lore then count it up.. and then setting the lore with the new Int
     
  4. Offline

    sharp237

    If this is the Lore:
    String lore = "- 0x clicked";

    Remove the random stringy bits:
    lore.replace("- ", "");
    lore.replace("x clicked", "");

    Now lore is just the number, so convert it to an Integer:
    int num = Integer.parseInt(lore);

    Then add 1:
    num++;

    Then re-add the stringy bits:
    lore = "- " + num + "x clicked";

    Then replace the item's lore with the new lore.
     
  5. I think this is what I need.. thanks!
    If there is a new problem.. I will reply
     
Thread Status:
Not open for further replies.

Share This Page