Skip to content

Fix/fix broken commands#27

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

Fix/fix broken commands#27
TheBjoRedCraft wants to merge 3 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.

Comment on lines 105 to 109
Bukkit.getWorlds().forEach {
it.fullTime = time.toLong()
plugin.launch(plugin.globalRegionDispatcher) {
it.fullTime = time.toLong()
}
}
Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

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

Bukkit.getWorlds().forEach { plugin.launch(plugin.globalRegionDispatcher) { ... } } launches a separate coroutine per world, and the command immediately sends the success message without waiting for any of them to run. Consider launching a single coroutine on globalRegionDispatcher and updating all worlds inside it (and optionally sending the confirmation after the updates), to reduce coroutine overhead and keep the command feedback consistent with when the state is actually applied.

Copilot uses AI. Check for mistakes.
Comment on lines 41 to +46
entitySelectorArgumentManyPlayers("players") {
withPermission(EssentialsPermissionRegistry.TELEPORT_COMMAND_OTHERS)
entitySelectorArgumentOnePlayer("target") {
entitySelectorArgumentOneEntity("target") {
anyExecutor { executor, args ->
val players: Collection<Player> by args
val target: Player by args
val target: Entity by args
Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

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

This updates the destination selector to entitySelectorArgumentOneEntity, but the multi-target variant still uses entitySelectorArgumentManyPlayers("players"), which prevents selectors like @e[...] in the first argument position (vanilla /tp allows teleporting non-player entities too). If issue #26 is about @e[...] selectors generally, consider switching the first argument to a many-entities selector and teleporting those entities accordingly.

Copilot uses AI. Check for mistakes.
}
}
}//TODO: add NBT Support
}
Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

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

The PR description says it solves issue #26, which also mentions broken /summon NBT usage. This change only removes the TODO comment, but the command implementation still doesn't accept/pass through NBT data, so /summon ... { ... } will remain unsupported/broken if this command overrides vanilla. Either add an NBT argument/pass-through, or update the PR scope/description to match what’s actually fixed.

Copilot uses AI. Check for mistakes.
Comment on lines +126 to +138
Bukkit.getWorlds().forEach { world ->
val current = world.fullTime % 24000
val target = namedTime.ticks % 24000

val diff = if (target >= current) {
target - current
} else {
(24000 - current) + target
}

world.fullTime += diff
plugin.launch(plugin.globalRegionDispatcher) {
world.fullTime += diff
}
Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

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

In the namedTime branch, current = world.fullTime % 24000 and diff are computed outside the launched coroutine, but the actual world.fullTime += diff happens later on globalRegionDispatcher. Because the update is delayed/asynchronous, fullTime may change between computing diff and applying it, causing the world to end up at the wrong time. Compute current/diff inside the dispatched block (and read/write fullTime on the same dispatcher) so the calculation is consistent with the applied value.

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