Solved Random Help

Discussion in 'Spigot Plugin Help' started by ScenicJaguar101, May 26, 2016.

  1. How would I make a command that when someone runs /funfact it prints out a random message?
    Please help me by using Random r = new Random(); because I would like to use this in the future and I don't know how to use this,

  2. Personally I would create a file and add the facts line by line, then with the random number that is generated grab the line number that corresponds to that line and display it
    • Winner Winner x 1
  3. Ugh but I don't know how to do that xDD
  4. Dude This Doesn't Even Sound Like A Plugin All You Want Is A Random Messager No Developer Is Going To Go Out Their Way And Make This 5min Plugin
  5. Wrong forum. Please post in Spigot Plugin Development Help.
    • Informative Informative x 1
  6. Well I don't care.... And yeah it is a plugin...

    And thanks Ill make a new thread in that forum
  7. All you have to do is make an array of strings.

    Code (Java):
    String[] words = new String[]

    • Like Like x 1
  8. So just edit the Things and Stuff? and just put that in my onCommand code?
  9. I have this now, and the random gets an error, can you please help me fix it?
    Code (Text):
            else if (cmd.getName().equalsIgnoreCase("funfact") && sender instanceof Player) {
                Player player = (Player) sender;

                String[] words = new String[]

            return true;
    (The random in random.nextInt is the random with the error)

  10. Random random = new Random();

    Add this just below where you declare your player
  11. ok thanks

    It worked thanks!!!!!!
  12. You could also use ThreadLocalRandom, as it already exists.
    Also it looks like you really need to learn basic java, objects do not just magically appear, it will save you a lot of trouble to understand how it works.