Array function.

Discussion in 'Spigot Plugin Development' started by natkemon, Jun 1, 2015.

  1. Hello.

    I'm in the process of making a plugin. I don't know how to set an array so that for example, if i put in

    getFood();

    it randomly sets you a food name which is configured in another file.
    that other file has like.
    cake
    cookies
    bread
    chicken

    So the array is defined in the main class file but then gets the array data from another file which assigns that player that food name

    I'm not too sure if i explained it right :S
     
  2. Are you trying to load the array from a file? Is it confug.yml?
     
  3. Yes, i'm trying to load the array from a file
     
  4. Create a buffered reader. Read each line in a while loop. Add each line to an ArrayList. Then, possibly, convert it into an array with the toArray() method.
     
  5. Is there possibly a link/thread that talks about arrays? I would like to understand the basics of it first
     
  6. clip

    Benefactor

  7. You're right. I'm just very tired at 4:30 AM with no sleep so I was thinking of reading from a text file in which there is one entry per line.
     
    • Optimistic Optimistic x 1