Hi guys, I'm here because I'm making a plugin and I need to know how I can have a counter of -Number of deaths -Number of kills -Ratio This 3 stats on 1 SB thanks for your help EDIT: Sorry for my bad english :3
Please show some effort first. You'll be more likely to find developers to help you if you first search Google yourself, and at least attempt what you're trying to do before asking for others to do it for you and just copy & paste into your IDE.
public void setPlayerBoard(Player player) { ScoreboardManager mang = Bukkit.getScoreboardManager(); Scoreboard board = mang.getNewScoreboard(); Objective objective = board.registerNewObjective("Stats", "dummy"); objective.setDisplaySlot(DisplaySlot.SIDEBAR); objective.setDisplayName(ChatColor.BLUE + "Your Stats"); Score kills = objective.getScore(Bukkit.getOfflinePlayer("Kills: " )); Score deaths = objective.getScore(Bukkit.getOfflinePlayer("Deaths: " )); TestPlayer play = pg.track.getPlayerData(player); TestScore values = play.getScore(); score.setScore(values.getTotalScore()); kills.setScore(values.getKills()); deaths.setScore(values.getDeaths()); player.setScoreboard(board); scoreTimer(player); } this should guide you for some part use it as a base
Make a scoreboard, take the number of deaths with the "PlayerDeathEvent", you can take the kills with the "PlayerDeathEvent" taking the killer and updating the scoreboard. EDIT: You can update the scoreboard, with a Runnable.
public static double getKdr(PvpPlayer pp) { int kills = pp.getKills(); int deaths = pp.getDeaths(); if(kills == 0 && deaths == 0) return 1; else if(kills > 0 && deaths == 0) { return kills; } else if(deaths > 0 && kills == 0) { return deaths; } else { return MathUtil.round(kills / (double) deaths, 2); } } use that to get KDR/ratio (Script found in pvplevels - https://github.com/Supermaxman/PvpL...s/src/com/lenis0012/bukkit/pvp/PvpLevels.java)