Skip to content

Folia support (Need code refactoring)#372

Closed
mani1232 wants to merge 16 commits intoWiIIiam278:masterfrom
mani1232:master
Closed

Folia support (Need code refactoring)#372
mani1232 wants to merge 16 commits intoWiIIiam278:masterfrom
mani1232:master

Conversation

@mani1232
Copy link
Copy Markdown

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

Copy link
Copy Markdown
Owner

@WiIIiam278 WiIIiam278 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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: true is possible in paper-plugin.yml files 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 :)

@WiIIiam278 WiIIiam278 added type: feature request This issue is about a new feature or request status: in progress This issue is in progress labels Apr 27, 2023
@WiIIiam278 WiIIiam278 self-assigned this Apr 27, 2023
@WiIIiam278 WiIIiam278 linked an issue Apr 27, 2023 that may be closed by this pull request
@mani1232 mani1232 requested a review from WiIIiam278 April 27, 2023 17:00
@mani1232 mani1232 requested a review from WiIIiam278 April 27, 2023 20:58
@mani1232
Copy link
Copy Markdown
Author

But it's better to transfer some tasks to RegionScheduler by location

Comment on lines +78 to +136
@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();
}
}
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be removed and PaperHuskHomes implement PaperTaskRunner instead :)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't do it, you did the same when registering commands
image

@WiIIiam278
Copy link
Copy Markdown
Owner

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:

  • All the TaskRunner logic moved away from PaperHuskHomes
  • The use of the AsyncScheduler instead of the global region scheduler for runAsync tasks
  • The use of the global region scheduler / entity scheduler for the runSync tasks

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

@WiIIiam278
Copy link
Copy Markdown
Owner

Closing in favor of #376

@WiIIiam278 WiIIiam278 closed this Apr 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: in progress This issue is in progress type: feature request This issue is about a new feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add compatibility with Folia

2 participants