Folia support (Need code refactoring)#372
Folia support (Need code refactoring)#372mani1232 wants to merge 16 commits intoWiIIiam278:masterfrom
Conversation
There was a problem hiding this comment.
I really appreciate your work here! Thanks for your interest in contributing to HuskHomes.
I've left quite a bunch of large review issues with this PR
- I'm not a big fan of some of the API decisions you've made in terms of the
TaskRunner; I'm not fond of requiring a Location and think that should be removed in favor of delegating async stuff to a different folia scheduler or the GlobalRegion scheduler. - I think all Folia logic should be moved to the Paper module -- and calls be moved to its' own utility class. I don't think Folia stuff should be compiled against on the Bukkit module in general.
- Some of this stuff hinges on whether
folia-supported: trueis possible inpaper-plugin.ymlfiles at the minute -- nor even if running Paper plugins is supported on Folia (I think it is, but Paper plugins are a recent addition, so I'm not sure).- If it is, great -- all folia logic should be moved to the paper module!
- If it isn't, I think we ought to check with the paper team if that's going to be added; if not we should move all the logic to its own folia module, implementing the bukkit module just like the paper module, but implementing the folia API. That could then be bundled into the fat Plugin jar.
- I'd like the footprint of the files touched by this PR to be kept to a minimum (hence why I'm also not fond of the Location param being added to
TaskRunner
Once again, thanks for your work. If you have any questions or comments, go ahead and ask in #huskhomes-dev on Discord, or below here :)
bukkit/src/main/java/net/william278/huskhomes/BukkitHuskHomes.java
Outdated
Show resolved
Hide resolved
common/src/main/java/net/william278/huskhomes/util/TaskRunner.java
Outdated
Show resolved
Hide resolved
paper/src/main/java/net/william278/huskhomes/PaperHuskHomes.java
Outdated
Show resolved
Hide resolved
bukkit/src/main/java/net/william278/huskhomes/BukkitHuskHomes.java
Outdated
Show resolved
Hide resolved
bukkit/src/main/java/net/william278/huskhomes/BukkitHuskHomes.java
Outdated
Show resolved
Hide resolved
bukkit/src/main/java/net/william278/huskhomes/BukkitHuskHomes.java
Outdated
Show resolved
Hide resolved
bukkit/src/main/java/net/william278/huskhomes/BukkitHuskHomes.java
Outdated
Show resolved
Hide resolved
sponge/src/main/java/net/william278/huskhomes/util/SpongeTaskRunner.java
Outdated
Show resolved
Hide resolved
paper/src/main/java/net/william278/huskhomes/util/FoliaTaskRunner.java
Outdated
Show resolved
Hide resolved
paper/src/main/java/net/william278/huskhomes/util/FoliaTaskRunner.java
Outdated
Show resolved
Hide resolved
paper/src/main/java/net/william278/huskhomes/PaperHuskHomes.java
Outdated
Show resolved
Hide resolved
paper/src/main/java/net/william278/huskhomes/PaperHuskHomes.java
Outdated
Show resolved
Hide resolved
paper/src/main/java/net/william278/huskhomes/util/FoliaTaskRunner.java
Outdated
Show resolved
Hide resolved
paper/src/main/java/net/william278/huskhomes/util/FoliaTaskRunner.java
Outdated
Show resolved
Hide resolved
paper/src/main/java/net/william278/huskhomes/util/FoliaTaskRunner.java
Outdated
Show resolved
Hide resolved
paper/src/main/java/net/william278/huskhomes/PaperHuskHomes.java
Outdated
Show resolved
Hide resolved
paper/src/main/java/net/william278/huskhomes/PaperHuskHomes.java
Outdated
Show resolved
Hide resolved
paper/src/main/java/net/william278/huskhomes/PaperHuskHomes.java
Outdated
Show resolved
Hide resolved
paper/src/main/java/net/william278/huskhomes/PaperHuskHomes.java
Outdated
Show resolved
Hide resolved
|
But it's better to transfer some tasks to RegionScheduler by location |
paper/src/main/java/net/william278/huskhomes/util/PaperTaskRunner.java
Outdated
Show resolved
Hide resolved
paper/src/main/java/net/william278/huskhomes/util/PaperTaskRunner.java
Outdated
Show resolved
Hide resolved
| @Override | ||
| public int runAsync(@NotNull Runnable runnable) { | ||
| if (folia) { | ||
| return paperTaskRunner.runAsync(runnable); // For Folia | ||
| } | ||
| return super.runAsync(runnable); // For Paper and forks | ||
| } | ||
|
|
||
| @Override | ||
| public <T> CompletableFuture<T> supplyAsync(@NotNull Supplier<T> supplier) { | ||
| if (folia) { | ||
| return paperTaskRunner.supplyAsync(supplier); | ||
| } | ||
| return super.supplyAsync(supplier); | ||
| } | ||
|
|
||
| @Override | ||
| public void runSync(@NotNull Runnable runnable) { | ||
| if (folia) { | ||
| paperTaskRunner.runSync(runnable); | ||
| } else { | ||
| super.runSync(runnable); | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| public int runAsyncRepeating(@NotNull Runnable runnable, long period) { | ||
| if (folia) { | ||
| return paperTaskRunner.runAsyncRepeating(runnable, period); | ||
| } | ||
| return super.runAsyncRepeating(runnable, period); | ||
| } | ||
|
|
||
| @Override | ||
| public void runLater(@NotNull Runnable runnable, long delay) { | ||
| if (folia) { | ||
| paperTaskRunner.runLater(runnable, delay); | ||
| } else { | ||
| super.runLater(runnable, delay); | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| public void cancelTask(int taskId) { | ||
| if (folia) { | ||
| paperTaskRunner.cancelTask(taskId); | ||
| } else { | ||
| super.cancelTask(taskId); | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| public void cancelAllTasks() { | ||
| if (folia) { | ||
| paperTaskRunner.cancelAllTasks(); | ||
| } else { | ||
| super.cancelAllTasks(); | ||
| } | ||
| } |
There was a problem hiding this comment.
This should be removed and PaperHuskHomes implement PaperTaskRunner instead :)
paper/src/main/java/net/william278/huskhomes/PaperHuskHomes.java
Outdated
Show resolved
Hide resolved
|
I'm in no rush to merge this, so there's no need to rush this ;) Before this is merged, I'd like to see:
I don't really want to merge this until then :) I don't want to tread on your shoes here, so while I do appreciate your work I'm also okay if you want to just close this and PR it myself |
|
Closing in favor of #376 |

For test you can use this server: play.worldmandia.cc