Added a random xp function

This commit is contained in:
Trixkz
2021-11-22 10:25:42 -05:00
parent abaa4828dc
commit 01f0417163
2 changed files with 16 additions and 0 deletions

View File

@ -5,8 +5,10 @@ import lombok.Setter;
import org.bukkit.entity.Player;
import rip.tilly.bedwars.BedWars;
import rip.tilly.bedwars.managers.PlayerDataManager;
import rip.tilly.bedwars.utils.CC;
import java.util.UUID;
import java.util.concurrent.ThreadLocalRandom;
@Getter
@Setter
@ -42,4 +44,17 @@ public class PlayerData {
this.playerDataManager.loadPlayerData(this);
}
public void addRandomXp(Player player) {
double xp = ThreadLocalRandom.current().nextDouble(0.01, 0.05);
this.xp += xp;
player.sendMessage(CC.translate("&b&l+" + ((int) (xp * 100)) + "&b&l% xp"));
if (this.xp >= 1) {
this.level += 1;
this.xp = this.xp - (long) this.xp;
}
}
}