2022-05-06 02:28:39 +00:00
|
|
|
package dev.plex.command.sub;
|
|
|
|
|
|
|
|
import dev.plex.Guilds;
|
|
|
|
import dev.plex.cache.DataUtils;
|
|
|
|
import dev.plex.command.PlexCommand;
|
|
|
|
import dev.plex.command.annotation.CommandParameters;
|
|
|
|
import dev.plex.command.annotation.CommandPermissions;
|
|
|
|
import dev.plex.command.source.RequiredCommandSource;
|
|
|
|
import dev.plex.rank.enums.Rank;
|
|
|
|
import net.kyori.adventure.text.Component;
|
2022-06-14 04:14:06 +00:00
|
|
|
import org.apache.commons.lang3.StringUtils;
|
2022-05-06 02:28:39 +00:00
|
|
|
import org.bukkit.command.CommandSender;
|
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
import org.jetbrains.annotations.NotNull;
|
|
|
|
import org.jetbrains.annotations.Nullable;
|
|
|
|
|
|
|
|
import java.time.format.DateTimeFormatter;
|
2022-05-10 01:58:05 +00:00
|
|
|
import java.util.List;
|
2022-05-06 02:28:39 +00:00
|
|
|
import java.util.concurrent.CompletableFuture;
|
2022-05-10 01:58:05 +00:00
|
|
|
import java.util.stream.Collectors;
|
2022-05-06 02:28:39 +00:00
|
|
|
|
2022-05-09 00:52:08 +00:00
|
|
|
@CommandParameters(name = "info", aliases = "information", usage = "/guild <command>", description = "Shows the guild's information")
|
2022-05-06 02:28:39 +00:00
|
|
|
@CommandPermissions(level = Rank.OP, source = RequiredCommandSource.IN_GAME, permission = "plex.guilds.info")
|
|
|
|
public class InfoSubCommand extends PlexCommand
|
|
|
|
{
|
|
|
|
public InfoSubCommand()
|
|
|
|
{
|
|
|
|
super(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
private final DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MM/dd/yyyy hh:mm:ss a");
|
2022-05-08 23:34:03 +00:00
|
|
|
|
2022-05-06 02:28:39 +00:00
|
|
|
@Override
|
|
|
|
protected Component execute(@NotNull CommandSender commandSender, @Nullable Player player, @NotNull String[] strings)
|
|
|
|
{
|
|
|
|
assert player != null;
|
|
|
|
CompletableFuture.runAsync(() ->
|
|
|
|
{
|
|
|
|
Guilds.get().getGuildHolder().getGuild(player.getUniqueId()).ifPresentOrElse(guild ->
|
|
|
|
{
|
|
|
|
send(player, mmString("<gradient:yellow:gold>====<aqua>" + guild.getName() + "<gradient:yellow:gold>===="));
|
|
|
|
send(player, mmString(""));
|
|
|
|
try
|
|
|
|
{
|
2022-05-08 23:34:03 +00:00
|
|
|
send(player, mmString("<gold>Owner: <yellow>" + DataUtils.getPlayer(guild.getOwner().getUuid(), false).getName()));
|
2022-05-06 02:28:39 +00:00
|
|
|
} catch (NullPointerException e)
|
|
|
|
{
|
|
|
|
send(player, mmString("<gold>Owner: <yellow>Unable to load cache..."));
|
|
|
|
}
|
2022-05-10 01:58:05 +00:00
|
|
|
List<String> members = guild.getMembers().stream().filter(member -> !member.getUuid().equals(guild.getOwner().getUuid())).map(member -> DataUtils.getPlayer(member.getUuid(), false).getName()).toList();
|
|
|
|
send(player, mmString("<gold>Members (" + members.size() + "): " + StringUtils.join(members, ", ")));
|
2022-05-06 02:28:39 +00:00
|
|
|
send(player, mmString("<gold>Moderators (" + guild.getModerators().size() + "): " + StringUtils.join(guild.getModerators().stream().map(uuid -> DataUtils.getPlayer(uuid, false).getName()).toList(), ", ")));
|
|
|
|
send(player, mmString("<gold>Prefix: " + (guild.getPrefix() == null ? "N/A" : guild.getPrefix())));
|
|
|
|
send(player, mmString("<gold>Created At: " + formatter.format(guild.getCreatedAt())));
|
2022-05-08 23:34:03 +00:00
|
|
|
}, () -> send(player, messageComponent("guildNotFound")));
|
2022-05-06 02:28:39 +00:00
|
|
|
});
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|