|
1 | 1 | package com.eternalcode.core.bridge.litecommand.argument; |
2 | 2 |
|
| 3 | +import com.eternalcode.annotations.scan.feature.FeatureDocs; |
| 4 | +import com.eternalcode.core.feature.vanish.VanishPermissionConstant; |
3 | 5 | import com.eternalcode.core.feature.vanish.VanishService; |
4 | 6 | import com.eternalcode.core.injector.annotations.Inject; |
5 | 7 | import com.eternalcode.core.injector.annotations.lite.LiteArgument; |
@@ -44,15 +46,25 @@ public ParseResult<Player> parse(Invocation<CommandSender> invocation, String ar |
44 | 46 | return ParseResult.success(target); |
45 | 47 | } |
46 | 48 |
|
| 49 | + @FeatureDocs( |
| 50 | + name = "Vanish tabulation", |
| 51 | + description = "EternalCore prevents non-admin players from seeing vanished players in the commands like /tpa." |
| 52 | + + " To re-enable this feature for specific players, grant them the eternalcore.vanish.tabulation.see permission." |
| 53 | + ) |
47 | 54 | @Override |
48 | 55 | public SuggestionResult suggest( |
49 | 56 | Invocation<CommandSender> invocation, |
50 | 57 | Argument<Player> argument, |
51 | 58 | SuggestionContext context |
52 | 59 | ) { |
| 60 | + CommandSender sender = invocation.sender(); |
53 | 61 | return this.server.getOnlinePlayers().stream() |
54 | | - .filter(player -> !this.vanishService.isVanished(player.getUniqueId())) |
55 | | - .map(player -> player.getName()) |
| 62 | + .filter(player -> this.canSeeVanished(sender) || !this.vanishService.isVanished(player.getUniqueId())) |
| 63 | + .map(Player::getName) |
56 | 64 | .collect(SuggestionResult.collector()); |
57 | 65 | } |
| 66 | + |
| 67 | + public boolean canSeeVanished(CommandSender sender) { |
| 68 | + return sender.hasPermission(VanishPermissionConstant.VANISH_SEE_TABULATION_PERMISSION); |
| 69 | + } |
58 | 70 | } |
0 commit comments