From 5dcff203ea157c00e1a23a3be47d5833f75620e6 Mon Sep 17 00:00:00 2001 From: Ling Bao Date: Sat, 14 Nov 2026 01:20:29 +1100 Subject: [PATCH 1/2] fix: use sender-aware completion for ban commands Route ban targets, active ban names and duration presets through framework providers for console and player completion. Require UltiTools-API 6.4.0 and align metadata, docs and regression tests. Co-Authored-By: Claude Opus 5.5 --- FEATURES.md | 9 +- README.md | 14 +- UAT-CHECKLIST.md | 12 +- pom.xml | 2 +- .../essentials/commands/BanCommand.java | 13 +- .../commands/BaseEssentialsCommand.java | 7 + .../essentials/commands/TempBanCommand.java | 20 +-- .../essentials/commands/UnbanCommand.java | 19 +-- src/main/resources/plugin.yml | 2 +- .../essentials/PluginMetadataTest.java | 38 ++--- .../commands/BanCommandBehaviorTest.java | 5 +- .../commands/BanCompletionTest.java | 146 ++++++++++++++++++ .../commands/TempBanCommandTest.java | 8 +- .../commands/VanishedPlayerExposureTest.java | 14 +- 14 files changed, 234 insertions(+), 75 deletions(-) create mode 100644 src/test/java/com/ultikits/plugins/essentials/commands/BanCompletionTest.java diff --git a/FEATURES.md b/FEATURES.md index 4be9979..3a0332c 100644 --- a/FEATURES.md +++ b/FEATURES.md @@ -281,14 +281,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, console and RCON, 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, console and RCON 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, console and RCON 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..f7c1b4e 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, console and RCON 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` 通过框架的发送者感知提供器,为玩家、控制台和 RCON 补全在线名字;玩家没有 `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..ecd5e8b 100644 --- a/UAT-CHECKLIST.md +++ b/UAT-CHECKLIST.md @@ -197,12 +197,22 @@ 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. + | 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` 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-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 | Candidates include `1h`, `12h`, `1d`, `1w`; every candidate starts with `1`, so `6h`, `3d`, `7d`, `30d` are absent. No ban or chat denial message 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` | Request player completion for `/ban aL`, `/tempban aL`, `/unban aL`; then grant the respective permission and repeat each request. Revoke grants and lift the fixture ban afterwards | Without permissions the three requests return no module candidates and no denial messages. With permissions `/ban` and `/tempban` include `Alice`, and `/unban` includes `AlexBanned`. If the positive controls fail, record blocked rather than passing an empty result | 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..3591d93 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,13 @@ protected List suggestOnlinePlayers(Player viewer, String prefix) { .collect(Collectors.toList()); } + /** + * 为玩家和非玩家发送者提供封禁目标,复用已有的玩家隐身过滤。 + */ + 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..967c9a4 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,8 +48,8 @@ public void tempban( @CmdMapping(format = " ") public void tempbanWithReason( @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, @CmdParam("reason") String reason ) { OfflinePlayer target = Bukkit.getOfflinePlayer(playerName); @@ -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..e1485ac 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). *