-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: zzuf <[email protected]>
- Loading branch information
Showing
2 changed files
with
50 additions
and
0 deletions.
There are no files selected for viewing
48 changes: 48 additions & 0 deletions
48
src/main/java/dev/pgm/community/commands/VanishedCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package dev.pgm.community.commands; | ||
|
||
import static net.kyori.adventure.text.Component.text; | ||
|
||
import dev.pgm.community.CommunityCommand; | ||
import dev.pgm.community.CommunityPermissions; | ||
import dev.pgm.community.utils.CommandAudience; | ||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
import net.kyori.adventure.text.Component; | ||
import net.kyori.adventure.text.format.NamedTextColor; | ||
import org.bukkit.Bukkit; | ||
import tc.oc.pgm.api.integration.Integration; | ||
import tc.oc.pgm.lib.cloud.commandframework.annotations.CommandDescription; | ||
import tc.oc.pgm.lib.cloud.commandframework.annotations.CommandMethod; | ||
import tc.oc.pgm.lib.cloud.commandframework.annotations.CommandPermission; | ||
import tc.oc.pgm.util.named.NameStyle; | ||
import tc.oc.pgm.util.player.PlayerComponent; | ||
import tc.oc.pgm.util.text.TextFormatter; | ||
|
||
public class VanishedCommand extends CommunityCommand { | ||
@CommandMethod("vanished") | ||
@CommandDescription("View a list of online vanished players") | ||
@CommandPermission(CommunityPermissions.VIEW_VANISHED) | ||
public void viewVanished(CommandAudience viewer) { | ||
List<Component> vanishedNames = | ||
Bukkit.getOnlinePlayers().stream() | ||
.filter(Integration::isVanished) | ||
.map(player -> PlayerComponent.player(player, NameStyle.VERBOSE)) | ||
.collect(Collectors.toList()); | ||
|
||
if (vanishedNames.isEmpty()) { | ||
viewer.sendWarning(text("No online players are vanished!")); | ||
return; | ||
} | ||
|
||
Component count = | ||
text() | ||
.append(text("Vanished", NamedTextColor.DARK_AQUA)) | ||
.append(text(": ")) | ||
.append(text(vanishedNames.size())) | ||
.build(); | ||
Component nameList = TextFormatter.list(vanishedNames, NamedTextColor.GRAY); | ||
|
||
viewer.sendMessage(count); | ||
viewer.sendMessage(nameList); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters