Plex/server/src/main/java/dev/plex/command/impl/AdminChatCMD.java

45 lines
1.9 KiB
Java
Raw Normal View History

2022-02-25 03:56:28 +00:00
package dev.plex.command.impl;
2022-08-03 00:03:04 +00:00
import dev.plex.cache.DataUtils;
2022-02-25 03:56:28 +00:00
import dev.plex.command.PlexCommand;
import dev.plex.command.annotation.CommandParameters;
import dev.plex.command.annotation.CommandPermissions;
import dev.plex.command.source.RequiredCommandSource;
2022-03-19 01:12:05 +00:00
import dev.plex.player.PlexPlayer;
2022-02-25 03:56:28 +00:00
import dev.plex.rank.enums.Rank;
2022-03-19 01:12:05 +00:00
import dev.plex.util.PlexUtils;
2022-08-03 00:03:04 +00:00
import dev.plex.util.minimessage.SafeMiniMessage;
import dev.plex.util.redis.MessageUtil;
2022-08-26 01:28:13 +00:00
import java.util.UUID;
2022-02-25 03:56:28 +00:00
import net.kyori.adventure.text.Component;
2022-08-03 00:03:04 +00:00
import org.apache.commons.lang3.BooleanUtils;
2022-06-08 20:09:42 +00:00
import org.apache.commons.lang3.StringUtils;
2022-02-25 03:56:28 +00:00
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@CommandPermissions(level = Rank.ADMIN, permission = "plex.adminchat", source = RequiredCommandSource.ANY)
2022-02-26 06:26:42 +00:00
@CommandParameters(name = "adminchat", description = "Talk privately with other admins", usage = "/<command> <message>", aliases = "o,ac,sc,staffchat")
2022-02-25 03:56:28 +00:00
public class AdminChatCMD extends PlexCommand
{
@Override
protected Component execute(@NotNull CommandSender sender, @Nullable Player playerSender, String[] args)
{
if (args.length == 0)
{
2022-08-03 00:03:04 +00:00
if (playerSender != null) {
PlexPlayer player = DataUtils.getPlayer(playerSender.getUniqueId());
player.setStaffChat(!player.isStaffChat());
return messageComponent("adminChatToggled", BooleanUtils.toStringOnOff(player.isStaffChat()));
}
2022-02-25 03:56:28 +00:00
return usage();
}
2022-08-03 00:03:04 +00:00
String message = StringUtils.join(args, " ");
plugin.getServer().getConsoleSender().sendMessage(messageComponent("adminChatFormat", sender.getName(), message));
MessageUtil.sendStaffChat(sender, SafeMiniMessage.mmDeserialize(message), PlexUtils.adminChat(sender.getName(), message).toArray(UUID[]::new));
2022-02-25 03:56:28 +00:00
return null;
}
}