Skip to content

Conversation

@Stabrinai
Copy link
Contributor

On the folia server, it is best to use entity threads for operations related to entities. Regional threads cannot handle entity operations correctly.

@alwyn974 alwyn974 requested a review from Copilot July 1, 2025 12:56
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR replaces all runAtLocation* scheduler calls with runAtEntity* to ensure tasks execute on entity threads instead of region threads.

  • Replaced scheduler methods across multiple classes to use entity-based scheduling
  • Updated teleport logic in TeleportAction to use teleportAsync
  • Adjusted API default action scheduling to entity-based calls

Reviewed Changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/main/java/fr/maxlego08/menu/zcore/utils/plugins/VersionChecker.java Switched runAtLocationLater to runAtEntityLater
src/main/java/fr/maxlego08/menu/website/ZWebsiteManager.java Replaced runAtLocation with runAtEntity
src/main/java/fr/maxlego08/menu/requirement/actions/TeleportAction.java Changed teleport scheduling to entity thread
src/main/java/fr/maxlego08/menu/requirement/actions/PlayerCommandAsOPAction.java Switched command scheduling to runAtEntity
src/main/java/fr/maxlego08/menu/requirement/actions/PlayerCommandAction.java Switched command scheduling to runAtEntity
src/main/java/fr/maxlego08/menu/inventory/inventories/InventoryDefault.java Updated inventory open calls to runAtEntity
src/main/java/fr/maxlego08/menu/inventory/VInventoryManager.java Switched delayed message scheduling to runAtEntityLater
src/main/java/fr/maxlego08/menu/ZInventory.java Changed runAtLocationLater to runAtEntityLater
Hooks/PacketEvents/src/main/java/fr/maxlego08/menu/hooks/packetevents/PacketUtils.java Switched to runAtEntityLater scheduling
API/src/main/java/fr/maxlego08/menu/api/requirement/Action.java Updated default action delay to runAtEntityLater
API/src/main/java/fr/maxlego08/menu/api/button/PerformButton.java Replaced runAtLocation with runAtEntity in button execution
Comments suppressed due to low confidence (3)

src/main/java/fr/maxlego08/menu/requirement/actions/TeleportAction.java:23

  • Calling teleportAsync inside an entity-scheduled task may lead to double-scheduling or unexpected thread contexts. Consider using player.teleport(location) directly within the entity scheduler for consistent behavior.
        this.plugin.getScheduler().runAtEntity(player, w -> plugin.getScheduler().teleportAsync(player, location));

Hooks/PacketEvents/src/main/java/fr/maxlego08/menu/hooks/packetevents/PacketUtils.java:78

  • The lambda passed to runAtEntityLater should accept a WrappedTask parameter (Consumer<WrappedTask>) rather than a Runnable. Change () -> { ... } to w -> { ... } to match the API signature.
        this.plugin.getScheduler().runAtEntityLater(player, () -> {

API/src/main/java/fr/maxlego08/menu/api/requirement/Action.java:36

  • Similarly, the lambda for runAtEntityLater must accept a WrappedTask argument. Replace () -> execute(...) with w -> execute(...) to adhere to the required Consumer<WrappedTask> signature.
            inventoryEngine.getPlugin().getScheduler().runAtEntityLater(player, () -> execute(player, button, inventoryEngine, placeholders), this.delay);

@Maxlego08 Maxlego08 merged commit a83a5cb into Maxlego08:main Jul 1, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants