Hello, I had a little question. So basically I have some heavy blocks of code that I want to run in AsyncTasks but I don't want to have a lot of AsyncTask classes, I would prefer to store them all in the same task class and call them from the plugin. I was thinking about asking for an $OPTION variable to use the AsyncTask and then looking if $OPTION === "blabla" to then execute a function in the task but I was looking for a more proper way to do it, if there is. I know AsyncTasks are not magical and won't remove 100% of the lags but it would at least reduce them. Or if there is better ways to do what I want, it would be welcomed lol.
If I were you I would make a task file to do like 10 blocks per tick. It would be like $mode === 1 first 10 blocks, $mode++, $mode === 2 another 10 blocks etc.
But it is not about blocks, it's just to execute blocks of codes that takes some time to process which freeze the server during a really small amount of time. This is why I need to find a way to only call one function in the task class depending on the player action. By "blocks of codes" I mean like 10 lines of code
Yes I know, this is what I explained in my first message, but I actually want something more proper than that if possible because I would need to have a long if and elseif thing to look what the $option is to calm the function in the task
I didn't think of a switch :thinking: that would be nice, better than the elseif thing. Ok I think I'll do that any other suggestions anyone ?
If those blocks of code have absolutely nothing to do with each other, the proper way would actually be putting them in separate classes.
Yes I know...but that would mean that I need like at least 15 task classes and each of them would be called only by one thing, which is kind of useless