Added a random xp function
This commit is contained in:
parent
abaa4828dc
commit
01f0417163
@ -41,6 +41,7 @@ public class GameEndListener implements Listener {
|
||||
if (winningTeam.getAllPlayers().contains(player.getUniqueId())) {
|
||||
player.sendTitle(new Title(winnerTitle, subTitle, 5, 20, 5));
|
||||
playerData.setWins(playerData.getWins() + 1);
|
||||
playerData.addRandomXp(player);
|
||||
} else if (losingTeam.getAllPlayers().contains(player.getUniqueId())) {
|
||||
player.sendTitle(new Title(losingTitle, subTitle, 5, 20, 5));
|
||||
playerData.setLosses(playerData.getLosses() + 1);
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user