Conversation
… target selection
…ronous time updates
There was a problem hiding this comment.
Pull request overview
This PR aims to resolve issue #26 by addressing broken Minecraft command behaviors (notably selector handling in /tp and time changes under Folia scheduling).
Changes:
- Dispatches
/timeworld-time mutations viaplugin.globalRegionDispatcher. - Updates
/tpdestination argument from “one player” to “one entity” to support selectors like@e[...]. - Removes the “TODO: add NBT Support” comment from
/summon.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
src/main/kotlin/dev/slne/surf/essentials/command/minecraft/TimeCommand.kt |
Routes some time mutations through Folia’s globalRegionDispatcher coroutine context. |
src/main/kotlin/dev/slne/surf/essentials/command/minecraft/TeleportCommand.kt |
Allows teleport target to be any entity instead of only a player. |
src/main/kotlin/dev/slne/surf/essentials/command/minecraft/SummonCommand.kt |
Removes NBT support TODO comment (no functional NBT change). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
src/main/kotlin/dev/slne/surf/essentials/command/minecraft/TimeCommand.kt
Show resolved
Hide resolved
src/main/kotlin/dev/slne/surf/essentials/command/minecraft/TeleportCommand.kt
Show resolved
Hide resolved
src/main/kotlin/dev/slne/surf/essentials/command/minecraft/SummonCommand.kt
Show resolved
Hide resolved
src/main/kotlin/dev/slne/surf/essentials/command/minecraft/TimeCommand.kt
Show resolved
Hide resolved
src/main/kotlin/dev/slne/surf/essentials/command/minecraft/TimeCommand.kt
Show resolved
Hide resolved
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 6 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| repeat(amount) { | ||
| player.location.world.spawnEntity(player.location, entityType) | ||
| } | ||
| location.world.spawnEntity(location, entityType) |
There was a problem hiding this comment.
location.world.spawnEntity(location, entityType) may execute on the caller’s region thread, which can be unsafe on Folia when the target location is in a different region. Consider dispatching the spawn on plugin.regionDispatcher(location) (similar to StrikeCommand) before calling spawnEntity.
| repeat(amount) { | ||
| location.world.spawnEntity(location, entityType) | ||
| } | ||
| entityBridge.createEntityByNbt(player.world, entityType, location, nbt) |
There was a problem hiding this comment.
createEntityByNbt is passed player.world even though a location is provided. Prefer using location.world (or the world implied by location) to avoid spawning into the wrong world if the command ever allows cross-world locations; also consider running this call on the appropriate Folia region dispatcher for location.
| success("Du hast ") | ||
| success("$amount ") | ||
| translatable(entityType.translationKey()).color(Colors.VARIABLE_VALUE) |
There was a problem hiding this comment.
For consistency with other commands, the summoned amount should be sent via variableValue(...) instead of success("$amount "), so it gets the expected variable-value styling (see e.g. ChangeSlotCommand.kt:19-22).
| repeat(amount) { | ||
| entityBridge.createEntityByNbt(player.world, entityType, location, nbt) | ||
| } |
There was a problem hiding this comment.
Same as above: the repeated createEntityByNbt(...) inside the repeat(amount) loop should use the world associated with location and should be executed on the correct Folia region dispatcher for that location to avoid cross-region access.
| plugin.launch(plugin.globalRegionDispatcher) { | ||
| world.fullTime += diff | ||
| } |
There was a problem hiding this comment.
In the namedTime path, diff is computed from world.fullTime read outside the globalRegionDispatcher coroutine. On Folia this can still be an illegal cross-region world access; consider moving the current/target/diff calculation inside the dispatched block (or otherwise reading fullTime on the same dispatcher) before mutating world.fullTime.
src/main/kotlin/dev/slne/surf/essentials/command/minecraft/SummonCommand.kt
Show resolved
Hide resolved
…ocation arguments
solves #26