Simple Question

Discussion in 'Plugin Development' started by XvBaseballkidvX, Oct 17, 2013.

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

    XvBaseballkidvX

    Hello everyone!

    I am currently making a DonationPerk plugin and had some questions about a few things.
    I am using a PlayerMoveEvent to generate a cool effect (Mob Spawner Flames) and wanted to tone down the amount of flames. So my question is, if I used a:

    Random() ran = new Random();

    On the player move event, would that cause lag on servers? Because its generating a random every time the player moves (Only if they are on an ArrayList though).

    Thank you for reading!
    All help is much appreciated!
     
  2. Offline

    drtshock

    The PlayerMoveEvent is called so often it's crazy. If you want to do something that requires a lot of calculations I would suggest using a timer and checking positions against last positions or something like that.

    But for what you're doing the event should be fine. Random is not an expensive call and shouldn't cause any issues.
     
    MrSnare likes this.
  3. Offline

    blablubbabc

    You could create one new Random object at plugin start, and then re-use it inside the PlayerMoveEvent.
     
  4. Offline

    Garris0n

    Except that it would spam ridiculous amounts of particles and, in this case, using a timer would actually make sense.
     
Thread Status:
Not open for further replies.

Share This Page