Skip to content

Fix/fix broken commands#27

Open
TheBjoRedCraft wants to merge 5 commits intoversion/1.21.11from
fix/fix-broken-commands
Open

Fix/fix broken commands#27
TheBjoRedCraft wants to merge 5 commits intoversion/1.21.11from
fix/fix-broken-commands

Conversation

@TheBjoRedCraft
Copy link
Member

solves #26

Copilot AI review requested due to automatic review settings February 6, 2026 15:39
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 aims to resolve issue #26 by addressing broken Minecraft command behaviors (notably selector handling in /tp and time changes under Folia scheduling).

Changes:

  • Dispatches /time world-time mutations via plugin.globalRegionDispatcher.
  • Updates /tp destination 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.

Copilot AI review requested due to automatic review settings February 7, 2026 22:22
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

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)
Copy link

Copilot AI Feb 7, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
repeat(amount) {
location.world.spawnEntity(location, entityType)
}
entityBridge.createEntityByNbt(player.world, entityType, location, nbt)
Copy link

Copilot AI Feb 7, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
Comment on lines +76 to +78
success("Du hast ")
success("$amount ")
translatable(entityType.translationKey()).color(Colors.VARIABLE_VALUE)
Copy link

Copilot AI Feb 7, 2026

Choose a reason for hiding this comment

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

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).

Copilot uses AI. Check for mistakes.
Comment on lines +70 to +72
repeat(amount) {
entityBridge.createEntityByNbt(player.world, entityType, location, nbt)
}
Copy link

Copilot AI Feb 7, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
Comment on lines +136 to +138
plugin.launch(plugin.globalRegionDispatcher) {
world.fullTime += diff
}
Copy link

Copilot AI Feb 7, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
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.

1 participant