[Lib] MyXpBar

Discussion in 'Resources' started by bubbleguj, Oct 15, 2013.

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

    bubbleguj

    A libary to edit the experience bar.

    Hey,
    it was just yesterday when I had a problem. Someone wanted me to make his own level/xp system. But not only the system. Also the bar has to fit into this new system. For example: normaly, you need 17 xp for level one. With this lib, you can change them, that you'll need 50 xp for lvl 1, 100 for lvl 2 and so on. And the best is: Everything will be converted to the xp bar, so everyone will think, "your" xp bar is showing the right level and xp.


    Download & source: https://github.com/bubbleguj/MyXpBarLib


    Add your custom levels and experience

    Before you can start editing your bar, you have to add a HashMap with your custom levels and experience. Create a HashMap like this:
    HashMap<Integer, Integer> customXpLevels = new HashMap<Integer, Integer>();
    customXpLevels.put(1, 17); //Level 1 needs 17 XP
    customXpLevels.put(2, 20); //Level 2 needs 20 XP
    customXpLevels.put(3, 40);
    customXpLevels.put(4, 68);

    Now you have to initialise the libary and add your HashMap.
    MyXpBar xpBar = new MyXpBar(customXpLevels);

    After you did this, you can start editing the bar.
    Methodes

    To add experience to someones bar, just use the addXp(Player p, int amount) method.
    xpBar.addXp(Bukkit.getPlayer("Notch"), 10); //This adds 10 experiences to Notchs experience bar

    To remove experience, use removeXp(Player p, int amount).
    xpBar.removeXp(Bukkit.getPlayer("Notch"), 10); //This removes 10 experiences from Notchs experience bar
     
    DSH105, Skyost and MTN like this.
  2. Offline

    macguy8

    Does this library automatically replace default Minecraft leveling?
     
  3. Offline

    bubbleguj

  4. Offline

    BungeeTheCookie

    Level 1 = 100000000 exp ;)
     
Thread Status:
Not open for further replies.

Share This Page