Advertisement
ZP4RKER

Level

Aug 19th, 2015
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.72 KB | None | 0 0
  1. package com.zp4rker.zlevels.util;
  2.  
  3. import com.zp4rker.zlevels.PlayerData;
  4. import org.bukkit.plugin.java.JavaPlugin;
  5.  
  6.  
  7. @SuppressWarnings("unused")
  8. public class Level {
  9.  
  10.     private static JavaPlugin plugin;
  11.  
  12.     public Level(JavaPlugin plugin) {
  13.         this.plugin = plugin;
  14.     }
  15.  
  16.     public static void refreshPlayerLevels(PlayerData playerData) {
  17.  
  18.         int level = playerData.getLevel();
  19.         int xp = playerData.getXp();
  20.  
  21.         while(xp >= (level * 250)) {
  22.             int amountOver = xp - (level * 250);
  23.             level++;
  24.             xp = amountOver;
  25.         }
  26.  
  27.         playerData.setXp(xp);
  28.         playerData.setLevel(level);
  29.  
  30.         plugin.getDatabase().save(playerData);
  31.  
  32.     }
  33.  
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement