diff --git a/src/main/java/rip/tilly/bedwars/listeners/game/GameEndListener.java b/src/main/java/rip/tilly/bedwars/listeners/game/GameEndListener.java index 84719ba..a09e373 100644 --- a/src/main/java/rip/tilly/bedwars/listeners/game/GameEndListener.java +++ b/src/main/java/rip/tilly/bedwars/listeners/game/GameEndListener.java @@ -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); diff --git a/src/main/java/rip/tilly/bedwars/playerdata/PlayerData.java b/src/main/java/rip/tilly/bedwars/playerdata/PlayerData.java index 85f4905..1880de7 100644 --- a/src/main/java/rip/tilly/bedwars/playerdata/PlayerData.java +++ b/src/main/java/rip/tilly/bedwars/playerdata/PlayerData.java @@ -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; + } + } }