Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package fr.tigger.voltiris.api.experience;
- import fr.tigger.voltiris.api.shop.Game;
- import net.Jean_Bonno.redis.Redis;
- import java.util.UUID;
- /**
- * Created by Tigger_San on 22/01/2017.
- */
- public class ExperienceUtil {
- public static int getExp(UUID id){
- int i=0;
- try {
- i = Integer.parseInt(Redis.hget("exp:" + id.toString(), "otb"));
- }
- catch (Exception e){
- }
- return i;
- }
- public static void addExp(UUID id,int value){
- Redis.hset("exp:"+id.toString(),"orb", new String((getExp(id)+value)+""));
- }
- public static int getLevel(UUID id){
- return getLvlForExp(getExp(id));
- }
- public static int getLvlForExp(int exp){
- for(int i=1; i<=250;i++){
- if(exp > (getValueForLvl(i))){
- return i;
- }
- }
- return 0;
- }
- public static double getValueForLvl(int n){
- if(n==1){
- return 200;
- }
- return getValueForLvl(n-1) * 1.1;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement