Solved Random Enchant Thingy.

Discussion in 'Plugin Development' started by DomThePotato, Mar 5, 2015.

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

    DomThePotato

    Hello. Basically, I am making a Votifier Listener. And on the vote event. I would like the player to receive a sword with a random safe enchant. And as you may or may not of guessed. I'm not too sure on how to do it D;. I feel like the information I've given is a bit vague, so anymore information is need please tell me.

    I am also aware this isn't where people do the work for you. So just like hints or improvements or something like that.

    This is what I've done so far: (It could be wrong :p)

    Code:
        Random Object = new Random();
        int Sharpness;
        int FireAspect;
        int Smite;
        int BaneOfSpiders;
        int KnockBack;
        int Looting;
    Thanks so much :D.

    DomThePotato :D
     
  2. Offline

    Skionz

    @DomThePotato Use naming conventions and the Random class. Random#nextInt(int) picks a random number between and including 0 to the argument you passed. Suppose you invoke Random#nextInt(3). The outcomes can either be 0, 1, or 2.
     
  3. Offline

    DomThePotato

    @Skionz Is that for enchant levels and/or just enchants? (I suppose it's for levels)
     
  4. Offline

    Skionz

  5. Offline

    DomThePotato

    Ok. I know I must sound silly. But I don't get what you mean. :/

    Code:
                Random Object = new Random();
                int Sharpness;
                int FireAspect;
                int Smite;
                int Spider;
                int KnockBack;
                int Looting;
               
                 Object.nextInt(5);
    How does that look?
     
Thread Status:
Not open for further replies.

Share This Page