How do I call a random string from a string list in the config

Discussion in 'Plugin Development' started by llkirkwood9, Dec 17, 2019.

Thread Status:
Not open for further replies.
  1. Offline

    llkirkwood9

    So for example if I have config as:
    Code:
    players:
      -  'player1'
      -  'player2'
    How would I be able to get one of those randomly?
     
  2. Offline

    Strahan

    Read the list into a variable, like List<String> players = getConfig().getStringList("players"); then you can use the size of the list as the basis for a random range (i.e. using whatever random object you have access to, you'd call nextInt(players.size))
     
Thread Status:
Not open for further replies.

Share This Page