Add updatehome and updatewarp to update home/warp's location#10
Add updatehome and updatewarp to update home/warp's location#10EasterGhost merged 1 commit intomasterfrom
updatehome and updatewarp to update home/warp's location#10Conversation
There was a problem hiding this comment.
Pull request overview
Adds new commands to update an existing Home/Warp’s stored location to the player’s current position, along with UI buttons and localized messages to support the workflow.
Changes:
- Registers new
/updatehome <name>and/updatewarp <name>commands and wires them into the command UI. - Enables mutating stored
NamedLocationcoordinates via a new setter to support updates. - Adds new translation keys/messages (EN + zh_CN) and whitelists the new commands for the client trusted-command bypass.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
src/main/resources/assets/teleport_commands_fabric/lang/zh_cn.json |
Adds zh_CN translations for home/warp update messages and a common “[update]” button label. |
src/main/resources/assets/teleport_commands_fabric/lang/en_us.json |
Adds en_US translations for home/warp update messages and a common “[update]” button label. |
src/main/java/org/AndrewElizabeth/teleportcommandsfabric/mixin/client/ClientPlayNetworkHandlerMixin.java |
Whitelists updatehome/updatewarp as trusted commands for unattended send. |
src/main/java/org/AndrewElizabeth/teleportcommandsfabric/common/NamedLocation.java |
Makes coordinates mutable and adds setCoordinates(...) to support updating location. |
src/main/java/org/AndrewElizabeth/teleportcommandsfabric/commands/warp/warp.java |
Registers the new updatewarp command node. |
src/main/java/org/AndrewElizabeth/teleportcommandsfabric/commands/warp/WarpMutationActions.java |
Implements updateWarp mutation logic and “same location” detection. |
src/main/java/org/AndrewElizabeth/teleportcommandsfabric/commands/warp/WarpFormatter.java |
Adds an “Update” action button to warp list entries (admin-only). |
src/main/java/org/AndrewElizabeth/teleportcommandsfabric/commands/warp/WarpAdminFormatter.java |
Adds an “Update” button to the admin warp map list entries. |
src/main/java/org/AndrewElizabeth/teleportcommandsfabric/commands/home/home.java |
Registers the new updatehome command node. |
src/main/java/org/AndrewElizabeth/teleportcommandsfabric/commands/home/HomeMutationActions.java |
Implements updateHome mutation logic and “same location” detection. |
src/main/java/org/AndrewElizabeth/teleportcommandsfabric/commands/home/HomeFormatter.java |
Adds an “Update” action button to home list entries. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| Optional<NamedLocation> warpToReset = WarpCommandSupport.resolveWarpForCommand(warpName, player, false); | ||
| if (warpToReset.isPresent()) { | ||
| if (isSameLocation(player, warpToReset.get(), worldString)) { | ||
| WarpMessages.send(player, "commands.teleport_commands.warp.updateSame", ChatFormatting.AQUA); | ||
| return; | ||
| } | ||
|
|
||
| warpToReset.get().setCoordinates( |
There was a problem hiding this comment.
Local variable name warpToReset reads like a reset operation, but this method is performing an update. Renaming it (e.g., warpToUpdate / warpToMove) would make the intent clearer and align with the command name updatewarp.
| Optional<NamedLocation> warpToReset = WarpCommandSupport.resolveWarpForCommand(warpName, player, false); | |
| if (warpToReset.isPresent()) { | |
| if (isSameLocation(player, warpToReset.get(), worldString)) { | |
| WarpMessages.send(player, "commands.teleport_commands.warp.updateSame", ChatFormatting.AQUA); | |
| return; | |
| } | |
| warpToReset.get().setCoordinates( | |
| Optional<NamedLocation> warpToUpdate = WarpCommandSupport.resolveWarpForCommand(warpName, player, false); | |
| if (warpToUpdate.isPresent()) { | |
| if (isSameLocation(player, warpToUpdate.get(), worldString)) { | |
| WarpMessages.send(player, "commands.teleport_commands.warp.updateSame", ChatFormatting.AQUA); | |
| return; | |
| } | |
| warpToUpdate.get().setCoordinates( |
| MutableComponent resetButton = CommandUiSupport.translatedButton( | ||
| player, | ||
| "commands.teleport_commands.common.update", | ||
| ChatFormatting.YELLOW, | ||
| new ClickEvent.RunCommand("updatewarp " + quotedName)); | ||
|
|
||
| CommandUiSupport.appendNameLine(message, currentWarp.getName(), visibilityState, toggleButton); | ||
| CommandUiSupport.appendNameLine(message, currentWarp.getName(), visibilityState, toggleButton, resetButton); |
There was a problem hiding this comment.
Variable resetButton is wired to the updatewarp command and uses the translated label common.update, so the name is misleading. Renaming it to updateButton (or similar) will reduce confusion when maintaining the formatter.
No description provided.