- Msg.send/broadcast/actionBar/title/legacy/plain for all 58 files sendMessage replacements (plan step 3) - ChatEventListener: AsyncChatEvent->AsyncPlayerChatEvent, getRecipients filtering, manual render+Msg.send loop, HIGHEST|ignoreCancelled, nobodyHeard via Bukkit scheduler (step 4) - EnhancedChatRenderer: remove ChatRenderer/Audience, render(Player,Component,Component,Player), getLocale String, Msg.actionBar - PlayerEventListener: join/quit/death String API, getCustomName/getDisplayName legacy, Msg.broadcast - FoliaUtil: IS_FOLIA false, Bukkit scheduler only; AutoMessageManager BukkitTask - CustomCommandManager: reflective getCommandMap; other mechanical fixes (displayName, kick, inventory titles) - single universal jar (variant A) - loads on Spigot 1.20.1 and Paper
66 lines
2.4 KiB
Java
66 lines
2.4 KiB
Java
package com.loki.lochat.commands.messaging;
|
|
|
|
import com.loki.lochat.compat.Msg;
|
|
|
|
import com.loki.lochat.LoChat;
|
|
import com.loki.lochat.api.service.MessagingService;
|
|
import com.loki.lochat.api.service.pm.PrivateMessageService;
|
|
import com.loki.lochat.utils.format.ChatFormatter;
|
|
|
|
import org.bukkit.Bukkit;
|
|
import org.bukkit.command.Command;
|
|
import org.bukkit.command.CommandExecutor;
|
|
import org.bukkit.command.CommandSender;
|
|
import org.bukkit.entity.Player;
|
|
import org.jetbrains.annotations.NotNull;
|
|
|
|
import java.util.Optional;
|
|
import java.util.UUID;
|
|
|
|
public class ReplyCommand implements CommandExecutor {
|
|
|
|
private final LoChat plugin;
|
|
private final MessagingService messagingService;
|
|
private final PrivateMessageService pmService;
|
|
|
|
public ReplyCommand(LoChat plugin) {
|
|
this.plugin = plugin;
|
|
this.messagingService = plugin.getServiceRegistry().get(MessagingService.class);
|
|
this.pmService = plugin.getServiceRegistry().get(PrivateMessageService.class);
|
|
}
|
|
|
|
@Override
|
|
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
|
if (!(sender instanceof Player player)) {
|
|
sender.sendMessage(plugin.getConfigManager().getMessagesConfig().getPlayerOnly());
|
|
return true;
|
|
}
|
|
if (!plugin.getConfigManager().isPmEnabled()) {
|
|
return true;
|
|
}
|
|
if (args.length == 0) {
|
|
Msg.send(player, ChatFormatter.parse(plugin.getMessageConfig().getInvalidUsage("/reply <сообщение>")));
|
|
return true;
|
|
}
|
|
|
|
Optional<UUID> lastUuid = messagingService.getLastConversation(player.getUniqueId());
|
|
if (lastUuid.isEmpty()) {
|
|
Msg.send(player, ChatFormatter.parse(plugin.getMessageConfig().get("pm.no-reply")));
|
|
return true;
|
|
}
|
|
|
|
Player target = Bukkit.getPlayer(lastUuid.get());
|
|
if (target == null) {
|
|
Msg.send(player, ChatFormatter.parse(plugin.getMessageConfig().get("pm.player-offline")));
|
|
return true;
|
|
}
|
|
if (messagingService.isIgnoring(target.getUniqueId(), player.getUniqueId())) {
|
|
Msg.send(player, ChatFormatter.parse(plugin.getMessageConfig().get("pm.ignored")));
|
|
return true;
|
|
}
|
|
|
|
String message = String.join(" ", args);
|
|
pmService.sendPrivateMessage(player, target, message);
|
|
return true;
|
|
}
|
|
}
|