Solved Best way to modify crop growth rates for specific chunks

Discussion in 'Spigot Plugin Development' started by myokan, Jun 8, 2019.

  1. I'm writing an upgrades plugin at the moment that includes various upgrades that players can apply to their claimed land. Most of these (damage reduction, food loss, experience, etc) are very easy, but I'd like to know everyone's thoughts on if there is a better way to do the following than what I was thinking of:

    * Speed up crop growth rates (by a percentage) in a player's claimed chunks.

    When I was looking through the javadocs, I couldn't find anything on this. So, this is the idea I had:

    1. In chunks that are claimed by players, cancel block growth events
    2. Have a runnable task that checks all claimed chunks, looks for crop blocks, checks their block states, and grows accordingly if possible.

    Would anyone know of a better way of accomplishing this? I think that the task would have the potential to cause lag once the server that it's running on has a lot of claimed chunks with upgrades (even if I'm able to do some of this async).

    Thanks for your help.

  2. You could increase the random tick speed overall on the server and cancel the natural growth events if a player without the right permission/ability wasn’t nearby. Or check those claims in a repeating task, and grow them artificially

    Sent from my iPhone using Tapatalk
  3. Thanks for your input. I figured out what I'm planning on doing.

    For anyone googling this: If you want to have a way to double crop growth, double the rate in spigot.yml or bukkit.yml (whichever it's in) and then in your BlockGrowEvent have a 50% chance of canceling if whatever condition to double isn't present.