From a62ab9b6843981c687153868b8106c1a4794b217 Mon Sep 17 00:00:00 2001 From: Ling Bao Date: Fri, 6 Nov 2026 21:02:55 +1100 Subject: [PATCH 1/3] feat(teleport): add permission-gated recall command (#53) Restore the live recall switch, preserve operator settings, respect teleport cancellation, and track recalled players for back. Add command, permission, configuration reload and localization regressions. Co-Authored-By: Claude Opus 5.5 --- FEATURES.md | 50 ++-- README.md | 14 ++ UAT-CHECKLIST.md | 22 +- .../essentials/commands/RecallCommand.java | 72 ++++++ .../essentials/config/EssentialsConfig.java | 5 +- .../essentials/config/RemovedConfigKeys.java | 91 +------ src/main/resources/lang/en.json | 10 +- src/main/resources/lang/zh.json | 10 +- .../UltiEssentialsRemovedConfigKeyTest.java | 118 +++++---- .../commands/RecallCommandTest.java | 233 ++++++++++++++++++ .../config/EssentialsConfigCommentsTest.java | 6 +- src/test/resources/config/config-comments.tsv | 3 +- 12 files changed, 445 insertions(+), 189 deletions(-) create mode 100644 src/main/java/com/ultikits/plugins/essentials/commands/RecallCommand.java create mode 100644 src/test/java/com/ultikits/plugins/essentials/commands/RecallCommandTest.java diff --git a/FEATURES.md b/FEATURES.md index 1dccfb6..15317f3 100644 --- a/FEATURES.md +++ b/FEATURES.md @@ -25,12 +25,12 @@ for UAT execution and issue reconciliation — the public description of these f `PlaceholderAPI#setPlaceholders`, they do not register their own expansion) and no `gate` rows (0 `@ConditionalOnConfig` sites) — all three Kinds stay in the vocabulary for cross-repository consistency even though none appears below. This module's one `scheduled` row is NOT backed by - the framework's `@Scheduled` annotation (0 sites) — see that row's own note. The six rows under + the framework's `@Scheduled` annotation (0 sites) — see that row's own note. The lifecycle rows under `## Lifecycle` are `event` rows with no `@EventHandler` site behind them, `ultiessentials.lock.protect-whole-container` is an `event` row whose behaviour runs inside every `ChestLockListener` handler rather than in one of its own, and `ultiessentials.tpa.clear-on-quit` runs in the same `PlayerQuitListener` handler as `ultiessentials.cleanup.on-quit`, so the 22 - `@EventHandler` sites in the positive control below match the other 22 `event` rows, not all 30: `/ul reload`, an unload and + `@EventHandler` sites in the positive control below count handler methods, not all 32 `event` rows: `/ul reload`, an unload and start-up are framework-invoked lifecycle steps, not commands this repository maps or config reads, so `event` is the closest-fitting Kind. - **Tier**, exactly three: `player`, `admin`, `internal`. Judged from what the feature is for, not @@ -48,7 +48,7 @@ for UAT execution and issue reconciliation — the public description of these f Kind (`config`, `event`, `gate`, `gui`, `persistence`, `scheduled`, `placeholder`) — the concept of "who this targets" does not apply to a config key or a background task the way it applies to a command. No class in this repository declares `@CmdTarget(CONSOLE)`; every command row below - is `player` (33 classes) or `both` (5 classes: `BanCommand`, `UnbanCommand`, `BanListCommand`, + is `player` (35 classes) or `both` (5 classes: `BanCommand`, `UnbanCommand`, `BanListCommand`, `TempBanCommand`, `WhitelistCommand` — all moderation commands, deliberately console-runnable). - **Permission:** the literal node string, `none`, or `n/a`, each optionally suffixed with the literal text `(requireOp=true)` (preceded by one space) when the row's class-level @@ -57,7 +57,7 @@ for UAT execution and issue reconciliation — the public description of these f `commands/` package (0 occurrences), so no row below carries the suffix. `n/a` is for every Kind that is not `command`. - **Source:** `ClassName#member` — the class and member that actually reads or applies the - feature — for every Kind, `config` included: all 78 `config` rows below cite the reading member, + feature — for every Kind, `config` included: all 79 `config` rows below cite the reading member, not merely the field declaration on the `@ConfigEntity` class (which only binds the key). - **Row order:** by section, then by ID ascending within the section. - **No manual prose:** no troubleshooting column, no explanatory paragraphs, no draft page text. A @@ -94,20 +94,20 @@ rather than an error: (naive 1) and `@ConditionalOnConfig` (naive 2), whose only occurrences are javadoc mentions in `UltiEssentials.java` — exactly the case the anchor exists to exclude. -**Positive control:** the line-start form returns `@CmdExecutor` = 38 (classes), `@CmdMapping` = -57 (formats), `@EventListener` = 12 (classes — 11 in `listener/`, 1 in `commands/BackCommand.java` +**Positive control:** the line-start form returns `@CmdExecutor` = 40 (classes), `@CmdMapping` = +59 (formats), `@EventListener` = 12 (classes — 11 in `listener/`, 1 in `commands/BackCommand.java` which is simultaneously a command executor and an event listener), `@EventHandler` = 22 (handler methods across those 12 classes; `JoinQuitListener#hideVanishedPlayers` became the 22nd with UltiKits/UltiEssentials#32), `@Scheduled` = 0, `@ConditionalOnConfig` = 0, `@ConfigEntity` = 5 -(classes), `@ConfigEntry` = 78, `@Table` = 4 (`HomeData`, `WarpData`, `BanData`, `ChestLockData`) — +(classes), `@ConfigEntry` = 79, `@Table` = 4 (`HomeData`, `WarpData`, `BanData`, `ChestLockData`) — confirmed by reading `WhitelistCommand.java` directly (6 `@CmdMapping` sites: `add `, `remove `, `list`, `on`, `off`, `status` — the largest single-class mapping count in this module) and `ChestLockListener.java` (7 `@EventHandler` sites: `onPlayerInteract`, `onBlockBreak`, `onEntityExplode`, `onBlockExplode`, `onPistonExtend`, `onPistonRetract`, `onInventoryMove` — the largest single-class handler count). `ultiessentials.whitelist.add` (`WhitelistCommand#add`) is -this module's standing positive control for the command-row count: 57 `@CmdMapping` sites, each the +this module's standing positive control for the command-row count: 59 `@CmdMapping` sites, each the Source of exactly one `command`-Kind row below, checked by identity, not merely by count — a table that -reports 38 (classes) instead of 57 (formats) is wrong. There are 58 `command` rows: the 58th, +reports 40 (classes) instead of 59 (formats) is wrong. There are 60 `command` rows: the additional, `ultiessentials.home.set-named.outcome-verified`, is a second row on `/sethome ` whose Source is `HomeService#setHome`, not a mapping (re-measured when the `@EventHandler` count above was updated; the earlier figure of 57 rows predates that row). @@ -138,8 +138,9 @@ behaviours. | ultiessentials.spawn.setlobby-writes-location-only | `/setlobby` (alias `/sethub`) writes exactly the six `lobby.location.*` settings of `config/lobby.yml` (`world`, `x`, `y`, `z`, `yaw`, `pitch`) through the framework's `saveOperatorChange` and nothing else: a comment or any other line made while the server runs stays byte for byte, while a location setting edited by hand is replaced by the command's value. When the framework refuses the write the file is unchanged, chat shows `Lobby not saved: . The lobby is unchanged; fix the file the server log names, then run /setlobby again.`, and the running lobby is restored to the values held before the command; any other failed write answers `Failed to save lobby` with the same rollback. Before UltiKits/UltiEssentials#72 the command saved the whole configuration, so a hand-edited location setting was left unwritten while chat said `Lobby set` | persistence | `/setlobby` (alias `/sethub`) | ultiessentials.lobby.set | player | admin | brief | SetLobbyCommand#setLobby, LobbyConfig#locationPaths | | ultiessentials.wild.teleport | Randomly teleport the sender within the configured min/max range of their current position, trying up to 10 candidate points and rejecting any that land on a solid ceiling/floor mismatch or on lava/water; each candidate's chunk is loaded (and, if new, generated) asynchronously, and the height lookup, the safety check and the teleport run in a main-thread task once it has loaded, so `/wild` does not stall the server tick; a player who logs out while a chunk loads is not teleported, and a search still waiting for a chunk or its main-thread check when the module unloads does nothing (UltiKits/UltiEssentials#24, fixed; earlier versions loaded every candidate chunk synchronously on the main thread); the success message names the landing block position, feet height included (UltiKits/UltiEssentials#33, fixed; earlier versions reported the floor block's height, one lower); refuses outright if `wild.min-range` >= `wild.max-range`; a second use within `features.wild.cooldown` seconds is refused by the framework's cooldown validator | command | `/wild` (alias `/rtp`) | ultiessentials.wild | player | player | brief | WildCommand#wildTeleport | | ultiessentials.back.teleport | Teleport the sender to the location recorded before their most recent teleport by one of this module's own commands (see `ultiessentials.back.track`); refuses if no location is recorded for them yet. `/back` is itself one of those teleports, so a second `/back` returns to where the first one started | command | `/back` | ultiessentials.back | player | player | brief | BackCommand#back | -| ultiessentials.back.track | Record the sender's pre-teleport location on a `PlayerTeleportEvent` (MONITOR priority, `ignoreCancelled = true`) only when one of this module's own commands started that teleport — `/home`, `/warp`, `/spawn`, `/lobby`, `/wild`, an accepted `/tpa` or `/tpahere`, and `/back` itself — marked around the teleport call by `OwnTeleports`; any other teleport is not tracked: another plugin's, a vanilla `/tp`, a portal, an ender pearl, or this module's join-time spawn teleport (UltiKits/UltiEssentials#39, fixed; earlier versions recorded every `COMMAND`- or `PLUGIN`-caused teleport, so a teleport by something else after a rejoin re-armed `/back`) | event | run `/home`, `/warp`, `/spawn`, `/lobby`, `/wild`, `/back`, or have a `/tpa`/`/tpahere` accepted | n/a | n/a | player | brief | BackCommand#onPlayerTeleport, OwnTeleports#teleport | +| ultiessentials.back.track | Record the teleported player's pre-teleport location on a `PlayerTeleportEvent` (MONITOR priority, `ignoreCancelled = true`) only when one of this module's own commands started that teleport — `/home`, `/warp`, `/spawn`, `/lobby`, `/wild`, an accepted `/tpa` or `/tpahere`, `/recall`, and `/back` itself — marked around the teleport call by `OwnTeleports`; any other teleport is not tracked: another plugin's, a vanilla `/tp`, a portal, an ender pearl, or this module's join-time spawn teleport (UltiKits/UltiEssentials#39, fixed; earlier versions recorded every `COMMAND`- or `PLUGIN`-caused teleport, so a teleport by something else after a rejoin re-armed `/back`) | event | run `/home`, `/warp`, `/spawn`, `/lobby`, `/wild`, `/back`, be recalled with `/recall`, or have a `/tpa`/`/tpahere` accepted | n/a | n/a | player | brief | BackCommand#onPlayerTeleport, OwnTeleports#teleport | | ultiessentials.back.cleanup-on-quit | Remove the quitting player's recorded back-location from the in-memory map on quit; `PlayerQuitListener#onPlayerQuit` (see `## Player Status & Utility`) performs the identical removal via `BackCommand.removePlayer(uuid)` on the SAME event, so this specific cleanup runs twice per quit — redundant but harmless, since removing an already-absent map key is a no-op | event | quit the server as any player who has a recorded back-location | n/a | n/a | internal | none | BackCommand#onPlayerQuit | +| ultiessentials.recall.summon | Immediately summon the exact-name (case-insensitive) online target to the player sender's current location and facing, across worlds, without cooldown or warmup; the sender stays still. Refuse self, disabled feature, offline/missing/vanished target (unless the sender holds `ultiessentials.hide.see`). Only a successful Bukkit teleport notifies both parties; cancellation or a false return reports failure only to the sender. The target's origin is tracked for separately permitted `/back`; completion excludes self and unseen vanished targets | command | `/recall ` | ultiessentials.recall.other | player | admin | brief | RecallCommand#recall, RecallCommand#suggest | ## Homes @@ -365,8 +366,7 @@ rather than renamed, and it prints no reload or unload line of its own. It decla refresh, `@ConditionalOnConfig` drift report — this module has 0 sites — and the framework's per-module `Module 'UltiEssentials' reloaded.` INFO line), then `onReload(ReloadReport)`, which calls `reload()` on `ScheduledCommandService`, `ScoreboardService` and `NamePrefixService` in that order -(see `## Configuration` for what each restart does) after first repeating the start-up check for -removed settings left in `config/essentials.yml` (`ultiessentials.lifecycle.removed-key-warning`), +(see `## Configuration` for what each restart does) after checking configuration availability, warning by name for any it cannot resolve rather than skipping it silently. That warning, and the unload's matching failure, cannot be produced on a stock install and are not checklist material: all four services are unconditional @@ -403,18 +403,14 @@ until someone runs the vanilla `team remove` on it. The changelog says so in bot `ConfigManager#reloadConfigs` re-initialises, in place, the same `EssentialsConfig` instance the container injected into `SpeedCommand`, which reads `features.speed.max-speed` at call time — the observable the first row below uses. The second row turns name prefixes on through a reload, the -third turns the scoreboard off through a reload, the fourth reads the warnings a removed setting left -in the file produces, the fifth unloads the module and reads whether -its repeating tasks stopped, the sixth unloads it while a player is vanished and reads that the -vanish is lifted for everyone, and the seventh states that a service which does not restart makes -the reload partial. +third turns the scoreboard off through a reload. The remaining lifecycle rows observe stopped tasks, +vanish lifted on unload, and partial reporting when a service does not restart. | ID | Feature | Kind | How to reach | Permission | Target | Tier | Manual | Source | |---|---|---|---|---|---|---|---|---| | ultiessentials.lifecycle.reload | `/ul reload UltiEssentials` re-reads this module's configuration files into the running module, so an edited value such as `features.speed.max-speed` applies to the next `/speed` without a restart; the module prints no reload line of its own. On UltiTools 6.2.5 the module's reload override replaced the framework's reload and only logged, so an edit took effect only after a restart | event | `/ul reload UltiEssentials` (framework calls `reloadSelf()`, which reloads configuration, refreshes language, reports `@ConditionalOnConfig` drift and logs its own per-module line) | n/a | n/a | admin | brief | SpeedCommand#setSpeed | | ultiessentials.lifecycle.reload-nameprefix | After `features.nameprefix.enabled` is changed from `false` to `true`, `/ul reload UltiEssentials` restarts `NamePrefixService` with the main scoreboard, so the restarted update task applies the configured prefix to every online player about 1 second after the reload and a player who joins afterwards gets it 0.5 seconds after joining, with no exception from `NamePrefixService#updatePlayer` (UltiKits/UltiEssentials#28) | event | `/ul reload UltiEssentials` after editing `features.nameprefix.enabled` to `true` in `config/essentials.yml` | n/a | n/a | admin | brief | UltiEssentials#onReload, NamePrefixService#reload | | ultiessentials.lifecycle.reload-scoreboard-off | After `features.scoreboard.enabled` is changed from `true` to `false`, `/ul reload UltiEssentials` cancels the sidebar update task and returns every player who had a sidebar to the server's main scoreboard, so the sidebar disappears and name prefixes (and any other team on the main scoreboard) become visible to those players without rejoining (UltiKits/UltiEssentials#28) | event | `/ul reload UltiEssentials` after editing `features.scoreboard.enabled` to `false` in `config/essentials.yml` | n/a | n/a | admin | brief | ScoreboardService#reload, ScoreboardService#shutdown | -| ultiessentials.lifecycle.removed-key-warning | At start-up and on every `/ul reload UltiEssentials`, log one WARN line for each setting this module has removed that is still in the operator's `config/essentials.yml` — `features.recall.enabled` (UltiKits/UltiEssentials#27) — naming the module, the file and the key and saying where the setting's job went (`UltiKits/UltiEssentials#53`, the `/recall` feature request); `features.wild.cooldown` is a live key and is never reported; a key holding an empty (null) value counts as present; a file without the removed key produces no such line; presence is read through the framework's `isPresentInFile` (UltiTools-API 6.3.0 removed the parsed-file accessor, UltiKits/UltiEssentials#68), so a file the framework could not read or parse produces no removed-key line — only the framework's own SEVERE `Cannot load config/essentials.yml` line — and a missing configuration bean produces one line saying the file was not checked rather than none | event | start the server, or run `/ul reload UltiEssentials`, with a removed key left in `plugins/UltiTools/pluginConfig/UltiEssentials/config/essentials.yml` | n/a | n/a | admin | brief | UltiEssentials#warnAboutRemovedSettings, RemovedConfigKeys#warningsFor | | ultiessentials.lifecycle.unload-tasks | `/upm uninstall UltiEssentials` stops every repeating task this module started: configured entries of `features.scheduled-commands.commands` stop being dispatched to the console, the sidebar and name-prefix update tasks stop, and a teleport warmup still counting down is cancelled rather than completed. Players who had a sidebar are returned to the server's main scoreboard and this module's name-prefix team entries are removed, although the now-empty teams stay registered. Before UltiKits/UltiEssentials#43 the module declared no `onUnregister()` hook, so all of these kept running against the uninstalled module until the server was restarted while the uninstall reported success. The one-shot delayed tasks are covered too (UltiKits/UltiEssentials#51, fixed): a pending `/tpa`/`/tpahere` request's expiry is cancelled, so neither player gets an expiry message from the uninstalled module, and a player who joined in the second before the uninstall is not put on a sidebar or into a name-prefix team afterwards, because the delayed join callbacks do nothing once their service is shut down | event | `/upm uninstall UltiEssentials` from the server console (framework calls `unregisterSelf()`, which runs `onUnregister()` and then unregisters this module's commands and listeners) | n/a | n/a | admin | brief | UltiEssentials#onUnregister, ScheduledCommandService#shutdown, ScoreboardService#shutdown, NamePrefixService#shutdown, TeleportService#shutdown, TpaService#shutdown | | ultiessentials.lifecycle.unload-reveals-vanished | `/upm uninstall UltiEssentials` first shows every player vanished with `/hide` to every other online player, using the same `UltiTools` plugin reference `/hide` used to hide them, and forgets all vanish state (including players who already left), so a reinstall starts consistent with what players see. Before the fix for UltiKits/UltiEssentials#32 the hides outlived the module, because they are recorded against the `UltiTools` Bukkit plugin, which stays enabled: a vanished player stayed hidden from the players online when they vanished, became visible to later joiners, and could not un-vanish until they relogged. The vanished player is not messaged | event | `/upm uninstall UltiEssentials` from the server console while a player is vanished | n/a | n/a | admin | brief | UltiEssentials#onUnregister, HideCommand#revealAllVanished | | ultiessentials.lifecycle.reload-partial | When one of the three services `/ul reload UltiEssentials` restarts (`ScheduledCommandService`, `ScoreboardService`, `NamePrefixService`) cannot be resolved or its `reload()` throws, the module still restarts the others, logs the failure naming the service (WARNING or SEVERE, as before), and records it in the framework's `ReloadReport` as ` could not be reached and was not restarted; …` or ` did not restart: `, so the sender's reply is `Module UltiEssentials reloaded partially; not reloaded: ` and the framework logs `Module 'UltiEssentials' reloaded partially; not reloaded: ` instead of the plain success line; a reload in which all three restart is reported as a plain success. Before this, `/ul reload UltiEssentials` replied success unconditionally (UltiKits/UltiEssentials#66, UltiKits/UltiTools-Reborn#529) | event | `/ul reload UltiEssentials` | n/a | n/a | admin | brief | UltiEssentials#onReload, UltiEssentials#reloadService | @@ -454,17 +450,17 @@ missing key or on Chinese text outside a catalogue. Exception messages thrown to ## Configuration -Every `@ConfigEntry`-annotated field across this module's five `@ConfigEntity` classes (78 keys -total: `EssentialsConfig` 59, `SpawnConfig` 8, `LobbyConfig` 6, `MotdConfig` 3, `TabBarConfig` 2 — -matching the reconciliation table's own `@ConfigEntry` count of 78 exactly; `EssentialsConfig` gained +Every `@ConfigEntry`-annotated field across this module's five `@ConfigEntity` classes (79 keys +total: `EssentialsConfig` 60, `SpawnConfig` 8, `LobbyConfig` 6, `MotdConfig` 3, `TabBarConfig` 2 — +matching the reconciliation table's own `@ConfigEntry` count of 79 exactly; `EssentialsConfig` gained `features.data-repair.enabled` with UltiKits/UltiEssentials#34 and lost `features.recall.enabled` -with UltiKits/UltiEssentials#27). Several of these keys +with UltiKits/UltiEssentials#27; #53 restores it with a real command). Several of these keys already have a behavioural row above (the various `features.*.enabled` toggles, home/warp/tpa warmups, deathpunish sub-toggles) — that row documents the *feature* the key drives, this row documents the *key* itself, at file-and-key granularity, so the reconciliation table can prove every key is accounted for without also making every behavioural row carry a `config` Kind. The last row of the table below, `ultiessentials.config.comments`, describes a behaviour of all five -files rather than a key, and is not counted among the 78. +files rather than a key, and is not counted among the 79. **Four keys were declared and shipped with a comment describing their effect, but were never read by any production code outside `EssentialsConfig` itself** (UltiKits/UltiEssentials#27). In 6.3.0 @@ -472,10 +468,7 @@ three are wired and one is removed. `features.ban.broadcast-ban` and `features.b now decide whether a ban and an unban are announced to the whole server; both default to `true`, which is what the commands always did. `features.wild.cooldown` is now `/wild`'s cooldown, bound through the framework's config-bound `@CmdCD` (UltiKits/UltiTools-Reborn#531); its default, 60, is -what the command always enforced. `features.recall.enabled` (there is no `/recall` command) was -**removed**: a copy left in an operator's file is reported by -`ultiessentials.lifecycle.removed-key-warning`, and `/recall` is recorded as a feature request, -UltiKits/UltiEssentials#53. +what the command always enforced. `features.recall.enabled` was removed in 6.3.0 while no command existed. Issue #53 restores it (default true) with the implemented staff summon. It is read at call time, applies on reload, preserves a legacy false, and is no longer reported as removed. **`/ul reload UltiEssentials` re-reads configuration values and restarts this module's scheduled-command, scoreboard and name-prefix background tasks.** Since @@ -522,6 +515,7 @@ affects only itself. | ID | Feature | Kind | How to reach | Permission | Target | Tier | Manual | Source | |---|---|---|---|---|---|---|---|---| | ultiessentials.config.essentials.features.back.enabled | Enable `/back` | config | `config/essentials.yml: features.back.enabled (default: true)` | n/a | n/a | admin | brief | BackCommand#back | +| ultiessentials.config.essentials.features.recall.enabled | Enable the staff-only `/recall ` summon; default true, existing false preserved; re-read on `/ul reload UltiEssentials` and consulted on every invocation, with no removed-key warning | config | `config/essentials.yml: features.recall.enabled (default: true)` | n/a | n/a | admin | brief | RecallCommand#recall | | ultiessentials.config.essentials.features.spawn.enabled | Enable `/spawn`, `/setspawn`, and the respawn/first-join auto-teleport listeners | config | `config/essentials.yml: features.spawn.enabled (default: true)` | n/a | n/a | admin | brief | SpawnCommand#teleportToSpawn | | ultiessentials.config.essentials.features.lobby.enabled | Enable `/lobby` and `/setlobby` | config | `config/essentials.yml: features.lobby.enabled (default: true)` | n/a | n/a | admin | brief | LobbyCommand#teleportToLobby | | ultiessentials.config.essentials.features.wild.enabled | Enable `/wild` | config | `config/essentials.yml: features.wild.enabled (default: true)` | n/a | n/a | admin | brief | WildCommand#wildTeleport | @@ -599,7 +593,7 @@ affects only itself. | ultiessentials.config.tabbar.tabbar.header | Tab-list header template, `&`-color-coded, with `%online%`/`%max%` substitution; the Java default is the header every earlier version shipped, written in the server's language at module enable and reload (`ultiessentials.lifecycle.config-text-materializer`); neither `tabbar.header` nor `tabbar.footer` carries `@NotEmpty`, and a blank value is the operator's way to show nothing and is never materialized | config | `config/tabbar.yml: tabbar.header (default: the shipped header, in the server's language)` | n/a | n/a | admin | brief | TabBarListener#updateTabBar | | ultiessentials.config.essentials.features.data-repair.enabled | Run this module's start-up repair that gives records written before UltiKits/UltiEssentials#34 was fixed the primary key they were saved without, in the JSON store; set to `false` to leave those JSON records as they are, in which case deleting or updating them keeps failing and one log line names this key. In SQLite the framework gives such records their key when it opens their tables, whatever this key says (UltiTools-API 6.3.0, UltiKits/UltiTools-Reborn#546); MySQL cannot hold them | config | `config/essentials.yml: features.data-repair.enabled (default: true)` | n/a | n/a | admin | brief | EntityIdBackfillService#run | | ultiessentials.config.tabbar.tabbar.footer | Tab-list footer template, `&`-color-coded, with `%online%`/`%max%` substitution; the Java default is the footer every earlier version shipped, written in the server's language at module enable and reload (`ultiessentials.lifecycle.config-text-materializer`); see `ultiessentials.config.tabbar.tabbar.header` for the blank semantics | config | `config/tabbar.yml: tabbar.footer (default: the shipped footer, in the server's language)` | n/a | n/a | admin | brief | TabBarListener#updateTabBar | -| ultiessentials.config.comments | The comment written above each of the 78 keys of the five configuration files comes from the module's language files and follows the server's `language`: each `@ConfigEntry(comment = "{key}")` is a single catalogue-key token `essentials.config..` (for example `essentials.config.essentials.features.back.enabled`), whose `lang/en.json` entry is the English comment (`Enable the /back command`) and whose `lang/zh.json` entry is the Chinese one the module always wrote. A fresh install under `language: en` therefore writes English comments (earlier versions wrote Chinese-only comments in every language), and the framework rewrites the comment lines of these keys in the server's current language whenever it loads or writes a file, an upgraded server's first start included; values are untouched. Only a comment the module wrote is rewritten - its catalogue text in either language, or a text an earlier release shipped and the entry registers in `@ConfigEntry(previousComments)` (release v1.0.0's shorter comment above `features.wild.cooldown`, UltiKits/UltiEssentials#73); a comment an operator wrote by hand stays byte for byte (UltiTools-API 6.3.0, maintainer decision 2026-10-04). A new Chinese-only `@ConfigEntry` comment fails the module's language guard 2 (UltiKits/UltiEssentials#67) | config | `config/essentials.yml`, `config/lobby.yml`, `config/motd.yml`, `config/spawn.yml`, `config/tabbar.yml` — the comment above each key | n/a | n/a | admin | none | EssentialsConfig, LobbyConfig, MotdConfig, SpawnConfig, TabBarConfig | +| ultiessentials.config.comments | The comment written above each of the 79 keys of the five configuration files comes from the module's language files and follows the server's `language`: each `@ConfigEntry(comment = "{key}")` is a single catalogue-key token `essentials.config..` (for example `essentials.config.essentials.features.back.enabled`), whose `lang/en.json` entry is the English comment (`Enable the /back command`) and whose `lang/zh.json` entry is the Chinese one the module always wrote. A fresh install under `language: en` therefore writes English comments (earlier versions wrote Chinese-only comments in every language), and the framework rewrites the comment lines of these keys in the server's current language whenever it loads or writes a file, an upgraded server's first start included; values are untouched. Only a comment the module wrote is rewritten - its catalogue text in either language, or a text an earlier release shipped and the entry registers in `@ConfigEntry(previousComments)` (release v1.0.0's shorter comment above `features.wild.cooldown`, UltiKits/UltiEssentials#73); a comment an operator wrote by hand stays byte for byte (UltiTools-API 6.3.0, maintainer decision 2026-10-04). A new Chinese-only `@ConfigEntry` comment fails the module's language guard 2 (UltiKits/UltiEssentials#67) | config | `config/essentials.yml`, `config/lobby.yml`, `config/motd.yml`, `config/spawn.yml`, `config/tabbar.yml` — the comment above each key | n/a | n/a | admin | none | EssentialsConfig, LobbyConfig, MotdConfig, SpawnConfig, TabBarConfig | ## Compatibility with other scoreboards diff --git a/README.md b/README.md index fb3240c..b5db080 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,7 @@ UltiEssentials 是基于 UltiTools-API 框架开发的服务器基础功能插 | 命令 | 描述 | 权限 | |------|------|------| | `/back` | 返回上一个传送位置 | `ultiessentials.back` | +| `/recall ` | Bring an online player to you / 召回在线玩家 | `ultiessentials.recall.other` | | `/spawn` | 传送到服务器出生点 | `ultiessentials.spawn.teleport` | | `/setspawn` | 设置服务器出生点 | `ultiessentials.spawn.set` | | `/lobby` `/hub` | 传送到主城 | `ultiessentials.lobby.teleport` | @@ -56,6 +57,16 @@ UltiEssentials 是基于 UltiTools-API 框架开发的服务器基础功能插 | `/wl off` | 禁用白名单 | `ultiessentials.whitelist.manage` | | `/wl status` | 查看白名单状态 | `ultiessentials.whitelist.manage` | +### Staff recall / 管理员召回 + +`/recall Traveler` immediately brings the online player named `Traveler` to your current position and facing, even from another world; your own position does not change. Use the complete username (case-insensitive), not a prefix. This is a **player-only staff command**, gated by `ultiessentials.recall.other`; `/back` or `/tpahere` access alone does not grant it. It has no self or console variant, cooldown or warmup. For a consent-based request, use `/tpahere` instead. A vanished target looks offline unless you hold `ultiessentials.hide.see`; Tab completion also hides them. Another plugin may cancel the teleport: you then see `Recall failed; the player was not teleported`, not a success. On success you see `Recalled Traveler to your location`, and Traveler is told who recalled them. The recalled player can return using `/back` if that feature and its separate permission are enabled. + +`features.recall.enabled` in `config/essentials.yml` defaults to `true` and now actually gates this command. Set it to `false` and run `/ul reload UltiEssentials` to refuse recalls. An existing `false` stays false; the module does not migrate or overwrite your choice. This key was removed in 6.3.0 when no command existed; with the implemented command it is live again and is no longer warned about as removed. A new JAR still requires a server restart. + +`/recall Traveler` 会立即把完整用户名为 `Traveler` 的在线玩家传送到你当前的位置和朝向,允许跨世界,你自己不会移动。用户名不区分大小写,但不接受名字前缀。仅玩家可执行,需要独立的 `ultiessentials.recall.other` 权限;拥有 `/back` 或 `/tpahere` 权限不代表可以召回别人。不能召回自己,控制台不可用,无冷却、无预热。需要对方同意时用 `/tpahere`。没有 `ultiessentials.hide.see` 权限时,隐身目标按离线处理,也不会出现在补全中。其他插件取消传送时只提示失败;成功时双方收到通知。被召回者另有 `/back` 权限且该功能开启时,可以返回原位。 + +`config/essentials.yml` 中的 `features.recall.enabled` 默认 `true`,现在会真正控制召回命令。改为 `false` 后执行 `/ul reload UltiEssentials` 即可禁用;旧文件中已有的 `false` 不会被覆盖。该键在 6.3.0 因命令尚不存在而删除,现在恢复为有效设置,不再报告“已移除”。更换 JAR 仍需重启。 + ### Commands that take over vanilla commands / 接管原版命令的命令 `/ban`, `/banlist` and `/scoreboard` deliberately take over the vanilla commands of the same name: `/ban` and `/banlist` work on this module's own ban records, not on the server's ban list, and `/scoreboard` toggles this module's sidebar. The vanilla commands stay reachable as `minecraft:ban`, `minecraft:banlist` and `minecraft:scoreboard`. @@ -103,6 +114,8 @@ features: # ===== 传送功能 ===== back: enabled: true # 启用 /back 返回命令 + recall: + enabled: true # Enable staff /recall; 启用管理员召回 spawn: enabled: true # 启用 /spawn 出生点命令 lobby: @@ -204,6 +217,7 @@ UltiEssentials 不提供自动回复,也不读取 `config/autoreply.yml`。关 | 权限 | 描述 | 默认 | |------|------|------| | `ultiessentials.back` | 使用 /back 命令 | 玩家 | +| `ultiessentials.recall.other` | Staff recall of another online player / 召回其他在线玩家 | Grant explicitly through your permissions plugin / 通过权限插件单独授予 | | `ultiessentials.spawn.teleport` | 传送到出生点 | 玩家 | | `ultiessentials.spawn.set` | 设置出生点 | OP | | `ultiessentials.lobby.teleport` | 传送到主城 | 玩家 | diff --git a/UAT-CHECKLIST.md b/UAT-CHECKLIST.md index 4ca511a..26ddecd 100644 --- a/UAT-CHECKLIST.md +++ b/UAT-CHECKLIST.md @@ -88,6 +88,13 @@ for real-machine verification, not user-facing documentation. | ultiessentials.back.track | `features.back.enabled: true` | 1. Run `ultiessentials.spawn.teleport`, noting the exact position beforehand, then immediately run `ultiessentials.back.teleport`. 2. Run `/back` once more | Step 1: the player returns to the EXACT position recorded before the `/spawn` teleport (not merely "near" it) — this module's own `/spawn` is tracked. Step 2: the player is back at the spawn point — `/back` is itself one of this module's teleports, so each `/back` records where it started (the EssentialsX documentation available for this release does not state this behaviour; the existing re-arm is kept and documented, UltiKits/UltiEssentials#39) | server | | | ultiessentials.back.track.neg-foreign-teleport | `language: en`; `features.back.enabled: true`; the player has joined in this session and has NOT been teleported by one of this module's commands since joining; `tp` runs from the server console | 1. From the console run `tp ~100 ~ ~` (a vanilla teleport this module did not start). 2. As the player run `/back` | Step 2: chat shows `No location to return to` and the player is not moved. Earlier versions recorded any `COMMAND`- or `PLUGIN`-caused teleport, so `/back` would have returned the player to where the `tp` started (UltiKits/UltiEssentials#39) | server | | | ultiessentials.back.cleanup-on-quit | `features.back.enabled: true`; the player has a recorded back-location (run `ultiessentials.back.track` first) | Quit and rejoin the server, then run `/back` | Chat shows the same translated `No location to return to` line as `ultiessentials.back.teleport.neg-no-location` -- the recorded location did not survive the quit | server | | +| ultiessentials.recall.summon | `language: en`; `features.recall.enabled: true`; two online players A (holding `ultiessentials.recall.other`) and B; both visible; A at a known safe position and facing, B at a different safe position in a second loaded world; B separately holds `ultiessentials.back`, with `features.back.enabled: true` | 1. Record A and B's exact positions/worlds and A's yaw/pitch. A runs `/recall `, using different letter case. 2. B runs `/back` | Step 1: B moves immediately to A's exact recorded position, world and facing, with no countdown or consent request; A stays at the same position; A sees `Recalled to your location`, B sees ` recalled you to their location`. Step 2: B returns to B's recorded original world and position. Missing either position read-back is blocked, not pass | server | | +| ultiessentials.recall.summon.neg-permission | `language: en`; recall enabled; non-operator A has `ultiessentials.back` and `ultiessentials.tpahere` but NOT `ultiessentials.recall.other`; visible online B at a distinct position | A runs `/recall `; then grant A `ultiessentials.recall.other` and repeat; revoke it afterwards | First use: framework no-permission response, B stays still and gets no recall notification. Control after grant: B moves to A and both get the success messages from `ultiessentials.recall.summon`; if the permission grant or the observation cannot be made, blocked; if granted and observed but still refused, fail | server | | +| ultiessentials.recall.summon.neg-invalid-target | `language: en`; recall enabled; A has recall permission; visible online B named `Traveler`, no player named `Trav` or `Nobody` online; A's full name differs from both | A runs `/recall Trav`, `/recall Nobody`, then `/recall ` | First two attempts each reply `Player not found or offline`; third replies `You cannot recall yourself`; neither player moves, B gets no notification | server | | +| ultiessentials.recall.summon.neg-vanish | `language: en`; recall enabled; A has recall permission but NOT `ultiessentials.hide.see`; B is online and vanished via `/hide`, a visible C is also online; all at distinguishable positions | 1. A completes `/recall `, then runs `/recall `. 2. Grant A `ultiessentials.hide.see`, complete again and run recall again. 3. Revoke that grant, un-vanish B | Step 1: completion lists C but neither A nor B; recall says `Player not found or offline`, B stays still and gets no notification. Step 2: completion lists B and C but not A; B moves to A and both get success messages. If C never appears, completion observations are blocked, not pass | java-client | | +| ultiessentials.recall.summon.neg-cancelled | `language: en`; recall enabled; A has recall permission; visible B at a different position; a test-only Bukkit listener installed for this fixture cancels B's PlayerTeleportEvent, and event observation confirms it ran; B has no prior tracked teleport this session, holds back permission and back is enabled | A runs `/recall `, then B runs `/back`; remove the test-only listener afterwards | Cancellation observed; B does not move; A sees `Recall failed; the player was not teleported`; B receives no recall-success notification, and `/back` says `No location to return to`. If no cancellation-capable fixture or event read-back exists, blocked, not pass (unit counterpart: RecallCommandTest#cancelledBukkitEventHasNoSuccessOrBackRecord) | server | | +| ultiessentials.recall.summon.neg-console | `language: en`; recall enabled; online B; run from server console | Console runs `recall ` | Framework refuses the player-only command; B does not move and receives no recall notification | server | | +| ultiessentials.config.essentials.features.recall.enabled | `language: en`; A has recall permission; visible online B at a distinct position; existing `config/essentials.yml` has `features.recall.enabled: false` and an operator comment on that line; config backed up before this row | 1. Restart; A runs recall; inspect the file and start log. 2. Change only recall enabled to true, run `ul reload UltiEssentials`, and A runs recall again. 3. Move B away, set false, reload, retry; restore backup | Step 1: `This feature is disabled`, no movement/target notification; file keeps false and the operator comment; no recall `has no effect` warning. Step 2: B moves to A with both success messages. Step 3: disabled reply, B stays at its new position, no target notification and no removed-key warning. If step 2 is observed but does not succeed, fail; unavailable observations are blocked, not pass | server | | ## Homes @@ -285,9 +292,7 @@ to the sender. This module's main config file on a server is `features.nameprefix.enabled` on through a reload, which restarts `NamePrefixService` against the re-read value. The third row turns `features.scoreboard.enabled` off through a reload, which must return players to the main scoreboard. The fourth row reads that a reload in which every service -restarts is replied to as a plain success, not as a partial reload. The fifth row leaves two settings -this module removed in its file and reads the start-up warning they produce, then removes them and -reads that a reload produces none; the sixth puts one back and reads the warning again after a reload. Name-prefix teams live on the server's main scoreboard, which the vanilla console +restarts is replied to as a plain success, not as a partial reload. The restored recall switch is exercised in the recall rows; it no longer produces a removed-key warning. Name-prefix teams live on the server's main scoreboard, which the vanilla console command `team list` reads: `NamePrefixService` names each player's team `up_` followed by the first 8 characters of that player's UUID, and keeps the team registered (only its entry is removed) when the player quits, when name prefixes are turned off, or when the module is unloaded. @@ -307,8 +312,6 @@ then reads whether they are visible to everyone after it. | ultiessentials.lifecycle.reload-nameprefix | `language: en` in `plugins/UltiTools/config.yml`; `UltiEssentials` loaded; in `plugins/UltiTools/pluginConfig/UltiEssentials/config/essentials.yml`, BEFORE the server's last restart: `features.nameprefix.enabled: false` (shipped default), `features.nameprefix.prefix-format: "&7[UAT] "` (NOT the shipped default: a literal with no placeholder, so the prefix depends on neither Vault nor PlaceholderAPI), `features.nameprefix.suffix-format: ""` (shipped default) and `features.scoreboard.enabled: false` (NOT the shipped `true` — same reason as `ultiessentials.nameprefix.on-join`: a sidebar moves the player off the main scoreboard the prefix team is on); before that restart, `team list` from the console listed no team whose name starts with `up_` (remove any left from an earlier run with `team remove `); two accounts, A online and B offline; `/ul` and `team` run from the server console | 1. From the console run `team list`, and as A open the tab list. 2. Edit `features.nameprefix.enabled` to `true` in that `essentials.yml` and save; from the console, on the SAME running server (no restart), run `ul reload UltiEssentials`. 3. Wait 2 seconds; from the console run `team list`, then `team list `; as A open the tab list. 4. Join as B and wait 1 second; from the console run `team list`, then `team list` on each `up_` team; as A open the tab list; read the console output since step 2. 5. Cleanup: set `features.nameprefix.enabled: false`, `features.nameprefix.prefix-format` back to its shipped default and `features.scoreboard.enabled: true`, save, run `ul reload UltiEssentials`, then run `team list` and `team remove` on each `up_` team it shows. | Step 1: `team list` shows no team whose name starts with `up_`, and A's tab-list name has no `[UAT]` prefix; if an `up_` team exists or A carries `[UAT]`, name prefixes were not off at boot: record the row `blocked`, never `pass`. Step 2: the console shows `Module 'UltiEssentials' reloaded.` and no exception stack trace. Step 3: `team list` shows exactly one `up_` team and listing it names A as its only member; A's tab-list name reads `[UAT] ` in gray followed by A's name — the prefix was applied by reload, without a restart. Step 4: `team list` shows exactly two `up_` teams, one naming A and one naming B as its only member; A's tab list shows both A and B with the gray `[UAT] ` prefix; the console shows no `NullPointerException` and no stack trace naming `NamePrefixService` since step 2. Step 5: after the cleanup reload, listing each `up_` team shows no members, and `team list` then shows no `up_` team | java-client | | | ultiessentials.lifecycle.reload-scoreboard-off | `language: en` in `plugins/UltiTools/config.yml`; `UltiEssentials` loaded; in `plugins/UltiTools/pluginConfig/UltiEssentials/config/essentials.yml`, BEFORE the server's last restart: `features.nameprefix.enabled: true` (NOT the shipped `false`), `features.nameprefix.prefix-format: "&7[UAT] "` (NOT the shipped default: a literal with no placeholder), `features.nameprefix.suffix-format: ""`, and `features.scoreboard.enabled: true` and `features.scoreboard.auto-enable: true` (both shipped defaults); two accounts A and B, each joined AFTER that restart and online for at least 5 seconds (so each has a name-prefix team and, 1 second after joining, a sidebar); `/ul`, `team` and `minecraft:scoreboard` run from the server console; before step 1, from the console, `minecraft:scoreboard objectives add uatlist dummy`, `minecraft:scoreboard objectives setdisplay list uatlist`, `minecraft:scoreboard players set uatlist 7` and `minecraft:scoreboard players set uatlist 7` were run (a tab-list score that exists only on the server's main scoreboard) | 1. As B, look at the screen and open the tab list; from the console run `team list`, then `team list` on each `up_` team it shows. 2. Edit `features.scoreboard.enabled` to `false` in that `essentials.yml` and save; from the console, on the SAME running server (no restart), run `ul reload UltiEssentials`. 3. Without either account rejoining, wait 2 seconds; as B look at the screen and open the tab list; from the console run `team list` on each `up_` team. 4. Cleanup: from the console run `minecraft:scoreboard objectives remove uatlist`; set `features.scoreboard.enabled: true`, `features.nameprefix.enabled: false` and `features.nameprefix.prefix-format` back to its shipped default, save, run `ul reload UltiEssentials`, then run `team list` and `team remove` on each `up_` team it shows. | Step 1: B sees the sidebar, titled `Server Info` at the shipped `features.scoreboard.title`, written into the file in English (or the configured title); `team list` shows two `up_` teams, one naming A and one naming B as its only member; B's tab list shows A and B WITH the gray `[UAT] ` prefix (the main scoreboard's teams are copied onto the sidebar's private scoreboard, UltiKits/UltiEssentials#40) and WITHOUT the `7` score, which exists only on the main scoreboard. If B has no sidebar, if no `up_` team names A or B, or if B's tab list already shows `7`, the starting state is wrong and step 3 would prove nothing: record the row `blocked`, never `pass`. Step 2: the console shows `Module 'UltiEssentials' reloaded.` and no exception stack trace. Step 3: B's sidebar is gone, and B's tab list now shows both A and B with the gray `[UAT] ` prefix AND the `7` score although neither account rejoined — the score exists only on the main scoreboard, so B is back on it; each `up_` team still names its player. Step 4: after the cleanup reload, listing each `up_` team shows no members, and `team list` then shows no `up_` team | java-client | | | ultiessentials.lifecycle.reload-partial | `language: en` in `plugins/UltiTools/config.yml`; `UltiEssentials` loaded; the server console, or `logs/latest.log`, is readable | 1. Run `ul reload UltiEssentials` from the console and read the reply and every line the reload logs. | Step 1: the reply is `Module UltiEssentials has been reloaded` and the log carries `Module 'UltiEssentials' reloaded.`; NO line contains `reloaded partially`, `did not restart` or `could not be reached` — a reload in which all three services restart is not reported as partial (the control). This row covers only that control. The partial reply itself (`Module UltiEssentials reloaded partially; not reloaded: did not restart: `) needs a service whose restart throws or cannot be resolved, which a stock install cannot produce — all three are unconditional `@Service` beans and their `reload()` bodies catch per-entry and per-player failures themselves — so it is held by `UltiEssentialsServiceReloadTest` (`theFrameworkReloadReportsTheFailedServiceAsPartial`, through the framework's own `reloadWithReport()`; `throwingServiceDoesNotStopTheOthers`, `throwingMiddleServiceDoesNotStopTheOthers`, `unresolvableServiceIsReportedOnReload`) (UltiKits/UltiEssentials#66) | server | | -| ultiessentials.lifecycle.removed-key-warning | `UltiEssentials` loaded and started at least once, so `plugins/UltiTools/pluginConfig/UltiEssentials/config/essentials.yml` exists; the server console, or `logs/latest.log`, is readable | 1. Stop the server. In `plugins/UltiTools/pluginConfig/UltiEssentials/config/essentials.yml` set `cooldown: 5` in the existing `features:` → `wild:` section, and add a `recall:` section with `enabled: false` under `features:`, indented like the file's other sections. Start the server and read every console line logged while `UltiEssentials` enables. 2. Delete the `recall:` section again, set `cooldown` back to `60`, save, run `ul reload UltiEssentials` from the console, and read every console line the reload logs. | Step 1: exactly one WARN line from this module mentions a removed setting — it contains `'features.recall.enabled' in config/essentials.yml has no effect` and `UltiKits/UltiEssentials#53`; NO line calls `features.wild.cooldown` removed or without effect, because it is a live key (the control that the check lists only removed keys); the module still enables. If the recall line does not appear, record `failed`, not `passed`: the positive half is what makes step 2 mean anything. Step 2: the reload logs the framework's `Module 'UltiEssentials' reloaded.` line and NO line containing `has no effect` — the warning follows the file, it is not printed unconditionally (UltiKits/UltiEssentials#27) | server | | -| ultiessentials.lifecycle.removed-key-warning.reload-restored | `language: en` in `plugins/UltiTools/config.yml`; `UltiEssentials` loaded and started at least once, so `plugins/UltiTools/pluginConfig/UltiEssentials/config/essentials.yml` exists and holds no `recall:` section; the server console, or `logs/latest.log`, is readable | 1. Stop the server. In `config/essentials.yml` add a `recall:` section with `enabled: false` under `features:`, indented like the file's other sections. Start the server and read every console line logged while `UltiEssentials` enables. 2. Without changing the file, run `ul reload UltiEssentials` from the console and read every line the reload logs. 3. Delete the `recall:` section, save, run `ul reload UltiEssentials` again and read every line it logs. | Step 1: exactly one WARN line from this module contains `'features.recall.enabled' in config/essentials.yml has no effect` and `UltiKits/UltiEssentials#53`, and the module enables (no `NoSuchMethodError` or refusal naming `UltiEssentials` — on UltiTools-API 6.3.0 the build before UltiKits/UltiEssentials#68 is refused at load). Step 2: the reload logs that same WARN line once more, and the framework's `Module 'UltiEssentials' reloaded.` line. If step 1 or step 2 shows no recall line, record `failed`: the positive half is what makes step 3 mean anything. Step 3: the reload logs `Module 'UltiEssentials' reloaded.` and NO line containing `has no effect` (UltiKits/UltiEssentials#68) | server | | | ultiessentials.lifecycle.unload-tasks | `language: en` in `plugins/UltiTools/config.yml`; `UltiEssentials` loaded; a copy of this module's JAR kept OUTSIDE the server directory before this row runs, because the uninstall deletes it from `plugins/UltiTools/plugins/` and the cleanup step puts it back; in `plugins/UltiTools/pluginConfig/UltiEssentials/config/essentials.yml`, BEFORE the server's last restart: `features.scheduled-commands.enabled: true` (NOT the shipped `false`), `features.scheduled-commands.commands` set to the single entry `20:say unload-check tick` (NOT the shipped default: a 20-second interval so three intervals fit inside this row's observation window, and a marker string no other plugin emits), `features.scoreboard.enabled: true` and `features.scoreboard.auto-enable: true` (both shipped defaults), `features.nameprefix.enabled: true` (NOT the shipped `false`), `features.nameprefix.prefix-format: "&7[UAT] "` (NOT the shipped default: a literal with no placeholder, so the prefix depends on neither Vault nor PlaceholderAPI) and `features.nameprefix.suffix-format: ""`; one account A, joined AFTER that restart and online for at least 5 seconds, so it has both a sidebar and a name-prefix team; `/upm` and `team` run from the server console (both require op) | 1. From the console run `team list`, then `team list` on the `up_` team it shows; as A, look at the screen; read the console for the next 45 seconds. 2. From the console run `upm uninstall UltiEssentials`. 3. Without restarting the server, wait 60 seconds; read the console output since step 2; as A, look at the screen; from the console run `team list`, then `team list` on each `up_` team it shows. 4. Cleanup: stop the server, copy the module JAR back into `plugins/UltiTools/plugins/`, set `features.scheduled-commands.enabled`, `features.scheduled-commands.commands`, `features.nameprefix.enabled` and `features.nameprefix.prefix-format` back to their shipped values, start the server, then from the console run `team list` and `team remove` on each `up_` team it shows. | Step 1: `team list` shows exactly one `up_` team and listing it names A as its only member; A sees the sidebar, titled `Server Info` at the shipped `features.scoreboard.title`, written into the file in English (or the configured title); the console prints `unload-check tick` at least twice during the 45 seconds. If any one of those three is missing, that task was not running and step 3 would prove nothing: record the row `blocked`, never `pass`. Step 2: the console replies that the module was uninstalled, and prints no exception stack trace. Step 3: NO further `unload-check tick` line has appeared since step 2, although three 20-second intervals have passed; A's sidebar is gone; the `up_` team is still listed and listing it now shows no members. Before UltiKits/UltiEssentials#43 all three kept running against the uninstalled module until the server was restarted — `unload-check tick` every 20 seconds, A's sidebar still refreshing, and A still a member of the team. Step 4: after the restart, `team list` shows no `up_` team | java-client | | | ultiessentials.lifecycle.unload-teleport-warmup | `language: en` in `plugins/UltiTools/config.yml`; `UltiEssentials` loaded; a copy of this module's JAR kept OUTSIDE the server directory, for the same reason as `ultiessentials.lifecycle.unload-tasks`; in `plugins/UltiTools/pluginConfig/UltiEssentials/config/essentials.yml`, BEFORE the server's last restart: `features.home.enabled: true` and `features.home.cancel-on-move: true` (both shipped defaults) and `features.home.teleport-warmup: 45` (NOT the shipped `3`: a three-second warmup leaves no window to run the uninstall while the countdown is still running; 45 is inside the key's `0..60` range); one account A, online, holding `ultiessentials.home` and NOT holding `ultiessentials.home.nowarmup` (that permission skips the warmup entirely, and then this row has nothing to observe), with one home already set (see `ultiessentials.home.set-default`); `/upm` runs from the server console | 1. As A, move at least 100 blocks away from that home and write down A's coordinates from the debug screen (F3). 2. As A, run `/home`, then watch chat for 5 seconds without moving. 3. Within the next 20 seconds, from the server console run `upm uninstall UltiEssentials`. 4. Without moving and without restarting the server, wait 60 seconds, then read A's chat and A's coordinates from the debug screen. 5. Cleanup: stop the server, copy the module JAR back into `plugins/UltiTools/plugins/`, set `features.home.teleport-warmup` back to `3`, and start the server. | Step 2: a countdown line appears in A's chat about once a second and its number decreases; A has not moved. Under `language: en` the line reads `Teleporting in s, please do not move...` (yellow, `essentials.teleport.warmup`); read its NUMBER. If no countdown line appears, the warmup did not start and step 4 would prove nothing: record the row `blocked`, never `pass`. Step 3: the console replies that the module was uninstalled, and prints no exception stack trace. Step 4: no further countdown line and no teleport line appear in A's chat, and A's coordinates are the ones written down in step 1 — A was NOT moved to the home. Before UltiKits/UltiEssentials#43 the countdown carried on after the uninstall and teleported A to the home when it reached zero | java-client | | | ultiessentials.lifecycle.unload-reveals-vanished | `language: en` in `plugins/UltiTools/config.yml`; `UltiEssentials` loaded; a copy of this module's JAR kept OUTSIDE the server directory, for the same reason as `ultiessentials.lifecycle.unload-tasks`; `features.hide.enabled: true` (shipped default); a first online player holding `ultiessentials.hide`; a second online player who does NOT hold `ultiessentials.hide.see`; a third player, also without it, who is offline | 1. The first player runs `/hide`, as in `ultiessentials.hide.toggle`; the second player opens the tab list. 2. From the server console run `upm uninstall UltiEssentials`. 3. The second player opens the tab list and looks at the first player's position; then the third player joins and does the same. 4. Cleanup: put the JAR back into `plugins/UltiTools/plugins/` and restart the server. | Step 1: the first player is absent from the second player's tab list — the control that the vanish took effect and that the tab list is being read; if the first player is still listed, record the row `blocked`. Step 3: the first player is listed in, and visible to, the second player again, and is listed for the third player too. Before the fix for UltiKits/UltiEssentials#32 the second player still could not see the first after the uninstall while the third player could | java-client | | @@ -335,8 +338,8 @@ then reads whether they are visible to everyone after it. ## Configuration One row per `@ConfigEntity` class (the config-per-file rule), not per key: `essentials.yml` -(59 keys), `spawn.yml` (8 keys), `lobby.yml` (6 keys), `motd.yml` (3 keys), `tabbar.yml` (2 keys) -— 78 keys total. `FEATURES.md`'s `## Configuration` heading carries the same two numbers and is +(60 keys), `spawn.yml` (8 keys), `lobby.yml` (6 keys), `motd.yml` (3 keys), `tabbar.yml` (2 keys) +— 79 keys total. `FEATURES.md`'s `## Configuration` heading carries the same two numbers and is the authority for them: reconcile against it rather than trusting the figures here, which went stale once already when `features.data-repair.enabled` was added and left this row telling testers to confirm 59 of 60 keys — a count that passes while the newly added, data-mutating safety switch @@ -347,12 +350,11 @@ these files as having no observable effect: of the four it used to (UltiKits/Ult the two `/ban`/`/unban` broadcast switches are now read and are exercised by `ultiessentials.ban.ban.neg-broadcast-off` and `ultiessentials.ban.unban.neg-broadcast-off`, `features.wild.cooldown` is now `/wild`'s cooldown and is exercised by the -`ultiessentials.wild.teleport.neg-cooldown-*` rows, and `features.recall.enabled` was removed — the -`essentials-yml` row below checks that it does not appear in a fresh file. +`ultiessentials.wild.teleport.neg-cooldown-*` rows, and `features.recall.enabled`, removed in 6.3.0, is restored with the implemented staff summon (#53). The `essentials-yml` row checks its live default true. | ID | Preconditions | Steps | Expected | Layer | Covers | |---|---|---|---|---|---| -| ultiessentials.config.essentials-yml | Fresh `config/essentials.yml` at its shipped default | Load the file; confirm all 59 keys listed under `FEATURES.md`'s `## Configuration` section are present at their documented defaults (including `features.wild.cooldown: 60`), and that `features.recall.enabled`, removed in 6.3.0, does not appear in the file (UltiKits/UltiEssentials#27); then set `features.heal.enabled: false` (default true), restart, and confirm `ultiessentials.heal.self` (see `## Player Status & Utility`) now shows the translated `This feature is disabled` line (`HealCommand.java:25`) instead of healing; separately set `features.home.default-max-homes: 1` (default 3) and confirm a second `/sethome` attempt now hits the limit at count 1, not 3. | All 59 keys present at their documented defaults, and the removed key absent, before any change; after the changes, `/heal` is refused while disabled, and the home limit is enforced at the new, lower value | protocol | | +| ultiessentials.config.essentials-yml | Fresh `config/essentials.yml` at its shipped default | Load the file; confirm all 60 keys listed under `FEATURES.md`'s `## Configuration` section are present at their documented defaults (including `features.wild.cooldown: 60`), including the restored `features.recall.enabled: true` (#53); then set `features.heal.enabled: false` (default true), restart, and confirm `ultiessentials.heal.self` (see `## Player Status & Utility`) now shows the translated `This feature is disabled` line (`HealCommand.java:25`) instead of healing; separately set `features.home.default-max-homes: 1` (default 3) and confirm a second `/sethome` attempt now hits the limit at count 1, not 3. | All 60 keys present at their documented defaults, including recall true, before any change; after the changes, `/heal` is refused while disabled, and the home limit is enforced at the new, lower value | protocol | | | ultiessentials.config.spawn-yml | Fresh `config/spawn.yml` at its shipped default | Load the file; confirm all 8 keys are present at their documented defaults; then set `spawn.location.x: 100` (default 0.0), restart, and confirm `/spawn` now teleports to X=100 rather than X=0 | All 8 keys present at their documented defaults before the change; after the change, `/spawn` teleports to the new X coordinate | server | | | ultiessentials.config.lobby-yml | Fresh `config/lobby.yml` at its shipped default | Load the file; confirm all 6 keys are present at their documented defaults; then set `lobby.location.y: 100` (default 64.0), restart, and confirm `/lobby` now teleports to Y=100 | All 6 keys present at their documented defaults before the change; after the change, `/lobby` teleports to the new Y coordinate | server | | | ultiessentials.config.motd-yml | Fresh `config/motd.yml` at its shipped default | Load the file; confirm all 3 keys are present at their documented defaults; then set `motd.line1` to a distinguishable value, restart, and ping the server's status | All 3 keys present at their documented defaults before the change; the server-list MOTD's first line shows the new, distinguishable value | os-input | | diff --git a/src/main/java/com/ultikits/plugins/essentials/commands/RecallCommand.java b/src/main/java/com/ultikits/plugins/essentials/commands/RecallCommand.java new file mode 100644 index 0000000..bb4f2ae --- /dev/null +++ b/src/main/java/com/ultikits/plugins/essentials/commands/RecallCommand.java @@ -0,0 +1,72 @@ +package com.ultikits.plugins.essentials.commands; + +import com.ultikits.plugins.essentials.config.EssentialsConfig; +import com.ultikits.plugins.essentials.service.OwnTeleports; +import com.ultikits.ultitools.annotations.I18n; +import com.ultikits.ultitools.annotations.command.CmdExecutor; +import com.ultikits.ultitools.annotations.command.CmdMapping; +import com.ultikits.ultitools.annotations.command.CmdParam; +import com.ultikits.ultitools.annotations.command.CmdSender; +import com.ultikits.ultitools.annotations.command.CmdTarget; +import org.bukkit.Bukkit; +import org.bukkit.command.Command; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import java.util.Collections; +import java.util.List; +import java.util.stream.Collectors; + +/** + * Immediate staff summon, not a return-location or consent-request command. + * Uses exact online names and respects Bukkit teleport cancellation; the summoned player can + * return with the separately permitted /back command. No cooldown, warmup or cross-world limit. + */ +@CmdTarget(CmdTarget.CmdTargetType.PLAYER) +@CmdExecutor(alias = {"recall"}, permission = "ultiessentials.recall.other", description = "essentials.command.recall.description") +@I18n("recall.description") +public class RecallCommand extends BaseEssentialsCommand { + private final EssentialsConfig config; + + public RecallCommand(EssentialsConfig config) { + this.config = config; + } + + @CmdMapping(format = "") + public void recall(@CmdSender Player sender, @CmdParam("player") String playerName) { + if (!config.isRecallEnabled()) { + sender.sendMessage(i18n("essentials.error.feature_disabled")); + return; + } + Player target = Bukkit.getPlayerExact(playerName); + if (target == null || !target.isOnline() || !HideCommand.canSee(sender, target)) { + sender.sendMessage(i18n("essentials.error.player_not_found_or_offline")); + return; + } + if (target.getUniqueId().equals(sender.getUniqueId())) { + sender.sendMessage(i18n("essentials.recall.self")); + return; + } + if (!OwnTeleports.teleport(target, sender.getLocation())) { + sender.sendMessage(i18n("essentials.recall.failed")); + return; + } + sender.sendMessage(String.format(i18n("essentials.recall.success"), target.getName())); + target.sendMessage(String.format(i18n("essentials.recall.target"), sender.getName())); + } + + @Override + protected void handleHelp(CommandSender sender) { + sender.sendMessage(i18n("essentials.help.recall")); + } + + @Override + protected List suggest(Player player, Command command, String[] args) { + if (args.length != 1) { + return Collections.emptyList(); + } + return suggestOnlinePlayers(player, args[0]).stream() + .filter(name -> !name.equalsIgnoreCase(player.getName())) + .collect(Collectors.toList()); + } +} diff --git a/src/main/java/com/ultikits/plugins/essentials/config/EssentialsConfig.java b/src/main/java/com/ultikits/plugins/essentials/config/EssentialsConfig.java index e809b30..0485490 100644 --- a/src/main/java/com/ultikits/plugins/essentials/config/EssentialsConfig.java +++ b/src/main/java/com/ultikits/plugins/essentials/config/EssentialsConfig.java @@ -56,8 +56,9 @@ public class EssentialsConfig extends AbstractConfigEntity { previousComments = {"随机传送冷却时间(秒)"}) private int wildCooldown = 60; - // features.recall.enabled was removed in 6.3.0: there is no /recall command. A copy left in an - // operator's file is reported by RemovedConfigKeys (UltiKits/UltiEssentials#27). + // Restored with the implemented staff summon (#53); an operator's existing false is preserved. + @ConfigEntry(path = "features.recall.enabled", comment = "{essentials.config.essentials.features.recall.enabled}") + private boolean recallEnabled = true; // ============ 玩家状态功能 ============ @ConfigEntry(path = "features.fly.enabled", comment = "{essentials.config.essentials.features.fly.enabled}") diff --git a/src/main/java/com/ultikits/plugins/essentials/config/RemovedConfigKeys.java b/src/main/java/com/ultikits/plugins/essentials/config/RemovedConfigKeys.java index 8ac615b..682c6ae 100644 --- a/src/main/java/com/ultikits/plugins/essentials/config/RemovedConfigKeys.java +++ b/src/main/java/com/ultikits/plugins/essentials/config/RemovedConfigKeys.java @@ -2,102 +2,31 @@ import com.ultikits.ultitools.abstracts.UltiToolsPlugin; -import java.util.ArrayList; import java.util.Collections; import java.util.List; /** - * Settings this module used to declare in {@code config/essentials.yml} and no longer reads, and the - * warning that tells an operator whose file still holds one. - *

- * Why a module needs this at all. Deleting a configuration field removes the key from the - * code, not from anybody's disk. The framework writes a missing key's declared default into the - * operator's file on first load and never deletes a key it no longer declares - * ({@code AbstractConfigEntity#init}), so every server that has run this module still has the keys - * below in its file, carrying whatever value its operator last set. Without this warning an edited - * value would go on looking like a setting. - *

- * Each line names the module, the file and the key, and says where the setting's job went, because - * "this does nothing" without "here is what does" is only half of what the operator has to act on. - *

- * The check is scoped to an explicit list rather than derived by comparing the file against the - * declared fields: an unknown key in the file is not necessarily a key this module ever had (a typo, - * a hand-written note, another tool's key), and reporting all of them would bury the real removals. - *

- * 本模块已删除、但仍可能留在运维 {@code config/essentials.yml} 中的配置项,以及提示运维的警告。 + * Compatibility entry point for the module's removed-setting check. + * The only formerly removed key, features.recall.enabled, is live again with #53. There are + * currently no removed settings to warn about; neither recall nor wild cooldown may be reported + * as having no effect. Retains the existing method and missing-configuration diagnostic. */ public final class RemovedConfigKeys { - - /** The module name each warning names, matching this module's runtime name. */ - private static final String MODULE = "UltiEssentials"; - - /** The file every key below lived in; used when the configuration bean is missing altogether. */ - private static final String FILE = "config/essentials.yml"; - - /** - * One entry per removed key, the key path as it appears in the file; where its job went is - * {@link #reason}. - *

- * {@code features.wild.cooldown} is deliberately absent: it is a live key, bound to - * {@code /wild}'s cooldown through the framework's config-bound {@code @CmdCD} - * (UltiKits/UltiTools-Reborn#531), and reporting it here would tell operators to delete a - * setting that works. - */ - private static final String[] REMOVED = { - "features.recall.enabled", - }; - - /** - * Where a removed key's job went, in the server's language; completes the sentence - * "... and can be deleted from the file -- %s.". One literal key per removed setting, so the - * language guard checks each of them. - */ - private static String reason(String key, UltiToolsPlugin plugin) { - if ("features.recall.enabled".equals(key)) { - return plugin.i18n("essentials.warn.removed.recall"); - } - throw new IllegalStateException("no reason text for removed key " + key); - } - private RemovedConfigKeys() { } /** - * Returns one warning per removed key that is still present in the operator's file, in the - * order the keys are listed above; an empty list when there is none. - *

- * Asks the framework whether each removed key is in the file through - * {@code AbstractConfigEntity#isPresentInFile(String)}, which answers from the file as it was last - * loaded -- including keys the entity no longer declares, which is exactly what a residual key is, - * and a key holding an explicit null. A fresh install has none of them, so a clean server gets an - * empty list. UltiTools-API 6.3.0 removed the parsed-file accessor this method used to read - * (UltiKits/UltiEssentials#68). - *

- * A file the framework could not read or parse reports no key present: the framework has already - * logged at SEVERE that it could not load the file and will not overwrite it, and repeating a - * removed-key warning for a file nobody could read would be a guess. - *

- * A configuration bean that is missing altogether yields a warning saying the file was not checked - * rather than an empty list: a check that silently does nothing and a server with no residual key - * would otherwise look the same in the log. + * Returns no removed-setting warnings for a loaded configuration. * - * @param config the module's configuration after the framework has loaded it; may be null - * @param plugin the module, whose language catalogue gives the warnings their text - * @return the warnings to log, never null + * @param config the loaded configuration, or null when it could not be resolved + * @param plugin the module providing the diagnostic's translation + * @return an empty list, or the existing missing-configuration warning */ public static List warningsFor(EssentialsConfig config, UltiToolsPlugin plugin) { if (config == null) { return Collections.singletonList(String.format(plugin.i18n("essentials.warn.removed_unreadable"), - MODULE, FILE)); - } - String file = config.getConfigFilePath(); - List warnings = new ArrayList<>(); - for (String removed : REMOVED) { - if (config.isPresentInFile(removed)) { - warnings.add(String.format(plugin.i18n("essentials.warn.removed_key"), MODULE, removed, file, - reason(removed, plugin))); - } + "UltiEssentials", "config/essentials.yml")); } - return warnings; + return Collections.emptyList(); } } diff --git a/src/main/resources/lang/en.json b/src/main/resources/lang/en.json index e9da7ca..fcc38b0 100644 --- a/src/main/resources/lang/en.json +++ b/src/main/resources/lang/en.json @@ -7,6 +7,14 @@ "essentials.teleport.success_warmup": "§aTeleport successful!", + "essentials.command.recall.description": "Bring an online player to your location", + "essentials.help.recall": "Usage: /recall - bring an online player to you", + "essentials.recall.self": "You cannot recall yourself", + "essentials.recall.failed": "Recall failed; the player was not teleported", + "essentials.recall.success": "Recalled %s to your location", + "essentials.recall.target": "%s recalled you to their location", + "essentials.config.essentials.features.recall.enabled": "Enable /recall to bring an online player to you (requires ultiessentials.recall.other)", + "essentials.back.no_location": "No location to return to", "essentials.back.success": "Teleported to previous location", @@ -271,9 +279,7 @@ "essentials.command.whitelist.description": "Manage the whitelist", "essentials.command.wild.description": "Random teleport", "essentials.help.wild": "Use /wild to teleport to a random place in the wild", - "essentials.warn.removed.recall": "this module has no /recall command, so the setting never switched anything; the command is recorded as a feature request in UltiKits/UltiEssentials#53 (UltiKits/UltiEssentials#27)", "essentials.warn.removed_unreadable": "%s: could not read %s, so it was not checked for settings this module has removed (UltiKits/UltiEssentials#27)", - "essentials.warn.removed_key": "%s: '%s' in %s has no effect and can be deleted from the file -- %s.", "essentials.lock.refusal_open": "§cThis container is locked by §f%s", "essentials.lock.refusal_break": "§cThis container is locked by §f%s§c and cannot be broken", "essentials.deathpunish.prefix": "Death penalty:", diff --git a/src/main/resources/lang/zh.json b/src/main/resources/lang/zh.json index 1554e01..2283da3 100644 --- a/src/main/resources/lang/zh.json +++ b/src/main/resources/lang/zh.json @@ -7,6 +7,14 @@ "essentials.teleport.success_warmup": "§a传送成功!", + "essentials.command.recall.description": "将在线玩家召回到你的位置", + "essentials.help.recall": "用法:/recall <玩家> - 将在线玩家召回到你身边", + "essentials.recall.self": "不能召回你自己", + "essentials.recall.failed": "召回失败;玩家未被传送", + "essentials.recall.success": "已将 %s 召回到你的位置", + "essentials.recall.target": "%s 将你召回到了其位置", + "essentials.config.essentials.features.recall.enabled": "启用 /recall 将在线玩家召回到你身边(需要 ultiessentials.recall.other 权限)", + "essentials.back.no_location": "没有可返回的位置", "essentials.back.success": "已传送到上一个位置", @@ -271,9 +279,7 @@ "essentials.command.whitelist.description": "白名单管理", "essentials.command.wild.description": "随机传送", "essentials.help.wild": "使用 /wild 随机传送到野外", - "essentials.warn.removed.recall": "本模块没有 /recall 命令,所以该设置从未开关过任何东西;该命令已作为功能请求记录在 UltiKits/UltiEssentials#53(UltiKits/UltiEssentials#27)", "essentials.warn.removed_unreadable": "%s:无法读取 %s,因此未检查其中是否残留本模块已删除的设置(UltiKits/UltiEssentials#27)", - "essentials.warn.removed_key": "%s:设置 '%s'(位于 %s)不起任何作用,可以从文件中删除——%s。", "essentials.lock.refusal_open": "§c该容器被 §f%s §c锁定", "essentials.lock.refusal_break": "§c该容器被 §f%s §c锁定,无法破坏", "essentials.deathpunish.prefix": "死亡惩罚:", diff --git a/src/test/java/com/ultikits/plugins/essentials/UltiEssentialsRemovedConfigKeyTest.java b/src/test/java/com/ultikits/plugins/essentials/UltiEssentialsRemovedConfigKeyTest.java index 48a9e9f..c4e3272 100644 --- a/src/test/java/com/ultikits/plugins/essentials/UltiEssentialsRemovedConfigKeyTest.java +++ b/src/test/java/com/ultikits/plugins/essentials/UltiEssentialsRemovedConfigKeyTest.java @@ -46,31 +46,10 @@ import static org.mockito.Mockito.verify; /** - * {@code features.recall.enabled} in {@code config/essentials.yml} never took effect -- there is no - * {@code /recall} command to switch -- and is removed in 6.3.0 (UltiKits/UltiEssentials#27; the - * command is feature request UltiKits/UltiEssentials#53). - *

- * {@code features.wild.cooldown}, the other key #27 found unread, is not removed: it is - * bound to {@code /wild}'s cooldown through the framework's config-bound {@code @CmdCD} - * (UltiKits/UltiTools-Reborn#531), so it is a live key and must never be reported as removed. Its - * behaviour is pinned by {@code WildCooldownBindingTest}. - *

- * Removing a key from the code does not remove it from an operator's file: the framework writes a - * missing key's declared default into the file on first load and never deletes a key it no longer - * declares, so every server that has run this module still carries the recall switch. These cases - * pin the warning that tells that operator, at start-up and again on {@code /ul reload}, and they - * pin that a fresh install no longer gets it written into its file. - * - *

Controls

- * A check that never fires and a server with nothing left over look identical in the log, so the - * positive cases sit beside two controls: a file with no removed key produces no warning at all, and - * a file holding {@code features.wild.enabled} -- a key this module still reads, in the same section - * as the removed cooldown -- produces none either, so the check tells "this key is in your file" - * apart from "this key is in your file and is dead". - *

- * 两个从未生效的配置项在 6.3.0 删除;运维文件里残留的旧键在启动和重载时各报一条警告。 + * Recall's former removed-key warning must disappear when #53 makes the switch live again. + * Exercises real framework file loading and module start/reload, preserving legacy values. */ -@DisplayName("Removed configuration keys (UltiKits/UltiEssentials#27)") +@DisplayName("Live recall configuration and former removed-key warnings (#53)") class UltiEssentialsRemovedConfigKeyTest { private static final String CONFIG_FILE = "config/essentials.yml"; @@ -110,8 +89,8 @@ private static Field ultiToolsField() throws Exception { // ==================== the declaration ==================== @Test - @DisplayName("EssentialsConfig declares the live wild cooldown and not the removed recall switch") - void configDeclaresWildCooldownButNotRecall() { + @DisplayName("EssentialsConfig declares both the live wild cooldown and restored recall switch") + void configDeclaresWildCooldownAndRecall() { List declared = new ArrayList<>(); for (Field field : EssentialsConfig.class.getDeclaredFields()) { ConfigEntry entry = field.getAnnotation(ConfigEntry.class); @@ -122,19 +101,20 @@ void configDeclaresWildCooldownButNotRecall() { // Control: the reflection reads the real declarations -- a key that stays is found. assertThat(declared).contains("features.wild.enabled", "features.ban.broadcast-ban"); assertThat(declared).contains(WILD_COOLDOWN); - assertThat(declared).doesNotContain(RECALL_ENABLED); + assertThat(declared).contains(RECALL_ENABLED); } @Test - @DisplayName("A fresh install's file gets the wild cooldown but not the removed recall switch") - void freshInstallFileCarriesWildCooldownButNotRecall() throws Exception { + @DisplayName("A fresh install gets both live keys and recall defaults to true") + void freshInstallFileCarriesWildCooldownAndRecall() throws Exception { boot(""); YamlConfiguration written = YamlConfiguration.loadConfiguration(configFile); // Control: the framework did write the declared defaults into the empty file. assertThat(written.contains("features.wild.enabled")).isTrue(); assertThat(written.contains(WILD_COOLDOWN)).isTrue(); - assertThat(written.contains(RECALL_ENABLED)).isFalse(); + assertThat(written.contains(RECALL_ENABLED)).isTrue(); + assertThat(written.getBoolean(RECALL_ENABLED)).isTrue(); } // ==================== the residual-key warning at start-up ==================== @@ -148,30 +128,29 @@ void startUpDoesNotReportTheLiveWildCooldown() throws Exception { } @Test - @DisplayName("Start-up names features.recall.enabled when it is still in the operator's file") - void startUpWarnsAboutResidualRecallSwitch() throws Exception { + @DisplayName("Start-up preserves legacy false without a removed-key warning") + void startUpPreservesLegacyRecallFalse() throws Exception { boot("features:\n recall:\n enabled: false\n"); - assertOneWarningNaming(startUpWarnings(), RECALL_ENABLED, "UltiEssentials#53"); + assertThat(startUpWarnings()).isEmpty(); + assertThat(config.isRecallEnabled()).isFalse(); + assertThat(YamlConfiguration.loadConfiguration(configFile).getBoolean(RECALL_ENABLED)).isFalse(); } @Test - @DisplayName("With the recall switch and the wild cooldown both in the file, only the recall switch is reported, once") - void startUpReportsOnlyTheRemovedKey() throws Exception { + @DisplayName("Both live switches in the file produce no removed-key warning") + void startUpReportsNeitherLiveKey() throws Exception { boot("features:\n wild:\n cooldown: 5\n recall:\n enabled: true\n"); - List warnings = startUpWarnings(); - - assertThat(warnings).hasSize(1); - assertThat(warnings).filteredOn(line -> line.contains(RECALL_ENABLED)).hasSize(1); - assertThat(warnings).filteredOn(line -> line.contains(WILD_COOLDOWN)).isEmpty(); + assertThat(startUpWarnings()).isEmpty(); + assertThat(YamlConfiguration.loadConfiguration(configFile).getBoolean(RECALL_ENABLED)).isTrue(); } // ==================== the residual-key warning on /ul reload ==================== @Test - @DisplayName("/ul reload names a removed key an operator put back into the file") - void reloadWarnsAboutAResidualKeyAddedSinceStartUp() throws Exception { + @DisplayName("/ul reload reads restored recall false without a removed-key warning") + void reloadReadsLiveRecallSwitch() throws Exception { boot(""); assertThat(startUpWarnings()).isEmpty(); @@ -179,7 +158,37 @@ void reloadWarnsAboutAResidualKeyAddedSinceStartUp() throws Exception { configManager.reloadConfigs(plugin); List warnings = warningsDuring(() -> invokeOnReload(plugin)); - assertOneWarningNaming(warnings, RECALL_ENABLED, "UltiEssentials#53"); + assertThat(warnings).isEmpty(); + assertThat(YamlConfiguration.loadConfiguration(configFile).getBoolean(RECALL_ENABLED)).isFalse(); + assertThat(config.isRecallEnabled()).isFalse(); + } + + @Test + void reloadChangesTheAlreadyConstructedRecallCommandWithoutRewritingLegacyFalse() throws Exception { + boot("features:\n recall:\n enabled: false # operator choice\n"); + com.ultikits.plugins.essentials.commands.RecallCommand command = + new com.ultikits.plugins.essentials.commands.RecallCommand(config); + Field field = com.ultikits.plugins.essentials.commands.BaseEssentialsCommand.class.getDeclaredField("plugin"); + field.setAccessible(true); + field.set(command, plugin); + org.bukkit.entity.Player sender = mock(org.bukkit.entity.Player.class); + command.recall(sender, "Nobody"); + verify(sender).sendMessage("This feature is disabled"); + assertThat(new String(Files.readAllBytes(configFile.toPath()), StandardCharsets.UTF_8)) + .contains("enabled: false # operator choice"); + + write("features:\n recall:\n enabled: true\n"); + configManager.reloadConfigs(plugin); + org.mockito.Mockito.clearInvocations(sender); + command.recall(sender, "Nobody"); + verify(sender).sendMessage("Player not found or offline"); + verify(sender, org.mockito.Mockito.never()).sendMessage("This feature is disabled"); + + write("features:\n recall:\n enabled: false\n"); + configManager.reloadConfigs(plugin); + org.mockito.Mockito.clearInvocations(sender); + command.recall(sender, "Nobody"); + verify(sender).sendMessage("This feature is disabled"); } @Test @@ -200,11 +209,11 @@ void startUpSaysSoWhenTheConfigurationCannotBeRead() throws Exception { // ==================== presence read through the framework (UltiKits/UltiEssentials#68) ==================== @Test - @DisplayName("#68: a removed key present with an explicit null value is still present in the file, and is reported") - void startUpReportsARemovedKeyHoldingAnExplicitNull() throws Exception { + @DisplayName("#53: null recall value is not falsely reported as a removed key") + void nullRecallDoesNotProduceRemovedKeyWarning() throws Exception { boot("features:\n recall:\n enabled:\n"); - assertOneWarningNaming(startUpWarnings(), RECALL_ENABLED, "UltiEssentials#53"); + assertThat(startUpWarnings()).isEmpty(); } @Test @@ -231,8 +240,8 @@ void anUnreadableFileReportsNoRemovedKey() throws Exception { } @Test - @DisplayName("#68: a removed key put back between two reloads is reported on the second, and not once it is removed again") - void aRemovedKeyRestoredBetweenTwoReloadsIsReportedOnTheSecond() throws Exception { + @DisplayName("#53: adding the now-live recall key between reloads never reports it removed") + void liveRecallRestoredBetweenReloadsIsNotReported() throws Exception { boot(""); assertThat(startUpWarnings()).isEmpty(); @@ -241,7 +250,7 @@ void aRemovedKeyRestoredBetweenTwoReloadsIsReportedOnTheSecond() throws Exceptio write("features:\n recall:\n enabled: true\n"); configManager.reloadConfigs(plugin); - assertOneWarningNaming(warningsDuring(() -> invokeOnReload(plugin)), RECALL_ENABLED, "UltiEssentials#53"); + assertThat(warningsDuring(() -> invokeOnReload(plugin))).isEmpty(); write("features:\n wild:\n enabled: true\n"); configManager.reloadConfigs(plugin); @@ -403,17 +412,6 @@ void aSecondStartUpMaterializesNothing() throws Exception { // ==================== helpers ==================== - private static void assertOneWarningNaming(List warnings, String key, String whereItWent) { - assertThat(warnings) - .withFailMessage("expected exactly one warning naming '%s', got %s", key, warnings) - .hasSize(1); - assertThat(warnings.get(0)) - .contains("UltiEssentials") - .contains(CONFIG_FILE) - .contains(key) - .contains(whereItWent); - } - /** * {@link #boot(String, String)} under {@code language: en}, the framework's default -- every * existing case in this file (removed-key warnings, wild cooldown) is language-independent, and the diff --git a/src/test/java/com/ultikits/plugins/essentials/commands/RecallCommandTest.java b/src/test/java/com/ultikits/plugins/essentials/commands/RecallCommandTest.java new file mode 100644 index 0000000..06fa4cd --- /dev/null +++ b/src/test/java/com/ultikits/plugins/essentials/commands/RecallCommandTest.java @@ -0,0 +1,233 @@ +package com.ultikits.plugins.essentials.commands; + +import com.ultikits.plugins.essentials.config.EssentialsConfig; +import com.ultikits.plugins.essentials.i18n.CatalogueText; +import com.ultikits.plugins.essentials.service.OwnTeleports; +import com.ultikits.plugins.essentials.utils.MockBukkitHelper; +import com.ultikits.ultitools.abstracts.UltiToolsPlugin; +import com.ultikits.ultitools.abstracts.command.CommandContext; +import com.ultikits.ultitools.abstracts.command.validation.validators.PermissionValidator; +import com.ultikits.ultitools.annotations.command.CmdExecutor; +import com.ultikits.ultitools.annotations.command.CmdTarget; +import org.bukkit.Location; +import org.bukkit.command.Command; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerTeleportEvent; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.mockbukkit.mockbukkit.MockBukkit; +import org.mockbukkit.mockbukkit.ServerMock; +import org.mockbukkit.mockbukkit.entity.PlayerMock; +import org.mockbukkit.mockbukkit.plugin.PluginMock; + +import java.lang.reflect.Field; +import java.util.UUID; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.Mockito.*; + +/** The new staff summon must not inherit self-service authority or bypass Bukkit cancellation. */ +class RecallCommandTest { + private ServerMock server; + private PluginMock bukkitPlugin; + private EssentialsConfig config; + private RecallCommand recall; + private BackCommand back; + private PlayerMock sender; + private PlayerMock target; + + @BeforeEach + void setUp() throws Exception { + MockBukkitHelper.clearForeignServer(); + server = MockBukkit.mock(); + bukkitPlugin = MockBukkit.createMockPlugin(); + config = new EssentialsConfig(); + recall = new RecallCommand(config); + back = new BackCommand(config); + UltiToolsPlugin plugin = mock(UltiToolsPlugin.class); + when(plugin.i18n(anyString())).thenAnswer(CatalogueText.answer("en")); + Field field = BaseEssentialsCommand.class.getDeclaredField("plugin"); + field.setAccessible(true); + field.set(recall, plugin); + field.set(back, plugin); + sender = server.addPlayer("Staff"); + target = server.addPlayer("Traveler"); + sender.teleport(new Location(server.addSimpleWorld("staff_world"), 42.5, 80, -12.5, 90, 15)); + target.teleport(new Location(server.addSimpleWorld("travel_world"), 200, 65, 300)); + BackCommand.removePlayer(sender.getUniqueId()); + BackCommand.removePlayer(target.getUniqueId()); + clearMessages(); + } + + @AfterEach + void tearDown() { + HideCommand.removePlayer(target.getUniqueId()); + BackCommand.removePlayer(sender.getUniqueId()); + BackCommand.removePlayer(target.getUniqueId()); + MockBukkitHelper.safeUnmock(); + } + + @Test + void recallsExactNameCaseInsensitivelyAcrossWorldsAndNotifiesBoth() { + Location destination = sender.getLocation(); + recall.recall(sender, "tRaVeLeR"); + assertThat(target.getLocation()).isEqualTo(destination); + assertThat(sender.getLocation()).isEqualTo(destination); + assertThat(sender.nextMessage()).isEqualTo("Recalled Traveler to your location"); + assertThat(target.nextMessage()).isEqualTo("Staff recalled you to their location"); + assertThat(sender.nextMessage()).isNull(); + assertThat(target.nextMessage()).isNull(); + } + + @Test + void prefixDoesNotRecallAnUnintendedPlayer() { + Location before = target.getLocation(); + recall.recall(sender, "Trav"); + assertThat(target.getLocation()).isEqualTo(before); + assertThat(sender.nextMessage()).isEqualTo("Player not found or offline"); + assertThat(target.nextMessage()).isNull(); + } + + @Test + void offlineTargetIsRefused() { + target.disconnect(); + recall.recall(sender, "Traveler"); + assertThat(sender.nextMessage()).isEqualTo("Player not found or offline"); + } + + @Test + void selfTargetIsRefused() { + Location before = sender.getLocation(); + recall.recall(sender, "Staff"); + assertThat(sender.nextMessage()).isEqualTo("You cannot recall yourself"); + assertThat(sender.getLocation()).isEqualTo(before); + } + + @Test + void disabledFeatureDoesNotMoveOrNotifyTargetAndAppliesAtCallTime() { + Location before = target.getLocation(); + config.setRecallEnabled(false); + recall.recall(sender, "Traveler"); + assertThat(sender.nextMessage()).isEqualTo("This feature is disabled"); + assertThat(target.getLocation()).isEqualTo(before); + assertThat(target.nextMessage()).isNull(); + config.setRecallEnabled(true); + recall.recall(sender, "Traveler"); + assertThat(target.getLocation()).isEqualTo(sender.getLocation()); + } + + @Test + void vanishedTargetLooksOfflineWithoutSeePermission() throws Exception { + markHidden(); + Location before = target.getLocation(); + recall.recall(sender, "Traveler"); + assertThat(sender.nextMessage()).isEqualTo("Player not found or offline"); + assertThat(target.getLocation()).isEqualTo(before); + assertThat(target.nextMessage()).isNull(); + sender.addAttachment(bukkitPlugin, "ultiessentials.hide.see", true); + recall.recall(sender, "Traveler"); + assertThat(target.getLocation()).isEqualTo(sender.getLocation()); + } + + @Test + void completionExcludesSelfAndHiddenTargetsButKeepsVisibleControl() throws Exception { + server.addPlayer("TravelBuddy"); + markHidden(); + Command command = mock(Command.class); + assertThat(recall.suggest(sender, command, new String[]{"trav"})).containsExactly("TravelBuddy"); + sender.addAttachment(bukkitPlugin, "ultiessentials.hide.see", true); + assertThat(recall.suggest(sender, command, new String[]{"trav"})).containsExactlyInAnyOrder("Traveler", "TravelBuddy"); + assertThat(recall.suggest(sender, command, new String[]{"Sta"})).isEmpty(); + assertThat(recall.suggest(sender, command, new String[]{"Traveler", ""})).isEmpty(); + } + + @Test + void helpExplainsUsage() { + recall.handleHelp(sender); + assertThat(sender.nextMessage()).isEqualTo("Usage: /recall - bring an online player to you"); + } + + @Test + void ordinarySelfServiceNodesDoNotGrantRecallButDedicatedNodeDoes() throws Exception { + sender.addAttachment(bukkitPlugin, "ultiessentials.back", true); + sender.addAttachment(bukkitPlugin, "ultiessentials.tpahere", true); + CmdExecutor executor = RecallCommand.class.getAnnotation(CmdExecutor.class); + assertThat(executor.alias()).containsExactly("recall"); + assertThat(executor.permission()).isEqualTo("ultiessentials.recall.other"); + assertThat(RecallCommand.class.getAnnotation(CmdTarget.class).value()).isEqualTo(CmdTarget.CmdTargetType.PLAYER); + CommandContext context = CommandContext.builder().sender(sender).executorClass(RecallCommand.class) + .matchedMethod(RecallCommand.class.getDeclaredMethod("recall", Player.class, String.class)).build(); + PermissionValidator validator = new PermissionValidator(executor.permission(), executor.requireOp()); + assertThat(validator.validate(context).isValid()).isFalse(); + sender.addAttachment(bukkitPlugin, "ultiessentials.recall.other", true); + assertThat(sender.isOp()).isFalse(); + assertThat(validator.validate(context).isValid()).isTrue(); + } + + @Test + void falseTeleportReturnReportsFailureWithoutTargetSuccessAndClearsMarker() { + Player refused = mock(Player.class); + UUID id = UUID.randomUUID(); + when(refused.getUniqueId()).thenReturn(id); + when(refused.isOnline()).thenReturn(true); + when(refused.teleport(any(Location.class))).thenAnswer(invocation -> { + assertThat(OwnTeleports.isInProgress(refused)).isTrue(); + return false; + }); + try (org.mockito.MockedStatic bukkit = mockStatic(org.bukkit.Bukkit.class)) { + bukkit.when(() -> org.bukkit.Bukkit.getPlayerExact("Refused")).thenReturn(refused); + recall.recall(sender, "Refused"); + } + verify(refused).teleport(sender.getLocation()); + verify(refused, never()).sendMessage(anyString()); + assertThat(sender.nextMessage()).isEqualTo("Recall failed; the player was not teleported"); + assertThat(OwnTeleports.isInProgress(refused)).isFalse(); + } + + @Test + void successfulRecallRecordsTargetsOriginForBackNotSenders() { + server.getPluginManager().registerEvents(back, bukkitPlugin); + Location origin = target.getLocation(); + recall.recall(sender, "Traveler"); + clearMessages(); + back.back(target); + assertThat(target.getLocation()).isEqualTo(origin); + back.back(sender); + assertThat(sender.nextMessage()).isEqualTo("No location to return to"); + } + + @Test + void cancelledBukkitEventHasNoSuccessOrBackRecord() { + server.getPluginManager().registerEvents(back, bukkitPlugin); + server.getPluginManager().registerEvents(new Listener() { + @EventHandler + public void cancel(PlayerTeleportEvent event) { + event.setCancelled(true); + } + }, bukkitPlugin); + Location origin = target.getLocation(); + recall.recall(sender, "Traveler"); + assertThat(target.getLocation()).isEqualTo(origin); + assertThat(sender.nextMessage()).isEqualTo("Recall failed; the player was not teleported"); + assertThat(target.nextMessage()).isNull(); + assertThat(OwnTeleports.isInProgress(target)).isFalse(); + back.back(target); + assertThat(target.nextMessage()).isEqualTo("No location to return to"); + } + + @SuppressWarnings("unchecked") + private void markHidden() throws Exception { + Field field = HideCommand.class.getDeclaredField("HIDDEN_PLAYERS"); + field.setAccessible(true); + ((java.util.Set) field.get(null)).add(target.getUniqueId()); + } + + private void clearMessages() { + while (sender.nextMessage() != null) { /* drain */ } + while (target.nextMessage() != null) { /* drain */ } + } +} diff --git a/src/test/java/com/ultikits/plugins/essentials/config/EssentialsConfigCommentsTest.java b/src/test/java/com/ultikits/plugins/essentials/config/EssentialsConfigCommentsTest.java index 0dc9094..9e54ef6 100644 --- a/src/test/java/com/ultikits/plugins/essentials/config/EssentialsConfigCommentsTest.java +++ b/src/test/java/com/ultikits/plugins/essentials/config/EssentialsConfigCommentsTest.java @@ -117,7 +117,7 @@ private static String fileOf(AbstractConfigEntity config) { // ==================== the declarations ==================== @Test - @DisplayName("every @ConfigEntry comment of the five files is one {key} token, the key the fixture names; 78 in all") + @DisplayName("every @ConfigEntry comment of the five files is one {key} token, the key the fixture names; 79 in all") void everyCommentIsOneCatalogueToken() throws Exception { Map declared = new LinkedHashMap<>(); for (Supplier config : CONFIGS) { @@ -133,8 +133,8 @@ void everyCommentIsOneCatalogueToken() throws Exception { for (Row row : rows()) { expected.put(row.file + " " + row.path, "{" + row.key + "}"); } - // Control: the reflection reads the real declarations, all 78 of them. - assertThat(declared).hasSize(78); + // Control: the reflection reads the real declarations, all 79 of them. + assertThat(declared).hasSize(79); assertThat(declared).containsExactlyInAnyOrderEntriesOf(expected); } diff --git a/src/test/resources/config/config-comments.tsv b/src/test/resources/config/config-comments.tsv index 12ae9e9..5907921 100644 --- a/src/test/resources/config/config-comments.tsv +++ b/src/test/resources/config/config-comments.tsv @@ -1,6 +1,7 @@ -# The 78 @ConfigEntry comments as master 0875d16 wrote them, and the catalogue key and English translation each +# The original 78 @ConfigEntry comments from master 0875d16, plus the restored recall switch (#53), and their translations # became (UltiKits/UltiEssentials#67). Columns: config file, key path, catalogue key, comment at master (the zh # catalogue text, verbatim), English translation (the en catalogue text). Read by EssentialsConfigCommentsTest. +config/essentials.yml features.recall.enabled essentials.config.essentials.features.recall.enabled 启用 /recall 将在线玩家召回到你身边(需要 ultiessentials.recall.other 权限) Enable /recall to bring an online player to you (requires ultiessentials.recall.other) config/essentials.yml features.back.enabled essentials.config.essentials.features.back.enabled 启用 /back 返回命令 Enable the /back command config/essentials.yml features.spawn.enabled essentials.config.essentials.features.spawn.enabled 启用 /spawn 出生点命令 Enable the /spawn command config/essentials.yml features.lobby.enabled essentials.config.essentials.features.lobby.enabled 启用 /lobby 主城命令 Enable the /lobby command From 0d5e36e1d41c07f3dbc3dae8c99b82baa1a93edd Mon Sep 17 00:00:00 2001 From: Ling Bao Date: Sat, 7 Nov 2026 05:42:03 +1100 Subject: [PATCH 2/3] fix(config): migrate the historical recall comment Recognise the v1.0.0 generated recall comment during language refresh while preserving operator edits and disabled values. Cover the historical comment independently from current translations and register its exact migration literal. Co-Authored-By: Claude Opus 5.5 --- .../essentials/config/EssentialsConfig.java | 5 +- .../config/EssentialsConfigCommentsTest.java | 50 +++++++++++++++++-- src/test/resources/config/config-comments.tsv | 8 +-- .../resources/i18n/cjk-literal-exemptions.tsv | 1 + 4 files changed, 54 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/ultikits/plugins/essentials/config/EssentialsConfig.java b/src/main/java/com/ultikits/plugins/essentials/config/EssentialsConfig.java index 0485490..c7c0d19 100644 --- a/src/main/java/com/ultikits/plugins/essentials/config/EssentialsConfig.java +++ b/src/main/java/com/ultikits/plugins/essentials/config/EssentialsConfig.java @@ -57,7 +57,10 @@ public class EssentialsConfig extends AbstractConfigEntity { private int wildCooldown = 60; // Restored with the implemented staff summon (#53); an operator's existing false is preserved. - @ConfigEntry(path = "features.recall.enabled", comment = "{essentials.config.essentials.features.recall.enabled}") + // Register v1.0.0's shipped comment so upgraded files follow the server's language; + // any other text above this key stays the operator's, as for wild cooldown (#73). + @ConfigEntry(path = "features.recall.enabled", comment = "{essentials.config.essentials.features.recall.enabled}", + previousComments = {"启用 /recall 召回命令"}) private boolean recallEnabled = true; // ============ 玩家状态功能 ============ diff --git a/src/test/java/com/ultikits/plugins/essentials/config/EssentialsConfigCommentsTest.java b/src/test/java/com/ultikits/plugins/essentials/config/EssentialsConfigCommentsTest.java index 9e54ef6..cd9f423 100644 --- a/src/test/java/com/ultikits/plugins/essentials/config/EssentialsConfigCommentsTest.java +++ b/src/test/java/com/ultikits/plugins/essentials/config/EssentialsConfigCommentsTest.java @@ -40,9 +40,9 @@ * real catalogues. *

* The expected texts come from {@code src/test/resources/config/config-comments.tsv}: each comment as - * master {@code 0875d16} wrote it (which the zh catalogue must hold verbatim) and its English - * translation. They are not read from the catalogue, so a missing or changed catalogue entry fails on - * the written file, not in the fixture. + * master {@code 0875d16} wrote it (or release {@code v1.0.0} for the restored recall switch), its English + * translation, and an optional updated Chinese text. They are not read from the catalogue, so a missing + * or changed catalogue entry fails on the written file, not in the fixture. *

* 注释从语言文件取:英文服务器写入英文注释,中文服务器写入与之前完全相同的中文注释;升级时只改注释,不改值。 */ @@ -71,6 +71,7 @@ private static final class Row { final String file; final String path; final String key; + final String historical; final String zh; final String en; @@ -78,7 +79,8 @@ private static final class Row { this.file = cells[0]; this.path = cells[1]; this.key = cells[2]; - this.zh = cells[3]; + this.historical = cells[3]; + this.zh = cells.length == 6 ? cells[5] : cells[3]; this.en = cells[4]; } } @@ -93,7 +95,7 @@ private static List rows() throws IOException { continue; } String[] cells = line.split("\t", -1); - assertThat(cells).as("fixture line " + line).hasSize(5); + assertThat(cells.length).as("fixture column count for " + line).isBetween(5, 6); rows.add(new Row(cells)); } } @@ -239,6 +241,44 @@ void releaseOneWildCooldownCommentFollowsTheLanguage() throws Exception { } } + @Test + @DisplayName("release v1.0.0's recall comment follows the language, an operator variant stays, and false survives (#53)") + void releaseOneRecallCommentFollowsTheLanguage() throws Exception { + Row row = null; + for (Row candidate : rowsFor("config/essentials.yml")) { + if (candidate.path.equals("features.recall.enabled")) { + row = candidate; + } + } + assertThat(row).as("control: the fixture has the restored recall row").isNotNull(); + // Byte-exact text from v1.0.0's EssentialsConfig annotation (the generated default). + assertThat(row.historical).isEqualTo("启用 /recall 召回命令"); + File file = new File(tempDir.toFile(), "config/essentials.yml"); + for (String language : new String[] {"en", "zh"}) { + for (String old : new String[] {row.historical, row.historical + "!"}) { + Files.deleteIfExists(file.toPath()); + load(EssentialsConfig::new, "zh"); + String current = new String(Files.readAllBytes(file.toPath()), StandardCharsets.UTF_8); + assertThat(commentAbove(current, row.path)).isEqualTo(row.zh); + assertThat(current).contains("recall:\n # " + row.zh + "\n enabled: true"); + String legacy = current.replace("# " + row.zh + "\n enabled: true", + "# " + old + "\n enabled: false"); + Files.write(file.toPath(), legacy.getBytes(StandardCharsets.UTF_8)); + + EssentialsConfig config = (EssentialsConfig) load(EssentialsConfig::new, language); + + String after = new String(Files.readAllBytes(file.toPath()), StandardCharsets.UTF_8); + String expected = old.equals(row.historical) ? ("en".equals(language) ? row.en : row.zh) : old; + assertThat(commentAbove(after, row.path)).as(language + " after " + old).isEqualTo(expected); + assertThat(config.isRecallEnabled()).isFalse(); + assertThat(nonCommentLines(after)).isEqualTo(nonCommentLines(legacy)); + load(EssentialsConfig::new, language); + assertThat(new String(Files.readAllBytes(file.toPath()), StandardCharsets.UTF_8)) + .as("the second load is byte-stable").isEqualTo(after); + } + } + } + // ==================== helpers ==================== /** Loads one configuration through the framework's real {@code init}, answering {@code i18n} in {@code language}. */ diff --git a/src/test/resources/config/config-comments.tsv b/src/test/resources/config/config-comments.tsv index 5907921..5cdc770 100644 --- a/src/test/resources/config/config-comments.tsv +++ b/src/test/resources/config/config-comments.tsv @@ -1,7 +1,7 @@ -# The original 78 @ConfigEntry comments from master 0875d16, plus the restored recall switch (#53), and their translations -# became (UltiKits/UltiEssentials#67). Columns: config file, key path, catalogue key, comment at master (the zh -# catalogue text, verbatim), English translation (the en catalogue text). Read by EssentialsConfigCommentsTest. -config/essentials.yml features.recall.enabled essentials.config.essentials.features.recall.enabled 启用 /recall 将在线玩家召回到你身边(需要 ultiessentials.recall.other 权限) Enable /recall to bring an online player to you (requires ultiessentials.recall.other) +# The original 78 @ConfigEntry comments from master 0875d16, plus the restored recall switch from v1.0.0 (#53). +# Columns: config file, key path, catalogue key, historical comment verbatim, English catalogue text, +# optional current Chinese catalogue text when it differs from history. Read by EssentialsConfigCommentsTest. +config/essentials.yml features.recall.enabled essentials.config.essentials.features.recall.enabled 启用 /recall 召回命令 Enable /recall to bring an online player to you (requires ultiessentials.recall.other) 启用 /recall 将在线玩家召回到你身边(需要 ultiessentials.recall.other 权限) config/essentials.yml features.back.enabled essentials.config.essentials.features.back.enabled 启用 /back 返回命令 Enable the /back command config/essentials.yml features.spawn.enabled essentials.config.essentials.features.spawn.enabled 启用 /spawn 出生点命令 Enable the /spawn command config/essentials.yml features.lobby.enabled essentials.config.essentials.features.lobby.enabled 启用 /lobby 主城命令 Enable the /lobby command diff --git a/src/test/resources/i18n/cjk-literal-exemptions.tsv b/src/test/resources/i18n/cjk-literal-exemptions.tsv index bdf95cd..2fd5b0a 100644 --- a/src/test/resources/i18n/cjk-literal-exemptions.tsv +++ b/src/test/resources/i18n/cjk-literal-exemptions.tsv @@ -13,3 +13,4 @@ src/main/java/com/ultikits/plugins/essentials/config/TabBarConfig.java &6=== 服 src/main/java/com/ultikits/plugins/essentials/config/TabBarConfig.java &7在线: &e%online%&7/&e%max% The default every earlier version shipped for tabbar.footer. It is the setting's Java default, which the framework writes for a missing key, and is compared byte for byte by materializeText to recognise an operator file nobody edited, which is then rewritten to this module jar's own catalogue text for the server's language (maintainer decision 2026-09-25, UltiKits/UltiEssentials#26). Under language: zh that text is these same bytes, so no text reaches a player from this literal that the jar's catalogue does not also hold src/main/java/com/ultikits/plugins/essentials/config/EssentialsConfig.java say {PLAYER} 死亡了! The default every earlier version shipped for features.deathpunish.command.commands. It is the setting's Java default, which the framework writes for a missing key, and is compared byte for byte by materializeText to recognise an operator file nobody edited, which is then rewritten to this module jar's own catalogue text for the server's language (maintainer decision 2026-09-25, UltiKits/UltiEssentials#26). Under language: zh that text is these same bytes, so no text reaches a player from this literal that the jar's catalogue does not also hold src/main/java/com/ultikits/plugins/essentials/config/EssentialsConfig.java 随机传送冷却时间(秒) The comment release v1.0.0 wrote above features.wild.cooldown, registered as @ConfigEntry(previousComments) so the framework recognises it as its own on an upgraded server and rewrites it in the server's language (UltiKits/UltiEssentials#73; maintainer decision 2026-10-04, UltiKits/UltiTools-Reborn#611). It is never written to a file and never shown to a player: the comment the framework writes comes from the language file +src/main/java/com/ultikits/plugins/essentials/config/EssentialsConfig.java 启用 /recall 召回命令 v1.0.0 generated comment kept in previousComments so upgrades can recognise and refresh it From 323020e7de479f3bf9ef7096cdf87815f9405911 Mon Sep 17 00:00:00 2001 From: Ling Bao Date: Sat, 7 Nov 2026 08:16:46 +1100 Subject: [PATCH 3/3] docs(uat): expect a hidden /recall for players without recall.other Co-Authored-By: Claude Opus 5.5 --- UAT-CHECKLIST.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/UAT-CHECKLIST.md b/UAT-CHECKLIST.md index 26ddecd..8f60e74 100644 --- a/UAT-CHECKLIST.md +++ b/UAT-CHECKLIST.md @@ -89,7 +89,7 @@ for real-machine verification, not user-facing documentation. | ultiessentials.back.track.neg-foreign-teleport | `language: en`; `features.back.enabled: true`; the player has joined in this session and has NOT been teleported by one of this module's commands since joining; `tp` runs from the server console | 1. From the console run `tp ~100 ~ ~` (a vanilla teleport this module did not start). 2. As the player run `/back` | Step 2: chat shows `No location to return to` and the player is not moved. Earlier versions recorded any `COMMAND`- or `PLUGIN`-caused teleport, so `/back` would have returned the player to where the `tp` started (UltiKits/UltiEssentials#39) | server | | | ultiessentials.back.cleanup-on-quit | `features.back.enabled: true`; the player has a recorded back-location (run `ultiessentials.back.track` first) | Quit and rejoin the server, then run `/back` | Chat shows the same translated `No location to return to` line as `ultiessentials.back.teleport.neg-no-location` -- the recorded location did not survive the quit | server | | | ultiessentials.recall.summon | `language: en`; `features.recall.enabled: true`; two online players A (holding `ultiessentials.recall.other`) and B; both visible; A at a known safe position and facing, B at a different safe position in a second loaded world; B separately holds `ultiessentials.back`, with `features.back.enabled: true` | 1. Record A and B's exact positions/worlds and A's yaw/pitch. A runs `/recall `, using different letter case. 2. B runs `/back` | Step 1: B moves immediately to A's exact recorded position, world and facing, with no countdown or consent request; A stays at the same position; A sees `Recalled to your location`, B sees ` recalled you to their location`. Step 2: B returns to B's recorded original world and position. Missing either position read-back is blocked, not pass | server | | -| ultiessentials.recall.summon.neg-permission | `language: en`; recall enabled; non-operator A has `ultiessentials.back` and `ultiessentials.tpahere` but NOT `ultiessentials.recall.other`; visible online B at a distinct position | A runs `/recall `; then grant A `ultiessentials.recall.other` and repeat; revoke it afterwards | First use: framework no-permission response, B stays still and gets no recall notification. Control after grant: B moves to A and both get the success messages from `ultiessentials.recall.summon`; if the permission grant or the observation cannot be made, blocked; if granted and observed but still refused, fail | server | | +| ultiessentials.recall.summon.neg-permission | `language: en`; recall enabled; non-operator A has `ultiessentials.back` and `ultiessentials.tpahere` but NOT `ultiessentials.recall.other`; visible online B at a distinct position | A runs `/recall `; then grant A `ultiessentials.recall.other` and repeat; revoke it afterwards | First use: The command is hidden: Minecraft's `Unknown or incomplete command` (`command.unknown.command`) and no module message; B stays still and gets no recall notification. Control after grant: B moves to A and both get the success messages from `ultiessentials.recall.summon`; if the permission grant or the observation cannot be made, blocked; if granted and observed but still refused, fail | server | | | ultiessentials.recall.summon.neg-invalid-target | `language: en`; recall enabled; A has recall permission; visible online B named `Traveler`, no player named `Trav` or `Nobody` online; A's full name differs from both | A runs `/recall Trav`, `/recall Nobody`, then `/recall ` | First two attempts each reply `Player not found or offline`; third replies `You cannot recall yourself`; neither player moves, B gets no notification | server | | | ultiessentials.recall.summon.neg-vanish | `language: en`; recall enabled; A has recall permission but NOT `ultiessentials.hide.see`; B is online and vanished via `/hide`, a visible C is also online; all at distinguishable positions | 1. A completes `/recall `, then runs `/recall `. 2. Grant A `ultiessentials.hide.see`, complete again and run recall again. 3. Revoke that grant, un-vanish B | Step 1: completion lists C but neither A nor B; recall says `Player not found or offline`, B stays still and gets no notification. Step 2: completion lists B and C but not A; B moves to A and both get success messages. If C never appears, completion observations are blocked, not pass | java-client | | | ultiessentials.recall.summon.neg-cancelled | `language: en`; recall enabled; A has recall permission; visible B at a different position; a test-only Bukkit listener installed for this fixture cancels B's PlayerTeleportEvent, and event observation confirms it ran; B has no prior tracked teleport this session, holds back permission and back is enabled | A runs `/recall `, then B runs `/back`; remove the test-only listener afterwards | Cancellation observed; B does not move; A sees `Recall failed; the player was not teleported`; B receives no recall-success notification, and `/back` says `No location to return to`. If no cancellation-capable fixture or event read-back exists, blocked, not pass (unit counterpart: RecallCommandTest#cancelledBukkitEventHasNoSuccessOrBackRecord) | server | |