1.14.4 Kill Scoreboard MySQL

Discussion in 'Spigot Plugin Development' started by Grauju, Jan 13, 2020.

  1. Hi, i want to code a scoreboard with players with the most kills.

    Here is how I order my Stats:

    Code (Java):
    public static void set() {
           
            ResultSet rs = MySQL.mysql.query("SELECT UUID FROM Stats ORDER BY Kills DESC LIMIT 10");
           
            int i = 0;
           
            try {
                while(rs.next()) {
                    i++;
                    rang.put(i, rs.getString("UUID"));
                }
            } catch (SQLException e) {
                e.printStackTrace();
            }

     
    Here is a little start with the scoreboard:

    Code (Java):
           
        for(int a = 0; a < 10; a++) {
                int id = a+1;
                String name = Bukkit.getOfflinePlayer(UUID.fromString(rang.get(id))).getName();
               
                final ScoreboardManager manager = Bukkit.getScoreboardManager();
                final Scoreboard board = manager.getNewScoreboard();
                final Objective objective = board.registerNewObjective("test", "dummy");
                objective.setDisplaySlot(DisplaySlot.SIDEBAR);
                objective.setDisplayName("§eTop Kills");
                final Score Score2 = objective.getScore("§8§3 ");
                Score2.setScore(a);
                final Score Score1 = objective.getScore("§8§3 ");
                Score1.setScore(a);
               
            }
        }
    }
     
  2. What is the issue?
     
  3. What is rang?
    Also in the set() method, what does int i is needed for?
     
  4. use an array or list to store your values and use the index to get what rank they are. youre using a map exactly how lists are used.
    also, youre declaring an entire new scoreboard and objective per person. that doesnt work. you need to create 1 scoreboard and 1 objective. give each player the scoreboard and create 1 score per person with a top score.