High use events

Discussion in 'Plugin Development' started by Sammy, Mar 22, 2011.

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

    Sammy

    There's one thing that always makes me shiver before use, and when I use it my laggy heart beats like crazy: High use events :p maybe because I came from garrysmod :rolleyes:
    What are high use events for me ? onMove, BLOCK_PLACED, BLOCK_RIGHTCLICKED, BLOCK_BREAK.....

    Are they safe too use without having the problem of creating loads of lag on servers with a lot of traffic? are all those events triggered by the server on the server?

    Maybe I'm thinking to much, but this is a question that I always face on my plugins
     
  2. Offline

    maxx001

    That is a VERY relevant question, which i also always ask my self before i use an event. It is one of the main reasons why i always decompile third party plugins before i use them or develop my own.

    It is a question that ALL plugin developers should ask before they begin storing data in a mysql table on each block_break event within the server thread.
     
  3. Offline

    Sammy

    That goes further on the question ;)
    Does a simple test of location on every OnMove done to every player on a 20 player server, creates lag? or is this a some what irrelevant computation on todays systems ?
     
  4. Offline

    Edward Hand

    I suppose you can think of it relative to what minecraft does anyway: Every time a player moves minecraft checks the player isn't trying to move into the inside of a block, and tests collisions between entities. It also checks whether they're moving into something harmful (lava) whether they're stepping on something interactive (like pressure plates/ploughed land), whether the player is stepping into a chunk that means that new chunks need to be loaded and sent to the player and so on and so on.
    The act of calling an event isn't especially stressful, so as long as you're not doing something mindlessly inefficient on every call, surely it can't be that bad?
     
  5. Offline

    petteyg359

    Put all event functions (onPlayerItem etc.) in events.txt, one per line.
    strings Plugin.jar | grep -f events.txt

    No need to "decompile".
     
  6. Offline

    Sammy

    @Edward Hand, your coding ninja skills always amaze me, now I understand it and will be less freaked out every time I call an event ^^
     
Thread Status:
Not open for further replies.

Share This Page