-
-
Notifications
You must be signed in to change notification settings - Fork 373
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enhance the scheduling system API for future additions #5960
base: dev/feature
Are you sure you want to change the base?
Conversation
Placing under draft until I get opinions from the Core SkriptLang team and I also have all the JavaDocs to do. |
Not core team, but Folia support would definitely be nice and fits the goals of Skript :) Would it be possible to convert all usages of BukkitScheduler to Skript's Task on the main branch and then rebase the folia branch? We probably should've stuck to Skript's Task anyway... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an admirable attempt and definitely something that needs doing, however it has brought to my attention how much of the existing task timing system is [dangerous/bizarre/inefficient] and I think this would be an excellent opportunity to clean up some of the main offenders.
We could fix the problems in a separate PR (in which case I'll dismiss my change request and approve this) but we should first discuss how we want to approach this.
/** | ||
* Class to handle the abstract versioning and to be loaded from the Skript main class. | ||
*/ | ||
public class TaskManager { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a lot of static abuse for something that probably ought not be.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's package only access. The Task class should not store which PlatformScheduler to use.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm going to agree with Kenzie here. I don't think there's a good reason for why we can't support multiple instances for this class.
I think it should be fine to accept any plugin instance. Additionally, if the static is needed for the Task class(es), have this class be used to create/submit new tasks. Though, the methods of this class seem to just wrap the Scheduler. Why not just have users submit tasks to the scheduler directly? e.g. Skript.getScheduler()
src/main/java/org/skriptlang/skript/scheduler/platforms/SpigotScheduler.java
Outdated
Show resolved
Hide resolved
src/main/java/org/skriptlang/skript/scheduler/platforms/SpigotScheduler.java
Outdated
Show resolved
Hide resolved
src/main/java/org/skriptlang/skript/scheduler/platforms/SpigotScheduler.java
Outdated
Show resolved
Hide resolved
bd134d0
to
3f08853
Compare
Closing due to inactivity. |
This is a very important future change requiring attention. |
There are requested changes still waiting from September 2023. These haven't been addressed since, hence closed for inactivity. Do you intend to address these requests? |
I would like this. |
I didn't realize how well I engineered this API. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks like a good step toward folia support :)
Co-authored-by: Ilari Suhonen <ilari.suhonen@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good start.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks really good
} | ||
|
||
/** | ||
* Re-schedules the task to run next after the given delay. If this task was repeating it will continue so using the same period as before. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this line mean that this method has no effect on repeating tasks? I think it should be rewritten to be a little clearer
src/main/java/org/skriptlang/skript/scheduler/PlatformScheduler.java
Outdated
Show resolved
Hide resolved
import ch.njol.skript.Skript; | ||
|
||
/** | ||
* Class to handle the abstract versioning and to be loaded from the Skript main class. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment doesn't make much sense. I would suggest instead maybe Handles the scheduling of tasks in a platform-agnostic manner. Loaded by the Skript main class.
src/main/java/org/skriptlang/skript/scheduler/package-info.java
Outdated
Show resolved
Hide resolved
src/main/java/org/skriptlang/skript/scheduler/platforms/FoliaScheduler.java
Outdated
Show resolved
Hide resolved
src/main/java/org/skriptlang/skript/scheduler/platforms/SpigotScheduler.java
Outdated
Show resolved
Hide resolved
long delayTicks = (task.getTimeUnit().toMillis(delay) / 1000) * 20; | ||
long periodTicks = (task.getTimeUnit().toMillis(task.getPeriod()) / 1000) * 20; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
again, why not / 50? Is it magic number concern?
Co-authored-by: sovdee <10354869+sovdeeth@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would like to see some changes to the design so that we can move away from all of the static usage.
/** | ||
* This file is part of Skript. | ||
* | ||
* Skript is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* Skript is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with Skript. If not, see <http://www.gnu.org/licenses/>. | ||
* | ||
* Copyright Peter Güttinger, SkriptLang team and contributors | ||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/** | |
* This file is part of Skript. | |
* | |
* Skript is free software: you can redistribute it and/or modify | |
* it under the terms of the GNU General Public License as published by | |
* the Free Software Foundation, either version 3 of the License, or | |
* (at your option) any later version. | |
* | |
* Skript is distributed in the hope that it will be useful, | |
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
* GNU General Public License for more details. | |
* | |
* You should have received a copy of the GNU General Public License | |
* along with Skript. If not, see <http://www.gnu.org/licenses/>. | |
* | |
* Copyright Peter Güttinger, SkriptLang team and contributors | |
*/ |
Fine to remove now
private long periodInTicks = -1; | ||
|
||
public Task(long delayInTicks, long periodInTicks) { | ||
this(Skript.getInstance(), delayInTicks, periodInTicks); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would document for these methods that the Skript instance is being used
/** | ||
* Class to handle the abstract versioning and to be loaded from the Skript main class. | ||
*/ | ||
public class TaskManager { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm going to agree with Kenzie here. I don't think there's a good reason for why we can't support multiple instances for this class.
I think it should be fine to accept any plugin instance. Additionally, if the static is needed for the Task class(es), have this class be used to create/submit new tasks. Though, the methods of this class seem to just wrap the Scheduler. Why not just have users submit tasks to the scheduler directly? e.g. Skript.getScheduler()
Description
Updates the entire Task scheduling system in Skript. This API change is required to support versioning reflection of future additions like Folia https://github.com/PaperMC/Folia
I have a branch which enables Folia support for Skript and completes the Task scheduling system to adapt to Folia properly https://github.com/SkriptLang/Skript/tree/feature/folia Do note this is in experimental phase and still throws exceptions due to the following;
The main changes that are needed to that branch is replacing
Bukkit.getScheduler
with Skript'snew Task
luckily old parts of Skript accomplish this, but ever since bensku additions, the Skript project has had the habit of usingBukkit.getScheduler
directly, rather than Skript's own Task. So many parts of Skript are going to need changes in that branch.Once this is merged, i'll directly work on the Folia branch for the FoliaScheduler class.
Target Minecraft Versions: none
Requirements: none
Related Issues: #5645