port: replace Paper component APIs, chat pipeline, events and schedulers

- 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
This commit is contained in:
loki5512344 2026-09-20 16:38:37 +02:00
parent 88e4e68cca
commit 7f513a7104
Signed by: boba
GPG key ID: 253067914055423B
56 changed files with 506 additions and 416 deletions

View file

@ -1,5 +1,7 @@
package com.loki.lochat.commands;
import com.loki.lochat.compat.Msg;
import com.loki.lochat.LoChat;
import com.loki.lochat.managers.CustomCommandManager;
import com.loki.lochat.utils.format.ChatFormatter;
@ -28,7 +30,7 @@ public class CustomCommandsCommand implements CommandExecutor, TabCompleter {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!sender.hasPermission("lochat.customcommands")) {
sender.sendMessage(ChatFormatter.parse("<#F44336>❌ У вас нет прав для использования этой команды!"));
Msg.send(sender, ChatFormatter.parse("<#F44336>❌ У вас нет прав для использования этой команды!"));
return true;
}
@ -42,14 +44,14 @@ public class CustomCommandsCommand implements CommandExecutor, TabCompleter {
case "reload" -> reloadCommands(sender);
case "enable" -> {
if (args.length < 2) {
sender.sendMessage(ChatFormatter.parse("<#FFA726>⚠️ Использование: /customcommands enable <команда>"));
Msg.send(sender, ChatFormatter.parse("<#FFA726>⚠️ Использование: /customcommands enable <команда>"));
return true;
}
toggleCommand(sender, args[1], true);
}
case "disable" -> {
if (args.length < 2) {
sender.sendMessage(ChatFormatter.parse("<#FFA726>⚠️ Использование: /customcommands disable <команда>"));
Msg.send(sender, ChatFormatter.parse("<#FFA726>⚠️ Использование: /customcommands disable <команда>"));
return true;
}
toggleCommand(sender, args[1], false);
@ -73,7 +75,7 @@ public class CustomCommandsCommand implements CommandExecutor, TabCompleter {
<gradient:#FFD700:#FFA500><bold>▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬</bold></gradient>
""");
sender.sendMessage(message);
Msg.send(sender, message);
}
private void showCommandsList(CommandSender sender) {
@ -91,21 +93,21 @@ public class CustomCommandsCommand implements CommandExecutor, TabCompleter {
}
message.append(ChatFormatter.parse("\n<gradient:#FFD700:#FFA500><bold>▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬</bold></gradient>"));
sender.sendMessage(message.build());
Msg.send(sender, message.build());
}
private void reloadCommands(CommandSender sender) {
try {
commandManager.reload();
sender.sendMessage(ChatFormatter.parse("<#4CAF50>✅ Кастомные команды успешно перезагружены!"));
Msg.send(sender, ChatFormatter.parse("<#4CAF50>✅ Кастомные команды успешно перезагружены!"));
} catch (Exception e) {
sender.sendMessage(ChatFormatter.parse("<#F44336>❌ Ошибка при перезагрузке команд: " + e.getMessage()));
Msg.send(sender, ChatFormatter.parse("<#F44336>❌ Ошибка при перезагрузке команд: " + e.getMessage()));
plugin.getLogger().severe("Ошибка перезагрузки кастомных команд: " + e.getMessage());
}
}
private void toggleCommand(CommandSender sender, String commandName, boolean enable) {
sender.sendMessage(ChatFormatter.parse(
Msg.send(sender, ChatFormatter.parse(
"<#FFA726>⚠️ Для изменения статуса команд отредактируйте файл custom-commands.yml и выполните /customcommands reload"
));
}

View file

@ -1,5 +1,7 @@
package com.loki.lochat.commands.admin.broadcast;
import com.loki.lochat.compat.Msg;
import com.loki.lochat.LoChat;
import com.loki.lochat.utils.format.ChatFormatter;
@ -26,12 +28,12 @@ public class AnnounceCommand implements CommandExecutor {
@Override
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
if (args.length == 0) {
sender.sendMessage(ChatFormatter.parse(plugin.getMessageConfig().getInvalidUsage("/announce <сообщение>")));
Msg.send(sender, ChatFormatter.parse(plugin.getMessageConfig().getInvalidUsage("/announce <сообщение>")));
return true;
}
if (args[0].equalsIgnoreCase("reload") && sender.hasPermission("chat.announce.reload")) {
plugin.reload();
sender.sendMessage(ChatFormatter.parse(plugin.getMessageConfig().get("announce.reloaded")));
Msg.send(sender, ChatFormatter.parse(plugin.getMessageConfig().get("announce.reloaded")));
return true;
}
@ -39,17 +41,17 @@ public class AnnounceCommand implements CommandExecutor {
Component formatted = ChatFormatter.formatAnnouncement(plugin.getConfigManager().getAnnouncementFormat(), message);
for (Player player : Bukkit.getOnlinePlayers()) {
player.sendMessage(formatted);
Msg.send(player, formatted);
if (plugin.getConfigManager().isAnnouncementActionBarEnabled()) {
player.sendActionBar(formatted);
Msg.actionBar(player, formatted);
}
if (plugin.getConfigManager().isAnnouncementTitleEnabled()) {
player.showTitle(Title.title(
Msg.title(player,
ChatFormatter.parse(plugin.getConfigManager().getAnnouncementTitleHeader()),
ChatFormatter.parse(message),
Title.Times.times(Duration.ofMillis(500),
Duration.ofSeconds(plugin.getConfigManager().getAnnouncementTitleDuration()),
Duration.ofMillis(500))));
Duration.ofMillis(500)));
}
}
plugin.getLogger().info("[ANNOUNCE] " + sender.getName() + ": " + ChatFormatter.stripTags(message));

View file

@ -1,5 +1,7 @@
package com.loki.lochat.commands.admin.broadcast;
import com.loki.lochat.compat.Msg;
import com.loki.lochat.LoChat;
import com.loki.lochat.integrations.DiscordIntegration;
import com.loki.lochat.utils.format.ChatFormatter;
@ -27,7 +29,7 @@ public class DiscordCommand implements CommandExecutor, TabCompleter {
@Override
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
if (!sender.hasPermission("lochat.discord.admin")) {
sender.sendMessage(ChatFormatter.parse(plugin.getMessageConfig().get("errors.no-permission")));
Msg.send(sender, ChatFormatter.parse(plugin.getMessageConfig().get("errors.no-permission")));
return true;
}
if (args.length == 0) {
@ -35,29 +37,30 @@ public class DiscordCommand implements CommandExecutor, TabCompleter {
return true;
}
switch (args[0].toLowerCase()) {
case "status" -> sender.sendMessage(ChatFormatter.parse(
case "status" -> Msg.send(sender, ChatFormatter.parse(
discord.isEnabled() ? "&#9878C9Discord &#7858E9включён" : "&#9878C9Discord &#CF6679отключён"));
case "reload" -> {
try {
discord.reload();
sender.sendMessage(ChatFormatter.parse("&#9878C9Discord &#7858E9перезагружен"));
Msg.send(sender, ChatFormatter.parse("&#9878C9Discord &#7858E9перезагружен"));
} catch (Exception e) {
sender.sendMessage(ChatFormatter.parse("&#CF6679Ошибка: " + e.getMessage()));
Msg.send(sender, ChatFormatter.parse("&#CF6679Ошибка: " + e.getMessage()));
}
}
case "test" -> {
if (!discord.isEnabled()) {
sender.sendMessage(ChatFormatter.parse("&#CF6679Discord отключён"));
Msg.send(sender, ChatFormatter.parse("&#CF6679Discord отключён"));
return true;
}
String msg = args.length > 1 ? String.join(" ", Arrays.copyOfRange(args, 1, args.length)) : "Тест от " + sender.getName();
sender.sendMessage(ChatFormatter.parse("&#B798A8Отправка..."));
Msg.send(sender, ChatFormatter.parse("&#B798A8Отправка..."));
java.util.concurrent.CompletableFuture.runAsync(() -> {
discord.sendTestMessage(msg, sender.getName());
if (sender instanceof org.bukkit.entity.Player p) {
p.getScheduler().run(plugin, t -> sender.sendMessage(ChatFormatter.parse("&#9878C9Отправлено &#7858E9✓")), null);
if (sender instanceof org.bukkit.entity.Player) {
org.bukkit.Bukkit.getScheduler().runTask(plugin,
() -> Msg.send(sender, ChatFormatter.parse("&#9878C9Отправлено &#7858E9✓")));
} else {
sender.sendMessage(ChatFormatter.parse("&#9878C9Отправлено &#7858E9✓"));
Msg.send(sender, ChatFormatter.parse("&#9878C9Отправлено &#7858E9✓"));
}
});
}
@ -67,7 +70,7 @@ public class DiscordCommand implements CommandExecutor, TabCompleter {
}
private void sendHelp(CommandSender s) {
s.sendMessage(ChatFormatter.parse("&#B798A8/discordadmin status|reload|test"));
Msg.send(s, ChatFormatter.parse("&#B798A8/discordadmin status|reload|test"));
}
@Override

View file

@ -1,5 +1,7 @@
package com.loki.lochat.commands.admin.chat;
import com.loki.lochat.compat.Msg;
import com.loki.lochat.LoChat;
import com.loki.lochat.api.service.MessagingService;
import com.loki.lochat.utils.format.ChatFormatter;
@ -27,7 +29,7 @@ public class ChatSpyCommand implements CommandExecutor {
return true;
}
boolean enabled = messagingService.toggleSpy(player.getUniqueId());
player.sendMessage(ChatFormatter.parse(plugin.getMessageConfig().get(enabled ? "spy.enabled" : "spy.disabled")));
Msg.send(player, ChatFormatter.parse(plugin.getMessageConfig().get(enabled ? "spy.enabled" : "spy.disabled")));
return true;
}
}

View file

@ -1,5 +1,7 @@
package com.loki.lochat.commands.admin.chat;
import com.loki.lochat.compat.Msg;
import com.loki.lochat.LoChat;
import com.loki.lochat.utils.format.ChatFormatter;
@ -26,7 +28,7 @@ public class ClearChatCommand implements CommandExecutor {
player.sendMessage("");
}
if (plugin.getConfigManager().isClearChatMessageEnabled()) {
player.sendMessage(ChatFormatter.parse(
Msg.send(player, ChatFormatter.parse(
plugin.getConfigManager().getClearChatMessage().replace("{player}", sender.getName())));
}
}

View file

@ -1,5 +1,7 @@
package com.loki.lochat.commands.admin.chat;
import com.loki.lochat.compat.Msg;
import com.loki.lochat.LoChat;
import com.loki.lochat.utils.format.ChatFormatter;
@ -24,37 +26,37 @@ public class ClearChatConfigCommand implements CommandExecutor, TabCompleter {
@Override
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
if (!sender.hasPermission("lochat.clearchat.config")) {
sender.sendMessage(plugin.getMessageConfig().getComponent("errors.no-permission"));
Msg.send(sender, plugin.getMessageConfig().getComponent("errors.no-permission"));
return true;
}
if (args.length == 0) {
sender.sendMessage(ChatFormatter.parse("&#B798A8Использование: &#7858E9/clearchatconfig <enable|disable|message|status>"));
Msg.send(sender, ChatFormatter.parse("&#B798A8Использование: &#7858E9/clearchatconfig <enable|disable|message|status>"));
return true;
}
switch (args[0].toLowerCase()) {
case "enable" -> {
plugin.getConfigManager().setClearChatMessageEnabled(true);
sender.sendMessage(ChatFormatter.parse("&#9878C9Сообщение очистки &#7858E9включено"));
Msg.send(sender, ChatFormatter.parse("&#9878C9Сообщение очистки &#7858E9включено"));
}
case "disable" -> {
plugin.getConfigManager().setClearChatMessageEnabled(false);
sender.sendMessage(ChatFormatter.parse("&#9878C9Сообщение очистки &#B798A8отключено"));
Msg.send(sender, ChatFormatter.parse("&#9878C9Сообщение очистки &#B798A8отключено"));
}
case "message" -> {
if (args.length < 2) {
sender.sendMessage(ChatFormatter.parse("&#CF6679Укажите текст!"));
Msg.send(sender, ChatFormatter.parse("&#CF6679Укажите текст!"));
return true;
}
String msg = String.join(" ", Arrays.copyOfRange(args, 1, args.length));
plugin.getConfigManager().setClearChatMessage(msg);
sender.sendMessage(ChatFormatter.parse("&#9878C9Сообщение установлено: &f" + msg));
Msg.send(sender, ChatFormatter.parse("&#9878C9Сообщение установлено: &f" + msg));
}
case "status" -> {
sender.sendMessage(ChatFormatter.parse("&#B798A8Включено: "
Msg.send(sender, ChatFormatter.parse("&#B798A8Включено: "
+ (plugin.getConfigManager().isClearChatMessageEnabled() ? "&#7858E9да" : "&#CF6679нет")));
sender.sendMessage(ChatFormatter.parse("&#B798A8Текст: &f" + plugin.getConfigManager().getClearChatMessage()));
Msg.send(sender, ChatFormatter.parse("&#B798A8Текст: &f" + plugin.getConfigManager().getClearChatMessage()));
}
default -> sender.sendMessage(ChatFormatter.parse("&#CF6679Неизвестный аргумент"));
default -> Msg.send(sender, ChatFormatter.parse("&#CF6679Неизвестный аргумент"));
}
return true;
}

View file

@ -1,5 +1,7 @@
package com.loki.lochat.commands.admin.system;
import com.loki.lochat.compat.Msg;
import com.google.common.io.ByteArrayDataOutput;
import com.google.common.io.ByteStreams;
import com.loki.lochat.LoChat;
@ -21,11 +23,11 @@ public class HubCommand implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!(sender instanceof Player player)) {
sender.sendMessage(ChatFormatter.parse(plugin.getMessageConfig().get("general.players-only")));
Msg.send(sender, ChatFormatter.parse(plugin.getMessageConfig().get("general.players-only")));
return true;
}
if (!plugin.getConfigManager().getBoolean("hub_command.enabled", true)) {
player.sendMessage(ChatFormatter.parse(plugin.getMessageConfig().get("general.command-disabled")));
Msg.send(player, ChatFormatter.parse(plugin.getMessageConfig().get("general.command-disabled")));
return true;
}
String server = plugin.getConfigManager().getString("hub_command.server", "hub");
@ -33,7 +35,7 @@ public class HubCommand implements CommandExecutor {
out.writeUTF("Connect");
out.writeUTF(server);
player.sendPluginMessage(plugin, "BungeeCord", out.toByteArray());
player.sendMessage(ChatFormatter.parse(plugin.getMessageConfig().get("hub.connecting").replace("%server%", server)));
Msg.send(player, ChatFormatter.parse(plugin.getMessageConfig().get("hub.connecting").replace("%server%", server)));
return true;
}
}

View file

@ -1,5 +1,7 @@
package com.loki.lochat.commands.admin.system;
import com.loki.lochat.compat.Msg;
import com.loki.lochat.LoChat;
import com.loki.lochat.utils.format.ChatFormatter;
@ -24,50 +26,48 @@ public class LoChatCommand implements CommandExecutor, TabCompleter {
@Override
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
if (!sender.hasPermission("lochat.admin")) {
sender.sendMessage(ChatFormatter.parse(plugin.getMessageConfig().getNoPermission()));
Msg.send(sender, ChatFormatter.parse(plugin.getMessageConfig().getNoPermission()));
return true;
}
if (args.length == 0) {
sender.sendMessage(ChatFormatter.parse("&#7858E9LoChat &#B798A8v" + plugin.getPluginMeta().getVersion()));
sender.sendMessage(ChatFormatter.parse("&#9878C9/lochat reload &#B798A8— перезагрузить конфиги"));
sender.sendMessage(ChatFormatter.parse("&#9878C9/lochat commands [reload] &#B798A8— кастомные команды"));
sender.sendMessage(ChatFormatter.parse("&#9878C9/lochat filterstats &#B798A8— статистика фильтров чата"));
Msg.send(sender, ChatFormatter.parse("&#7858E9LoChat &#B798A8v" + plugin.getDescription().getVersion()));
Msg.send(sender, ChatFormatter.parse("&#9878C9/lochat reload &#B798A8— перезагрузить конфиги"));
Msg.send(sender, ChatFormatter.parse("&#9878C9/lochat commands [reload] &#B798A8— кастомные команды"));
Msg.send(sender, ChatFormatter.parse("&#9878C9/lochat filterstats &#B798A8— статистика фильтров чата"));
return true;
}
switch (args[0].toLowerCase()) {
case "reload" -> {
plugin.reload();
sender.sendMessage(ChatFormatter.parse("&#9878C9Конфигурация &#7858E9перезагружена!"));
Msg.send(sender, ChatFormatter.parse("&#9878C9Конфигурация &#7858E9перезагружена!"));
}
case "commands" -> {
if (args.length > 1 && args[1].equalsIgnoreCase("reload")) {
plugin.getCustomCommandManager().reload();
sender.sendMessage(ChatFormatter.parse("&#9878C9Кастомные команды &#7858E9перезагружены!"));
Msg.send(sender, ChatFormatter.parse("&#9878C9Кастомные команды &#7858E9перезагружены!"));
} else {
var cmds = plugin.getCustomCommandManager().getCommands();
sender.sendMessage(ChatFormatter.parse("&#B798A8Кастомные команды &#9878C9(" + cmds.size() + "&#9878C9):"));
cmds.values().forEach(c -> sender.sendMessage(
ChatFormatter.parse("&#7858E9/" + c.name() + " &#B798A8(" + c.type() + ")")));
Msg.send(sender, ChatFormatter.parse("&#B798A8Кастомные команды &#9878C9(" + cmds.size() + "&#9878C9):"));
cmds.values().forEach(c -> Msg.send(sender, ChatFormatter.parse("&#7858E9/" + c.name() + " &#B798A8(" + c.type() + ")")));
}
}
case "filterstats" -> {
var filter = plugin.getChatFilter();
if (filter == null) {
sender.sendMessage(ChatFormatter.parse("&#CF6679Фильтр чата недоступен"));
Msg.send(sender, ChatFormatter.parse("&#CF6679Фильтр чата недоступен"));
break;
}
var stats = filter.getStatistics();
long total = stats.getTotalBlocked();
sender.sendMessage(ChatFormatter.parse(
Msg.send(sender, ChatFormatter.parse(
"&#B798A8Фильтры чата: &#9878C9заблокировано &#7858E9" + total + "&#9878C9 сообщений"));
if (total == 0) {
sender.sendMessage(ChatFormatter.parse("&#B798A8Пока нечего показывать"));
Msg.send(sender, ChatFormatter.parse("&#B798A8Пока нечего показывать"));
break;
}
stats.snapshot().forEach((name, count) -> sender.sendMessage(
ChatFormatter.parse("&#7858E9" + name + ":&#9878C9 " + count)));
stats.snapshot().forEach((name, count) -> Msg.send(sender, ChatFormatter.parse("&#7858E9" + name + ":&#9878C9 " + count)));
}
default -> sender.sendMessage(ChatFormatter.parse("&#CF6679Неизвестная команда"));
default -> Msg.send(sender, ChatFormatter.parse("&#CF6679Неизвестная команда"));
}
return true;
}

View file

@ -1,5 +1,7 @@
package com.loki.lochat.commands.admin.system;
import com.loki.lochat.compat.Msg;
import com.loki.lochat.LoChat;
import com.loki.lochat.utils.format.ChatFormatter;
@ -19,14 +21,14 @@ public class ReloadConfigCommand implements CommandExecutor {
@Override
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
if (!sender.hasPermission("lochat.admin.reload")) {
sender.sendMessage(ChatFormatter.parse(plugin.getConfigManager().getMessagesConfig().getNoPermission()));
Msg.send(sender, ChatFormatter.parse(plugin.getConfigManager().getMessagesConfig().getNoPermission()));
return true;
}
try {
plugin.reload();
sender.sendMessage(ChatFormatter.parse("&#9878C9Все конфигурации &#7858E9успешно перезагружены!"));
Msg.send(sender, ChatFormatter.parse("&#9878C9Все конфигурации &#7858E9успешно перезагружены!"));
} catch (Exception e) {
sender.sendMessage(ChatFormatter.parse("&#CF6679Ошибка при перезагрузке: " + e.getMessage()));
Msg.send(sender, ChatFormatter.parse("&#CF6679Ошибка при перезагрузке: " + e.getMessage()));
plugin.getLogger().severe("Ошибка при перезагрузке: " + e.getMessage());
}
return true;

View file

@ -1,5 +1,7 @@
package com.loki.lochat.commands.chat;
import com.loki.lochat.compat.Msg;
import com.loki.lochat.LoChat;
import com.loki.lochat.api.service.ChannelService;
import com.loki.lochat.channel.Channel;
@ -31,7 +33,7 @@ public class ChannelCommand extends PlayerCommand {
@NotNull String label, @NotNull String[] args) {
ChannelService channels = plugin.getServiceRegistry().get(ChannelService.class);
if (!channels.isEnabled()) {
player.sendMessage(ChatFormatter.parse("&#CF6679Система каналов отключена"));
Msg.send(player, ChatFormatter.parse("&#CF6679Система каналов отключена"));
return true;
}
@ -44,9 +46,9 @@ public class ChannelCommand extends PlayerCommand {
case "off", "leave" -> {
if (channels.isInChannel(player)) {
channels.leave(player);
player.sendMessage(ChatFormatter.parse("&#9878C9Вы вышли из канала"));
Msg.send(player, ChatFormatter.parse("&#9878C9Вы вышли из канала"));
} else {
player.sendMessage(ChatFormatter.parse("&#B798A8Вы не находитесь в канале"));
Msg.send(player, ChatFormatter.parse("&#B798A8Вы не находитесь в канале"));
}
}
case "list" -> listChannels(player, channels);
@ -59,22 +61,22 @@ public class ChannelCommand extends PlayerCommand {
Channel active = channels.getActive(player).orElse(null);
if (active == null) {
Channel def = channels.getDefault();
player.sendMessage(ChatFormatter.parse("&#B798A8Вы в дефолтном канале [&#7858E9"
Msg.send(player, ChatFormatter.parse("&#B798A8Вы в дефолтном канале [&#7858E9"
+ (def == null ? "?" : def.display() + "&8 " + def.prefix()) + "&#B798A8]"));
} else {
player.sendMessage(ChatFormatter.parse("&#9878C9Вы в канале [&#7858E9"
Msg.send(player, ChatFormatter.parse("&#9878C9Вы в канале [&#7858E9"
+ active.display() + "&8 " + active.prefix() + "&#9878C9]"));
}
player.sendMessage(ChatFormatter.parse("&#B798A8/join <канал> &#9878C9— войти, "
Msg.send(player, ChatFormatter.parse("&#B798A8/join <канал> &#9878C9— войти, "
+ "&#B798A8/channel list &#9878C9— все каналы"));
}
private void listChannels(Player player, ChannelService channels) {
player.sendMessage(ChatFormatter.parse("&#B798A8Доступные каналы:"));
Msg.send(player, ChatFormatter.parse("&#B798A8Доступные каналы:"));
for (Channel c : channels.getChannels()) {
boolean canUse = channels.canUse(player, c);
boolean active = c.equals(channels.getActive(player).orElse(null));
player.sendMessage(ChatFormatter.parse((canUse ? "&#9878C9" : "&#CF6679")
Msg.send(player, ChatFormatter.parse((canUse ? "&#9878C9" : "&#CF6679")
+ (active ? "\u25B8 " : "\u25AA ") + c.display() + "&8 " + c.prefix()
+ (canUse ? "" : " &#CF6679(нет прав)")
+ " &#B798A8— " + (c.isGlobalScope() ? "глобальный" : "локальный, " + c.radius() + "б")));
@ -84,21 +86,21 @@ public class ChannelCommand extends PlayerCommand {
private void joinChannel(Player player, ChannelService channels, String name) {
Channel channel = channels.find(name);
if (channel == null) {
player.sendMessage(ChatFormatter.parse("&#CF6679Канал &#7858E9" + name + " &#CF6679не найден"));
Msg.send(player, ChatFormatter.parse("&#CF6679Канал &#7858E9" + name + " &#CF6679не найден"));
return;
}
if (!channels.canUse(player, channel)) {
player.sendMessage(ChatFormatter.parse(
Msg.send(player, ChatFormatter.parse(
plugin.getConfigManager().getMessagesConfig().getNoPermission()));
return;
}
Channel active = channels.getActive(player).orElse(null);
channels.join(player, channel);
if (channel.equals(active)) {
player.sendMessage(ChatFormatter.parse("&#B798A8Вы уже в канале [&#7858E9"
Msg.send(player, ChatFormatter.parse("&#B798A8Вы уже в канале [&#7858E9"
+ channel.display() + "&8 " + channel.prefix() + "&#B798A8]"));
} else {
player.sendMessage(ChatFormatter.parse("&#9878C9Вы вошли в канал [&#7858E9"
Msg.send(player, ChatFormatter.parse("&#9878C9Вы вошли в канал [&#7858E9"
+ channel.display() + "&8 " + channel.prefix() + "&#9878C9]"));
}
}

View file

@ -1,5 +1,7 @@
package com.loki.lochat.commands.chat;
import com.loki.lochat.compat.Msg;
import com.loki.lochat.LoChat;
import com.loki.lochat.api.service.ChatService;
import com.loki.lochat.utils.format.ChatFormatter;
@ -30,16 +32,16 @@ public class GlobalChatCommand implements CommandExecutor {
if (command.getName().equalsIgnoreCase("globalchat")) {
if (args.length > 0 && args[0].equalsIgnoreCase("toggle")) {
boolean enabled = chatService.toggleGlobalChat(player.getUniqueId());
player.sendMessage(ChatFormatter.parse(
Msg.send(player, ChatFormatter.parse(
plugin.getMessageConfig().get(enabled ? "global.toggled-on" : "global.toggled-off")));
} else {
player.sendMessage(ChatFormatter.parse(plugin.getMessageConfig().getInvalidUsage("/globalchat toggle")));
Msg.send(player, ChatFormatter.parse(plugin.getMessageConfig().getInvalidUsage("/globalchat toggle")));
}
return true;
}
if (args.length == 0) {
player.sendMessage(ChatFormatter.parse(plugin.getMessageConfig().getInvalidUsage("/g <сообщение>")));
Msg.send(player, ChatFormatter.parse(plugin.getMessageConfig().getInvalidUsage("/g <сообщение>")));
return true;
}

View file

@ -1,5 +1,7 @@
package com.loki.lochat.commands.chat;
import com.loki.lochat.compat.Msg;
import com.loki.lochat.LoChat;
import com.loki.lochat.api.service.ChannelService;
import com.loki.lochat.channel.Channel;
@ -28,22 +30,22 @@ public class JoinChannelCommand extends PlayerCommand {
protected boolean executePlayerCommand(@NotNull Player player, @NotNull Command command,
@NotNull String label, @NotNull String[] args) {
if (!plugin.getConfigManager().getChannelConfig().isEnabled()) {
player.sendMessage(ChatFormatter.parse("&#CF6679Система каналов отключена"));
Msg.send(player, ChatFormatter.parse("&#CF6679Система каналов отключена"));
return true;
}
if (args.length == 0) {
player.sendMessage(ChatFormatter.parse("&#CF6679Использование: &#7858E9/join <канал>"));
Msg.send(player, ChatFormatter.parse("&#CF6679Использование: &#7858E9/join <канал>"));
return true;
}
ChannelService channels = plugin.getServiceRegistry().get(ChannelService.class);
Channel channel = channels.find(args[0]);
if (channel == null) {
player.sendMessage(ChatFormatter.parse("&#CF6679Канал &#7858E9" + args[0] + " &#CF6679не найден"));
Msg.send(player, ChatFormatter.parse("&#CF6679Канал &#7858E9" + args[0] + " &#CF6679не найден"));
return true;
}
if (!channels.canUse(player, channel)) {
player.sendMessage(ChatFormatter.parse(
Msg.send(player, ChatFormatter.parse(
plugin.getConfigManager().getMessagesConfig().getNoPermission()));
return true;
}
@ -51,13 +53,13 @@ public class JoinChannelCommand extends PlayerCommand {
Channel active = channels.getActive(player).orElse(null);
channels.join(player, channel);
if (channel.equals(channels.getDefault())) {
player.sendMessage(ChatFormatter.parse("&#9878C9Вы в канале [&#7858E9"
Msg.send(player, ChatFormatter.parse("&#9878C9Вы в канале [&#7858E9"
+ channel.display() + "&8 " + channel.prefix() + "&#9878C9] (дефолтный)"));
} else if (channel.equals(active)) {
player.sendMessage(ChatFormatter.parse("&#B798A8Вы уже в канале [&#7858E9"
Msg.send(player, ChatFormatter.parse("&#B798A8Вы уже в канале [&#7858E9"
+ channel.display() + "&8 " + channel.prefix() + "&#B798A8]"));
} else {
player.sendMessage(ChatFormatter.parse("&#9878C9Вы вошли в канал [&#7858E9"
Msg.send(player, ChatFormatter.parse("&#9878C9Вы вошли в канал [&#7858E9"
+ channel.display() + "&8 " + channel.prefix() + "&#9878C9]"));
}
return true;

View file

@ -1,5 +1,7 @@
package com.loki.lochat.commands.chat;
import com.loki.lochat.compat.Msg;
import com.loki.lochat.LoChat;
import com.loki.lochat.api.service.ChannelService;
import com.loki.lochat.commands.base.PlayerCommand;
@ -23,15 +25,15 @@ public class LeaveChannelCommand extends PlayerCommand {
@NotNull String label, @NotNull String[] args) {
ChannelService channels = plugin.getServiceRegistry().get(ChannelService.class);
if (!channels.isEnabled()) {
player.sendMessage(ChatFormatter.parse("&#CF6679Система каналов отключена"));
Msg.send(player, ChatFormatter.parse("&#CF6679Система каналов отключена"));
return true;
}
if (!channels.isInChannel(player)) {
player.sendMessage(ChatFormatter.parse("&#B798A8Вы не находитесь в канале"));
Msg.send(player, ChatFormatter.parse("&#B798A8Вы не находитесь в канале"));
return true;
}
channels.leave(player);
player.sendMessage(ChatFormatter.parse("&#9878C9Вы вышли из канала"));
Msg.send(player, ChatFormatter.parse("&#9878C9Вы вышли из канала"));
return true;
}
}

View file

@ -1,5 +1,7 @@
package com.loki.lochat.commands.chat;
import com.loki.lochat.compat.Msg;
import com.loki.lochat.LoChat;
import com.loki.lochat.api.service.ChatService;
import com.loki.lochat.utils.format.ChatFormatter;
@ -28,7 +30,7 @@ public class LocalChatCommand implements CommandExecutor {
}
if (args.length == 0) {
player.sendMessage(ChatFormatter.parse(plugin.getMessageConfig().getInvalidUsage("/l <сообщение>")));
Msg.send(player, ChatFormatter.parse(plugin.getMessageConfig().getInvalidUsage("/l <сообщение>")));
return true;
}

View file

@ -1,5 +1,7 @@
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.utils.format.ChatFormatter;
@ -28,26 +30,26 @@ public class IgnoreCommand implements CommandExecutor {
return true;
}
if (args.length == 0) {
player.sendMessage(ChatFormatter.parse(plugin.getMessageConfig().getInvalidUsage("/ignore <ник>")));
Msg.send(player, ChatFormatter.parse(plugin.getMessageConfig().getInvalidUsage("/ignore <ник>")));
return true;
}
Player target = Bukkit.getPlayer(args[0]);
if (target == null) {
player.sendMessage(ChatFormatter.parse(plugin.getMessageConfig().getPlayerNotFound()));
Msg.send(player, ChatFormatter.parse(plugin.getMessageConfig().getPlayerNotFound()));
return true;
}
if (target.equals(player)) {
player.sendMessage(ChatFormatter.parse(plugin.getMessageConfig().get("ignore.self")));
Msg.send(player, ChatFormatter.parse(plugin.getMessageConfig().get("ignore.self")));
return true;
}
if (messagingService.isIgnoring(player.getUniqueId(), target.getUniqueId())) {
player.sendMessage(ChatFormatter.parse(plugin.getMessageConfig().get("ignore.already-ignored")));
Msg.send(player, ChatFormatter.parse(plugin.getMessageConfig().get("ignore.already-ignored")));
return true;
}
messagingService.addIgnore(player.getUniqueId(), target.getUniqueId());
player.sendMessage(ChatFormatter.parse(plugin.getMessageConfig().get("ignore.added", "{player}", target.getName())));
Msg.send(player, ChatFormatter.parse(plugin.getMessageConfig().get("ignore.added", "{player}", target.getName())));
return true;
}
}

View file

@ -1,5 +1,7 @@
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.utils.format.ChatFormatter;
@ -33,18 +35,18 @@ public class IgnoreListCommand implements CommandExecutor {
Set<UUID> ignored = messagingService.getIgnoredPlayers(player.getUniqueId());
if (ignored.isEmpty()) {
player.sendMessage(ChatFormatter.parse(plugin.getMessageConfig().get("ignore.list-empty")));
Msg.send(player, ChatFormatter.parse(plugin.getMessageConfig().get("ignore.list-empty")));
return true;
}
player.sendMessage(ChatFormatter.parse(plugin.getMessageConfig().get("ignore.list-header")));
Msg.send(player, ChatFormatter.parse(plugin.getMessageConfig().get("ignore.list-header")));
for (UUID uuid : ignored) {
String name = PlayerUtil.getPlayerName(uuid);
if (name != null) {
player.sendMessage(ChatFormatter.parse("&#9878C9◆ &f" + name));
Msg.send(player, ChatFormatter.parse("&#9878C9◆ &f" + name));
}
}
player.sendMessage(ChatFormatter.parse(plugin.getMessageConfig().get("ignore.list-footer")
Msg.send(player, ChatFormatter.parse(plugin.getMessageConfig().get("ignore.list-footer")
.replace("{count}", String.valueOf(ignored.size()))));
return true;

View file

@ -1,5 +1,7 @@
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;
@ -34,25 +36,25 @@ public class MsgCommand implements CommandExecutor {
return true;
}
if (args.length < 2) {
player.sendMessage(ChatFormatter.parse(plugin.getMessageConfig().getInvalidUsage("/msg <ник> <сообщение>")));
Msg.send(player, ChatFormatter.parse(plugin.getMessageConfig().getInvalidUsage("/msg <ник> <сообщение>")));
return true;
}
Player target = Bukkit.getPlayer(args[0]);
if (target == null) {
player.sendMessage(ChatFormatter.parse(plugin.getMessageConfig().get("pm.player-offline")));
Msg.send(player, ChatFormatter.parse(plugin.getMessageConfig().get("pm.player-offline")));
return true;
}
if (target.equals(player)) {
player.sendMessage(ChatFormatter.parse(plugin.getMessageConfig().get("pm.self")));
Msg.send(player, ChatFormatter.parse(plugin.getMessageConfig().get("pm.self")));
return true;
}
if (messagingService.isIgnoring(target.getUniqueId(), player.getUniqueId())) {
player.sendMessage(ChatFormatter.parse(plugin.getMessageConfig().get("pm.ignored")));
Msg.send(player, ChatFormatter.parse(plugin.getMessageConfig().get("pm.ignored")));
return true;
}
if (messagingService.isIgnoring(player.getUniqueId(), target.getUniqueId())) {
player.sendMessage(ChatFormatter.parse(plugin.getMessageConfig().get("pm.ignored")));
Msg.send(player, ChatFormatter.parse(plugin.getMessageConfig().get("pm.ignored")));
return true;
}

View file

@ -1,5 +1,7 @@
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;
@ -37,23 +39,23 @@ public class ReplyCommand implements CommandExecutor {
return true;
}
if (args.length == 0) {
player.sendMessage(ChatFormatter.parse(plugin.getMessageConfig().getInvalidUsage("/reply <сообщение>")));
Msg.send(player, ChatFormatter.parse(plugin.getMessageConfig().getInvalidUsage("/reply <сообщение>")));
return true;
}
Optional<UUID> lastUuid = messagingService.getLastConversation(player.getUniqueId());
if (lastUuid.isEmpty()) {
player.sendMessage(ChatFormatter.parse(plugin.getMessageConfig().get("pm.no-reply")));
Msg.send(player, ChatFormatter.parse(plugin.getMessageConfig().get("pm.no-reply")));
return true;
}
Player target = Bukkit.getPlayer(lastUuid.get());
if (target == null) {
player.sendMessage(ChatFormatter.parse(plugin.getMessageConfig().get("pm.player-offline")));
Msg.send(player, ChatFormatter.parse(plugin.getMessageConfig().get("pm.player-offline")));
return true;
}
if (messagingService.isIgnoring(target.getUniqueId(), player.getUniqueId())) {
player.sendMessage(ChatFormatter.parse(plugin.getMessageConfig().get("pm.ignored")));
Msg.send(player, ChatFormatter.parse(plugin.getMessageConfig().get("pm.ignored")));
return true;
}

View file

@ -1,5 +1,7 @@
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.utils.format.ChatFormatter;
@ -28,22 +30,22 @@ public class UnignoreCommand implements CommandExecutor {
return true;
}
if (args.length == 0) {
player.sendMessage(ChatFormatter.parse(plugin.getMessageConfig().getInvalidUsage("/unignore <ник>")));
Msg.send(player, ChatFormatter.parse(plugin.getMessageConfig().getInvalidUsage("/unignore <ник>")));
return true;
}
Player target = Bukkit.getPlayer(args[0]);
if (target == null) {
player.sendMessage(ChatFormatter.parse(plugin.getMessageConfig().getPlayerNotFound()));
Msg.send(player, ChatFormatter.parse(plugin.getMessageConfig().getPlayerNotFound()));
return true;
}
if (!messagingService.isIgnoring(player.getUniqueId(), target.getUniqueId())) {
player.sendMessage(ChatFormatter.parse(plugin.getMessageConfig().get("ignore.not-ignored")));
Msg.send(player, ChatFormatter.parse(plugin.getMessageConfig().get("ignore.not-ignored")));
return true;
}
messagingService.removeIgnore(player.getUniqueId(), target.getUniqueId());
player.sendMessage(ChatFormatter.parse(plugin.getMessageConfig().get("ignore.removed", "{player}", target.getName())));
Msg.send(player, ChatFormatter.parse(plugin.getMessageConfig().get("ignore.removed", "{player}", target.getName())));
return true;
}
}

View file

@ -1,5 +1,7 @@
package com.loki.lochat.commands.moderation.ban;
import com.loki.lochat.compat.Msg;
import com.loki.lochat.LoChat;
import com.loki.lochat.api.service.MuteService;
import com.loki.lochat.api.service.PunishmentService;
@ -41,35 +43,35 @@ public class BanCommand implements CommandExecutor, TabCompleter {
@NotNull String label, @NotNull String[] args) {
MessagesConfig msg = plugin.getConfigManager().getMessagesConfig();
if (!sender.hasPermission("lochat.ban")) {
sender.sendMessage(ChatFormatter.parse(msg.getNoPermission()));
Msg.send(sender, ChatFormatter.parse(msg.getNoPermission()));
return true;
}
if (args.length < 1) {
sender.sendMessage(ChatFormatter.parse(msg.getBanUsage()));
sender.sendMessage(ChatFormatter.parse(msg.getMuteTimeHelp()));
Msg.send(sender, ChatFormatter.parse(msg.getBanUsage()));
Msg.send(sender, ChatFormatter.parse(msg.getMuteTimeHelp()));
return true;
}
String targetName = args[0];
UUID targetUuid = PlayerUtil.findPlayerUUID(targetName);
if (targetUuid == null) {
sender.sendMessage(ChatFormatter.parse(msg.getPlayerNotFound()));
Msg.send(sender, ChatFormatter.parse(msg.getPlayerNotFound()));
return true;
}
if (sender instanceof Player p && p.getUniqueId().equals(targetUuid)) {
sender.sendMessage(ChatFormatter.parse("&#CF6679Нельзя забанить самого себя"));
Msg.send(sender, ChatFormatter.parse("&#CF6679Нельзя забанить самого себя"));
return true;
}
Player onlineTarget = Bukkit.getPlayer(targetUuid);
if (onlineTarget != null && onlineTarget.hasPermission("lochat.bypass.ban") && !sender.hasPermission("lochat.ban.override")) {
sender.sendMessage(ChatFormatter.parse("&#CF6679Нельзя забанить этого игрока"));
Msg.send(sender, ChatFormatter.parse("&#CF6679Нельзя забанить этого игрока"));
return true;
}
if (punishmentService.isBanned(targetUuid)) {
sender.sendMessage(ChatFormatter.parse(msg.getAlreadyBanned()));
Msg.send(sender, ChatFormatter.parse(msg.getAlreadyBanned()));
return true;
}
@ -90,13 +92,13 @@ public class BanCommand implements CommandExecutor, TabCompleter {
String durationLabel = durationMs == 0
? msg.getModerationDurationPermanent()
: muteService.formatTime(durationMs);
sender.sendMessage(ChatFormatter.parse(msg.getBanConfirm().replace("{player}", finalName).replace("{duration}", durationLabel)));
Msg.send(sender, ChatFormatter.parse(msg.getBanConfirm().replace("{player}", finalName).replace("{duration}", durationLabel)));
BanRecord ban = punishmentService.getActiveBan(targetUuid);
if (ban != null) {
Player kicked = Bukkit.getPlayer(targetUuid);
if (kicked != null && kicked.isOnline()) {
kicked.kick(punishmentService.buildBanKickMessage(ban));
Msg.kick(kicked, punishmentService.buildBanKickMessage(ban));
}
}
return true;
@ -126,7 +128,7 @@ public class BanCommand implements CommandExecutor, TabCompleter {
} else {
durationMs = muteService.parseTime(timeStr);
if (durationMs < 0) {
sender.sendMessage(ChatFormatter.parse(msg.getInvalidTime()));
Msg.send(sender, ChatFormatter.parse(msg.getInvalidTime()));
return new DurationResult(0, "", false);
}
}

View file

@ -1,5 +1,7 @@
package com.loki.lochat.commands.moderation.ban;
import com.loki.lochat.compat.Msg;
import com.loki.lochat.LoChat;
import com.loki.lochat.api.service.PunishmentService;
import com.loki.lochat.config.MessagesConfig;
@ -37,22 +39,22 @@ public class UnbanCommand implements CommandExecutor, TabCompleter {
@NotNull String label, @NotNull String[] args) {
MessagesConfig msg = plugin.getConfigManager().getMessagesConfig();
if (!sender.hasPermission("lochat.unban")) {
sender.sendMessage(ChatFormatter.parse(msg.getNoPermission()));
Msg.send(sender, ChatFormatter.parse(msg.getNoPermission()));
return true;
}
if (args.length < 1) {
sender.sendMessage(ChatFormatter.parse("&#B798A8Использование: &#7858E9/lunban <ник>"));
Msg.send(sender, ChatFormatter.parse("&#B798A8Использование: &#7858E9/lunban <ник>"));
return true;
}
UUID uuid = PlayerUtil.findPlayerUUID(args[0]);
if (uuid == null) {
sender.sendMessage(ChatFormatter.parse(msg.getPlayerNotFound()));
Msg.send(sender, ChatFormatter.parse(msg.getPlayerNotFound()));
return true;
}
if (!punishmentService.isBanned(uuid)) {
sender.sendMessage(ChatFormatter.parse(msg.getNotBanned()));
Msg.send(sender, ChatFormatter.parse(msg.getNotBanned()));
return true;
}
@ -62,7 +64,7 @@ public class UnbanCommand implements CommandExecutor, TabCompleter {
}
punishmentService.unban(uuid);
sender.sendMessage(ChatFormatter.parse(msg.getUnbanConfirm().replace("{player}", name)));
Msg.send(sender, ChatFormatter.parse(msg.getUnbanConfirm().replace("{player}", name)));
return true;
}

View file

@ -1,5 +1,7 @@
package com.loki.lochat.commands.moderation.mute;
import com.loki.lochat.compat.Msg;
import com.loki.lochat.LoChat;
import com.loki.lochat.api.service.MuteService;
import com.loki.lochat.data.model.MuteData;
@ -32,7 +34,7 @@ public class MuteBlameCommand implements CommandExecutor, TabCompleter {
@Override
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
if (!sender.hasPermission("lochat.muteblame")) {
sender.sendMessage(plugin.getMessageConfig().getComponent("errors.no-permission"));
Msg.send(sender, plugin.getMessageConfig().getComponent("errors.no-permission"));
return true;
}
if (args.length < 1) {

View file

@ -1,5 +1,7 @@
package com.loki.lochat.commands.moderation.mute;
import com.loki.lochat.compat.Msg;
import com.loki.lochat.LoChat;
import com.loki.lochat.api.service.MuteService;
import com.loki.lochat.config.MessagesConfig;
@ -40,14 +42,14 @@ public class MuteCommand implements CommandExecutor, TabCompleter {
MessagesConfig hm = plugin.getConfigManager().getMessagesConfig();
if (!sender.hasPermission("lochat.mute")) {
sender.sendMessage(plugin.getMessageConfig().getComponent("errors.no-permission"));
Msg.send(sender, plugin.getMessageConfig().getComponent("errors.no-permission"));
return true;
}
if (args.length < 1) {
sender.sendMessage(ChatFormatter.parse(hm.getMuteUsage()));
sender.sendMessage(ChatFormatter.parse(hm.getMuteTimeHelp()));
sender.sendMessage(ChatFormatter.parse(hm.getMuteSilentHelp()));
Msg.send(sender, ChatFormatter.parse(hm.getMuteUsage()));
Msg.send(sender, ChatFormatter.parse(hm.getMuteTimeHelp()));
Msg.send(sender, ChatFormatter.parse(hm.getMuteSilentHelp()));
return true;
}
@ -63,18 +65,18 @@ public class MuteCommand implements CommandExecutor, TabCompleter {
if (sender instanceof Player p && !muteService.canMuteForDuration(p, duration)) {
long max = muteService.getMaxDuration(p);
sender.sendMessage(ChatFormatter.parse("&#CF6679Нельзя мутить на такой срок! &#B798A8Максимум: &#7858E9" +
Msg.send(sender, ChatFormatter.parse("&#CF6679Нельзя мутить на такой срок! &#B798A8Максимум: &#7858E9" +
(max == 0 ? "навсегда" : muteService.formatTime(max))));
return true;
}
UUID targetUUID = com.loki.lochat.utils.player.PlayerUtil.findPlayerUUID(targetName);
if (targetUUID == null) {
sender.sendMessage(plugin.getMessageConfig().getComponent("errors.player-not-found"));
Msg.send(sender, plugin.getMessageConfig().getComponent("errors.player-not-found"));
return true;
}
if (muteService.isMuted(targetUUID)) {
sender.sendMessage(ChatFormatter.parse("&#CF6679Игрок уже замучен!"));
Msg.send(sender, ChatFormatter.parse("&#CF6679Игрок уже замучен!"));
return true;
}
@ -104,7 +106,7 @@ public class MuteCommand implements CommandExecutor, TabCompleter {
}
if (silent && !sender.hasPermission("lochat.mute.silent")) {
sender.sendMessage(ChatFormatter.parse(hm.getNoSilentMutePermission()));
Msg.send(sender, ChatFormatter.parse(hm.getNoSilentMutePermission()));
return null;
}
@ -131,7 +133,7 @@ public class MuteCommand implements CommandExecutor, TabCompleter {
}
long dur = muteService.parseTime(timeStr);
if (dur < 0) {
sender.sendMessage(ChatFormatter.parse(hm.getMuteTimeHelp()));
Msg.send(sender, ChatFormatter.parse(hm.getMuteTimeHelp()));
}
return dur;
}
@ -145,27 +147,27 @@ public class MuteCommand implements CommandExecutor, TabCompleter {
muteService.mute(targetUUID, finalName, duration, reason, op);
String timeDisplay = duration == 0 ? "навсегда" : muteService.formatTime(duration);
sender.sendMessage(ChatFormatter.parse("&#9878C9Игрок &#7858E9" + finalName + " &#9878C9замучен на &#7858E9" + timeDisplay));
sender.sendMessage(ChatFormatter.parse("&#B798A8Причина: &f" + reason));
Msg.send(sender, ChatFormatter.parse("&#9878C9Игрок &#7858E9" + finalName + " &#9878C9замучен на &#7858E9" + timeDisplay));
Msg.send(sender, ChatFormatter.parse("&#B798A8Причина: &f" + reason));
if (target != null) {
String youMsg = duration == 0
? hm.getMutedPermanent().replace("{reason}", reason)
: hm.getMutedMessage().replace("{reason}", reason).replace("{time}", timeDisplay);
target.sendMessage(ChatFormatter.parse(youMsg));
Msg.send(target, ChatFormatter.parse(youMsg));
}
if (silent) {
String msgText = hm.getPlayerMutedSilent().replace("{player}", finalName).replace("{time}", timeDisplay);
for (Player p : Bukkit.getOnlinePlayers()) {
if (p.hasPermission("lochat.mute.see-silent")) {
p.sendMessage(ChatFormatter.parse(msgText));
Msg.send(p, ChatFormatter.parse(msgText));
}
}
} else {
String broadcastMsg = (duration == 0 ? hm.getPlayerMutedPermanent() : hm.getPlayerMuted())
.replace("{player}", finalName).replace("{time}", timeDisplay).replace("{reason}", reason);
Bukkit.broadcast(ChatFormatter.parse(broadcastMsg));
Msg.broadcast(ChatFormatter.parse(broadcastMsg));
}
String voiceCmd = plugin.getConfig().getString("moderation.voice-mute-console-command", "");

View file

@ -1,5 +1,7 @@
package com.loki.lochat.commands.moderation.mute;
import com.loki.lochat.compat.Msg;
import com.loki.lochat.LoChat;
import com.loki.lochat.api.service.MuteService;
import com.loki.lochat.data.model.MuteData;
@ -33,7 +35,7 @@ public class MuteHistoryCommand implements CommandExecutor, TabCompleter {
@Override
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
if (!sender.hasPermission("lochat.mutehistory")) {
sender.sendMessage(plugin.getMessageConfig().getComponent("errors.no-permission"));
Msg.send(sender, plugin.getMessageConfig().getComponent("errors.no-permission"));
return true;
}
if (args.length < 1) {
@ -46,7 +48,7 @@ public class MuteHistoryCommand implements CommandExecutor, TabCompleter {
uuid = muteService.getUUIDByName(args[0]);
}
if (uuid == null) {
sender.sendMessage(plugin.getMessageConfig().getComponent("errors.player-not-found"));
Msg.send(sender, plugin.getMessageConfig().getComponent("errors.player-not-found"));
return true;
}

View file

@ -1,5 +1,7 @@
package com.loki.lochat.commands.moderation.mute;
import com.loki.lochat.compat.Msg;
import com.loki.lochat.LoChat;
import com.loki.lochat.api.service.MuteService;
import com.loki.lochat.data.model.MuteData;
@ -29,7 +31,7 @@ public class MuteListCommand implements CommandExecutor {
@Override
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
if (!sender.hasPermission("lochat.mutelist")) {
sender.sendMessage(plugin.getMessageConfig().getComponent("errors.no-permission"));
Msg.send(sender, plugin.getMessageConfig().getComponent("errors.no-permission"));
return true;
}

View file

@ -1,5 +1,7 @@
package com.loki.lochat.commands.moderation.mute;
import com.loki.lochat.compat.Msg;
import com.loki.lochat.LoChat;
import com.loki.lochat.api.service.MuteService;
import com.loki.lochat.utils.format.ChatFormatter;
@ -30,11 +32,11 @@ public class UnmuteCommand implements CommandExecutor, TabCompleter {
@Override
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
if (!sender.hasPermission("lochat.unmute")) {
sender.sendMessage(plugin.getMessageConfig().getComponent("errors.no-permission"));
Msg.send(sender, plugin.getMessageConfig().getComponent("errors.no-permission"));
return true;
}
if (args.length < 1) {
sender.sendMessage(ChatFormatter.parse("&#CF6679Использование: /unmute <ник> [-s]"));
Msg.send(sender, ChatFormatter.parse("&#CF6679Использование: /unmute <ник> [-s]"));
return true;
}
@ -48,13 +50,13 @@ public class UnmuteCommand implements CommandExecutor, TabCompleter {
}
}
if (silent && !sender.hasPermission("lochat.mute.silent")) {
sender.sendMessage(ChatFormatter.parse(plugin.getConfigManager().getMessagesConfig().getNoSilentUnmutePermission()));
Msg.send(sender, ChatFormatter.parse(plugin.getConfigManager().getMessagesConfig().getNoSilentUnmutePermission()));
return true;
}
UUID uuid = com.loki.lochat.utils.player.PlayerUtil.findPlayerUUID(targetName);
if (uuid == null) {
sender.sendMessage(plugin.getMessageConfig().getComponent("errors.player-not-found"));
Msg.send(sender, plugin.getMessageConfig().getComponent("errors.player-not-found"));
return true;
}
@ -63,22 +65,22 @@ public class UnmuteCommand implements CommandExecutor, TabCompleter {
String op = sender.getName();
if (muteService.unmute(uuid, op)) {
sender.sendMessage(ChatFormatter.parse("&#9878C9Игрок &#7858E9" + name + " &#9878C9размучен"));
Msg.send(sender, ChatFormatter.parse("&#9878C9Игрок &#7858E9" + name + " &#9878C9размучен"));
if (target != null) {
target.sendMessage(ChatFormatter.parse("&#9878C9Вы были &#7858E9размучены!"));
Msg.send(target, ChatFormatter.parse("&#9878C9Вы были &#7858E9размучены!"));
}
if (silent) {
String msg = "&#B798A8[&#9878C9ТИХО&#B798A8] &#7858E9" + name + " &#B798A8размучен &#9878C9(" + op + ")";
for (Player p : Bukkit.getOnlinePlayers()) {
if (p.hasPermission("lochat.mute.see-silent")) {
p.sendMessage(ChatFormatter.parse(msg));
Msg.send(p, ChatFormatter.parse(msg));
}
}
} else {
Bukkit.broadcast(ChatFormatter.parse("&#9878C9Игрок &#7858E9" + name + " &#9878C9размучен модератором &#7858E9" + op));
Msg.broadcast(ChatFormatter.parse("&#9878C9Игрок &#7858E9" + name + " &#9878C9размучен модератором &#7858E9" + op));
}
} else {
sender.sendMessage(ChatFormatter.parse(plugin.getConfigManager().getMessagesConfig().getPlayerNotMutedSimple()));
Msg.send(sender, ChatFormatter.parse(plugin.getConfigManager().getMessagesConfig().getPlayerNotMutedSimple()));
}
return true;
}

View file

@ -1,5 +1,7 @@
package com.loki.lochat.commands.moderation.warn;
import com.loki.lochat.compat.Msg;
import com.loki.lochat.LoChat;
import com.loki.lochat.api.service.PunishmentService;
import com.loki.lochat.config.MessagesConfig;
@ -37,17 +39,17 @@ public class SilentWarnCommand implements CommandExecutor, TabCompleter {
@NotNull String label, @NotNull String[] args) {
MessagesConfig msg = plugin.getConfigManager().getMessagesConfig();
if (!sender.hasPermission("lochat.warn.silent")) {
sender.sendMessage(ChatFormatter.parse(msg.getNoPermission()));
Msg.send(sender, ChatFormatter.parse(msg.getNoPermission()));
return true;
}
if (args.length < 1) {
sender.sendMessage(ChatFormatter.parse(msg.getSilentWarnUsage()));
Msg.send(sender, ChatFormatter.parse(msg.getSilentWarnUsage()));
return true;
}
UUID targetUuid = PlayerUtil.findPlayerUUID(args[0]);
if (targetUuid == null) {
sender.sendMessage(ChatFormatter.parse(msg.getPlayerNotFound()));
Msg.send(sender, ChatFormatter.parse(msg.getPlayerNotFound()));
return true;
}
@ -62,12 +64,12 @@ public class SilentWarnCommand implements CommandExecutor, TabCompleter {
punishmentService.addWarn(targetUuid, name, mod, reason, true);
sender.sendMessage(ChatFormatter.parse(msg.getWarnStaffConfirm().replace("{player}", name).replace("{reason}", reason)));
Msg.send(sender, ChatFormatter.parse(msg.getWarnStaffConfirm().replace("{player}", name).replace("{reason}", reason)));
String staffLine = msg.getSilentWarnStaff().replace("{player}", name).replace("{reason}", reason);
for (Player p : Bukkit.getOnlinePlayers()) {
if (p.hasPermission("lochat.warn.notify")) {
p.sendMessage(ChatFormatter.parse(staffLine));
Msg.send(p, ChatFormatter.parse(staffLine));
}
}
return true;

View file

@ -1,5 +1,7 @@
package com.loki.lochat.commands.moderation.warn;
import com.loki.lochat.compat.Msg;
import com.loki.lochat.LoChat;
import com.loki.lochat.api.service.PunishmentService;
import com.loki.lochat.config.MessagesConfig;
@ -37,22 +39,22 @@ public class WarnCommand implements CommandExecutor, TabCompleter {
@NotNull String label, @NotNull String[] args) {
MessagesConfig msg = plugin.getConfigManager().getMessagesConfig();
if (!sender.hasPermission("lochat.warn")) {
sender.sendMessage(ChatFormatter.parse(msg.getNoPermission()));
Msg.send(sender, ChatFormatter.parse(msg.getNoPermission()));
return true;
}
if (args.length < 1) {
sender.sendMessage(ChatFormatter.parse(msg.getWarnUsage()));
Msg.send(sender, ChatFormatter.parse(msg.getWarnUsage()));
return true;
}
UUID targetUuid = PlayerUtil.findPlayerUUID(args[0]);
if (targetUuid == null) {
sender.sendMessage(ChatFormatter.parse(msg.getPlayerNotFound()));
Msg.send(sender, ChatFormatter.parse(msg.getPlayerNotFound()));
return true;
}
if (sender instanceof Player p && p.getUniqueId().equals(targetUuid)) {
sender.sendMessage(ChatFormatter.parse("&#CF6679Нельзя выдать варн самому себе"));
Msg.send(sender, ChatFormatter.parse("&#CF6679Нельзя выдать варн самому себе"));
return true;
}
@ -65,16 +67,16 @@ public class WarnCommand implements CommandExecutor, TabCompleter {
Player targetOnline = Bukkit.getPlayer(targetUuid);
if (targetOnline != null && targetOnline.hasPermission("lochat.bypass.warn")) {
sender.sendMessage(ChatFormatter.parse("&#CF6679У этого игрока защита от варнов"));
Msg.send(sender, ChatFormatter.parse("&#CF6679У этого игрока защита от варнов"));
return true;
}
punishmentService.addWarn(targetUuid, name, mod, reason, false);
sender.sendMessage(ChatFormatter.parse(msg.getWarnStaffConfirm().replace("{player}", name).replace("{reason}", reason)));
Msg.send(sender, ChatFormatter.parse(msg.getWarnStaffConfirm().replace("{player}", name).replace("{reason}", reason)));
if (targetOnline != null && targetOnline.isOnline()) {
targetOnline.sendMessage(ChatFormatter.parse(msg.getWarnReceived().replace("{reason}", reason)));
Msg.send(targetOnline, ChatFormatter.parse(msg.getWarnReceived().replace("{reason}", reason)));
}
return true;
}

View file

@ -1,5 +1,7 @@
package com.loki.lochat.commands.nick;
import com.loki.lochat.compat.Msg;
import com.loki.lochat.LoChat;
import com.loki.lochat.api.service.NickService;
import com.loki.lochat.utils.format.ChatFormatter;
@ -29,55 +31,55 @@ public class NickCommand implements CommandExecutor, TabCompleter {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!(sender instanceof Player player)) {
sender.sendMessage(Component.text(plugin.getConfigManager().getMessagesConfig().getPlayerOnly(), NamedTextColor.RED));
Msg.send(sender, Component.text(plugin.getConfigManager().getMessagesConfig().getPlayerOnly(), NamedTextColor.RED));
return true;
}
if (!player.hasPermission("lochat.nick")) {
player.sendMessage(ChatFormatter.parse(plugin.getConfigManager().getMessagesConfig().getNoPermission()));
Msg.send(player, ChatFormatter.parse(plugin.getConfigManager().getMessagesConfig().getNoPermission()));
return true;
}
if (args.length == 0) {
var nick = nickService.getNickname(player.getUniqueId());
if (nick.isPresent()) {
player.sendMessage(ChatFormatter.parse(plugin.getMessageConfig().get("nick.current", "{nick}", nick.get())));
player.sendMessage(ChatFormatter.parse(plugin.getMessageConfig().get("nick.reset-usage")));
Msg.send(player, ChatFormatter.parse(plugin.getMessageConfig().get("nick.current", "{nick}", nick.get())));
Msg.send(player, ChatFormatter.parse(plugin.getMessageConfig().get("nick.reset-usage")));
} else {
player.sendMessage(ChatFormatter.parse(plugin.getMessageConfig().get("nick.no-nick")));
player.sendMessage(ChatFormatter.parse(plugin.getMessageConfig().get("nick.set-usage")));
Msg.send(player, ChatFormatter.parse(plugin.getMessageConfig().get("nick.no-nick")));
Msg.send(player, ChatFormatter.parse(plugin.getMessageConfig().get("nick.set-usage")));
}
return true;
}
if (args[0].equalsIgnoreCase("reset")) {
if (nickService.getNickname(player.getUniqueId()).isEmpty()) {
player.sendMessage(ChatFormatter.parse(plugin.getMessageConfig().get("nick.no-nick")));
Msg.send(player, ChatFormatter.parse(plugin.getMessageConfig().get("nick.no-nick")));
return true;
}
nickService.resetNickname(player.getUniqueId());
player.sendMessage(ChatFormatter.parse(plugin.getMessageConfig().get("nick.reset-success")));
Msg.send(player, ChatFormatter.parse(plugin.getMessageConfig().get("nick.reset-success")));
return true;
}
String nickname = String.join(" ", args);
if (!nickService.isValidNickname(nickname)) {
player.sendMessage(ChatFormatter.parse(plugin.getMessageConfig().get("nick.invalid")));
player.sendMessage(ChatFormatter.parse(plugin.getMessageConfig().get("nick.requirements-header")));
player.sendMessage(ChatFormatter.parse(plugin.getMessageConfig().get("nick.requirements-length")));
player.sendMessage(ChatFormatter.parse(plugin.getMessageConfig().get("nick.requirements-chars")));
Msg.send(player, ChatFormatter.parse(plugin.getMessageConfig().get("nick.invalid")));
Msg.send(player, ChatFormatter.parse(plugin.getMessageConfig().get("nick.requirements-header")));
Msg.send(player, ChatFormatter.parse(plugin.getMessageConfig().get("nick.requirements-length")));
Msg.send(player, ChatFormatter.parse(plugin.getMessageConfig().get("nick.requirements-chars")));
return true;
}
if (nickService.isNicknameTaken(nickname)) {
var cur = nickService.getNickname(player.getUniqueId());
if (cur.isEmpty() || !cur.get().equals(nickname)) {
player.sendMessage(ChatFormatter.parse(plugin.getMessageConfig().get("nick.taken")));
Msg.send(player, ChatFormatter.parse(plugin.getMessageConfig().get("nick.taken")));
return true;
}
}
if (nickService.setNickname(player.getUniqueId(), nickname)) {
player.sendMessage(ChatFormatter.parse(plugin.getMessageConfig().get("nick.set-success", "{nick}", nickname)));
Msg.send(player, ChatFormatter.parse(plugin.getMessageConfig().get("nick.set-success", "{nick}", nickname)));
} else {
player.sendMessage(ChatFormatter.parse(plugin.getMessageConfig().get("nick.error")));
Msg.send(player, ChatFormatter.parse(plugin.getMessageConfig().get("nick.error")));
}
return true;
}

View file

@ -1,5 +1,7 @@
package com.loki.lochat.commands.nick;
import com.loki.lochat.compat.Msg;
import com.loki.lochat.LoChat;
import com.loki.lochat.api.service.MuteService;
import com.loki.lochat.api.service.PunishmentService;
@ -41,17 +43,17 @@ public class PlayerInfoCommand implements CommandExecutor, TabCompleter {
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command,
@NotNull String label, @NotNull String[] args) {
if (!sender.hasPermission("lochat.playerinfo")) {
sender.sendMessage(ChatFormatter.parse(plugin.getConfigManager().getMessagesConfig().getNoPermission()));
Msg.send(sender, ChatFormatter.parse(plugin.getConfigManager().getMessagesConfig().getNoPermission()));
return true;
}
if (args.length < 1) {
sender.sendMessage(ChatFormatter.parse("&#B798A8Использование: &#7858E9/playerinfo <ник>"));
Msg.send(sender, ChatFormatter.parse("&#B798A8Использование: &#7858E9/playerinfo <ник>"));
return true;
}
UUID uuid = PlayerUtil.findPlayerUUID(args[0]);
if (uuid == null) {
sender.sendMessage(ChatFormatter.parse("&#CF6679Игрок не найден"));
Msg.send(sender, ChatFormatter.parse("&#CF6679Игрок не найден"));
return true;
}
@ -62,22 +64,22 @@ public class PlayerInfoCommand implements CommandExecutor, TabCompleter {
Player target = Bukkit.getPlayer(uuid);
sender.sendMessage(ChatFormatter.parse("<gradient:#7858E9:#B798A8><bold>═══════ Профиль: " + name + " ═══════</bold></gradient>"));
Msg.send(sender, ChatFormatter.parse("<gradient:#7858E9:#B798A8><bold>═══════ Профиль: " + name + " ═══════</bold></gradient>"));
if (target != null) {
sender.sendMessage(ChatFormatter.parse("&#9878C9❤ &fЗдоровье: &#7858E9" + Math.round(target.getHealth()) + "/20"));
sender.sendMessage(ChatFormatter.parse("&#9878C9✦ &fРежим: &#7858E9" + target.getGameMode().name().toLowerCase()));
sender.sendMessage(ChatFormatter.parse("&#9878C9◆ &fМир: &#7858E9" + target.getWorld().getName()));
Msg.send(sender, ChatFormatter.parse("&#9878C9❤ &fЗдоровье: &#7858E9" + Math.round(target.getHealth()) + "/20"));
Msg.send(sender, ChatFormatter.parse("&#9878C9✦ &fРежим: &#7858E9" + target.getGameMode().name().toLowerCase()));
Msg.send(sender, ChatFormatter.parse("&#9878C9◆ &fМир: &#7858E9" + target.getWorld().getName()));
} else {
sender.sendMessage(ChatFormatter.parse("&#B798A8Игрок &#7858E9не в сети"));
Msg.send(sender, ChatFormatter.parse("&#B798A8Игрок &#7858E9не в сети"));
}
if (plugin.getGradientModule() != null && target != null) {
sender.sendMessage(ChatFormatter.parse("&#9878C9⚡ &fГрадиент: " + plugin.getGradientModule().getFormattedName(target)));
Msg.send(sender, ChatFormatter.parse("&#9878C9⚡ &fГрадиент: " + plugin.getGradientModule().getFormattedName(target)));
}
int warns = punishmentService.getWarnCount(uuid);
sender.sendMessage(ChatFormatter.parse("&#CF6679⚠ &fВарнов всего: &#7858E9" + warns));
Msg.send(sender, ChatFormatter.parse("&#CF6679⚠ &fВарнов всего: &#7858E9" + warns));
List<WarnEntry> recent = punishmentService.getWarns(uuid);
int show = Math.min(5, recent.size());
@ -86,7 +88,7 @@ public class PlayerInfoCommand implements CommandExecutor, TabCompleter {
String tag = w.silent ? "&#B798A8[тихий] " : "";
String reason = w.reason != null ? w.reason : "—";
long t = w.time;
sender.sendMessage(ChatFormatter.parse(
Msg.send(sender, ChatFormatter.parse(
tag + "&#9878C9• &7" + formatTime(t) + " &#B798A8от &#7858E9" + w.moderator + "&#9878C9: &f" + reason));
}
@ -95,27 +97,27 @@ public class PlayerInfoCommand implements CommandExecutor, TabCompleter {
String until = ban.isPermanent()
? "&#CF6679навсегда"
: "&#7858E9" + muteService.formatTime(Math.max(0, ban.until - System.currentTimeMillis()));
sender.sendMessage(ChatFormatter.parse("&#CF6679🚫 &fБан: &cактивен &7(" + until + "&7)"));
sender.sendMessage(ChatFormatter.parse("&#B798A8Причина: &f" + (ban.reason != null ? ban.reason : "—")));
Msg.send(sender, ChatFormatter.parse("&#CF6679🚫 &fБан: &cактивен &7(" + until + "&7)"));
Msg.send(sender, ChatFormatter.parse("&#B798A8Причина: &f" + (ban.reason != null ? ban.reason : "—")));
} else {
sender.sendMessage(ChatFormatter.parse("&#9878C9🚫 &fБан: &aнет"));
Msg.send(sender, ChatFormatter.parse("&#9878C9🚫 &fБан: &aнет"));
}
if (muteService.isMuted(uuid)) {
MuteData md = muteService.getMuteData(uuid);
long rem = muteService.getRemainingTime(uuid);
String remStr = rem < 0 ? "навсегда" : muteService.formatTime(rem);
sender.sendMessage(ChatFormatter.parse("&#CF6679🔇 &fМут: &cда &7(" + remStr + "&7)"));
Msg.send(sender, ChatFormatter.parse("&#CF6679🔇 &fМут: &cда &7(" + remStr + "&7)"));
if (md != null) {
sender.sendMessage(ChatFormatter.parse("&#B798A8Причина: &f" + (md.getReason() != null ? md.getReason() : "—")));
Msg.send(sender, ChatFormatter.parse("&#B798A8Причина: &f" + (md.getReason() != null ? md.getReason() : "—")));
}
} else {
sender.sendMessage(ChatFormatter.parse("&#9878C9🔇 &fМут: &aнет"));
Msg.send(sender, ChatFormatter.parse("&#9878C9🔇 &fМут: &aнет"));
}
var muteHist = muteService.getPlayerHistory(uuid);
if (muteHist != null && !muteHist.isEmpty()) {
sender.sendMessage(ChatFormatter.parse("&#B798A8Записей в истории мутов: &#7858E9" + muteHist.size()));
Msg.send(sender, ChatFormatter.parse("&#B798A8Записей в истории мутов: &#7858E9" + muteHist.size()));
}
return true;

View file

@ -1,5 +1,7 @@
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;
@ -37,7 +39,7 @@ public class DoCommand extends PlayerCommand {
int remaining = playerService.getRemainingCooldown(player.getUniqueId(), "rp_do", cooldown);
String msg = plugin.getConfigManager().getMessagesConfig().getCooldownMessage()
.replace("{remaining}", String.valueOf(remaining));
player.sendMessage(ChatFormatter.parse(msg));
Msg.send(player, ChatFormatter.parse(msg));
return true;
}

View file

@ -1,5 +1,7 @@
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;
@ -37,7 +39,7 @@ public class MeCommand extends PlayerCommand {
int remaining = playerService.getRemainingCooldown(player.getUniqueId(), "rp_me", cooldown);
String msg = plugin.getConfigManager().getMessagesConfig().getCooldownMessage()
.replace("{remaining}", String.valueOf(remaining));
player.sendMessage(ChatFormatter.parse(msg));
Msg.send(player, ChatFormatter.parse(msg));
return true;
}

View file

@ -1,5 +1,7 @@
package com.loki.lochat.commands.rp;
import com.loki.lochat.compat.Msg;
import com.loki.lochat.LoChat;
import com.loki.lochat.commands.base.PlayerCommand;
import com.loki.lochat.config.RatConfig;
@ -41,19 +43,19 @@ public class RollCommand extends PlayerCommand {
try {
max = Integer.parseInt(args[0]);
if (max < 2) {
player.sendMessage(ChatFormatter.parse(
Msg.send(player, ChatFormatter.parse(
plugin.getConfigManager().getString("rp.roll-min-error",
"<red>Минимальное значение кубика: 2</red>")));
return true;
}
if (max > RatConfig.ROLL_ABSOLUTE_MAX) {
player.sendMessage(ChatFormatter.parse(
Msg.send(player, ChatFormatter.parse(
plugin.getConfigManager().getString("rp.roll-max-error",
"<red>Максимальное значение кубика: 1000000</red>")));
return true;
}
} catch (NumberFormatException e) {
player.sendMessage(ChatFormatter.parse(
Msg.send(player, ChatFormatter.parse(
plugin.getConfigManager().getString("rp.roll-invalid-number",
"<red>Укажите число: /roll [максимум]</red>")));
return true;

View file

@ -1,5 +1,7 @@
package com.loki.lochat.commands.rp;
import com.loki.lochat.compat.Msg;
import com.loki.lochat.LoChat;
import com.loki.lochat.utils.player.DistanceUtil;
@ -22,7 +24,7 @@ public final class RpUtil {
public static void sendToRadius(Player sender, Component message, int radius) {
for (Player player : Bukkit.getOnlinePlayers()) {
if (DistanceUtil.isInRange(sender, player, radius)) {
player.sendMessage(message);
Msg.send(player, message);
}
}
}
@ -39,8 +41,10 @@ public final class RpUtil {
} catch (Exception ignored) {
}
// Пробуем взять displayName (может содержать градиент от NickService)
Component displayName = player.displayName();
// Пробуем взять displayName (может содержать градиент от NickService) — Spigot: legacy String
String displayNameLegacy = player.getDisplayName();
Component displayName = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer
.legacySection().deserialize(displayNameLegacy);
String plain = PlainTextComponentSerializer.plainText().serialize(displayName);
// Если displayName == обычное имя — возвращаем его напрямую (без потери цветов не нужно)
if (plain.equals(player.getName())) {

View file

@ -1,5 +1,7 @@
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;
@ -40,7 +42,7 @@ public class TryCommand extends PlayerCommand {
int remaining = playerService.getRemainingCooldown(player.getUniqueId(), "rp_try", cooldown);
String msg = plugin.getConfigManager().getMessagesConfig().getCooldownMessage()
.replace("{remaining}", String.valueOf(remaining));
player.sendMessage(ChatFormatter.parse(msg));
Msg.send(player, ChatFormatter.parse(msg));
return true;
}

View file

@ -1,5 +1,7 @@
package com.loki.lochat.config;
import com.loki.lochat.compat.Msg;
import com.loki.lochat.LoChat;
import com.loki.lochat.utils.format.ChatFormatter;
@ -64,14 +66,14 @@ public class MessageConfig {
* Отправляет сообщение игроку
*/
public void send(CommandSender sender, String path) {
sender.sendMessage(getComponent(path));
Msg.send(sender, getComponent(path));
}
/**
* Отправляет сообщение игроку с заменами
*/
public void send(CommandSender sender, String path, String... replacements) {
sender.sendMessage(getComponent(path, replacements));
Msg.send(sender, getComponent(path, replacements));
}
// Shortcuts

View file

@ -1,5 +1,7 @@
package com.loki.lochat.core.filter;
import com.loki.lochat.compat.Msg;
import com.loki.lochat.api.filter.MessageFilter;
import com.loki.lochat.api.service.MuteService;
import com.loki.lochat.config.MessagesConfig;
@ -49,6 +51,6 @@ public class MuteFilter implements MessageFilter {
.replace("{time}", timeStr);
}
player.sendMessage(ChatFormatter.parse(msg));
Msg.send(player, ChatFormatter.parse(msg));
}
}

View file

@ -1,5 +1,7 @@
package com.loki.lochat.core.service;
import com.loki.lochat.compat.Msg;
import com.loki.lochat.LoChat;
import com.loki.lochat.api.service.ChatService;
import com.loki.lochat.api.service.MessageService;
@ -52,9 +54,10 @@ public class ChatServiceImpl implements ChatService {
return;
}
EnhancedChatRenderer renderer = new EnhancedChatRenderer(plugin, true);
Component senderDisplay = Component.text(sender.getDisplayName());
for (Player p : Bukkit.getOnlinePlayers()) {
if (!isGlobalChatDisabled(p.getUniqueId())) {
p.sendMessage(renderer.render(sender, sender.displayName(), msg, p));
Msg.send(p, renderer.render(sender, senderDisplay, msg, p));
}
}
}
@ -69,14 +72,15 @@ public class ChatServiceImpl implements ChatService {
EnhancedChatRenderer renderer = new EnhancedChatRenderer(plugin, false);
int count = 0;
Component senderDisplay2 = Component.text(sender.getDisplayName());
for (Player p : Bukkit.getOnlinePlayers()) {
if (DistanceUtil.isInRange(sender, p, radius)) {
p.sendMessage(renderer.render(sender, sender.displayName(), msg, p));
Msg.send(p, renderer.render(sender, senderDisplay2, msg, p));
count++;
}
}
if (count <= 1) {
sender.sendMessage(ChatFormatter.parse(
Msg.send(sender, ChatFormatter.parse(
plugin.getConfig().getString("messages.local.nobody-heard",
"<color:#9878C9>Вас никто не услышал — рядом нет игроков</color>")));
}
@ -135,7 +139,7 @@ public class ChatServiceImpl implements ChatService {
int minLength = appearance.getMinMessageLength();
int maxLength = appearance.getMaxMessageLength();
if (text.length() < minLength || text.length() > maxLength) {
sender.sendMessage(ChatFormatter.parse(
Msg.send(sender, ChatFormatter.parse(
"&#CF6679Сообщение должно содержать от " + minLength + " до " + maxLength + " символов"));
return null;
}
@ -148,7 +152,7 @@ public class ChatServiceImpl implements ChatService {
if (filter != null) {
FilterResult result = filter.filterMessage(sender, text);
if (!result.allowed()) {
sender.sendMessage(ChatFormatter.parse(result.blockReason()));
Msg.send(sender, ChatFormatter.parse(result.blockReason()));
return null;
}
text = result.filteredMessage();

View file

@ -1,5 +1,7 @@
package com.loki.lochat.core.service;
import com.loki.lochat.compat.Msg;
import com.loki.lochat.api.service.NickService;
import com.loki.lochat.config.RatConfig;
import com.loki.lochat.utils.format.ChatFormatter;
@ -99,8 +101,9 @@ public class NickServiceImpl implements NickService {
// Сбрасываем display
Player onlinePlayer = Bukkit.getPlayer(player);
if (onlinePlayer != null) {
onlinePlayer.displayName(Component.text(onlinePlayer.getName()));
onlinePlayer.playerListName(Component.text(onlinePlayer.getName()));
Component reset = Component.text(onlinePlayer.getName());
Msg.setDisplayName(onlinePlayer, reset);
Msg.setPlayerListName(onlinePlayer, reset);
}
}
@ -155,12 +158,13 @@ public class NickServiceImpl implements NickService {
if (nickname.isPresent()) {
// Парсим ник с цветами
Component nickComponent = ChatFormatter.parse(nickname.get());
player.displayName(nickComponent);
player.playerListName(nickComponent);
Msg.setDisplayName(player, nickComponent);
Msg.setPlayerListName(player, nickComponent);
} else {
// Используем обычное имя
player.displayName(Component.text(player.getName()));
player.playerListName(Component.text(player.getName()));
Component reset = Component.text(player.getName());
Msg.setDisplayName(player, reset);
Msg.setPlayerListName(player, reset);
}
}

View file

@ -1,5 +1,7 @@
package com.loki.lochat.core.service.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.PlayerService;
@ -67,14 +69,14 @@ public class PrivateMessageServiceImpl implements PrivateMessageService {
playerSender.getUniqueId(), "pm", cooldown);
String cooldownMessage = plugin.getConfigManager().getMessagesConfig()
.getCooldownMessage().replace("{remaining}", String.valueOf(remaining));
sender.sendMessage(ChatFormatter.parse(cooldownMessage));
Msg.send(sender, ChatFormatter.parse(cooldownMessage));
return;
}
playerService.setCooldown(playerSender.getUniqueId(), "pm");
sender.sendMessage(ChatFormatter.formatPmSentNew(
Msg.send(sender, ChatFormatter.formatPmSentNew(
plugin.getMessageConfig().getPmFormatSent(), playerSender, target, message));
target.sendMessage(ChatFormatter.formatPmReceivedNew(
Msg.send(target, ChatFormatter.formatPmReceivedNew(
plugin.getMessageConfig().getPmFormatReceived(), playerSender, target, message));
if (plugin.getConfigManager().isPmSoundEnabled()) {
Sound sound = PlayerUtil.parseSound(plugin.getConfigManager().getPmSoundType(), null);

View file

@ -1,5 +1,7 @@
package com.loki.lochat.core.service.messaging;
import com.loki.lochat.compat.Msg;
import com.loki.lochat.config.MessageConfig;
import com.loki.lochat.utils.format.ChatFormatter;
@ -46,7 +48,7 @@ public class SpyService {
for (UUID spyUuid : spyEnabled) {
Player spy = Bukkit.getPlayer(spyUuid);
if (spy != null && spy.isOnline() && !spy.equals(sender) && !spy.equals(receiver)) {
spy.sendMessage(ChatFormatter.parse(format
Msg.send(spy, ChatFormatter.parse(format
.replace("{sender}", sender.getName())
.replace("{receiver}", receiver.getName())
.replace("{message}", message)));
@ -67,7 +69,7 @@ public class SpyService {
for (UUID spyUuid : spyEnabled) {
Player spy = Bukkit.getPlayer(spyUuid);
if (spy != null && spy.isOnline() && !spy.equals(sender)) {
spy.sendMessage(ChatFormatter.parse(format
Msg.send(spy, ChatFormatter.parse(format
.replace("{type}", chatType)
.replace("{sender}", sender.getName())
.replace("{message}", plainMessage)));

View file

@ -1,5 +1,7 @@
package com.loki.lochat.gradient.config;
import com.loki.lochat.compat.Msg;
import com.loki.lochat.utils.format.ChatFormatter;
import net.kyori.adventure.text.Component;
@ -86,13 +88,13 @@ public class GradientMessages {
* Отправляет сообщение игроку
*/
public void send(CommandSender sender, String key) {
sender.sendMessage(getComponent(key));
Msg.send(sender, getComponent(key));
}
/**
* Отправляет сообщение игроку с заменами
*/
public void send(CommandSender sender, String key, String... replacements) {
sender.sendMessage(getComponent(key, replacements));
Msg.send(sender, getComponent(key, replacements));
}
}

View file

@ -1,5 +1,7 @@
package com.loki.lochat.gradient.gui;
import com.loki.lochat.compat.Msg;
import com.loki.lochat.config.RatConfig;
import com.loki.lochat.gradient.GradientModule;
import com.loki.lochat.gradient.util.GradientUtil;
@ -55,7 +57,7 @@ public final class GradientConfirmGUI implements InventoryHolder {
return;
}
this.inventory = Bukkit.createInventory(this, 27,
Component.text("Подтверждение", NamedTextColor.DARK_GRAY));
Msg.inventoryTitle(Component.text("Подтверждение", NamedTextColor.DARK_GRAY)));
setupItems();
}
@ -72,7 +74,7 @@ public final class GradientConfirmGUI implements InventoryHolder {
String preview = buildPreview();
// Для GUI используем LegacyComponentSerializer с поддержкой HEX
Component previewComponent = SERIALIZER.deserialize(preview);
skullMeta.displayName(previewComponent.decoration(TextDecoration.ITALIC, false));
Msg.itemName(skullMeta, previewComponent.decoration(TextDecoration.ITALIC, false));
List<Component> lore = new ArrayList<>();
lore.add(Component.empty());
@ -83,7 +85,7 @@ public final class GradientConfirmGUI implements InventoryHolder {
.append(Component.text(price + " PP", NamedTextColor.GOLD))
.decoration(TextDecoration.ITALIC, false));
}
skullMeta.lore(lore);
Msg.itemLore(skullMeta, lore);
head.setItemMeta(skullMeta);
inventory.setItem(RatConfig.GUI_PREVIEW_SLOT, head);
@ -93,7 +95,7 @@ public final class GradientConfirmGUI implements InventoryHolder {
confirmLore.add(Component.empty());
confirmLore.add(Component.text("Нажмите для подтверждения", NamedTextColor.GREEN)
.decoration(TextDecoration.ITALIC, false));
confirmMeta.lore(confirmLore);
Msg.itemLore(confirmMeta, confirmLore);
confirm.setItemMeta(confirmMeta);
inventory.setItem(RatConfig.GUI_CONFIRM_SLOT, confirm);
@ -103,7 +105,7 @@ public final class GradientConfirmGUI implements InventoryHolder {
cancelLore.add(Component.empty());
cancelLore.add(Component.text("Нажмите для отмены", NamedTextColor.RED)
.decoration(TextDecoration.ITALIC, false));
cancelMeta.lore(cancelLore);
Msg.itemLore(cancelMeta, cancelLore);
cancel.setItemMeta(cancelMeta);
inventory.setItem(RatConfig.GUI_CANCEL_SLOT, cancel);
}
@ -187,7 +189,7 @@ public final class GradientConfirmGUI implements InventoryHolder {
private ItemStack createItem(Material material, String name) {
ItemStack item = new ItemStack(material);
ItemMeta meta = item.getItemMeta();
meta.displayName(LegacyComponentSerializer.legacySection().deserialize(name)
Msg.itemName(meta, LegacyComponentSerializer.legacySection().deserialize(name)
.decoration(TextDecoration.ITALIC, false));
item.setItemMeta(meta);
return item;

View file

@ -1,5 +1,7 @@
package com.loki.lochat.gradient.util;
import com.loki.lochat.compat.Msg;
import com.loki.lochat.gradient.GradientModule;
import com.loki.lochat.gradient.config.GradientConfig;
import com.loki.lochat.gradient.data.GradientPlayerData;
@ -32,8 +34,8 @@ public final class DisplayNameUtil {
// Конвертируем в legacy формат для display name
displayName = convertMiniMessageToLegacy(displayName);
var component = SERIALIZER.deserialize(displayName);
player.displayName(component);
player.playerListName(component);
Msg.setDisplayName(player, component);
Msg.setPlayerListName(player, component);
}
/**

View file

@ -40,7 +40,7 @@ public class PlaceholderAPIHook extends PlaceholderExpansion {
@Override
public @NotNull String getVersion() {
return plugin.getPluginMeta().getVersion();
return plugin.getDescription().getVersion();
}
@Override

View file

@ -5,21 +5,24 @@ import com.loki.lochat.api.service.ChannelService;
import com.loki.lochat.api.service.MessageService;
import com.loki.lochat.api.service.PlayerService;
import com.loki.lochat.channel.Channel;
import com.loki.lochat.compat.Msg;
import com.loki.lochat.core.filter.AdvancedMessageFilter;
import com.loki.lochat.core.filter.FilterResult;
import com.loki.lochat.renderer.EnhancedChatRenderer;
import com.loki.lochat.utils.format.ChatFormatter;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.plugin.java.JavaPlugin;
import io.papermc.paper.event.player.AsyncChatEvent;
import java.util.HashSet;
import java.util.Set;
public class ChatEventListener implements Listener {
private final JavaPlugin plugin;
@ -37,10 +40,10 @@ public class ChatEventListener implements Listener {
this.channelService = channelService;
}
@EventHandler(priority = EventPriority.HIGHEST)
public void onChat(AsyncChatEvent event) {
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onChat(AsyncPlayerChatEvent event) {
Player sender = event.getPlayer();
String rawMessage = PlainTextComponentSerializer.plainText().serialize(event.message());
String rawMessage = event.getMessage();
LoChat loChat = (LoChat) plugin;
// Система каналов: если игрок в присоединённом канале — маршрутизируем туда
@ -54,7 +57,7 @@ public class ChatEventListener implements Listener {
ChatMode mode = determineChatMode(loChat, rawMessage);
if (mode == null) {
event.setCancelled(true);
sender.sendMessage(ChatFormatter.parse("&#CF6679Этот режим чата отключен!"));
Msg.send(sender, ChatFormatter.parse("&#CF6679Этот режим чата отключен!"));
return;
}
@ -62,7 +65,8 @@ public class ChatEventListener implements Listener {
boolean isGlobal = mode.isGlobal;
// Проверки: мут, кулдаун, фильтры
if (!processFilters(event, sender, plainMessage, isGlobal)) {
Component messageComponent = processFilters(event, sender, plainMessage, isGlobal);
if (messageComponent == null) {
return;
}
@ -71,8 +75,17 @@ public class ChatEventListener implements Listener {
handleLocalChat(event, sender, loChat);
}
// Рендеринг и интеграции
event.renderer(new EnhancedChatRenderer(plugin, isGlobal));
// Рендеринг и доставка
EnhancedChatRenderer renderer = new EnhancedChatRenderer(plugin, isGlobal);
Component displayName = buildDisplayName(sender);
Set<Player> recipients = new HashSet<>(event.getRecipients());
event.setCancelled(true);
for (Player viewer : recipients) {
Component rendered = renderer.render(sender, displayName, messageComponent, viewer);
Msg.send(viewer, rendered);
}
Component consoleRendered = renderer.render(sender, displayName, messageComponent, null);
Bukkit.getConsoleSender().sendMessage(Msg.plain(consoleRendered));
loChat.getDiscordIntegration().sendChatMessage(sender, plainMessage, isGlobal);
recordStatistics(loChat, sender, isGlobal);
}
@ -80,7 +93,7 @@ public class ChatEventListener implements Listener {
/**
* Маршрутизация сообщения в присоединённый (не-дефолтный) канал.
*/
private void handleChannelChat(AsyncChatEvent event, Player sender, Channel channel, String rawMessage) {
private void handleChannelChat(AsyncPlayerChatEvent event, Player sender, Channel channel, String rawMessage) {
String plainMessage = rawMessage.stripLeading();
// Кулдаун канала
@ -92,23 +105,21 @@ public class ChatEventListener implements Listener {
String msg = ((LoChat) plugin).getConfigManager().getMessagesConfig().getCooldownMessage()
.replace("{remaining}", String.valueOf(remaining));
event.setCancelled(true);
sender.sendMessage(ChatFormatter.parse(msg));
Msg.send(sender, ChatFormatter.parse(msg));
return;
}
playerService.setCooldown(sender.getUniqueId(), cooldownType);
}
if (!processFilters(event, sender, plainMessage, channel.isGlobalScope())) {
Component messageComponent = processFilters(event, sender, plainMessage, channel.isGlobalScope());
if (messageComponent == null) {
return;
}
// Радиус локального канала
if (channel.isLocalScope()) {
int radius = channel.radius();
event.viewers().removeIf(v -> {
if (!(v instanceof Player p)) {
return false;
}
event.getRecipients().removeIf(p -> {
try {
return !com.loki.lochat.utils.player.DistanceUtil.isInRange(sender, p, radius);
} catch (Exception e) {
@ -117,7 +128,16 @@ public class ChatEventListener implements Listener {
});
}
event.renderer(new EnhancedChatRenderer(plugin, channel));
EnhancedChatRenderer renderer = new EnhancedChatRenderer(plugin, channel);
Component displayName = buildDisplayName(sender);
Set<Player> recipients = new HashSet<>(event.getRecipients());
event.setCancelled(true);
for (Player viewer : recipients) {
Component rendered = renderer.render(sender, displayName, messageComponent, viewer);
Msg.send(viewer, rendered);
}
Component consoleRendered = renderer.render(sender, displayName, messageComponent, null);
Bukkit.getConsoleSender().sendMessage(Msg.plain(consoleRendered));
LoChat loChat = (LoChat) plugin;
loChat.getDiscordIntegration().sendChatMessage(sender, plainMessage, channel.isGlobalScope());
playerService.recordMessage(sender.getUniqueId(), "channel_" + channel.id());
@ -147,21 +167,21 @@ public class ChatEventListener implements Listener {
return new ChatMode(isGlobal, message);
}
private boolean processFilters(AsyncChatEvent event, Player sender, String plainMessage, boolean isGlobal) {
private Component processFilters(AsyncPlayerChatEvent event, Player sender, String plainMessage, boolean isGlobal) {
LoChat loChat = (LoChat) plugin;
// Мут, кулдаун
if (!messageService.processMessage(sender, plainMessage)) {
event.setCancelled(true);
return false;
return null;
}
// Капс, реклама, повторы
FilterResult filterResult = advancedFilter.filterMessage(sender, plainMessage);
if (!filterResult.allowed()) {
event.setCancelled(true);
sender.sendMessage(ChatFormatter.parse(filterResult.blockReason()));
return false;
Msg.send(sender, ChatFormatter.parse(filterResult.blockReason()));
return null;
}
String filteredMessage = filterResult.filteredMessage();
@ -177,17 +197,13 @@ public class ChatEventListener implements Listener {
messageComponent = ChatFormatter.parseWithDefaultMessageColor(filteredMessage, defaultColor);
}
event.message(messageComponent);
return true;
return messageComponent;
}
private void handleLocalChat(AsyncChatEvent event, Player sender, LoChat loChat) {
private void handleLocalChat(AsyncPlayerChatEvent event, Player sender, LoChat loChat) {
int radius = loChat.getConfigManager().getAppearanceConfig().getLocalRadius();
event.viewers().removeIf(v -> {
if (!(v instanceof Player p)) {
return false;
}
event.getRecipients().removeIf(p -> {
try {
return !com.loki.lochat.utils.player.DistanceUtil.isInRange(sender, p, radius);
} catch (Exception e) {
@ -195,18 +211,24 @@ public class ChatEventListener implements Listener {
}
});
long recipients = event.viewers().stream()
.filter(v -> v instanceof Player p && !p.equals(sender))
long recipients = event.getRecipients().stream()
.filter(p -> !p.equals(sender))
.count();
if (recipients == 0) {
String msg = loChat.getConfigManager().getMessagesConfig().getNobodyHeard();
sender.getScheduler().run(plugin, t ->
sender.sendMessage(ChatFormatter.parse(msg)), null
);
Bukkit.getScheduler().runTask(plugin, () -> Msg.send(sender, ChatFormatter.parse(msg)));
}
}
private Component buildDisplayName(Player sender) {
String legacyName = sender.getDisplayName();
if (legacyName == null || legacyName.isBlank()) {
return Component.text(sender.getName());
}
return ChatFormatter.parse(legacyName);
}
private void recordStatistics(LoChat loChat, Player sender, boolean isGlobal) {
playerService.recordMessage(sender.getUniqueId(), isGlobal ? "global" : "local");
}

View file

@ -2,8 +2,6 @@ package com.loki.lochat.listener;
import com.loki.lochat.integrations.DiscordIntegration;
import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
@ -58,9 +56,8 @@ public class DiscordEventListener implements Listener {
}
Player player = event.getEntity();
String deathMessage = event.deathMessage() != null ?
PlainTextComponentSerializer.plainText().serialize(event.deathMessage()) :
"умер";
String raw = event.getDeathMessage();
String deathMessage = raw != null ? raw : "умер";
discord.sendPlayerDeath(player, deathMessage);
}

View file

@ -1,6 +1,7 @@
package com.loki.lochat.listener;
import com.loki.lochat.api.service.PunishmentService;
import com.loki.lochat.compat.Msg;
import com.loki.lochat.data.model.BanRecord;
import org.bukkit.event.EventHandler;
@ -28,6 +29,6 @@ public class ModerationListener implements Listener {
if (ban == null) {
return;
}
event.disallow(AsyncPlayerPreLoginEvent.Result.KICK_BANNED, punishmentService.buildBanKickMessage(ban));
event.disallow(AsyncPlayerPreLoginEvent.Result.KICK_BANNED, Msg.legacy(punishmentService.buildBanKickMessage(ban)));
}
}

View file

@ -4,12 +4,11 @@ import com.loki.lochat.LoChat;
import com.loki.lochat.api.service.MessagingService;
import com.loki.lochat.api.service.NickService;
import com.loki.lochat.api.service.PlayerService;
import com.loki.lochat.compat.Msg;
import com.loki.lochat.config.ConfigManager;
import com.loki.lochat.core.filter.AdvancedMessageFilter;
import com.loki.lochat.utils.format.ChatFormatter;
import net.kyori.adventure.text.Component;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
@ -52,7 +51,8 @@ public class PlayerEventListener implements Listener {
if (configManager.isJoinMessageEnabled()) {
String format = configManager.getJoinMessageFormat();
String message = format.replace("{player}", player.getName());
event.joinMessage(ChatFormatter.parse(message));
event.setJoinMessage(null);
Msg.broadcast(ChatFormatter.parse(message));
}
}
@ -72,7 +72,8 @@ public class PlayerEventListener implements Listener {
if (configManager.isQuitMessageEnabled()) {
String format = configManager.getQuitMessageFormat();
String message = format.replace("{player}", player.getName());
event.quitMessage(ChatFormatter.parse(message));
event.setQuitMessage(null);
Msg.broadcast(ChatFormatter.parse(message));
}
}
@ -82,7 +83,7 @@ public class PlayerEventListener implements Listener {
return;
}
Player player = event.getPlayer();
Player player = event.getEntity();
Player killer = player.getKiller();
String message;
@ -98,8 +99,8 @@ public class PlayerEventListener implements Listener {
.replace("{weapon}", weaponName);
} else {
// Проверяем убийцу-моба
Entity lastDamager = player.getLastDamageCause() != null ?
player.getLastDamageCause().getEntity() : null;
Entity lastDamager = player.getLastDamageCause() != null
? player.getLastDamageCause().getEntity() : null;
if (lastDamager instanceof LivingEntity mob && !(lastDamager instanceof Player)) {
String mobName = getMobName(mob);
@ -108,15 +109,15 @@ public class PlayerEventListener implements Listener {
.replace("{killer}", mobName);
} else {
// Обычная смерть
Component deathMsg = event.deathMessage();
String deathText = deathMsg != null ? ChatFormatter.toPlain(deathMsg) : "умер";
String deathMsg = event.getDeathMessage();
String deathText = deathMsg != null ? ChatFormatter.toPlain(ChatFormatter.parse(deathMsg)) : "умер";
message = configManager.getDeathDefaultFormat()
.replace("{player}", player.getName())
.replace("{death_message}", deathText);
}
}
event.deathMessage(ChatFormatter.parse(message));
event.setDeathMessage(Msg.legacy(ChatFormatter.parse(message)));
}
private String getWeaponName(ItemStack item) {
@ -125,15 +126,19 @@ public class PlayerEventListener implements Listener {
}
if (item.hasItemMeta() && item.getItemMeta().hasDisplayName()) {
return ChatFormatter.toPlain(item.getItemMeta().displayName());
String dn = item.getItemMeta().getDisplayName();
if (dn != null) {
return ChatFormatter.toPlain(ChatFormatter.parse(dn));
}
}
return translateMaterial(item.getType().name());
}
private String getMobName(LivingEntity mob) {
if (mob.customName() != null) {
return ChatFormatter.toPlain(mob.customName());
String cn = mob.getCustomName();
if (cn != null) {
return ChatFormatter.toPlain(ChatFormatter.parse(cn));
}
return translateEntityType(mob.getType().name());
}

View file

@ -1,8 +1,9 @@
package com.loki.lochat.managers;
import com.loki.lochat.compat.Msg;
import com.loki.lochat.LoChat;
import com.loki.lochat.utils.format.ChatFormatter;
import com.loki.lochat.utils.platform.FoliaUtil;
import net.kyori.adventure.text.Component;
@ -18,16 +19,13 @@ import java.util.Map;
import java.util.Random;
import java.util.concurrent.atomic.AtomicInteger;
import io.papermc.paper.threadedregions.scheduler.ScheduledTask;
public class AutoMessageManager {
private final LoChat plugin;
private final Random random = new Random();
private final AtomicInteger currentIndex = new AtomicInteger(0);
// ✅ FIX: Сохраняем ссылку на задачу для отмены
private Object scheduledTask; // BukkitTask или ScheduledTask
private BukkitTask scheduledTask;
private Map<String, List<String>> messages;
private List<String> messageOrder;
@ -90,37 +88,19 @@ public class AutoMessageManager {
int intervalSeconds = plugin.getConfigManager().getAutoMessagesInterval();
long intervalTicks = intervalSeconds * 20L;
// Используем FoliaUtil для совместимости с Paper и Folia
if (FoliaUtil.isFolia()) {
long delayMs = intervalTicks * 50;
long periodMs = intervalTicks * 50;
scheduledTask = Bukkit.getAsyncScheduler().runAtFixedRate(
plugin,
task -> broadcastNextMessage(),
delayMs,
periodMs,
java.util.concurrent.TimeUnit.MILLISECONDS
);
} else {
scheduledTask = Bukkit.getScheduler().runTaskTimerAsynchronously(
plugin,
this::broadcastNextMessage,
intervalTicks,
intervalTicks
);
}
plugin.getLogger().info("Автосообщения запущены (интервал: " + intervalSeconds + " сек, режим: " + mode + ")");
}
public void stop() {
// ✅ FIX: Отменяем scheduled task
if (scheduledTask != null) {
if (scheduledTask instanceof ScheduledTask) {
((ScheduledTask) scheduledTask).cancel();
} else if (scheduledTask instanceof BukkitTask) {
((BukkitTask) scheduledTask).cancel();
}
scheduledTask.cancel();
scheduledTask = null;
}
}
@ -159,7 +139,7 @@ public class AutoMessageManager {
}
for (var player : Bukkit.getOnlinePlayers()) {
player.sendMessage(formatted);
Msg.send(player, formatted);
}
}
}

View file

@ -1,5 +1,7 @@
package com.loki.lochat.managers;
import com.loki.lochat.compat.Msg;
import com.loki.lochat.LoChat;
import com.loki.lochat.commands.CustomCommand;
import com.loki.lochat.managers.commands.MessageSender;
@ -66,9 +68,29 @@ public class CustomCommandManager {
plugin.getLogger().info("Загружено " + commands.size() + " кастомных команд");
}
private CommandMap getCommandMap() {
try {
java.lang.reflect.Method m = Bukkit.getServer().getClass().getMethod("getCommandMap");
return (CommandMap) m.invoke(Bukkit.getServer());
} catch (Exception ignored) {
}
try {
java.lang.reflect.Method m2 = Bukkit.getPluginManager().getClass().getMethod("getCommandMap");
return (CommandMap) m2.invoke(Bukkit.getPluginManager());
} catch (Exception ignored) {
}
try {
java.lang.reflect.Field f = Bukkit.getPluginManager().getClass().getDeclaredField("commandMap");
f.setAccessible(true);
return (CommandMap) f.get(Bukkit.getPluginManager());
} catch (Exception ex) {
throw new RuntimeException("Unable to get CommandMap", ex);
}
}
private void registerCommand(CustomCommandData data) {
try {
CommandMap commandMap = Bukkit.getCommandMap();
CommandMap commandMap = getCommandMap();
CustomCommand command = new CustomCommand(data.name(), this);
commandMap.register("lochat", command);
@ -108,7 +130,7 @@ public class CustomCommandManager {
}
if (data.permission() != null && !player.hasPermission(data.permission())) {
player.sendMessage(ChatFormatter.parse(plugin.getMessageConfig().getNoPermission()));
Msg.send(player, ChatFormatter.parse(plugin.getMessageConfig().getNoPermission()));
return true;
}
@ -126,7 +148,7 @@ public class CustomCommandManager {
private void sendBungeeCommand(Player player, CustomCommandData data) {
if (!data.message().isEmpty()) {
player.sendMessage(ChatFormatter.parse(data.message()));
Msg.send(player, ChatFormatter.parse(data.message()));
}
String serverName = getServerFromConfig(data);
@ -157,7 +179,7 @@ public class CustomCommandManager {
player.sendPluginMessage(plugin, "BungeeCord", b.toByteArray());
} catch (Exception e) {
plugin.getLogger().severe("Ошибка подключения к серверу " + serverName + ": " + e.getMessage());
player.sendMessage(ChatFormatter.parse("<#F44336>❌ Ошибка подключения к серверу"));
Msg.send(player, ChatFormatter.parse("<#F44336>❌ Ошибка подключения к серверу"));
}
}

View file

@ -1,5 +1,7 @@
package com.loki.lochat.managers.commands;
import com.loki.lochat.compat.Msg;
import com.loki.lochat.utils.format.ChatFormatter;
import net.kyori.adventure.text.Component;
@ -19,13 +21,13 @@ public class MessageSender {
Component formatted = ChatFormatter.parse(message);
switch (target.toLowerCase()) {
case "player" -> sender.sendMessage(formatted);
case "broadcast" -> Bukkit.broadcast(formatted);
case "server" -> Bukkit.getOnlinePlayers().forEach(p -> p.sendMessage(formatted));
case "player" -> Msg.send(sender, formatted);
case "broadcast" -> Msg.broadcast(formatted);
case "server" -> Bukkit.getOnlinePlayers().forEach(p -> Msg.send(p, formatted));
default -> {
Player targetPlayer = Bukkit.getPlayer(target);
if (targetPlayer != null && targetPlayer.isOnline()) {
targetPlayer.sendMessage(formatted);
Msg.send(targetPlayer, formatted);
}
}
}
@ -39,23 +41,19 @@ public class MessageSender {
Component title = ChatFormatter.parse(titleText);
Component subtitle = ChatFormatter.parse(subtitleText);
Title titleObj = Title.title(
title,
subtitle,
Title.Times.times(
Title.Times times = Title.Times.times(
Duration.ofMillis(500),
Duration.ofMillis(3000),
Duration.ofMillis(500)
)
);
switch (target.toLowerCase()) {
case "player" -> sender.showTitle(titleObj);
case "broadcast", "server" -> Bukkit.getOnlinePlayers().forEach(p -> p.showTitle(titleObj));
case "player" -> Msg.title(sender, title, subtitle, times);
case "broadcast", "server" -> Bukkit.getOnlinePlayers().forEach(p -> Msg.title(p, title, subtitle, times));
default -> {
Player targetPlayer = Bukkit.getPlayer(target);
if (targetPlayer != null && targetPlayer.isOnline()) {
targetPlayer.showTitle(titleObj);
Msg.title(targetPlayer, title, subtitle, times);
}
}
}
@ -65,12 +63,12 @@ public class MessageSender {
Component formatted = ChatFormatter.parse(message);
switch (target.toLowerCase()) {
case "player" -> sender.sendActionBar(formatted);
case "broadcast", "server" -> Bukkit.getOnlinePlayers().forEach(p -> p.sendActionBar(formatted));
case "player" -> Msg.actionBar(sender, formatted);
case "broadcast", "server" -> Bukkit.getOnlinePlayers().forEach(p -> Msg.actionBar(p, formatted));
default -> {
Player targetPlayer = Bukkit.getPlayer(target);
if (targetPlayer != null && targetPlayer.isOnline()) {
targetPlayer.sendActionBar(formatted);
Msg.actionBar(targetPlayer, formatted);
}
}
}

View file

@ -12,9 +12,7 @@ public class PlaceholderProcessor {
// Базовые плейсхолдеры
result = result.replace("{player}", player.getName());
result = result.replace("{displayname}",
net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer.plainText()
.serialize(player.displayName()));
result = result.replace("{displayname}", player.getDisplayName());
result = result.replace("{world}", player.getWorld().getName());
result = result.replace("{x}", String.valueOf(player.getLocation().getBlockX()));
result = result.replace("{y}", String.valueOf(player.getLocation().getBlockY()));

View file

@ -1,6 +1,7 @@
package com.loki.lochat.renderer;
import com.loki.lochat.channel.Channel;
import com.loki.lochat.compat.Msg;
import com.loki.lochat.renderer.components.EmojiComponent;
import com.loki.lochat.renderer.components.GradientBuilder;
import com.loki.lochat.renderer.components.UrlProcessor;
@ -9,7 +10,6 @@ import com.loki.lochat.utils.format.ChatFormatter;
import com.loki.lochat.utils.format.TextFormatter;
import com.loki.lochat.utils.player.MentionHandler;
import net.kyori.adventure.audience.Audience;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.event.ClickEvent;
import net.kyori.adventure.text.event.HoverEvent;
@ -24,12 +24,10 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import io.papermc.paper.chat.ChatRenderer;
/**
* Рендерер чата — глобальный и локальный режимы
*/
public class EnhancedChatRenderer implements ChatRenderer {
public class EnhancedChatRenderer {
private static final TextColor FALLBACK_COLOR = NamedTextColor.WHITE;
@ -57,20 +55,19 @@ public class EnhancedChatRenderer implements ChatRenderer {
this.cfg = loChat.getConfigManager();
}
@Override
public Component render(Player source, Component sourceDisplayName, Component message, Audience viewer) {
public Component render(Player source, Component sourceDisplayName, Component message, Player viewer) {
// Обрабатываем сообщение
Component processed = message;
processed = TextFormatter.formatMarkdown(processed);
processed = UrlProcessor.process(processed);
processed = EmojiComponent.processEmojis(processed);
if (viewer instanceof Player vp) {
processed = mentionHandler.processMentions(processed, source, vp);
if (viewer != null) {
processed = mentionHandler.processMentions(processed, source, viewer);
if (cfg.isTranslationEnabled()) {
com.loki.lochat.LoChat loChat = (com.loki.lochat.LoChat) plugin;
if (loChat.getTranslationService().isEnabled()) {
sendTranslationAsync(vp, PlainTextComponentSerializer.plainText().serialize(processed));
sendTranslationAsync(viewer, PlainTextComponentSerializer.plainText().serialize(processed));
}
}
}
@ -85,7 +82,7 @@ public class EnhancedChatRenderer implements ChatRenderer {
Component separator = buildSeparator();
Component playerPrefix = buildPlayerPrefix(source);
Component playerSuffix = buildPlayerSuffix(source);
Component player = buildPlayerComponent(source);
Component player = buildPlayerComponent(source, sourceDisplayName);
return buildFormattedMessage(format, Map.of(
"emoji", emoji,
@ -196,8 +193,8 @@ public class EnhancedChatRenderer implements ChatRenderer {
return Component.text(text, parseColor(color));
}
private Component buildPlayerComponent(Player player) {
Component displayName = player.displayName();
private Component buildPlayerComponent(Player player, Component sourceDisplayName) {
Component displayName = sourceDisplayName != null ? sourceDisplayName : Component.text(player.getName());
com.loki.lochat.config.AppearanceConfig appearanceCfg = cfg.getAppearanceConfig();
@ -248,19 +245,24 @@ public class EnhancedChatRenderer implements ChatRenderer {
}
com.loki.lochat.LoChat loChat = (com.loki.lochat.LoChat) plugin;
TranslationService ts = loChat.getTranslationService();
String viewerLang = viewer.locale().getLanguage();
ts.translateAsync(plainText, viewerLang)
String localeStr = viewer.getLocale();
String viewerLang = "en";
if (localeStr != null && !localeStr.isBlank()) {
viewerLang = localeStr.split("[_\\-]")[0].toLowerCase();
}
final String lang = viewerLang;
ts.translateAsync(plainText, lang)
.thenAccept(translated -> {
if (translated.equals(plainText)) {
return;
}
String langName = LANGUAGE_NAMES.getOrDefault(viewerLang, viewerLang.toUpperCase(java.util.Locale.ROOT));
String langName = LANGUAGE_NAMES.getOrDefault(lang, lang.toUpperCase(java.util.Locale.ROOT));
Component component = Component.text()
.append(com.loki.lochat.utils.format.ChatFormatter.parse(
"&#AAAAAA[" + langName + "]&#FFFFFF "))
.append(Component.text(translated))
.build();
viewer.sendActionBar(component);
Msg.actionBar(viewer, component);
});
}

View file

@ -76,7 +76,7 @@ public final class ChatFormatter {
public static void sendMessage(Player player, Component component) {
if (player != null && component != null) {
player.sendMessage(component);
com.loki.lochat.compat.Msg.send(player, component);
}
}

View file

@ -5,42 +5,25 @@ import org.bukkit.entity.Entity;
import org.bukkit.plugin.java.JavaPlugin;
/**
* Утилита для совместимости с Folia
* Утилита для совместимости с Folia — на Spigot 1.20.1 всегда false.
*/
public class FoliaUtil {
private FoliaUtil() {
}
private static boolean isFolia;
static {
try {
Class.forName("io.papermc.paper.threadedregions.RegionizedServer");
isFolia = true;
} catch (ClassNotFoundException e) {
isFolia = false;
}
}
private static final boolean IS_FOLIA = false;
public static boolean isFolia() {
return isFolia;
return IS_FOLIA;
}
public static void runAsync(JavaPlugin plugin, Runnable task) {
if (isFolia) {
Bukkit.getAsyncScheduler().runNow(plugin, scheduledTask -> task.run());
} else {
Bukkit.getScheduler().runTaskAsynchronously(plugin, task);
}
}
public static void runEntityTask(JavaPlugin plugin, Entity entity, Runnable task) {
if (isFolia) {
entity.getScheduler().run(plugin, scheduledTask -> task.run(), null);
} else {
Bukkit.getScheduler().runTask(plugin, task);
}
}
/**
* Запускает глобальную повторяющуюся задачу
@ -51,17 +34,6 @@ public class FoliaUtil {
* @param periodTicks период повторения (в тиках)
*/
public static void runTimerAsync(JavaPlugin plugin, Runnable task, long delayTicks, long periodTicks) {
if (isFolia) {
// В Folia используем AsyncScheduler для глобальных задач
long delayMs = delayTicks * 50; // 1 тик = 50мс
long periodMs = periodTicks * 50;
Bukkit.getAsyncScheduler().runAtFixedRate(
plugin, scheduledTask -> task.run(), delayMs, periodMs,
java.util.concurrent.TimeUnit.MILLISECONDS
);
} else {
// В Paper/Spigot используем обычный scheduler
Bukkit.getScheduler().runTaskTimerAsynchronously(plugin, task, delayTicks, periodTicks);
}
}
}