Solved Displaying percentage on XP bar

Discussion in 'Spigot Plugin Development' started by Nighterance, May 3, 2017.

  1. Hello! So I am using player xp bar in my custom plugin. I have cancelled all evets that give you exp, and you can't get it, unless you sell items in my shop. Since I needed different math used to give player xp per items (since you can't give player xp less than 1) and I am starting from level 1.

    Currently I am saving player sold items to a file, then, when new item is sold, player gets xp determed by file (if player has sold 10 items and we divide them by 10, we do /xp set player items/10 Everything works, except, I still am giving exp, and if player has not enought for 1xp +, then nothing displays on xp bar (that is logical). Is there a way I can manipulate xp bar and move it everytime I want (if person sells item)?

    I can't use xp since it does not go till end if level is too low.
  2. The xp bar is a float variable between 0 and 1, 0 being empty 0.25 being 1/4, 0.5 being half etc.

    You could calculate the percent the player is from a level and set the bar to that and it would be relevant to how far they are until next level

    Sent from my iPhone using Tapatalk
    • Agree Agree x 1
  3. Thanks, I found how to do it

    Seems that .setxp can be float as well :D
  4. So mark the thread as solved? I think your problem was solved.
    • Agree Agree x 2
  5. Yes, sorry, forgot about it.