diff --git a/FEATURES.md b/FEATURES.md index 4be9979..5ed41a5 100644 --- a/FEATURES.md +++ b/FEATURES.md @@ -121,7 +121,8 @@ when the `@EventHandler` count above was updated; the earlier figure of 57 rows enforced by the framework's own cooldown validator and read from `features.wild.cooldown`, default 60 seconds, `0` for none, at load and at `/ul reload`; before UltiKits/UltiEssentials#27 the key was never read and the cooldown was a fixed 60 seconds, and binding it needs the framework's -config-bound `@CmdCD`, UltiKits/UltiTools-Reborn#531, hence this module's `api-version: 630`), and +config-bound `@CmdCD` (UltiKits/UltiTools-Reborn#531), available since UltiTools-API 6.3.0; +the module now declares `api-version: 640` for sender-aware completion), and `BackCommand` (`ultiessentials.back`, simultaneously a command executor and, via `@EventListener`, an event listener). `RespawnListener` and `JoinQuitListener` back the automatic spawn-teleport behaviours. @@ -281,14 +282,17 @@ backed by `BanService` and the persisted `BanData` entity — see `## Data Persi vanilla ban list — a name unbanned by this plugin's commands may still be banned by a separate vanilla `/ban`, and `UnbanCommand`/`BanService#isBannedInServerBanList` exist specifically to report that distinction rather than a false "not banned anywhere". +The three name-ban commands use UltiTools-API 6.4.0 completion providers. If there are no +candidates for a non-player request, the framework still returns `null` and Bukkit may +fall back to its default online-name list; this module does not override that contract. | ID | Feature | Kind | How to reach | Permission | Target | Tier | Manual | Source | |---|---|---|---|---|---|---|---|---| -| ultiessentials.ban.ban | Permanently ban a player (online or previously-seen offline) with the default reason `No reason` when none is given (in the server's language at the time of the ban, and stored with the ban), kicking them immediately if online, and announcing the ban — to the whole server, or to the issuer alone when `features.ban.broadcast-ban` is `false`. Completing `` (here and in `/tempban`) lists the online players the sender may see: a vanished player is left out for a sender without `ultiessentials.hide.see` (UltiKits/UltiEssentials#56) `/ban` deliberately takes over the vanilla `/ban` of the same name (maintainer decision 2026-09-27, UltiKits/UltiEssentials#61): it records the ban in this module's own store, not in the server's ban list, and the vanilla command stays reachable as `minecraft:ban`. | command | `/ban ` (alias `/eban`) | ultiessentials.ban | both | admin | brief | BanCommand#ban, BaseEssentialsCommand#suggestOnlinePlayers | +| ultiessentials.ban.ban | Permanently ban a player (online or previously-seen offline) with the default reason `No reason` when none is given (in the server's language at the time of the ban, and stored with the ban), kicking them immediately if online, and announcing the ban — to the whole server, or to the issuer alone when `features.ban.broadcast-ban` is `false`. Completing `` (here and in `/tempban`) uses sender-aware providers for players and the server console, with case-insensitive prefix matching and framework permission/target filtering. Players without `ultiessentials.hide.see` do not see vanished targets; non-player senders see all online players (UltiKits/UltiEssentials#56, #96). `/ban` deliberately takes over the vanilla `/ban` of the same name (maintainer decision 2026-09-27, UltiKits/UltiEssentials#61): it records the ban in this module's own store, not in the server's ban list, and the vanilla command stays reachable as `minecraft:ban`. | command | `/ban ` (alias `/eban`) | ultiessentials.ban | both | admin | brief | BanCommand#ban, BaseEssentialsCommand#suggestBanPlayers | | ultiessentials.ban.ban-with-reason | Permanently ban a player with a given reason, kicking them immediately if online, and announcing the ban and reason — to the whole server, or to the issuer alone when `features.ban.broadcast-ban` is `false` | command | `/ban ` | ultiessentials.ban | both | admin | brief | BanCommand#banWithReason | -| ultiessentials.ban.tempban | Temporarily ban a player for a parsed duration (`1d`/`2h`/`30m`/`1w`, combinable e.g. `1d12h30m`) with the same default reason as `ultiessentials.ban.ban` (see that row), refusing on an unparseable duration, and announcing the ban as `ultiessentials.ban.ban` does | command | `/tempban ` | ultiessentials.ban.temp | both | admin | brief | TempBanCommand#tempban | +| ultiessentials.ban.tempban | Temporarily ban a player for a parsed duration (`1d`/`2h`/`30m`/`1w`, combinable e.g. `1d12h30m`) with the same default reason as `ultiessentials.ban.ban` (see that row), refusing on an unparseable duration, and announcing the ban as `ultiessentials.ban.ban` does. Player and server-console completion uses the same online-name provider as `/ban`; duration presets (`1h`, `6h`, `12h`, `1d`, `3d`, `7d`, `30d`, `1w`) are prefix-filtered through the framework | command | `/tempban ` | ultiessentials.ban.temp | both | admin | brief | TempBanCommand#tempban, TempBanCommand#suggestDurations, BaseEssentialsCommand#suggestBanPlayers | | ultiessentials.ban.tempban-with-reason | Temporarily ban a player for a parsed duration with a given reason, announcing the ban and reason as `ultiessentials.ban.ban-with-reason` does | command | `/tempban ` | ultiessentials.ban.temp | both | admin | brief | TempBanCommand#tempbanWithReason | -| ultiessentials.ban.unban | Unban a player by name (this plugin's own record only), reporting one of four distinct outcomes depending on whether the plugin's own record and/or the server's own vanilla ban list currently ban the name (see section note); the two success outcomes are reported only once no active record remains for the name (re-queried after the deactivation, because the framework's `update(T)` returns no affected-row count), so the unban broadcast (sent on the plain-success outcome only, and only while `features.ban.broadcast-unban` is `true`) cannot fire for a ban that is still in force; a ban record that survives the attempt is reported as a failure to lift it, never as a name that was never banned. An IP-only record (from `/banip`) stores its canonical address as its name, so `/unban
` spelled exactly that way also deactivates it and reports a player unban; `/unbanip` is the intended command for addresses (#94) | command | `/unban ` | ultiessentials.unban | both | admin | brief | UnbanCommand#unban | +| ultiessentials.ban.unban | Unban a player by name (this plugin's own record only), reporting one of four distinct outcomes depending on whether the plugin's own record and/or the server's own vanilla ban list currently ban the name (see section note); the two success outcomes are reported only once no active record remains for the name (re-queried after the deactivation, because the framework's `update(T)` returns no affected-row count), so the unban broadcast (sent on the plain-success outcome only, and only while `features.ban.broadcast-unban` is `true`) cannot fire for a ban that is still in force; a ban record that survives the attempt is reported as a failure to lift it, never as a name that was never banned. An IP-only record (from `/banip`) stores its canonical address as its name, so `/unban
` spelled exactly that way also deactivates it and reports a player unban; `/unbanip` is the intended command for addresses (#94). Player and server-console completion suggests distinct names from this module's active, unexpired records (including IP-only names), not online players or the vanilla ban list; prefix matching is case-insensitive and framework permission/target filtering applies (#96) | command | `/unban ` | ultiessentials.unban | both | admin | brief | UnbanCommand#unban, UnbanCommand#suggestBannedPlayers | | ultiessentials.ban.ip-create | Permanently ban a canonical numeric IPv4/IPv6 address without a player UUID; verify insertion before kicking every matching online connection and confirming to the issuer; duplicate, disabled, invalid and failed writes are distinct outcomes; broadcast only with `features.ban.broadcast-ban` | command | `/banip ` | ultiessentials.banip | both | admin | brief | BanIpCommand#ban, BanService#banIp | | ultiessentials.ban.ip-create-with-reason | Same IP-only ban with an explicit reason, retained in the record and kick message | command | `/banip ` | ultiessentials.banip | both | admin | brief | BanIpCommand#banWithReason | | ultiessentials.ban.ip-lift | Deactivate every active, unexpired module record matching the canonical address; re-query before success, distinguish failed update from no active record, report a remaining vanilla IP ban without modifying it, and broadcast only plain success with `features.ban.broadcast-unban`; remains available while enforcement is disabled | command | `/unbanip ` | ultiessentials.unbanip | both | admin | brief | UnbanIpCommand#unban, BanService#unbanIp | diff --git a/README.md b/README.md index ba63560..f597046 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,10 @@ # UltiEssentials -[![UltiTools-API](https://img.shields.io/badge/UltiTools--API-6.3.0%2B-blue)](https://github.com/UltiKits/UltiTools-Reborn) +[![UltiTools-API](https://img.shields.io/badge/UltiTools--API-6.4.0%2B-blue)](https://github.com/UltiKits/UltiTools-Reborn) -Requires **UltiTools-API 6.3.0 or later**; an older framework refuses to load this module (it declares `api-version: 630`). +Requires **UltiTools-API 6.4.0 or later**; an older framework refuses to load this module (it declares `api-version: 640`). -需要 **UltiTools-API 6.3.0 或更高版本**;更早的框架会拒绝加载本模块(本模块声明 `api-version: 630`)。 +需要 **UltiTools-API 6.4.0 或更高版本**;更早的框架会拒绝加载本模块(本模块声明 `api-version: 640`)。 UltiEssentials 是基于 UltiTools-API 框架开发的服务器基础功能插件模块,提供了常用的传送、玩家状态、管理员工具和服务器自定义功能。 @@ -82,6 +82,12 @@ These commands never change the separate vanilla IP ban list. A remaining vanill `config/essentials.yml` 中的 `features.recall.enabled` 默认 `true`,现在会真正控制召回命令。改为 `false` 后执行 `/ul reload UltiEssentials` 即可禁用;旧文件中已有的 `false` 不会被覆盖。该键在 6.3.0 因命令尚不存在而删除,现在恢复为有效设置,不再报告“已移除”。更换 JAR 仍需重启。 +### Ban command completion / 封禁命令补全 + +`/ban` and `/tempban` suggest online names for players and the server console through the framework's sender-aware providers. Players without `ultiessentials.hide.see` do not see vanished targets; non-player senders see every online player. `/tempban` also suggests duration presets matching the typed prefix. `/unban` suggests distinct names from this module's active, unexpired ban records (including the address stored as an IP-only record's name), not the online-player list or vanilla bans. Candidates are prefix-matched without regard to case and go through framework permission/target filtering. If no candidates remain for a non-player sender, UltiTools-API 6.4.0 still permits Bukkit's default online-name fallback. + +`/ban`、`/tempban` 通过框架的发送者感知提供器,为玩家和服务器控制台补全在线名字;玩家没有 `ultiessentials.hide.see` 权限时看不到隐身目标,非玩家发送者可看到全部在线玩家。`/tempban` 还会按已输入前缀补全预设时长。`/unban` 补全本模块有效、未过期封禁记录中的去重名称(包括 IP 封禁记录保存为名称的地址),而不是在线玩家或原版封禁名单。候选按前缀匹配、不区分大小写,并经过框架的权限和发送者类型过滤。非玩家请求没有候选时,UltiTools-API 6.4.0 仍允许 Bukkit 回退到默认的在线名字补全。 + ### 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`. @@ -111,7 +117,7 @@ The sidebar is drawn on a private scoreboard this module assigns to each player ## 📦 安装 -1. 确保服务器已安装 [UltiTools-API](https://github.com/UltiKits/UltiTools-Reborn) 6.3.0 或更高版本。本模块声明 `api-version: 630`,更早的框架会拒绝加载它 +1. 确保服务器已安装 [UltiTools-API](https://github.com/UltiKits/UltiTools-Reborn) 6.4.0 或更高版本。本模块声明 `api-version: 640`,更早的框架会拒绝加载它 2. 将 `UltiEssentials-1.0.0.jar` 放入 `plugins/UltiTools/plugins/` 目录 3. 重启服务器(`/ul reload` 只重载配置,不会加载新的模块 jar) diff --git a/UAT-CHECKLIST.md b/UAT-CHECKLIST.md index b2a23af..5fb8238 100644 --- a/UAT-CHECKLIST.md +++ b/UAT-CHECKLIST.md @@ -91,7 +91,7 @@ for real-machine verification, not user-facing documentation. | 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: 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-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`, have A disconnect and rejoin to refresh the client's command list, complete again and run recall again. 3. Revoke that grant, have A rejoin again, 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 | | @@ -197,12 +197,24 @@ for real-machine verification, not user-facing documentation. ## Moderation +Completion rows below require UltiTools-API 6.4.0 or later. Use completion requests only, +not command execution; a missing console completion interface is `blocked`, not a pass +inferred from executing a command. UltiTools-API 6.4.0 may return `null` for non-player requests +without candidates, allowing Bukkit's default names; the empty-candidate case is not asserted +as suppression of that fallback. After setting up or changing a player's permissions, +have that player disconnect and rejoin before completion requests so the client's command +list is refreshed; do not use `/minecraft:reload`. + | ID | Preconditions | Steps | Expected | Layer | Covers | |---|---|---|---|---|---| | ultiessentials.ban.ban | `language: en`; `features.ban.enabled: true` and `features.ban.broadcast-ban: true` (both shipped defaults); a target player, online or previously-seen offline, not currently banned | Run `/ban ` | If online, the target is kicked immediately with the kick screen `You have been banned` / blank / `Reason: No reason` / `Banned by: ` / `Duration: Permanent` / blank / `If you think this is a mistake, contact the server staff`; the server broadcasts `[Ban] was permanently banned by ` then `Reason: No reason` | server | | | ultiessentials.ban.ban.neg-already-banned | `language: en`; `features.ban.enabled: true`; the target is already actively banned (run `ultiessentials.ban.ban` first) | Run `/ban ` again | Chat shows `This player is already banned`; no duplicate ban record or duplicate broadcast occurs | server | | | ultiessentials.ban.ban.neg-broadcast-off | `language: en`; `features.ban.enabled: true` (shipped default); `features.ban.broadcast-ban: false` (NOT the shipped default — set it in `plugins/UltiTools/pluginConfig/UltiEssentials/config/essentials.yml`, then run `ul reload UltiEssentials` from the console); the issuer is an online player holding `ultiessentials.ban`; a SECOND online player, neither the issuer nor the target, is watching chat; a target not currently banned | The issuer runs `/ban griefing`. Cleanup: set `features.ban.broadcast-ban: true`, run `ul reload UltiEssentials`, then `/unban ` | The target is banned as in `ultiessentials.ban.ban` (kicked if online; `/banlist` lists the target). The ISSUER's chat shows the ban notice naming the target and the reason line showing `griefing`; the SECOND player's chat shows neither line. In the cleanup, the second player's chat DOES show the unban notice (`features.ban.broadcast-unban` is still at its default) — the control that their chat is being read; if it does not, record the row `blocked`, because "shows neither line" would then prove nothing. If the issuer sees neither ban line, record `failed`: with the switch off the notice is the issuer's only confirmation, and a ban that succeeds in silence is what this row guards against (UltiKits/UltiEssentials#27) | server | | -| ultiessentials.ban.ban.neg-completion-vanished | `features.ban.enabled: true`; `features.hide.enabled: true` (shipped defaults); a player who is online and vanished (run `ultiessentials.hide.toggle` as that player first); a sender holding `ultiessentials.ban` and NOT holding `ultiessentials.hide.see`; a second online player who is not vanished | 1. As the sender, type `/ban ` and press Tab. 2. Type `/tempban ` and press Tab. 3. Grant the sender `ultiessentials.hide.see` and repeat step 1. 4. Cleanup: revoke `ultiessentials.hide.see` from the sender | Steps 1 and 2: the suggestions list the second player and NOT the vanished player. Step 3: the vanished player's name is listed too. Earlier versions listed the vanished player to every sender (UltiKits/UltiEssentials#56) | java-client | | +| ultiessentials.ban.ban.neg-completion-vanished | `features.ban.enabled: true`; `features.hide.enabled: true` (shipped defaults); a player who is online and vanished (run `ultiessentials.hide.toggle` as that player first); a player sender holding BOTH `ultiessentials.ban` and `ultiessentials.ban.temp` and NOT holding `ultiessentials.hide.see`; a second online player who is not vanished | 1. As the sender, type `/ban ` and press Tab. 2. Type `/tempban ` and press Tab. 3. Grant the sender `ultiessentials.hide.see`, have the sender disconnect and rejoin to refresh the client's command list, and repeat step 1. 4. Cleanup: revoke `ultiessentials.hide.see` from the sender and rejoin again | Steps 1 and 2: the suggestions list the second player and NOT the vanished player. Step 3: the vanished player's name is listed too. Earlier versions listed the vanished player to every sender (UltiKits/UltiEssentials#56) | java-client | | +| ultiessentials.ban.ban.neg-completion-console | Console completion interface; online `Alice` and `AlexHidden`, with `AlexHidden` vanished through `/hide`; console has `ultiessentials.ban` and `ultiessentials.ban.temp` | Request console completion of `ban aL` and `tempban aL`; also check aliases `eban aL` and `tban aL`. Do not execute these bans. Clean up vanish afterwards | Every request lists `Alice` and `AlexHidden`; names with another prefix are absent. Console does not require `ultiessentials.hide.see`. No ban is created. Record each command separately | server | | +| ultiessentials.ban.tempban.neg-completion-duration | Online `Alice`; a player holding `ultiessentials.ban.temp` and a console completion interface | As BOTH senders, complete `tempban Alice 1` (the player types `/tempban Alice 1`) without executing | For each sender, candidates are exactly `1h`, `12h`, `1d`, `1w`, each once (order does not matter); `6h`, `3d`, `7d`, `30d` are absent. No ban or server chat line occurs | server | | +| ultiessentials.ban.unban.neg-completion-console | Offline `AlexBanned` has one active, unexpired MODULE ban, not just a vanilla ban; online `Alice` is not banned; a player holding `ultiessentials.unban`; console completion interface with that permission | As BOTH senders, complete `unban aL` without executing (player types `/unban aL`). Clean up with `unban AlexBanned` after observations | Each completion contains `AlexBanned` once and does NOT contain online `Alice`. The active module ban remains until cleanup. Record each sender separately; this must be an observed completion, not a `/banlist` inference | server | | +| ultiessentials.ban.ban.neg-completion-permission | Online `Alice`; active module ban for offline `AlexBanned`; non-OP player initially holding none of `ultiessentials.ban`, `ultiessentials.ban.temp`, `ultiessentials.unban`; rejoin after the initial permission setup and after every grant/revocation to refresh the client's command list, without `/minecraft:reload` | Type `/ban aL`, `/tempban aL`, `/unban aL` and request completion without executing; then grant the respective permission, have the player disconnect and rejoin, and repeat each request. Revoke grants, rejoin and lift the fixture ban afterwards. Record the client observations separately from framework-filter coverage | Without permissions Paper hides these commands from the client: no module candidates and no server chat line appear; the client's own `Unknown or incomplete command` hint is expected, NOT a module denial message. This client observation proves command hiding only, NOT the framework's internal permission filter, since no completion request reaches it; that filter is covered separately by `BanCompletionTest#unauthorizedPlayerGetsNoCandidatesOrDenialMessages`, not claimed as proved by this row. After grants and rejoining, `/ban` and `/tempban` include `Alice`, and `/unban` includes `AlexBanned`. If setup, refresh or observation is unavailable, record blocked, not a pass from emptiness; if permissions and refresh are confirmed but positive candidates are wrong, record fail | java-client | | | ultiessentials.ban.ban-with-reason | `language: en`; `features.ban.enabled: true`; `features.ban.broadcast-ban: true` (shipped default); a target not currently banned | Run `/ban griefing` | The target is kicked (if online) with `griefing` shown as the reason in the kick screen; the broadcast names both the target and `griefing` | server | | | ultiessentials.ban.tempban | `language: en`; `features.ban.enabled: true`; `features.ban.broadcast-ban: true` (shipped default); a target not currently banned | Run `/tempban 1h` | The target is kicked (if online) with a "remaining time" section in the kick screen reflecting approximately 1 hour; the broadcast names the target, the fixed default reason, and the formatted duration | server | | | ultiessentials.ban.tempban.neg-bad-duration | `language: en`; `features.ban.enabled: true` | Run `/tempban notaduration` | Chat shows `Invalid duration format` followed by `Examples: 1d, 2h, 30m, 1w, 1d12h30m`; no ban is created | server | | diff --git a/pom.xml b/pom.xml index fa1fc06..675e16f 100644 --- a/pom.xml +++ b/pom.xml @@ -24,7 +24,7 @@ 1.8 UTF-8 - 6.3.0 + 6.4.0 1.21.11-R0.1-SNAPSHOT diff --git a/src/main/java/com/ultikits/plugins/essentials/commands/BanCommand.java b/src/main/java/com/ultikits/plugins/essentials/commands/BanCommand.java index 9ddeef9..25bc278 100644 --- a/src/main/java/com/ultikits/plugins/essentials/commands/BanCommand.java +++ b/src/main/java/com/ultikits/plugins/essentials/commands/BanCommand.java @@ -5,12 +5,10 @@ import com.ultikits.ultitools.annotations.Autowired; import com.ultikits.ultitools.annotations.command.*; import org.bukkit.Bukkit; -import org.bukkit.command.Command; import org.bukkit.OfflinePlayer; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; -import java.util.List; import java.util.UUID; /** @@ -39,14 +37,14 @@ public class BanCommand extends BaseEssentialsCommand { private EssentialsConfig config; @CmdMapping(format = "") - public void ban(@CmdSender CommandSender sender, @CmdParam("player") String playerName) { + public void ban(@CmdSender CommandSender sender, @CmdParam(value = "player", suggest = "suggestBanPlayers") String playerName) { banWithReason(sender, playerName, i18n("essentials.ban.no_reason")); } @CmdMapping(format = " ") public void banWithReason( @CmdSender CommandSender sender, - @CmdParam("player") String playerName, + @CmdParam(value = "player", suggest = "suggestBanPlayers") String playerName, @CmdParam("reason") String reason ) { OfflinePlayer target = Bukkit.getOfflinePlayer(playerName); @@ -109,11 +107,4 @@ protected void handleHelp(CommandSender sender) { sender.sendMessage(i18n("essentials.help.ban")); } - @Override - protected List suggest(Player player, Command command, String[] args) { - if (args.length == 1) { - return suggestOnlinePlayers(player, args[0]); - } - return super.suggest(player, command, args); - } } diff --git a/src/main/java/com/ultikits/plugins/essentials/commands/BaseEssentialsCommand.java b/src/main/java/com/ultikits/plugins/essentials/commands/BaseEssentialsCommand.java index 3e638cd..fe63b4f 100644 --- a/src/main/java/com/ultikits/plugins/essentials/commands/BaseEssentialsCommand.java +++ b/src/main/java/com/ultikits/plugins/essentials/commands/BaseEssentialsCommand.java @@ -57,6 +57,19 @@ protected List suggestOnlinePlayers(Player viewer, String prefix) { .collect(Collectors.toList()); } + /** + * Suggests online ban targets using the existing player visibility filter. + * A non-player sender is treated as the console and sees all online players, + * including vanished players. + * + * @param sender the sender requesting completion + * @param prefix the typed prefix, or {@code null} + * @return the matching names visible to the sender + */ + protected List suggestBanPlayers(CommandSender sender, String prefix) { + return suggestOnlinePlayers(sender instanceof Player ? (Player) sender : null, prefix); + } + /** * Default implementation for help command. * Subclasses can override this to provide custom help messages. diff --git a/src/main/java/com/ultikits/plugins/essentials/commands/TempBanCommand.java b/src/main/java/com/ultikits/plugins/essentials/commands/TempBanCommand.java index 427504d..6c1a393 100644 --- a/src/main/java/com/ultikits/plugins/essentials/commands/TempBanCommand.java +++ b/src/main/java/com/ultikits/plugins/essentials/commands/TempBanCommand.java @@ -6,7 +6,6 @@ import com.ultikits.ultitools.annotations.command.*; import org.bukkit.Bukkit; import org.bukkit.OfflinePlayer; -import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; @@ -40,8 +39,8 @@ public class TempBanCommand extends BaseEssentialsCommand { @CmdMapping(format = " ") public void tempban( @CmdSender CommandSender sender, - @CmdParam("player") String playerName, - @CmdParam("duration") String duration + @CmdParam(value = "player", suggest = "suggestBanPlayers") String playerName, + @CmdParam(value = "duration", suggest = "suggestDurations") String duration ) { tempbanWithReason(sender, playerName, duration, i18n("essentials.ban.no_reason")); } @@ -49,7 +48,7 @@ public void tempban( @CmdMapping(format = " ") public void tempbanWithReason( @CmdSender CommandSender sender, - @CmdParam("player") String playerName, + @CmdParam(value = "player", suggest = "suggestBanPlayers") String playerName, @CmdParam("duration") String duration, @CmdParam("reason") String reason ) { @@ -122,14 +121,7 @@ protected void handleHelp(CommandSender sender) { sender.sendMessage(i18n("essentials.help.tempban.combined")); } - @Override - protected List suggest(Player player, Command command, String[] args) { - if (args.length == 1) { - return suggestOnlinePlayers(player, args[0]); - } - if (args.length == 2) { - return java.util.Arrays.asList("1h", "6h", "12h", "1d", "3d", "7d", "30d", "1w"); - } - return super.suggest(player, command, args); + private List suggestDurations(CommandSender sender) { + return java.util.Arrays.asList("1h", "6h", "12h", "1d", "3d", "7d", "30d", "1w"); } } diff --git a/src/main/java/com/ultikits/plugins/essentials/commands/UnbanCommand.java b/src/main/java/com/ultikits/plugins/essentials/commands/UnbanCommand.java index 5112969..0ea86fa 100644 --- a/src/main/java/com/ultikits/plugins/essentials/commands/UnbanCommand.java +++ b/src/main/java/com/ultikits/plugins/essentials/commands/UnbanCommand.java @@ -6,9 +6,7 @@ import com.ultikits.ultitools.annotations.Autowired; import com.ultikits.ultitools.annotations.command.*; import org.bukkit.Bukkit; -import org.bukkit.command.Command; import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; import java.util.List; import java.util.stream.Collectors; @@ -37,7 +35,7 @@ public class UnbanCommand extends BaseEssentialsCommand { private EssentialsConfig config; @CmdMapping(format = "") - public void unban(@CmdSender CommandSender sender, @CmdParam("player") String playerName) { + public void unban(@CmdSender CommandSender sender, @CmdParam(value = "player", suggest = "suggestBannedPlayers") String playerName) { BanService.UnbanResult outcome = banService.unbanPlayerByName(playerName); if (outcome == BanService.UnbanResult.FAILED) { @@ -81,15 +79,10 @@ protected void handleHelp(CommandSender sender) { sender.sendMessage(i18n("essentials.help.unban")); } - @Override - protected List suggest(Player player, Command command, String[] args) { - if (args.length == 1) { - return banService.getActiveBans().stream() - .map(BanData::getPlayerName) - .filter(n -> n.toLowerCase().startsWith(args[0].toLowerCase())) - .distinct() - .collect(Collectors.toList()); - } - return super.suggest(player, command, args); + private List suggestBannedPlayers(CommandSender sender) { + return banService.getActiveBans().stream() + .map(BanData::getPlayerName) + .distinct() + .collect(Collectors.toList()); } } diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 951ade0..d96f2ab 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -4,6 +4,6 @@ main: com.ultikits.plugins.essentials.UltiEssentials authors: - wisdommen - UltiKits Team -api-version: 630 +api-version: 640 identify-string: ultiessentials loadAfter: [] diff --git a/src/test/java/com/ultikits/plugins/essentials/PluginMetadataTest.java b/src/test/java/com/ultikits/plugins/essentials/PluginMetadataTest.java index 1fb62ea..ab0a3b8 100644 --- a/src/test/java/com/ultikits/plugins/essentials/PluginMetadataTest.java +++ b/src/test/java/com/ultikits/plugins/essentials/PluginMetadataTest.java @@ -25,7 +25,7 @@ * repository's own records (UltiKits/UltiTools-Reborn#474, #544). *
    *
  • {@code api-version} is the lowest UltiTools level this build runs on. This module is built - * against UltiTools 6.3.0, so it must declare {@code 630}: an older framework then refuses it at + * against UltiTools 6.4.0, so it must declare {@code 640}: an older framework then refuses it at * load with a warning that names the cause.
  • *
  • {@code identify-string} is the key the framework's update check and {@code /upm update} use to * find this module in the UltiCloud catalogue; a module without it is skipped by both. It must @@ -38,17 +38,17 @@ * Files outside the test classpath are found from the project directory Surefire reports * ({@code basedir}), not from whatever directory the runner started in. */ -@DisplayName("Release metadata: api-version 630, identify-string and the README's framework floor") +@DisplayName("Release metadata: api-version 640, identify-string and the README's framework floor") class PluginMetadataTest { - /** The UltiTools level this module needs: 6.3, encoded the way {@code api-version} encodes it. */ - private static final int REQUIRED_API_VERSION = 630; + /** The UltiTools level this module needs: 6.4, encoded the way {@code api-version} encodes it. */ + private static final int REQUIRED_API_VERSION = 640; - /** The README's UltiTools-API badge, e.g. {@code UltiTools--API-6.3.0%2B-blue}. */ + /** The README's UltiTools-API badge, e.g. {@code UltiTools--API-6.4.0%2B-blue}. */ private static final Pattern BADGE = Pattern.compile("UltiTools--API-(\\d+\\.\\d+\\.\\d+)(?:%2B|\\+)?-"); /** - * A minimum-version claim in prose: {@code 6.3.0+}, {@code 6.3.0 或更高版本}, {@code 6.3.0 or later}. + * A minimum-version claim in prose: {@code 6.4.0+}, {@code 6.4.0 或更高版本}, {@code 6.4.0 or later}. * Only major version 6 is read, which in these READMEs is always the framework (module versions are * 1.x/2.x; Paper and Java are written with two components). */ @@ -83,7 +83,7 @@ private static String read(Path path) throws IOException { /** * Whether {@code major.minor.patch} is exactly the framework level {@code apiVersion} encodes: - * {@code 630} is major 6, minor 3. The patch never counts. + * {@code 640} is major 6, minor 4. The patch never counts. */ static boolean namesLevel(String version, int apiVersion) { String[] parts = version.split("\\."); @@ -93,8 +93,8 @@ static boolean namesLevel(String version, int apiVersion) { } @Test - @DisplayName("plugin.yml declares api-version 630") - void declaresApiVersion630() throws Exception { + @DisplayName("plugin.yml declares api-version 640") + void declaresApiVersion640() throws Exception { YamlConfiguration yml = shippedPluginYml(); // Control: this is the module's own descriptor, not some other plugin.yml on the classpath. assertThat(yml.getString("main")).as("control: main class").isEqualTo(UltiEssentials.class.getName()); @@ -116,14 +116,14 @@ void identifyStringMatchesUltikitsJson() throws Exception { } @Test - @DisplayName("the README's badge and every framework minimum in its prose name UltiTools 6.3") + @DisplayName("the README's badge and every framework minimum in its prose name UltiTools 6.4") void readmeNamesTheDeclaredFloor() throws Exception { String text = read(projectFile("README.md")); Matcher badge = BADGE.matcher(text); // Control: the badge is really there and parsed, so the comparison below is not vacuous. assertThat(badge.find()).as("README carries the UltiTools-API badge").isTrue(); assertThat(namesLevel(badge.group(1), REQUIRED_API_VERSION)) - .as("badge %s names UltiTools 6.3", badge.group(1)) + .as("badge %s names UltiTools 6.4", badge.group(1)) .isTrue(); List stale = new ArrayList<>(); @@ -133,18 +133,18 @@ void readmeNamesTheDeclaredFloor() throws Exception { stale.add(claim.group()); } } - assertThat(stale).as("framework minimums in the README that are not 6.3").isEmpty(); + assertThat(stale).as("framework minimums in the README that are not 6.4").isEmpty(); } @Test - @DisplayName("control: 6.3.0 and 6.3.12 name 630; 6.2.0, 6.2.10, 6.4.0 and 7.3.0 do not") + @DisplayName("control: 6.4.0 and 6.4.12 name 640; 6.2.0, 6.2.10, 6.3.0 and 7.3.0 do not") void levelComparison() { - assertThat(namesLevel("6.3.0", 630)).isTrue(); - assertThat(namesLevel("6.3.12", 630)).isTrue(); - assertThat(namesLevel("6.2.0", 630)).isFalse(); - assertThat(namesLevel("6.2.10", 630)).isFalse(); - assertThat(namesLevel("6.4.0", 630)).isFalse(); - assertThat(namesLevel("7.3.0", 630)).isFalse(); + assertThat(namesLevel("6.4.0", 640)).isTrue(); + assertThat(namesLevel("6.4.12", 640)).isTrue(); + assertThat(namesLevel("6.2.0", 640)).isFalse(); + assertThat(namesLevel("6.2.10", 640)).isFalse(); + assertThat(namesLevel("6.3.0", 640)).isFalse(); + assertThat(namesLevel("7.3.0", 640)).isFalse(); } @Test diff --git a/src/test/java/com/ultikits/plugins/essentials/commands/BanCommandBehaviorTest.java b/src/test/java/com/ultikits/plugins/essentials/commands/BanCommandBehaviorTest.java index fa8ede3..49c6a91 100644 --- a/src/test/java/com/ultikits/plugins/essentials/commands/BanCommandBehaviorTest.java +++ b/src/test/java/com/ultikits/plugins/essentials/commands/BanCommandBehaviorTest.java @@ -104,11 +104,12 @@ void nullTargetNameFallsBackToTypedName() { @Test @DisplayName("suggest with one argument suggests online player names") void suggestWithOneArgSuggestsOnlinePlayers() { + when(player.hasPermission("ultiessentials.ban")).thenReturn(true); Player online = EssentialsTestHelper.createMockPlayer("Alice", UUID.randomUUID()); doReturn(java.util.Collections.singletonList(online)) .when(EssentialsTestHelper.getMockServer()).getOnlinePlayers(); - List result = command.suggest(player, mock(org.bukkit.command.Command.class), new String[]{"A"}); + List result = command.onTabComplete(player, mock(org.bukkit.command.Command.class), "ban", new String[]{"A"}); assertThat(result).contains("Alice"); } @@ -126,7 +127,7 @@ void suggestWithOtherArgCountDefersToSuper() { doReturn(java.util.Collections.singletonList(online)) .when(EssentialsTestHelper.getMockServer()).getOnlinePlayers(); - List result = command.suggest(player, mock(org.bukkit.command.Command.class), new String[]{}); + List result = command.onTabComplete(player, mock(org.bukkit.command.Command.class), "ban", new String[]{}); assertThat(result).isEmpty(); } diff --git a/src/test/java/com/ultikits/plugins/essentials/commands/BanCompletionTest.java b/src/test/java/com/ultikits/plugins/essentials/commands/BanCompletionTest.java new file mode 100644 index 0000000..d7d128a --- /dev/null +++ b/src/test/java/com/ultikits/plugins/essentials/commands/BanCompletionTest.java @@ -0,0 +1,145 @@ +package com.ultikits.plugins.essentials.commands; + +import com.ultikits.plugins.essentials.entity.BanData; +import com.ultikits.plugins.essentials.service.BanService; +import com.ultikits.plugins.essentials.utils.EssentialsTestHelper; +import org.bukkit.command.Command; +import org.bukkit.command.CommandSender; +import org.bukkit.command.ConsoleCommandSender; +import org.bukkit.command.RemoteConsoleCommandSender; +import org.bukkit.entity.Player; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; + +import java.util.Arrays; +import java.util.Collections; +import java.util.Set; +import java.util.UUID; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.Mockito.*; + +class BanCompletionTest { + private BanService banService; + private Command bukkitCommand; + private Player viewer; + private Player visible; + private Player hidden; + + @BeforeEach + void setUp() throws Exception { + EssentialsTestHelper.setUp(); + hiddenPlayers().clear(); + banService = mock(BanService.class); + bukkitCommand = mock(Command.class); + viewer = EssentialsTestHelper.createMockPlayer("Moderator", UUID.randomUUID()); + visible = EssentialsTestHelper.createMockPlayer("Alice", UUID.randomUUID()); + hidden = EssentialsTestHelper.createMockPlayer("AlexHidden", UUID.randomUUID()); + hiddenPlayers().add(hidden.getUniqueId()); + doReturn(Arrays.asList(visible, hidden)).when(EssentialsTestHelper.getMockServer()).getOnlinePlayers(); + when(banService.getActiveBans()).thenReturn(Arrays.asList( + BanData.builder().playerName("AlexBanned").build(), + BanData.builder().playerName("AlexBanned").build(), + BanData.builder().playerName("BobBanned").build())); + } + + @AfterEach + void tearDown() throws Exception { + hiddenPlayers().clear(); + EssentialsTestHelper.tearDown(); + } + + @SuppressWarnings("unchecked") + private Set hiddenPlayers() throws Exception { + return (Set) EssentialsTestHelper.getStaticField(HideCommand.class, "HIDDEN_PLAYERS"); + } + + private BaseEssentialsCommand executor(String name) throws Exception { + BaseEssentialsCommand executor; + switch (name) { + case "ban": executor = new BanCommand(); break; + case "tempban": executor = new TempBanCommand(); break; + default: executor = new UnbanCommand(); break; + } + EssentialsTestHelper.setField(executor, "plugin", EssentialsTestHelper.getMockPlugin()); + EssentialsTestHelper.setField(executor, "banService", banService); + return executor; + } + + private String permission(String name) { + return "tempban".equals(name) ? "ultiessentials.ban.temp" : "ultiessentials." + name; + } + + @ParameterizedTest + @ValueSource(strings = {"ban", "tempban"}) + void consoleAndRconExplicitlyCompleteOnlineNames(String name) throws Exception { + BaseEssentialsCommand executor = executor(name); + for (CommandSender sender : Arrays.asList(mock(ConsoleCommandSender.class), + mock(RemoteConsoleCommandSender.class))) { + when(sender.hasPermission(permission(name))).thenReturn(true); + assertThat(executor.onTabComplete(sender, bukkitCommand, name, new String[]{"aL"})) + .containsExactlyInAnyOrder("Alice", "AlexHidden"); + } + } + + @Test + void consoleAndRconCompleteActiveBanNamesNotOnlineNames() throws Exception { + BaseEssentialsCommand executor = executor("unban"); + for (CommandSender sender : Arrays.asList(mock(ConsoleCommandSender.class), + mock(RemoteConsoleCommandSender.class))) { + when(sender.hasPermission("ultiessentials.unban")).thenReturn(true); + assertThat(executor.onTabComplete(sender, bukkitCommand, "unban", new String[]{"aL"})) + .containsExactly("AlexBanned"); + } + } + + @ParameterizedTest + @ValueSource(booleans = {false, true}) + void consoleAndPlayerCompleteDurationPresetsWithPrefixFiltering(boolean playerSender) throws Exception { + BaseEssentialsCommand executor = executor("tempban"); + CommandSender sender = playerSender ? viewer : mock(ConsoleCommandSender.class); + when(sender.hasPermission("ultiessentials.ban.temp")).thenReturn(true); + assertThat(executor.onTabComplete(sender, bukkitCommand, "tempban", new String[]{"Alice", "1"})) + .containsExactlyInAnyOrder("1h", "12h", "1d", "1w"); + } + + @ParameterizedTest + @ValueSource(strings = {"ban", "tempban"}) + void playerCompletionPreservesVanishVisibility(String name) throws Exception { + BaseEssentialsCommand executor = executor(name); + when(viewer.hasPermission(permission(name))).thenReturn(true); + assertThat(executor.onTabComplete(viewer, bukkitCommand, name, new String[]{"aL"})) + .containsExactly("Alice"); + when(viewer.hasPermission("ultiessentials.hide.see")).thenReturn(true); + assertThat(executor.onTabComplete(viewer, bukkitCommand, name, new String[]{"aL"})) + .containsExactlyInAnyOrder("Alice", "AlexHidden"); + } + + @Test + void playerUnbanCompletionUsesDeduplicatedActiveBanNames() throws Exception { + when(viewer.hasPermission("ultiessentials.unban")).thenReturn(true); + assertThat(executor("unban").onTabComplete(viewer, bukkitCommand, "unban", new String[]{"aL"})) + .containsExactly("AlexBanned"); + } + + @ParameterizedTest + @ValueSource(strings = {"ban", "tempban", "unban"}) + void unauthorizedPlayerGetsNoCandidatesOrDenialMessages(String name) throws Exception { + assertThat(executor(name).onTabComplete(viewer, bukkitCommand, name, new String[]{""})).isEmpty(); + verify(viewer, never()).sendMessage(anyString()); + verifyNoInteractions(banService); + } + + @Test + void consoleUnbanWithNoActiveBansRetainsFrameworkFallbackContract() throws Exception { + CommandSender console = mock(ConsoleCommandSender.class); + when(console.hasPermission("ultiessentials.unban")).thenReturn(true); + when(banService.getActiveBans()).thenReturn(Collections.emptyList()); + assertThat(executor("unban").onTabComplete(console, bukkitCommand, "unban", new String[]{""})).isNull(); + verify(banService).getActiveBans(); + } +} diff --git a/src/test/java/com/ultikits/plugins/essentials/commands/TempBanCommandTest.java b/src/test/java/com/ultikits/plugins/essentials/commands/TempBanCommandTest.java index 6a16624..04815db 100644 --- a/src/test/java/com/ultikits/plugins/essentials/commands/TempBanCommandTest.java +++ b/src/test/java/com/ultikits/plugins/essentials/commands/TempBanCommandTest.java @@ -215,6 +215,10 @@ void delegatesWithDefaultReason() { @Nested @DisplayName("suggest") class SuggestTests { + @BeforeEach + void grantCompletionPermission() { + when(player.hasPermission("ultiessentials.ban.temp")).thenReturn(true); + } @Test @DisplayName("One argument suggests online player names") @@ -223,7 +227,7 @@ void oneArgSuggestsOnlinePlayers() { doReturn(java.util.Collections.singletonList(online)) .when(EssentialsTestHelper.getMockServer()).getOnlinePlayers(); - List result = command.suggest(player, mock(org.bukkit.command.Command.class), new String[]{"A"}); + List result = command.onTabComplete(player, mock(org.bukkit.command.Command.class), "tempban", new String[]{"A"}); assertThat(result).contains("Alice"); } @@ -231,7 +235,7 @@ void oneArgSuggestsOnlinePlayers() { @Test @DisplayName("Two arguments suggest the fixed set of duration presets") void twoArgsSuggestDurationPresets() { - List result = command.suggest(player, mock(org.bukkit.command.Command.class), new String[]{"BadPlayer", ""}); + List result = command.onTabComplete(player, mock(org.bukkit.command.Command.class), "tempban", new String[]{"BadPlayer", ""}); assertThat(result).contains("1h", "1d", "1w"); } diff --git a/src/test/java/com/ultikits/plugins/essentials/commands/VanishedPlayerExposureTest.java b/src/test/java/com/ultikits/plugins/essentials/commands/VanishedPlayerExposureTest.java index 1d33494..328cd10 100644 --- a/src/test/java/com/ultikits/plugins/essentials/commands/VanishedPlayerExposureTest.java +++ b/src/test/java/com/ultikits/plugins/essentials/commands/VanishedPlayerExposureTest.java @@ -157,6 +157,12 @@ void aSenderWhoMaySeeVanishedPlayersReachesThem() throws Exception { @Nested @DisplayName("ban completion") class BanCompletion { + @BeforeEach + void grantCompletionPermissions() { + when(sender.hasPermission("ultiessentials.ban")).thenReturn(true); + when(sender.hasPermission("ultiessentials.ban.temp")).thenReturn(true); + when(vanished.hasPermission("ultiessentials.ban")).thenReturn(true); + } @Test @DisplayName("/ban and /tempban completion leave a vanished player out for a sender who may not see them") @@ -169,8 +175,8 @@ void completionHidesVanishedPlayers() throws Exception { EssentialsTestHelper.setField(tempBan, "plugin", EssentialsTestHelper.getMockPlugin()); EssentialsTestHelper.setField(tempBan, "banService", mock(BanService.class)); - List banNames = ban.suggest(sender, mock(Command.class), new String[]{""}); - List tempBanNames = tempBan.suggest(sender, mock(Command.class), new String[]{""}); + List banNames = ban.onTabComplete(sender, mock(Command.class), "ban", new String[]{""}); + List tempBanNames = tempBan.onTabComplete(sender, mock(Command.class), "tempban", new String[]{""}); assertThat(banNames).contains("Seeker").doesNotContain("Ghost"); assertThat(tempBanNames).contains("Seeker").doesNotContain("Ghost"); @@ -184,7 +190,7 @@ void aVanishedPlayerCompletesTheirOwnName() throws Exception { EssentialsTestHelper.setField(ban, "plugin", EssentialsTestHelper.getMockPlugin()); EssentialsTestHelper.setField(ban, "banService", mock(BanService.class)); - assertThat(ban.suggest(vanished, mock(Command.class), new String[]{""})).contains("Ghost", "Seeker"); + assertThat(ban.onTabComplete(vanished, mock(Command.class), "ban", new String[]{""})).contains("Ghost", "Seeker"); } @Test @@ -196,7 +202,7 @@ void completionShowsVanishedPlayersToThoseWhoMaySee() throws Exception { EssentialsTestHelper.setField(ban, "plugin", EssentialsTestHelper.getMockPlugin()); EssentialsTestHelper.setField(ban, "banService", mock(BanService.class)); - assertThat(ban.suggest(sender, mock(Command.class), new String[]{""})).contains("Ghost", "Seeker"); + assertThat(ban.onTabComplete(sender, mock(Command.class), "ban", new String[]{""})).contains("Ghost", "Seeker"); } }