Solved Mining Level

Discussion in 'Plugin Development' started by MattTheBeast, May 29, 2017.

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

    MattTheBeast

    Hi, so basically I'm in need of help for creating a mining level system. How it will work is it will display on a scoreboard A players mining lv. Players earn xp from mining ores. The problem is, this is the first time I create a leveling system on a scoreboard and I am wondering what the best way to make it is.

    Here is what I think I should do but it would take long...

    If( theplayersxp > 100 < 200) player lv = 1
    If( theplayersxp > 200 < 350) player lv = 2
    ... and so on

    Thanks for helping me out
     
  2. Offline

    Caderape2

    @MattTheBeast
    The best way would be to create a formula according to the exp for determine the actual level.
    You will have to create it on your own.
     
  3. Offline

    MattTheBeast

    @Caderape2 well thats why I'm asking the question, I'm wondering if anybody can help me make the formule
     
  4. Offline

    CeramicTitan

    It's not so easy without all of the factors. You need to think about how much exp a player gets for each ore mined, how many levels there are and how much exp is needed to level up. I'm probably forgetting something but there are lots of things you need to think about when programming, if you wanna make a good solution.

    I would do something like this and it encompassess all the things I spoke about earlier.
    PHP:
    private int experience 0;

    private 
    HashMap intint experienceNeeded = new HashMap < > ();//Level associated with exp needed.
    public int getPlayerLevel(Player playerMineral ore) {
      
    int level getCurrentPlayerLevel() //get current player level somehow
      
    experience += getExperienceForMining(ore); //Increment experience
      
    for (int experienceRequiredexperienceNeeded.entrySet() { //Sort through hashamp
        
    if (experience == experienceRequired.getValue()) { //Narrow down values - i.e the experience needed to level up - if the player has that exp level up
         
    level experienceRequired.getKey(); //Get level associated with the experience gained.
         //Another way to do this is via the factory method, but this way is a little more elegant
        
    }
       }
       return 
    level;
      }
     
    Last edited: May 29, 2017
  5. Offline

    Caderape2

    @MattTheBeast
    I don't think you have to do it complicated.

    A simple formula like this would ask 100 exp for the first level, 110 the second, 120 the third etc..
    You can modify it for add more experience required between two levels.

    You will have to store the player level and the actual experience, and reset the exp when a player level up
     
  6. Offline

    MattTheBeast

  7. Offline

    Zombie_Striker

    @MattTheBeast
    If your problem has been solved, mark this thread as solved.
     
Thread Status:
Not open for further replies.

Share This Page