1.14.4 How to make custom experience fit boss bars?

Discussion in 'Spigot Plugin Development' started by kinukin, Feb 4, 2020.

  1. So I'm trying to make it so that the boss bars show the current experience of the player.

    For example if the player is level 1 the max experience will be 200 until level 2.

    So how can I make it so that the progress bar sets the progress of the player experience?

    This is what I got so far:

    Code (Text):
        public void progressBarExperience(Player p) {
            int playerLevel = Experience.getLevel(p);
               switch(playerLevel) {
              case 1:
                  double experience = Experience.getExperience(p) * 1 / 200;
                  bar.setProgress(experience);
                  break;
              case 2:
                  double experience1 = Experience.getExperience(p) * 1 / 400;
                  bar.setProgress(experience1);
                  break;
              case 3:
                  double experience2 = Experience.getExperience(p) * 1 / 500;  
                  bar.setProgress(experience2);
                  break;
              case 4:
                  double experience3 = Experience.getExperience(p) * 1 / 800;
                  bar.setProgress(experience3);
                  break;
              case 5:
                  double experience4 = Experience.getExperience(p) * 1 / 1000;  
                  bar.setProgress(experience4);
                  break;
          }
     
    • Funny Funny x 1
  2. What exactly about that code does not work?
     
  3. why not use xp bar for this?
     
    • Agree Agree x 1