- 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
70 lines
2.5 KiB
Java
70 lines
2.5 KiB
Java
package com.loki.lochat.commands.rp;
|
|
|
|
import com.loki.lochat.compat.Msg;
|
|
|
|
import com.loki.lochat.LoChat;
|
|
import com.loki.lochat.api.service.PlayerService;
|
|
import com.loki.lochat.commands.base.PlayerCommand;
|
|
import com.loki.lochat.utils.format.ChatFormatter;
|
|
|
|
import net.kyori.adventure.text.Component;
|
|
|
|
import org.bukkit.command.Command;
|
|
import org.bukkit.entity.Player;
|
|
import org.jetbrains.annotations.NotNull;
|
|
|
|
/**
|
|
* /me <действие>
|
|
* Видят игроки в радиусе rp.radius блоков.
|
|
* Формат: * ИгрокИмя действие
|
|
*/
|
|
public class MeCommand extends PlayerCommand {
|
|
|
|
private final PlayerService playerService;
|
|
|
|
public MeCommand(LoChat plugin) {
|
|
super(plugin);
|
|
this.playerService = plugin.getServiceRegistry().get(PlayerService.class);
|
|
}
|
|
|
|
@Override
|
|
protected boolean executePlayerCommand(@NotNull Player player, @NotNull Command command,
|
|
@NotNull String label, @NotNull String[] args) {
|
|
if (!requirePermission(player, "lochat.rp.me")) {
|
|
return true;
|
|
}
|
|
|
|
int cooldown = plugin.getConfigManager().getInt("rp.cooldowns.me", 0);
|
|
if (cooldown > 0 && playerService.isOnCooldown(player.getUniqueId(), "rp_me", cooldown)) {
|
|
int remaining = playerService.getRemainingCooldown(player.getUniqueId(), "rp_me", cooldown);
|
|
String msg = plugin.getConfigManager().getMessagesConfig().getCooldownMessage()
|
|
.replace("{remaining}", String.valueOf(remaining));
|
|
Msg.send(player, ChatFormatter.parse(msg));
|
|
return true;
|
|
}
|
|
|
|
if (args.length == 0) {
|
|
sendUsage(player, "/me <действие>");
|
|
return true;
|
|
}
|
|
|
|
String action = String.join(" ", args);
|
|
String format = plugin.getConfigManager().getString("rp.me-format",
|
|
"<gray>* </gray><white>{player}</white><gray> {action}</gray>");
|
|
|
|
String displayName = RpUtil.getDisplayName(plugin, player);
|
|
Component message = ChatFormatter.parse(
|
|
format.replace("{player}", displayName)
|
|
.replace("{action}", action)
|
|
);
|
|
|
|
int radius = plugin.getConfigManager().getInt("rp.radius", 100);
|
|
RpUtil.sendToRadius(player, message, radius);
|
|
|
|
if (cooldown > 0) {
|
|
playerService.setCooldown(player.getUniqueId(), "rp_me");
|
|
}
|
|
plugin.getLogger().info("[ME] " + player.getName() + ": " + action);
|
|
return true;
|
|
}
|
|
}
|