Advertisement
Tigger_San

Untitled

Jan 22nd, 2017
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.16 KB | None | 0 0
  1. package fr.tigger.voltiris.api.experience;
  2.  
  3. import fr.tigger.voltiris.api.shop.Game;
  4. import net.Jean_Bonno.redis.Redis;
  5.  
  6. import java.util.UUID;
  7.  
  8. /**
  9.  * Created by Tigger_San on 22/01/2017.
  10.  */
  11. public class ExperienceUtil {
  12.         public static int getExp(UUID id){
  13.             int i=0;
  14.             try {
  15.  
  16.                 i = Integer.parseInt(Redis.hget("exp:"  + id.toString(), "otb"));
  17.             }
  18.             catch (Exception e){
  19.  
  20.             }
  21.             return i;
  22.         }
  23.         public static void addExp(UUID id,int value){
  24.             Redis.hset("exp:"+id.toString(),"orb", new String((getExp(id)+value)+""));
  25.         }
  26.  
  27.         public static int getLevel(UUID id){
  28.             return getLvlForExp(getExp(id));
  29.         }
  30.  
  31.  
  32.         public static int getLvlForExp(int exp){
  33.             for(int i=1; i<=250;i++){
  34.                 if(exp > (getValueForLvl(i))){
  35.                     return i;
  36.                 }
  37.             }
  38.             return 0;
  39.         }
  40.  
  41.  
  42.         public static double getValueForLvl(int n){
  43.             if(n==1){
  44.                 return 200;
  45.             }
  46.             return getValueForLvl(n-1) * 1.1;
  47.         }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement