Solved yml or SQLite database

Discussion in 'Plugin Development' started by torpkev, Nov 15, 2018.

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

    torpkev

    I'd like to perform an event on a timed basis -

    Each time checking the position of each player on a list and then getting the list of nearby players and performing an action for each of them as needed. Then I'd also like to check either a SQLite database or yml file for some information about a player and perform an action based on that (particle effects etc.)

    My question is - how often is too often for running a scheduler. The code performed each time won't be overly excessive, but I'd rather not have it drag the server down.

    Would every 20-30 seconds be too often?

    I'm going to be recording some information on a player that I'll be calling from a scheduler on a regular basis.

    The data will be include all players that have joined the server and will include something like:

    uuid
    type: stringvalue
    dtime: datetime

    It is fairly simple data, so a yml file might make sense, but as it can include all players, I'd worry about the file getting overly large.

    I know its partially an opinion thing, but which would be the best approach? Reading from the yml file each time or from the database?
     
    Last edited by a moderator: Nov 15, 2018
  2. Online

    timtower Administrator Administrator Moderator

    Merged threads due to being about the same thing.
    @torpkev What kind of actions do you want to perform? Because in my opinion neither of those things will do the trick if you use it often.
     
  3. Offline

    torpkev

    I used 2 threads as they were technically different questions and I didn't really want to muddy the water on what I was asking - will try to keep to a single thread moving forward.

    Basically - every x seconds (preferably 20-30 seconds) I'd would like to get a list of all online players, and using that:

    1) Check the player, see if they have an infection (which would be saved either in the yml or database) and if so, reduce their health, apply an effect if needed (slowness, weakness etc.) and a particle effect if necessary. Possibly increasing the potency of the infection depending on how long they've had it (the date/time of infection would be in the yml/database)

    2) Check if any other players are within 15 blocks, if so, based on a random chance, apply the infection to them as well That would save the infection to either the yml or database.

    3) Check every players biome to see if it is the swamp, and if so, based on a random chance, apply an infection to the player if they do not already have it (again, saving to the yml or database).

    Other than this, I'm listening to the EntityDamageEvent to check when the player is hit by a zombie which could apply the infection, as well as the PlayerItemConsumeEvent and PlayerInteractEvent to check to see if the cure has been administered.

    What I don't know is if the 20-30 seconds is too often to check the player, and if I should use yml or database for storing the info. Or, if there is some other event which would make more sense than using the scheduler at all.

    Hope that clears up what I'm getting at.

    Thanks!
     
  4. Online

    timtower Administrator Administrator Moderator

    @torpkev Yeah, just load it into the memory of the plugin.
    You don't need a database or yml for that.
    You just need to save it in the onDisable.
     
  5. Offline

    torpkev

    ok cool.. so better to leave it in memory and then save that off later.

    How about the scheduler.. is 20-30 seconds between running excessive? I'm fairly new to the scheduler so not sure what kind of impact it has on performance.
     
  6. Online

    timtower Administrator Administrator Moderator

    Based on what you are doing I would think that 1 second is fine as well.
     
    torpkev likes this.
  7. Offline

    torpkev

    Fantastic. thanks
     
Thread Status:
Not open for further replies.

Share This Page