Give randomly Strings out

Discussion in 'Plugin Development' started by Dark-Panther, Apr 7, 2011.

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

    Dark-Panther

    I'm writing a plugin, that gives out messages on a specified event...
    I created a config.yml u.s.w.
    Now my problem: In my config I wrote down several strings, that I like to give out on the event.
    The Event isn't a problem, but I dont know, how I should make the sendMessage of the strings.

    My strings are called:
    Code:
     public enum Sprueche {
             Spruch1,
             Spruch2,
             Spruch3,
             Spruch4,
             Spruch5,
             Spruch6,
             Spruch7;
    
    
             }
        

    Please help me!
     
  2. Offline

    Ne0nx3r0

  3. Offline

    Dark-Panther

    Mhh no, not completly, it should give random strings out from a config.yml file
     
  4. Offline

    Archelaus


    Code:
        public ArrayList<String> getConfigString(){
            Configuration config = new Configuration(new File(plugin.getDataFolder + File.separator + "config.yml"));
            ArrayList<String> stringArray = new ArrayList<String>();
            for(Sprueche n : Sprueche.values()){
                stringArray.add(config.getString(n.toString(), null));
            }
            return stringArray;
        }
    

    Above reads them. Use random numbers to decide which to send.
     
Thread Status:
Not open for further replies.

Share This Page