Creating a leaderboard for guilds/clans etc

Discussion in 'Spigot Plugin Development' started by NegativeExpert9, Jan 14, 2019.

  1. Hey.

    So I have a config file like so:

    Code (YAML):
    stats:
      players
    :
        a7547ccc-eb0b-4420-9fc3-983cea0d6bc9
    :
          name
    : Emperio
          kills
    : 7
          deaths
    : 0
          kingdom
    : TheCoolKids
          confirmed
    : 'no'
        404af9b4-7797-46b2-8ef0-26635f03ce07
    :
          name
    : Ikararua
          kills
    : 3
          deaths
    : 4
          kingdom
    : real
          confirmed
    : 'no'
        40d87105-6190-44ee-9441-3a5b59b9256d
    :
          name
    : _ExpertGamer_
          kills
    : 0
          deaths
    : 6
          kingdom
    : TheCoolKids
          confirmed
    : 'no'
    kingdoms
    :
    - Test1UUID
    - Test2UUID
    - Normandy
    - TheCoolKids
    - real
    chooser
    :
      x
    : 209.30854025905884
      y
    : 72.0
      z
    : 281.62504910285327
    data
    :
      Frankia
    :
        king
    : none
        points
    : 0
        influence
    : 0
        players
    :
          normal
    :
         - Test2UUID
          mod
    :
         - Test1UUID
          - Test2UUID
          general
    :
         - Test1UUID
      Normandy
    :
        king
    : 'null'
        points
    : 0
        influence
    : 0
        players
    :
          normal
    :
         - Test1UUID
          - Test2UUID
          mod
    :
         - Test1UUID
          - Test2UUID
          general
    :
         - Test1UUID
      TheCoolKids
    :
        king
    : a7547ccc-eb0b-4420-9fc3-983cea0d6bc9
        points
    : -3
        influence
    : 0
        players
    :
          normal
    :
         - Test1UUID
          - Test2UUID
          mod
    :
         - Test1UUID
          - 40d87105-6190-44ee-9441-3a5b59b9256d
          general
    :
         - Test1UUID
      real
    :
        king
    : 404af9b4-7797-46b2-8ef0-26635f03ce07
        points
    : 6
        influence
    : 0
        motto
    : loool
        players
    :
          normal
    :
         - Test1UUID
          - Test2UUID
          mod
    :
         - Test1UUID
          - Test2UUID
          general
    :
         - Test1UUID
     
    I have a method Kingdom.getPoints(); I'd like to arrange these in Descending order for me to be able to list them as a leaderboard.

    Any suggestions?
     
  2. Put it in a map (like Map<String, Integer>, String = name of kingdon, Integer = points) and then sort it by value
     

Share This Page