fix: encapsulation, star imports, checkstyle warnings (520→41), remove casts
This commit is contained in:
parent
90c3cac5cf
commit
4efccd3968
85 changed files with 466 additions and 291 deletions
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -1,16 +1,35 @@
|
|||
package com.loki.lochat.commands;
|
||||
|
||||
import com.loki.lochat.LoChat;
|
||||
import com.loki.lochat.commands.admin.broadcast.*;
|
||||
import com.loki.lochat.commands.admin.chat.*;
|
||||
import com.loki.lochat.commands.admin.system.*;
|
||||
import com.loki.lochat.commands.chat.*;
|
||||
import com.loki.lochat.commands.messaging.*;
|
||||
import com.loki.lochat.commands.moderation.ban.*;
|
||||
import com.loki.lochat.commands.moderation.mute.*;
|
||||
import com.loki.lochat.commands.moderation.warn.*;
|
||||
import com.loki.lochat.commands.nick.*;
|
||||
import com.loki.lochat.commands.rp.*;
|
||||
import com.loki.lochat.commands.admin.broadcast.AnnounceCommand;
|
||||
import com.loki.lochat.commands.admin.broadcast.DiscordCommand;
|
||||
import com.loki.lochat.commands.admin.chat.ChatSpyCommand;
|
||||
import com.loki.lochat.commands.admin.chat.ClearChatCommand;
|
||||
import com.loki.lochat.commands.admin.chat.ClearChatConfigCommand;
|
||||
import com.loki.lochat.commands.admin.system.LoChatCommand;
|
||||
import com.loki.lochat.commands.admin.system.ReloadConfigCommand;
|
||||
import com.loki.lochat.commands.chat.GlobalChatCommand;
|
||||
import com.loki.lochat.commands.chat.LocalChatCommand;
|
||||
import com.loki.lochat.commands.messaging.IgnoreCommand;
|
||||
import com.loki.lochat.commands.messaging.IgnoreListCommand;
|
||||
import com.loki.lochat.commands.messaging.MsgCommand;
|
||||
import com.loki.lochat.commands.messaging.ReplyCommand;
|
||||
import com.loki.lochat.commands.messaging.UnignoreCommand;
|
||||
import com.loki.lochat.commands.moderation.ban.BanCommand;
|
||||
import com.loki.lochat.commands.moderation.ban.UnbanCommand;
|
||||
import com.loki.lochat.commands.moderation.mute.MuteBlameCommand;
|
||||
import com.loki.lochat.commands.moderation.mute.MuteCommand;
|
||||
import com.loki.lochat.commands.moderation.mute.MuteHistoryCommand;
|
||||
import com.loki.lochat.commands.moderation.mute.MuteListCommand;
|
||||
import com.loki.lochat.commands.moderation.mute.UnmuteCommand;
|
||||
import com.loki.lochat.commands.moderation.warn.SilentWarnCommand;
|
||||
import com.loki.lochat.commands.moderation.warn.WarnCommand;
|
||||
import com.loki.lochat.commands.nick.NickCommand;
|
||||
import com.loki.lochat.commands.nick.PlayerInfoCommand;
|
||||
import com.loki.lochat.commands.rp.DoCommand;
|
||||
import com.loki.lochat.commands.rp.MeCommand;
|
||||
import com.loki.lochat.commands.rp.RollCommand;
|
||||
import com.loki.lochat.commands.rp.TryCommand;
|
||||
|
||||
import org.bukkit.command.PluginCommand;
|
||||
|
||||
|
|
|
|||
|
|
@ -32,7 +32,9 @@ public final class CustomCommand extends Command {
|
|||
}
|
||||
|
||||
@Override
|
||||
public @NotNull List<String> tabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException {
|
||||
public @NotNull List<String> tabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull
|
||||
String[] args) throws IllegalArgumentException {
|
||||
|
||||
// Базовое автодополнение - можно расширить при необходимости
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -70,7 +70,10 @@ public class DiscordCommand implements CommandExecutor, TabCompleter {
|
|||
}
|
||||
|
||||
@Override
|
||||
public @Nullable List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, @NotNull String[] args) {
|
||||
public @Nullable List<String> onTabComplete(
|
||||
@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias,
|
||||
@NotNull String[] args
|
||||
) {
|
||||
if (!sender.hasPermission("lochat.discord.admin")) {
|
||||
return null;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,7 +59,10 @@ public class ClearChatConfigCommand implements CommandExecutor, TabCompleter {
|
|||
}
|
||||
|
||||
@Override
|
||||
public @Nullable List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, @NotNull String[] args) {
|
||||
public @Nullable List<String> onTabComplete(
|
||||
@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias,
|
||||
@NotNull String[] args
|
||||
) {
|
||||
if (args.length == 1) {
|
||||
return List.of("enable", "disable", "message", "status").stream()
|
||||
.filter(s -> s.startsWith(args[0].toLowerCase())).toList();
|
||||
|
|
|
|||
|
|
@ -54,7 +54,10 @@ public class LoChatCommand implements CommandExecutor, TabCompleter {
|
|||
}
|
||||
|
||||
@Override
|
||||
public @Nullable List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, @NotNull String[] args) {
|
||||
public @Nullable List<String> onTabComplete(
|
||||
@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias,
|
||||
@NotNull String[] args
|
||||
) {
|
||||
if (!sender.hasPermission("lochat.admin")) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,7 +44,9 @@ public class IgnoreListCommand implements CommandExecutor {
|
|||
player.sendMessage(ChatFormatter.parse("⚖C9◆ &f" + name));
|
||||
}
|
||||
}
|
||||
player.sendMessage(ChatFormatter.parse(plugin.getMessageConfig().get("ignore.list-footer").replace("{count}", String.valueOf(ignored.size()))));
|
||||
player.sendMessage(ChatFormatter.parse(plugin.getMessageConfig().get("ignore.list-footer")
|
||||
.replace("{count}", String.valueOf(ignored.size()))));
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -73,33 +73,13 @@ public class BanCommand implements CommandExecutor, TabCompleter {
|
|||
return true;
|
||||
}
|
||||
|
||||
String timeStr = null;
|
||||
StringBuilder reasonBuilder = new StringBuilder();
|
||||
for (int i = 1; i < args.length; i++) {
|
||||
if (timeStr == null && isTimeFormat(args[i])) {
|
||||
timeStr = args[i];
|
||||
} else {
|
||||
if (reasonBuilder.length() > 0) {
|
||||
reasonBuilder.append(" ");
|
||||
}
|
||||
reasonBuilder.append(args[i]);
|
||||
}
|
||||
}
|
||||
|
||||
long durationMs;
|
||||
if (timeStr == null || timeStr.isEmpty()) {
|
||||
durationMs = 0;
|
||||
} else if (timeStr.equalsIgnoreCase("perm") || timeStr.equals("0")) {
|
||||
durationMs = 0;
|
||||
} else {
|
||||
durationMs = muteService.parseTime(timeStr);
|
||||
if (durationMs < 0) {
|
||||
sender.sendMessage(ChatFormatter.parse(msg.getInvalidTime()));
|
||||
DurationResult parsed = parseDuration(sender, args, msg);
|
||||
if (!parsed.valid) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
String reason = reasonBuilder.length() > 0 ? reasonBuilder.toString() : msg.getModerationDefaultReason();
|
||||
long durationMs = parsed.durationMs;
|
||||
String reason = parsed.reason;
|
||||
String finalName = PlayerUtil.getPlayerName(targetUuid);
|
||||
if (finalName == null) {
|
||||
finalName = targetName;
|
||||
|
|
@ -122,6 +102,39 @@ public class BanCommand implements CommandExecutor, TabCompleter {
|
|||
return true;
|
||||
}
|
||||
|
||||
private record DurationResult(long durationMs, String reason, boolean valid) { }
|
||||
|
||||
private DurationResult parseDuration(CommandSender sender, String[] args, MessagesConfig msg) {
|
||||
String timeStr = null;
|
||||
StringBuilder reasonBuilder = new StringBuilder();
|
||||
for (int i = 1; i < args.length; i++) {
|
||||
if (timeStr == null && isTimeFormat(args[i])) {
|
||||
timeStr = args[i];
|
||||
} else {
|
||||
if (reasonBuilder.length() > 0) {
|
||||
reasonBuilder.append(" ");
|
||||
}
|
||||
reasonBuilder.append(args[i]);
|
||||
}
|
||||
}
|
||||
|
||||
long durationMs;
|
||||
if (timeStr == null || timeStr.isEmpty()) {
|
||||
durationMs = 0;
|
||||
} else if (timeStr.equalsIgnoreCase("perm") || timeStr.equals("0")) {
|
||||
durationMs = 0;
|
||||
} else {
|
||||
durationMs = muteService.parseTime(timeStr);
|
||||
if (durationMs < 0) {
|
||||
sender.sendMessage(ChatFormatter.parse(msg.getInvalidTime()));
|
||||
return new DurationResult(0, "", false);
|
||||
}
|
||||
}
|
||||
|
||||
String reason = reasonBuilder.length() > 0 ? reasonBuilder.toString() : msg.getModerationDefaultReason();
|
||||
return new DurationResult(durationMs, reason, true);
|
||||
}
|
||||
|
||||
private boolean isTimeFormat(String s) {
|
||||
return s.equalsIgnoreCase("perm") || s.matches("\\d+[dhms]?");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -56,7 +56,9 @@ public class MuteBlameCommand implements CommandExecutor, TabCompleter {
|
|||
String status = e.unmuted ? "⚖C9Размучен" : (e.duration == 0 ? "&#CF6679Активен (навсегда)" :
|
||||
System.currentTimeMillis() > e.mutedAt + e.duration ? "&#B798A8Истёк" : "&#CF6679Активен");
|
||||
sender.sendMessage("⚖C9" + idx + ". &f" + (e.playerName != null ? e.playerName : "???") + " &#B798A8— " + status);
|
||||
sender.sendMessage(" &f" + fmt.format(new Date(e.mutedAt)) + " &#B798A8Длительность: &f" + (e.duration == 0 ? "навсегда" : muteService.formatTime(e.duration)));
|
||||
sender.sendMessage(" &f" + fmt.format(new Date(e.mutedAt)) + " &#B798A8Длительность: &f" + (e.duration
|
||||
== 0 ? "навсегда" : muteService.formatTime(e.duration)));
|
||||
|
||||
sender.sendMessage(" &#B798A8Причина: &f" + (e.reason != null ? e.reason : "—"));
|
||||
idx++;
|
||||
}
|
||||
|
|
@ -64,7 +66,10 @@ public class MuteBlameCommand implements CommandExecutor, TabCompleter {
|
|||
}
|
||||
|
||||
@Override
|
||||
public @Nullable List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, @NotNull String[] args) {
|
||||
public @Nullable List<String> onTabComplete(
|
||||
@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias,
|
||||
@NotNull String[] args
|
||||
) {
|
||||
List<String> c = new ArrayList<>();
|
||||
if (args.length == 1) {
|
||||
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||
|
|
|
|||
|
|
@ -31,6 +31,8 @@ public class MuteCommand implements CommandExecutor, TabCompleter {
|
|||
this.muteService = plugin.getServiceRegistry().get(MuteService.class);
|
||||
}
|
||||
|
||||
private record ParsedArgs(String targetName, long duration, String reason, boolean silent) { }
|
||||
|
||||
@Override
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command,
|
||||
@NotNull String label, @NotNull String[] args) {
|
||||
|
|
@ -49,7 +51,38 @@ public class MuteCommand implements CommandExecutor, TabCompleter {
|
|||
return true;
|
||||
}
|
||||
|
||||
// Парсим аргументы
|
||||
ParsedArgs parsed = parseArgs(sender, args, hm);
|
||||
if (parsed == null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
String targetName = parsed.targetName;
|
||||
long duration = parsed.duration;
|
||||
String reason = parsed.reason;
|
||||
boolean silent = parsed.silent;
|
||||
|
||||
if (sender instanceof Player p && !muteService.canMuteForDuration(p, duration)) {
|
||||
long max = muteService.getMaxDuration(p);
|
||||
sender.sendMessage(ChatFormatter.parse("&#CF6679Нельзя мутить на такой срок! &#B798A8Максимум: ẲE9" +
|
||||
(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"));
|
||||
return true;
|
||||
}
|
||||
if (muteService.isMuted(targetUUID)) {
|
||||
sender.sendMessage(ChatFormatter.parse("&#CF6679Игрок уже замучен!"));
|
||||
return true;
|
||||
}
|
||||
|
||||
doMute(sender, hm, targetUUID, targetName, duration, reason, silent);
|
||||
return true;
|
||||
}
|
||||
|
||||
private ParsedArgs parseArgs(CommandSender sender, String[] args, MessagesConfig hm) {
|
||||
String targetName = null;
|
||||
String timeStr = null;
|
||||
boolean silent = false;
|
||||
|
|
@ -72,45 +105,39 @@ public class MuteCommand implements CommandExecutor, TabCompleter {
|
|||
|
||||
if (silent && !sender.hasPermission("lochat.mute.silent")) {
|
||||
sender.sendMessage(ChatFormatter.parse(hm.getNoSilentMutePermission()));
|
||||
return true;
|
||||
return null;
|
||||
}
|
||||
|
||||
String reason = reasonBuilder.length() > 0 ? reasonBuilder.toString() : hm.getDefaultMuteReason();
|
||||
|
||||
// Длительность
|
||||
long duration;
|
||||
if (timeStr == null || timeStr.isEmpty()) {
|
||||
duration = sender instanceof Player p ? muteService.getMaxDuration(p) : 0;
|
||||
if (duration == -1) {
|
||||
duration = muteService.parseTime(hm.getDefaultMuteDuration());
|
||||
}
|
||||
} else if (timeStr.equalsIgnoreCase("perm") || timeStr.equals("0")) {
|
||||
duration = 0;
|
||||
} else {
|
||||
duration = muteService.parseTime(timeStr);
|
||||
long duration = resolveDuration(sender, timeStr, hm);
|
||||
if (duration < 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return new ParsedArgs(targetName, duration, reason, silent);
|
||||
}
|
||||
|
||||
private long resolveDuration(CommandSender sender, String timeStr, MessagesConfig hm) {
|
||||
if (timeStr == null || timeStr.isEmpty()) {
|
||||
long dur = sender instanceof Player p ? muteService.getMaxDuration(p) : 0;
|
||||
if (dur == -1) {
|
||||
dur = muteService.parseTime(hm.getDefaultMuteDuration());
|
||||
}
|
||||
return dur;
|
||||
}
|
||||
if (timeStr.equalsIgnoreCase("perm") || timeStr.equals("0")) {
|
||||
return 0;
|
||||
}
|
||||
long dur = muteService.parseTime(timeStr);
|
||||
if (dur < 0) {
|
||||
sender.sendMessage(ChatFormatter.parse(hm.getMuteTimeHelp()));
|
||||
return true;
|
||||
}
|
||||
return dur;
|
||||
}
|
||||
|
||||
if (sender instanceof Player p && !muteService.canMuteForDuration(p, duration)) {
|
||||
long max = muteService.getMaxDuration(p);
|
||||
sender.sendMessage(ChatFormatter.parse("&#CF6679Нельзя мутить на такой срок! &#B798A8Максимум: ẲE9" +
|
||||
(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"));
|
||||
return true;
|
||||
}
|
||||
if (muteService.isMuted(targetUUID)) {
|
||||
sender.sendMessage(ChatFormatter.parse("&#CF6679Игрок уже замучен!"));
|
||||
return true;
|
||||
}
|
||||
|
||||
private void doMute(CommandSender sender, MessagesConfig hm, UUID targetUUID,
|
||||
String targetName, long duration, String reason, boolean silent) {
|
||||
Player target = Bukkit.getPlayer(targetUUID);
|
||||
String finalName = com.loki.lochat.utils.player.PlayerUtil.getPlayerName(targetUUID);
|
||||
String op = sender.getName();
|
||||
|
|
@ -146,8 +173,6 @@ public class MuteCommand implements CommandExecutor, TabCompleter {
|
|||
String c = voiceCmd.replace("{player}", finalName).replace("{uuid}", targetUUID.toString());
|
||||
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), c);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean isTimeFormat(String s) {
|
||||
|
|
|
|||
|
|
@ -76,7 +76,10 @@ public class MuteHistoryCommand implements CommandExecutor, TabCompleter {
|
|||
}
|
||||
|
||||
@Override
|
||||
public @Nullable List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, @NotNull String[] args) {
|
||||
public @Nullable List<String> onTabComplete(
|
||||
@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias,
|
||||
@NotNull String[] args
|
||||
) {
|
||||
List<String> c = new ArrayList<>();
|
||||
if (args.length == 1) {
|
||||
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||
|
|
|
|||
|
|
@ -84,7 +84,10 @@ public class UnmuteCommand implements CommandExecutor, TabCompleter {
|
|||
}
|
||||
|
||||
@Override
|
||||
public @Nullable List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, @NotNull String[] args) {
|
||||
public @Nullable List<String> onTabComplete(
|
||||
@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias,
|
||||
@NotNull String[] args
|
||||
) {
|
||||
List<String> c = new ArrayList<>();
|
||||
if (args.length == 1) {
|
||||
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||
|
|
|
|||
|
|
@ -35,7 +35,8 @@ public class DoCommand extends PlayerCommand {
|
|||
int cooldown = plugin.getConfigManager().getInt("rp.cooldowns.do", 0);
|
||||
if (cooldown > 0 && playerService.isOnCooldown(player.getUniqueId(), "rp_do", cooldown)) {
|
||||
int remaining = playerService.getRemainingCooldown(player.getUniqueId(), "rp_do", cooldown);
|
||||
String msg = plugin.getConfigManager().getMessagesConfig().getCooldownMessage().replace("{remaining}", String.valueOf(remaining));
|
||||
String msg = plugin.getConfigManager().getMessagesConfig().getCooldownMessage()
|
||||
.replace("{remaining}", String.valueOf(remaining));
|
||||
player.sendMessage(ChatFormatter.parse(msg));
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,7 +35,8 @@ public class MeCommand extends PlayerCommand {
|
|||
int cooldown = plugin.getConfigManager().getInt("rp.cooldowns.me", 0);
|
||||
if (cooldown > 0 && playerService.isOnCooldown(player.getUniqueId(), "rp_me", cooldown)) {
|
||||
int remaining = playerService.getRemainingCooldown(player.getUniqueId(), "rp_me", cooldown);
|
||||
String msg = plugin.getConfigManager().getMessagesConfig().getCooldownMessage().replace("{remaining}", String.valueOf(remaining));
|
||||
String msg = plugin.getConfigManager().getMessagesConfig().getCooldownMessage()
|
||||
.replace("{remaining}", String.valueOf(remaining));
|
||||
player.sendMessage(ChatFormatter.parse(msg));
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,7 +38,8 @@ public class TryCommand extends PlayerCommand {
|
|||
int cooldown = plugin.getConfigManager().getInt("rp.cooldowns.try", 0);
|
||||
if (cooldown > 0 && playerService.isOnCooldown(player.getUniqueId(), "rp_try", cooldown)) {
|
||||
int remaining = playerService.getRemainingCooldown(player.getUniqueId(), "rp_try", cooldown);
|
||||
String msg = plugin.getConfigManager().getMessagesConfig().getCooldownMessage().replace("{remaining}", String.valueOf(remaining));
|
||||
String msg = plugin.getConfigManager().getMessagesConfig().getCooldownMessage()
|
||||
.replace("{remaining}", String.valueOf(remaining));
|
||||
player.sendMessage(ChatFormatter.parse(msg));
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,9 +35,9 @@ public class AppearanceConfig extends BaseConfig {
|
|||
*/
|
||||
private void loadEmojiCache() {
|
||||
emojiCache.clear();
|
||||
if (config.isConfigurationSection("emojis")) {
|
||||
for (String key : config.getConfigurationSection("emojis").getKeys(false)) {
|
||||
emojiCache.put(key, config.getString("emojis." + key));
|
||||
if (getConfig().isConfigurationSection("emojis")) {
|
||||
for (String key : getConfig().getConfigurationSection("emojis").getKeys(false)) {
|
||||
emojiCache.put(key, getConfig().getString("emojis." + key));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -45,7 +45,7 @@ public class AppearanceConfig extends BaseConfig {
|
|||
// ========== ПРЕФИКСЫ ==========
|
||||
|
||||
private String getPrefixValue(String chatType, String key, String defaultValue) {
|
||||
return config.getString("prefixes." + chatType + "." + key, defaultValue);
|
||||
return getConfig().getString("prefixes." + chatType + "." + key, defaultValue);
|
||||
}
|
||||
|
||||
public String getGlobalEmoji() {
|
||||
|
|
@ -55,7 +55,7 @@ public class AppearanceConfig extends BaseConfig {
|
|||
return getPrefixValue("global", "text", "GLOBAL");
|
||||
}
|
||||
public List<String> getGlobalColors() {
|
||||
return config.getStringList("prefixes.global.colors");
|
||||
return getConfig().getStringList("prefixes.global.colors");
|
||||
}
|
||||
public String getGlobalSeparatorText() {
|
||||
return getPrefixValue("global", "separator.text", " ▶ ");
|
||||
|
|
@ -74,7 +74,7 @@ public class AppearanceConfig extends BaseConfig {
|
|||
return getPrefixValue("local", "text", "LOCAL");
|
||||
}
|
||||
public List<String> getLocalColors() {
|
||||
return config.getStringList("prefixes.local.colors");
|
||||
return getConfig().getStringList("prefixes.local.colors");
|
||||
}
|
||||
public String getLocalSeparatorText() {
|
||||
return getPrefixValue("local", "separator.text", " ▶ ");
|
||||
|
|
@ -89,20 +89,20 @@ public class AppearanceConfig extends BaseConfig {
|
|||
// ========== ФОРМАТ СООБЩЕНИЙ ==========
|
||||
|
||||
public String getGlobalChatFormat() {
|
||||
return config.getString("chat-format.global", "{emoji} {prefix} {separator} {player} : {message}");
|
||||
return getConfig().getString("chat-format.global", "{emoji} {prefix} {separator} {player} : {message}");
|
||||
}
|
||||
|
||||
public String getLocalChatFormat() {
|
||||
return config.getString("chat-format.local", "{emoji} {prefix} {separator} {player} : {message}");
|
||||
return getConfig().getString("chat-format.local", "{emoji} {prefix} {separator} {player} : {message}");
|
||||
}
|
||||
|
||||
// ========== HOVER ЭФФЕКТЫ ==========
|
||||
|
||||
public boolean isHoverEnabled() {
|
||||
return config.getBoolean("hover.enabled", true);
|
||||
return getConfig().getBoolean("hover.enabled", true);
|
||||
}
|
||||
public List<String> getHoverFormat() {
|
||||
return config.getStringList("hover.format");
|
||||
return getConfig().getStringList("hover.format");
|
||||
}
|
||||
|
||||
// ========== ЭМОДЗИ ==========
|
||||
|
|
@ -117,20 +117,20 @@ public class AppearanceConfig extends BaseConfig {
|
|||
// ========== НАСТРОЙКИ ЧАТА ==========
|
||||
|
||||
public int getLocalRadius() {
|
||||
return config.getInt("chat.local_radius", 100);
|
||||
return getConfig().getInt("chat.local_radius", 100);
|
||||
}
|
||||
public int getClearLines() {
|
||||
return config.getInt("chat.clear_lines", 100);
|
||||
return getConfig().getInt("chat.clear_lines", 100);
|
||||
}
|
||||
public int getMinMessageLength() {
|
||||
return config.getInt("chat.min_message_length", 1);
|
||||
return getConfig().getInt("chat.min_message_length", 1);
|
||||
}
|
||||
public int getMaxMessageLength() {
|
||||
return config.getInt("chat.max_message_length", 2000);
|
||||
return getConfig().getInt("chat.max_message_length", 2000);
|
||||
}
|
||||
|
||||
private String getChatColor(String type, String defaultColor) {
|
||||
return config.getString("chat.colors." + type, defaultColor);
|
||||
return getConfig().getString("chat.colors." + type, defaultColor);
|
||||
}
|
||||
|
||||
public String getNobodyHeardColor() {
|
||||
|
|
@ -152,18 +152,18 @@ public class AppearanceConfig extends BaseConfig {
|
|||
// ========== DISCORD ==========
|
||||
|
||||
public String getDiscordEmoji(String event) {
|
||||
return config.getString("discord.emojis." + event, "");
|
||||
return getConfig().getString("discord.emojis." + event, "");
|
||||
}
|
||||
public String getDiscordEventTitle(String event) {
|
||||
return config.getString("discord.event_titles." + event, "");
|
||||
return getConfig().getString("discord.event_titles." + event, "");
|
||||
}
|
||||
public String getDefaultAvatarUrl() {
|
||||
return config.getString("discord.avatar_urls.default", "https://mc-heads.net/avatar/minecraft/64");
|
||||
return getConfig().getString("discord.avatar_urls.default", "https://mc-heads.net/avatar/minecraft/64");
|
||||
}
|
||||
public String getPlayerAvatarUrl() {
|
||||
return config.getString("discord.avatar_urls.player", "https://mc-heads.net/avatar/{player}/64");
|
||||
return getConfig().getString("discord.avatar_urls.player", "https://mc-heads.net/avatar/{player}/64");
|
||||
}
|
||||
public String getDefaultEmbedColor() {
|
||||
return config.getString("discord.default_embed_color", "5865F2");
|
||||
return getConfig().getString("discord.default_embed_color", "5865F2");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,8 +14,8 @@ import java.nio.file.Files;
|
|||
*/
|
||||
public abstract class BaseConfig {
|
||||
protected final JavaPlugin plugin;
|
||||
protected File configFile;
|
||||
protected FileConfiguration config;
|
||||
private File configFile;
|
||||
private FileConfiguration config;
|
||||
private final String fileName;
|
||||
private final boolean inConfigFolder;
|
||||
|
||||
|
|
@ -112,6 +112,10 @@ public abstract class BaseConfig {
|
|||
// Переопределяется в подклассах
|
||||
}
|
||||
|
||||
protected File getConfigFile() {
|
||||
return configFile;
|
||||
}
|
||||
|
||||
/**
|
||||
* Получить FileConfiguration
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -16,146 +16,146 @@ public class FiltersConfig extends BaseConfig {
|
|||
// ── Капс ────────────────────────────────────────────────────────────────────
|
||||
|
||||
public boolean isCapsEnabled() {
|
||||
return config.getBoolean("caps.enabled", true);
|
||||
return getConfig().getBoolean("caps.enabled", true);
|
||||
}
|
||||
|
||||
public int getCapsMaxPercent() {
|
||||
return config.getInt("caps.max-percent", 70);
|
||||
return getConfig().getInt("caps.max-percent", 70);
|
||||
}
|
||||
|
||||
public int getCapsMinLength() {
|
||||
return config.getInt("caps.min-length", 5);
|
||||
return getConfig().getInt("caps.min-length", 5);
|
||||
}
|
||||
|
||||
public boolean isCapsAutoLowercase() {
|
||||
return config.getBoolean("caps.auto-lowercase", true);
|
||||
return getConfig().getBoolean("caps.auto-lowercase", true);
|
||||
}
|
||||
|
||||
public boolean isCapsBlock() {
|
||||
return config.getBoolean("caps.block", false);
|
||||
return getConfig().getBoolean("caps.block", false);
|
||||
}
|
||||
|
||||
// ── Мат ─────────────────────────────────────────────────────────────────────
|
||||
|
||||
public boolean isSwearEnabled() {
|
||||
return config.getBoolean("swear.enabled", true);
|
||||
return getConfig().getBoolean("swear.enabled", true);
|
||||
}
|
||||
|
||||
public String getSwearAction() {
|
||||
return config.getString("swear.action", "replace");
|
||||
return getConfig().getString("swear.action", "replace");
|
||||
}
|
||||
|
||||
public String getSwearReplacementChar() {
|
||||
return config.getString("swear.replacement-char", "*");
|
||||
return getConfig().getString("swear.replacement-char", "*");
|
||||
}
|
||||
|
||||
public boolean isSwearCheckFragments() {
|
||||
return config.getBoolean("swear.check-fragments", true);
|
||||
return getConfig().getBoolean("swear.check-fragments", true);
|
||||
}
|
||||
|
||||
public boolean isSwearIgnoreCase() {
|
||||
return config.getBoolean("swear.ignore-case", true);
|
||||
return getConfig().getBoolean("swear.ignore-case", true);
|
||||
}
|
||||
|
||||
public boolean isSwearUseExternalFile() {
|
||||
return config.getBoolean("swear.use-external-file", true);
|
||||
return getConfig().getBoolean("swear.use-external-file", true);
|
||||
}
|
||||
|
||||
public List<String> getSwearWords() {
|
||||
return config.getStringList("swear.words");
|
||||
return getConfig().getStringList("swear.words");
|
||||
}
|
||||
|
||||
public String getSwearBlockMessage() {
|
||||
return config.getString("swear.block-message", "&#CF6679Мат запрещён");
|
||||
return getConfig().getString("swear.block-message", "&#CF6679Мат запрещён");
|
||||
}
|
||||
|
||||
// ── Реклама ─────────────────────────────────────────────────────────────────
|
||||
|
||||
public boolean isAdvertisingEnabled() {
|
||||
return config.getBoolean("advertising.enabled", true);
|
||||
return getConfig().getBoolean("advertising.enabled", true);
|
||||
}
|
||||
|
||||
public boolean isBlockHiddenUrls() {
|
||||
return config.getBoolean("advertising.block-hidden-urls", true);
|
||||
return getConfig().getBoolean("advertising.block-hidden-urls", true);
|
||||
}
|
||||
|
||||
public boolean isBlockDomains() {
|
||||
return config.getBoolean("advertising.block-domains", true);
|
||||
return getConfig().getBoolean("advertising.block-domains", true);
|
||||
}
|
||||
|
||||
public List<String> getWhitelistedDomains() {
|
||||
return config.getStringList("advertising.whitelist");
|
||||
return getConfig().getStringList("advertising.whitelist");
|
||||
}
|
||||
|
||||
public List<String> getBlacklistedDomains() {
|
||||
return config.getStringList("advertising.blacklist");
|
||||
return getConfig().getStringList("advertising.blacklist");
|
||||
}
|
||||
|
||||
public String getAdvertisingBlockMessage() {
|
||||
return config.getString("advertising.blocked-message", "&#CF6679Реклама запрещена!");
|
||||
return getConfig().getString("advertising.blocked-message", "&#CF6679Реклама запрещена!");
|
||||
}
|
||||
|
||||
// ── IP адреса ───────────────────────────────────────────────────────────────
|
||||
|
||||
public boolean isIpEnabled() {
|
||||
return config.getBoolean("ip.enabled", true);
|
||||
return getConfig().getBoolean("ip.enabled", true);
|
||||
}
|
||||
|
||||
public boolean isIpBlock() {
|
||||
return config.getBoolean("ip.block", false);
|
||||
return getConfig().getBoolean("ip.block", false);
|
||||
}
|
||||
|
||||
public String getIpReplacement() {
|
||||
return config.getString("ip.replacement", "[IP скрыт]");
|
||||
return getConfig().getString("ip.replacement", "[IP скрыт]");
|
||||
}
|
||||
|
||||
public String getIpBlockMessage() {
|
||||
return config.getString("ip.blocked-message", "&#CF6679IP адреса запрещены!");
|
||||
return getConfig().getString("ip.blocked-message", "&#CF6679IP адреса запрещены!");
|
||||
}
|
||||
|
||||
// ── Повторяющиеся символы ───────────────────────────────────────────────────
|
||||
|
||||
public boolean isRepeatEnabled() {
|
||||
return config.getBoolean("repeat.enabled", true);
|
||||
return getConfig().getBoolean("repeat.enabled", true);
|
||||
}
|
||||
|
||||
public int getRepeatMaxRepeats() {
|
||||
return config.getInt("repeat.max-repeats", 3);
|
||||
return getConfig().getInt("repeat.max-repeats", 3);
|
||||
}
|
||||
|
||||
// ── Флуд ────────────────────────────────────────────────────────────────────
|
||||
|
||||
public boolean isFloodEnabled() {
|
||||
return config.getBoolean("flood.enabled", true);
|
||||
return getConfig().getBoolean("flood.enabled", true);
|
||||
}
|
||||
|
||||
public int getFloodMaxMessages() {
|
||||
return config.getInt("flood.max-messages", 5);
|
||||
return getConfig().getInt("flood.max-messages", 5);
|
||||
}
|
||||
|
||||
public int getFloodTimePeriod() {
|
||||
return config.getInt("flood.time-period", 10);
|
||||
return getConfig().getInt("flood.time-period", 10);
|
||||
}
|
||||
|
||||
public String getFloodBlockMessage() {
|
||||
return config.getString("flood.block-message", "&#CF6679Не флудите!");
|
||||
return getConfig().getString("flood.block-message", "&#CF6679Не флудите!");
|
||||
}
|
||||
|
||||
// ── Спам ────────────────────────────────────────────────────────────────────
|
||||
|
||||
public boolean isSpamEnabled() {
|
||||
return config.getBoolean("spam.enabled", true);
|
||||
return getConfig().getBoolean("spam.enabled", true);
|
||||
}
|
||||
|
||||
public int getSpamMaxSimilarMessages() {
|
||||
return config.getInt("spam.max-similar-messages", 3);
|
||||
return getConfig().getInt("spam.max-similar-messages", 3);
|
||||
}
|
||||
|
||||
public int getSpamSimilarityThreshold() {
|
||||
return config.getInt("spam.similarity-threshold", 80);
|
||||
return getConfig().getInt("spam.similarity-threshold", 80);
|
||||
}
|
||||
|
||||
public String getSpamBlockMessage() {
|
||||
return config.getString("spam.block-message", "&#CF6679Не отправляйте одинаковые сообщения");
|
||||
return getConfig().getString("spam.block-message", "&#CF6679Не отправляйте одинаковые сообщения");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,158 +14,163 @@ public class MessagesConfig extends BaseConfig {
|
|||
// ── Общие сообщения ────────────────────────────────────────────────────────
|
||||
|
||||
public String getNoPermission() {
|
||||
return config.getString("general.no_permission", "&#CF6679Нет прав!");
|
||||
return getConfig().getString("general.no_permission", "&#CF6679Нет прав!");
|
||||
}
|
||||
|
||||
public String getPlayerOnly() {
|
||||
return config.getString("general.player_only", "&#CF6679Только для игроков!");
|
||||
return getConfig().getString("general.player_only", "&#CF6679Только для игроков!");
|
||||
}
|
||||
|
||||
public String getPlayerNotFound() {
|
||||
return config.getString("general.player_not_found", "&#CF6679Игрок не найден!");
|
||||
return getConfig().getString("general.player_not_found", "&#CF6679Игрок не найден!");
|
||||
}
|
||||
|
||||
// ── Кулдаун ────────────────────────────────────────────────────────────────
|
||||
|
||||
public String getCooldownMessage() {
|
||||
return config.getString("commands.cooldown.message", "&#B798A8Подождите ẲE9{remaining} &#B798A8сек");
|
||||
return getConfig().getString("commands.cooldown.message", "&#B798A8Подождите ẲE9{remaining} &#B798A8сек");
|
||||
}
|
||||
|
||||
// ── Локальный чат ──────────────────────────────────────────────────────────
|
||||
|
||||
public String getNobodyHeard() {
|
||||
return config.getString("local_chat.nobody_heard", "⚖C9Вас никто не услышал &#B798A8— рядом нет игроков");
|
||||
return getConfig().getString("local_chat.nobody_heard", "⚖C9Вас никто не услышал &#B798A8— рядом нет игроков");
|
||||
}
|
||||
|
||||
// ── Мут ────────────────────────────────────────────────────────────────────
|
||||
|
||||
public String getMutedMessage() {
|
||||
return config.getString("mute.muted_message", "&#CF6679Вы замучены! &#B798A8Причина: ẲE9{reason}&#B798A8. Осталось: ẲE9{time}");
|
||||
return getConfig().getString("mute.muted_message", "&#CF6679Вы замучены! &#B798A8Причина: ẲE9{reason}"
|
||||
+ "&#B798A8. Осталось: ẲE9{time}");
|
||||
}
|
||||
|
||||
public String getMutedPermanent() {
|
||||
return config.getString("mute.muted_permanent", "&#CF6679Вы замучены навсегда! &#B798A8Причина: ẲE9{reason}");
|
||||
return getConfig().getString("mute.muted_permanent", "&#CF6679Вы замучены навсегда! &#B798A8Причина: ẲE9{reason}");
|
||||
}
|
||||
|
||||
public String getPlayerMuted() {
|
||||
return config.getString("mute.player_muted", "⚖C9Игрок ẲE9{player} ⚖C9замучен на ẲE9{time}⚖C9. Причина: &#B798A8{reason}");
|
||||
return getConfig().getString("mute.player_muted", "⚖C9Игрок ẲE9{player} ⚖C9замучен на"
|
||||
+ "ẲE9{time}⚖C9. Причина: &#B798A8{reason}");
|
||||
}
|
||||
|
||||
public String getPlayerMutedPermanent() {
|
||||
return config.getString("mute.player_muted_permanent", "⚖C9Игрок ẲE9{player} ⚖C9замучен навсегда. Причина: &#B798A8{reason}");
|
||||
return getConfig().getString("mute.player_muted_permanent", "⚖C9Игрок ẲE9{player} ⚖C9замучен"
|
||||
+ "навсегда. Причина: &#B798A8{reason}");
|
||||
}
|
||||
|
||||
public String getPlayerMutedSilent() {
|
||||
return config.getString("mute.player_muted_silent", "&#B798A8[⚖C9ТИХИЙ МУТ&#B798A8] ẲE9{player} &#B798A8замучен на ẲE9{time}");
|
||||
return getConfig().getString("mute.player_muted_silent", "&#B798A8[⚖C9ТИХИЙ МУТ&#B798A8] ẲE9{player}"
|
||||
+ "&#B798A8замучен на ẲE9{time}");
|
||||
}
|
||||
|
||||
public String getPlayerUnmuted() {
|
||||
return config.getString("mute.player_unmuted", "⚖C9Игрок ẲE9{player} ⚖C9размучен");
|
||||
return getConfig().getString("mute.player_unmuted", "⚖C9Игрок ẲE9{player} ⚖C9размучен");
|
||||
}
|
||||
|
||||
public String getPlayerNotMuted() {
|
||||
return config.getString("mute.not_muted", "&#B798A8Игрок ẲE9{player} &#B798A8не замучен");
|
||||
return getConfig().getString("mute.not_muted", "&#B798A8Игрок ẲE9{player} &#B798A8не замучен");
|
||||
}
|
||||
|
||||
public String getPlayerNotMutedSimple() {
|
||||
return config.getString("mute.player_not_muted_simple", "&#CF6679Игрок не замучен!");
|
||||
return getConfig().getString("mute.player_not_muted_simple", "&#CF6679Игрок не замучен!");
|
||||
}
|
||||
|
||||
public String getInvalidTime() {
|
||||
return config.getString("mute.invalid_time", "&#CF6679Неверный формат времени!");
|
||||
return getConfig().getString("mute.invalid_time", "&#CF6679Неверный формат времени!");
|
||||
}
|
||||
|
||||
public String getAlreadyMuted() {
|
||||
return config.getString("mute.already_muted", "&#CF6679Игрок уже замучен!");
|
||||
return getConfig().getString("mute.already_muted", "&#CF6679Игрок уже замучен!");
|
||||
}
|
||||
|
||||
public String getNoSilentUnmutePermission() {
|
||||
return config.getString("mute.no_silent_unmute_permission", "&#CF6679Нет права на тихий размут!");
|
||||
return getConfig().getString("mute.no_silent_unmute_permission", "&#CF6679Нет права на тихий размут!");
|
||||
}
|
||||
|
||||
public String getNoSilentMutePermission() {
|
||||
return config.getString("commands.mute.no_silent_permission", "&#CF6679Нет права на тихий мут");
|
||||
return getConfig().getString("commands.mute.no_silent_permission", "&#CF6679Нет права на тихий мут");
|
||||
}
|
||||
|
||||
public String getMuteUsage() {
|
||||
return config.getString("commands.mute.usage", "&#B798A8Использование: ẲE9/mute <ник> [время] [-s] [причина]");
|
||||
return getConfig().getString("commands.mute.usage", "&#B798A8Использование: ẲE9/mute <ник> [время] [-s] [причина]");
|
||||
}
|
||||
|
||||
public String getMuteTimeHelp() {
|
||||
return config.getString("commands.mute.time_help", "⚖C9Время: ẲE91d⚖C9, ẲE92h⚖C9, ẲE930m⚖C9, ẲE960s⚖C9, ẲE9perm");
|
||||
return getConfig().getString("commands.mute.time_help", "⚖C9Время: ẲE91d⚖C9, ẲE92h⚖C9, ẲE930m⚖C9, ẲE960s⚖C9, ẲE9perm");
|
||||
}
|
||||
|
||||
public String getMuteSilentHelp() {
|
||||
return config.getString("commands.mute.silent_help", "&#B798A8-s ⚖C9— тихий мут (право ẲE9lochat.mute.silent⚖C9)");
|
||||
return getConfig().getString("commands.mute.silent_help", "&#B798A8-s ⚖C9— тихий мут (право"
|
||||
+ "ẲE9lochat.mute.silent⚖C9)");
|
||||
}
|
||||
|
||||
public String getDefaultMuteReason() {
|
||||
return config.getString("commands.mute.default_reason", "Без причины");
|
||||
return getConfig().getString("commands.mute.default_reason", "Без причины");
|
||||
}
|
||||
|
||||
public String getDefaultMuteDuration() {
|
||||
return config.getString("commands.mute.default_duration", "7d");
|
||||
return getConfig().getString("commands.mute.default_duration", "7d");
|
||||
}
|
||||
|
||||
// ── ЛС ─────────────────────────────────────────────────────────────────────
|
||||
|
||||
public String getNoReplyTarget() {
|
||||
return config.getString("private_messages.no_reply_target", "&#CF6679Нет цели для ответа");
|
||||
return getConfig().getString("private_messages.no_reply_target", "&#CF6679Нет цели для ответа");
|
||||
}
|
||||
|
||||
public String getPlayerOffline() {
|
||||
return config.getString("private_messages.player_offline", "&#CF6679Игрок ẲE9{player} &#CF6679не в сети");
|
||||
return getConfig().getString("private_messages.player_offline", "&#CF6679Игрок ẲE9{player} &#CF6679не в сети");
|
||||
}
|
||||
|
||||
public String getCannotMessageSelf() {
|
||||
return config.getString("private_messages.cannot_message_self", "&#CF6679Нельзя писать самому себе");
|
||||
return getConfig().getString("private_messages.cannot_message_self", "&#CF6679Нельзя писать самому себе");
|
||||
}
|
||||
|
||||
// ── Игнор ──────────────────────────────────────────────────────────────────
|
||||
|
||||
public String getPlayerIgnored() {
|
||||
return config.getString("ignore.player_ignored", "⚖C9Игрок ẲE9{player} ⚖C9добавлен в игнор");
|
||||
return getConfig().getString("ignore.player_ignored", "⚖C9Игрок ẲE9{player} ⚖C9добавлен в игнор");
|
||||
}
|
||||
|
||||
public String getPlayerUnignored() {
|
||||
return config.getString("ignore.player_unignored", "⚖C9Игрок ẲE9{player} ⚖C9убран из игнора");
|
||||
return getConfig().getString("ignore.player_unignored", "⚖C9Игрок ẲE9{player} ⚖C9убран из игнора");
|
||||
}
|
||||
|
||||
public String getAlreadyIgnored() {
|
||||
return config.getString("ignore.already_ignored", "&#B798A8Игрок ẲE9{player} &#B798A8уже в игноре");
|
||||
return getConfig().getString("ignore.already_ignored", "&#B798A8Игрок ẲE9{player} &#B798A8уже в игноре");
|
||||
}
|
||||
|
||||
public String getNotIgnored() {
|
||||
return config.getString("ignore.not_ignored", "&#B798A8Игрок ẲE9{player} &#B798A8не в игноре");
|
||||
return getConfig().getString("ignore.not_ignored", "&#B798A8Игрок ẲE9{player} &#B798A8не в игноре");
|
||||
}
|
||||
|
||||
public String getCannotIgnoreSelf() {
|
||||
return config.getString("ignore.cannot_ignore_self", "&#CF6679Нельзя игнорировать самого себя");
|
||||
return getConfig().getString("ignore.cannot_ignore_self", "&#CF6679Нельзя игнорировать самого себя");
|
||||
}
|
||||
|
||||
public String getIgnoreListEmpty() {
|
||||
return config.getString("ignore.ignore_list_empty", "&#B798A8Список игнора пуст");
|
||||
return getConfig().getString("ignore.ignore_list_empty", "&#B798A8Список игнора пуст");
|
||||
}
|
||||
|
||||
public String getIgnoreListHeader() {
|
||||
return config.getString("ignore.ignore_list_header", "&#B798A8Игнорируемые игроки⚖C9:");
|
||||
return getConfig().getString("ignore.ignore_list_header", "&#B798A8Игнорируемые игроки⚖C9:");
|
||||
}
|
||||
|
||||
// ── Модерация (варны / баны) ────────────────────────────────────────────────
|
||||
|
||||
public String getModerationDefaultReason() {
|
||||
return config.getString("moderation.default_reason", "Без причины");
|
||||
return getConfig().getString("moderation.default_reason", "Без причины");
|
||||
}
|
||||
|
||||
public String getModerationDurationPermanent() {
|
||||
return config.getString("moderation.duration_permanent", "навсегда");
|
||||
return getConfig().getString("moderation.duration_permanent", "навсегда");
|
||||
}
|
||||
|
||||
/**
|
||||
* MiniMessage + legacy &# цвета; плейсхолдеры {reason},{moderator},{duration},{player}; перевод строки \\n
|
||||
*/
|
||||
public String getBanKickMessage() {
|
||||
return config.getString("moderation.ban_kick_message", defaultBanKick());
|
||||
return getConfig().getString("moderation.ban_kick_message", defaultBanKick());
|
||||
}
|
||||
|
||||
private String defaultBanKick() {
|
||||
|
|
@ -178,42 +183,44 @@ public class MessagesConfig extends BaseConfig {
|
|||
}
|
||||
|
||||
public String getWarnReceived() {
|
||||
return config.getString("moderation.warn_received", "&#CF6679⚠ Вам выдано предупреждение! &#B798A8Причина: ẲE9{reason}");
|
||||
return getConfig().getString("moderation.warn_received", "&#CF6679⚠ Вам выдано предупреждение! &#B798A8Причина: ẲE9{reason}");
|
||||
}
|
||||
|
||||
public String getWarnStaffConfirm() {
|
||||
return config.getString("moderation.warn_staff_confirm", "⚖C9Игроку ẲE9{player} ⚖C9выдан варн. &#B798A8Причина: ẲE9{reason}");
|
||||
return getConfig().getString("moderation.warn_staff_confirm", "⚖C9Игроку ẲE9{player} ⚖C9выдан"
|
||||
+ "варн. &#B798A8Причина: ẲE9{reason}");
|
||||
}
|
||||
|
||||
public String getSilentWarnStaff() {
|
||||
return config.getString("moderation.silent_warn_staff", "&#B798A8[⚖C9ТИХИЙ ВАРН&#B798A8] ẲE9{player}⚖C9: &#B798A8{reason}");
|
||||
return getConfig().getString("moderation.silent_warn_staff", "&#B798A8[⚖C9ТИХИЙ ВАРН&#B798A8] ẲE9{player}⚖C9: &#B798A8{reason}");
|
||||
}
|
||||
|
||||
public String getBanUsage() {
|
||||
return config.getString("moderation.ban_usage", "&#B798A8Использование: ẲE9/lban <ник> [время|perm] [причина]");
|
||||
return getConfig().getString("moderation.ban_usage", "&#B798A8Использование: ẲE9/lban <ник> [время|perm] [причина]");
|
||||
}
|
||||
|
||||
public String getBanConfirm() {
|
||||
return config.getString("moderation.ban_confirm", "⚖C9Игрок ẲE9{player} ⚖C9забанен. &#B798A8Срок: ẲE9{duration}");
|
||||
return getConfig().getString("moderation.ban_confirm", "⚖C9Игрок ẲE9{player} ⚖C9забанен."
|
||||
+ "&#B798A8Срок: ẲE9{duration}");
|
||||
}
|
||||
|
||||
public String getUnbanConfirm() {
|
||||
return config.getString("moderation.unban_confirm", "⚖C9Бан снят с ẲE9{player}");
|
||||
return getConfig().getString("moderation.unban_confirm", "⚖C9Бан снят с ẲE9{player}");
|
||||
}
|
||||
|
||||
public String getNotBanned() {
|
||||
return config.getString("moderation.not_banned", "&#CF6679Игрок не забанен!");
|
||||
return getConfig().getString("moderation.not_banned", "&#CF6679Игрок не забанен!");
|
||||
}
|
||||
|
||||
public String getAlreadyBanned() {
|
||||
return config.getString("moderation.already_banned", "&#CF6679Игрок уже забанен!");
|
||||
return getConfig().getString("moderation.already_banned", "&#CF6679Игрок уже забанен!");
|
||||
}
|
||||
|
||||
public String getWarnUsage() {
|
||||
return config.getString("moderation.warn_usage", "&#B798A8Использование: ẲE9/warn <ник> [причина]");
|
||||
return getConfig().getString("moderation.warn_usage", "&#B798A8Использование: ẲE9/warn <ник> [причина]");
|
||||
}
|
||||
|
||||
public String getSilentWarnUsage() {
|
||||
return config.getString("moderation.silent_warn_usage", "&#B798A8Использование: ẲE9/silentwarn <ник> [причина]");
|
||||
return getConfig().getString("moderation.silent_warn_usage", "&#B798A8Использование: ẲE9/silentwarn <ник> [причина]");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,48 +14,48 @@ public class MuteConfig extends BaseConfig {
|
|||
// ── Основные настройки ──────────────────────────────────────────────────────
|
||||
|
||||
public boolean isEnabled() {
|
||||
return config.getBoolean("enabled", true);
|
||||
return getConfig().getBoolean("enabled", true);
|
||||
}
|
||||
|
||||
public String getDefaultDuration() {
|
||||
return config.getString("default-duration", "7d");
|
||||
return getConfig().getString("default-duration", "7d");
|
||||
}
|
||||
|
||||
public String getDefaultReason() {
|
||||
return config.getString("default-reason", "Без причины");
|
||||
return getConfig().getString("default-reason", "Без причины");
|
||||
}
|
||||
|
||||
public int getMaxHistoryPerPlayer() {
|
||||
return config.getInt("max-history-per-player", 50);
|
||||
return getConfig().getInt("max-history-per-player", 50);
|
||||
}
|
||||
|
||||
// ── Права на длительность ───────────────────────────────────────────────────
|
||||
|
||||
public boolean isPermissionBasedDuration() {
|
||||
return config.getBoolean("permission-based-duration", true);
|
||||
return getConfig().getBoolean("permission-based-duration", true);
|
||||
}
|
||||
|
||||
// ── Уведомления ─────────────────────────────────────────────────────────────
|
||||
|
||||
public boolean isNotifyOnMute() {
|
||||
return config.getBoolean("notify.on-mute", true);
|
||||
return getConfig().getBoolean("notify.on-mute", true);
|
||||
}
|
||||
|
||||
public boolean isNotifyOnUnmute() {
|
||||
return config.getBoolean("notify.on-unmute", true);
|
||||
return getConfig().getBoolean("notify.on-unmute", true);
|
||||
}
|
||||
|
||||
public boolean isNotifyOnExpire() {
|
||||
return config.getBoolean("notify.on-expire", true);
|
||||
return getConfig().getBoolean("notify.on-expire", true);
|
||||
}
|
||||
|
||||
// ── Тихий мут ───────────────────────────────────────────────────────────────
|
||||
|
||||
public boolean isSilentMuteEnabled() {
|
||||
return config.getBoolean("silent-mute.enabled", true);
|
||||
return getConfig().getBoolean("silent-mute.enabled", true);
|
||||
}
|
||||
|
||||
public boolean isSilentMuteLogToConsole() {
|
||||
return config.getBoolean("silent-mute.log-to-console", true);
|
||||
return getConfig().getBoolean("silent-mute.log-to-console", true);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,54 +14,54 @@ public class SoundsConfig extends BaseConfig {
|
|||
// ── Звуки упоминаний ────────────────────────────────────────────────────────
|
||||
|
||||
public boolean isMentionSoundEnabled() {
|
||||
return config.getBoolean("mention.enabled", true);
|
||||
return getConfig().getBoolean("mention.enabled", true);
|
||||
}
|
||||
|
||||
public String getMentionSound() {
|
||||
return config.getString("mention.sound", "BLOCK_NOTE_BLOCK_PLING");
|
||||
return getConfig().getString("mention.sound", "BLOCK_NOTE_BLOCK_PLING");
|
||||
}
|
||||
|
||||
public float getMentionVolume() {
|
||||
return (float) config.getDouble("mention.volume", 1.0);
|
||||
return (float) getConfig().getDouble("mention.volume", 1.0);
|
||||
}
|
||||
|
||||
public float getMentionPitch() {
|
||||
return (float) config.getDouble("mention.pitch", 1.0);
|
||||
return (float) getConfig().getDouble("mention.pitch", 1.0);
|
||||
}
|
||||
|
||||
// ── Звуки личных сообщений ──────────────────────────────────────────────────
|
||||
|
||||
public boolean isPmSoundEnabled() {
|
||||
return config.getBoolean("pm.enabled", true);
|
||||
return getConfig().getBoolean("pm.enabled", true);
|
||||
}
|
||||
|
||||
public String getPmSound() {
|
||||
return config.getString("pm.sound", "ENTITY_EXPERIENCE_ORB_PICKUP");
|
||||
return getConfig().getString("pm.sound", "ENTITY_EXPERIENCE_ORB_PICKUP");
|
||||
}
|
||||
|
||||
public float getPmVolume() {
|
||||
return (float) config.getDouble("pm.volume", 1.0);
|
||||
return (float) getConfig().getDouble("pm.volume", 1.0);
|
||||
}
|
||||
|
||||
public float getPmPitch() {
|
||||
return (float) config.getDouble("pm.pitch", 1.0);
|
||||
return (float) getConfig().getDouble("pm.pitch", 1.0);
|
||||
}
|
||||
|
||||
// ── Звуки команд ────────────────────────────────────────────────────────────
|
||||
|
||||
public boolean isCommandSoundEnabled() {
|
||||
return config.getBoolean("command.enabled", false);
|
||||
return getConfig().getBoolean("command.enabled", false);
|
||||
}
|
||||
|
||||
public String getCommandSound() {
|
||||
return config.getString("command.sound", "UI_BUTTON_CLICK");
|
||||
return getConfig().getString("command.sound", "UI_BUTTON_CLICK");
|
||||
}
|
||||
|
||||
public float getCommandVolume() {
|
||||
return (float) config.getDouble("command.volume", 0.5);
|
||||
return (float) getConfig().getDouble("command.volume", 0.5);
|
||||
}
|
||||
|
||||
public float getCommandPitch() {
|
||||
return (float) config.getDouble("command.pitch", 1.0);
|
||||
return (float) getConfig().getDouble("command.pitch", 1.0);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -173,7 +173,8 @@ public class ConfigAccessor {
|
|||
}
|
||||
|
||||
public String getDeathPlayerKillFormat() {
|
||||
return config.getString("messages.death.player_kill", "&#CF6679☠ &#B798A8{player} ẲE9был убит игроком &#B798A8{killer} ⚖C9({weapon})");
|
||||
return config.getString("messages.death.player_kill", "&#CF6679☠ &#B798A8{player} ẲE9был убит"
|
||||
+ "игроком &#B798A8{killer} ⚖C9({weapon})");
|
||||
}
|
||||
|
||||
public String getDeathMobKillFormat() {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,10 @@
|
|||
package com.loki.lochat.core.filter;
|
||||
|
||||
import com.loki.lochat.core.filter.filters.*;
|
||||
import com.loki.lochat.core.filter.filters.CharacterFilter;
|
||||
import com.loki.lochat.core.filter.filters.FloodFilter;
|
||||
import com.loki.lochat.core.filter.filters.SpamFilter;
|
||||
import com.loki.lochat.core.filter.filters.SwearFilter;
|
||||
import com.loki.lochat.core.filter.filters.UrlFilter;
|
||||
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
|
|
|
|||
|
|
@ -10,7 +10,9 @@ import java.io.BufferedReader;
|
|||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.*;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class SwearFilter {
|
||||
|
|
|
|||
|
|
@ -1,10 +1,22 @@
|
|||
package com.loki.lochat.core.registry;
|
||||
|
||||
import com.loki.lochat.api.service.*;
|
||||
import com.loki.lochat.api.service.ChatService;
|
||||
import com.loki.lochat.api.service.MentionService;
|
||||
import com.loki.lochat.api.service.MessageService;
|
||||
import com.loki.lochat.api.service.MessagingService;
|
||||
import com.loki.lochat.api.service.MuteService;
|
||||
import com.loki.lochat.api.service.NickService;
|
||||
import com.loki.lochat.api.service.PlayerService;
|
||||
import com.loki.lochat.api.service.PunishmentService;
|
||||
import com.loki.lochat.config.ConfigManager;
|
||||
import com.loki.lochat.config.MessageConfig;
|
||||
import com.loki.lochat.core.factory.ServiceFactory;
|
||||
import com.loki.lochat.core.service.*;
|
||||
import com.loki.lochat.core.service.ChatServiceImpl;
|
||||
import com.loki.lochat.core.service.MentionServiceImpl;
|
||||
import com.loki.lochat.core.service.MessageServiceImpl;
|
||||
import com.loki.lochat.core.service.NickServiceImpl;
|
||||
import com.loki.lochat.core.service.PlayerServiceImpl;
|
||||
import com.loki.lochat.core.service.PunishmentServiceImpl;
|
||||
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,9 @@ import com.loki.lochat.utils.format.TimeFormatter;
|
|||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Сервис мутов с использованием Strategy pattern
|
||||
|
|
|
|||
|
|
@ -15,9 +15,21 @@ import net.kyori.adventure.text.Component;
|
|||
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.io.*;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.io.Reader;
|
||||
import java.io.Writer;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
/**
|
||||
|
|
@ -137,11 +149,11 @@ public class PunishmentServiceImpl implements PunishmentService {
|
|||
for (Map.Entry<UUID, List<WarnEntry>> e : warns.entrySet()) {
|
||||
List<WarnEntry> list = e.getValue();
|
||||
synchronized (list) {
|
||||
snap.warns.put(e.getKey().toString(), new ArrayList<>(list));
|
||||
snap.getWarns().put(e.getKey().toString(), new ArrayList<>(list));
|
||||
}
|
||||
}
|
||||
for (Map.Entry<UUID, BanRecord> e : bans.entrySet()) {
|
||||
snap.bans.put(e.getKey().toString(), e.getValue());
|
||||
snap.getBans().put(e.getKey().toString(), e.getValue());
|
||||
}
|
||||
try (Writer w = new OutputStreamWriter(new FileOutputStream(dataFile), java.nio.charset.StandardCharsets.UTF_8)) {
|
||||
gson.toJson(snap, w);
|
||||
|
|
@ -172,16 +184,16 @@ public class PunishmentServiceImpl implements PunishmentService {
|
|||
if (snap == null) {
|
||||
return;
|
||||
}
|
||||
if (snap.warns != null) {
|
||||
for (Map.Entry<String, List<WarnEntry>> e : snap.warns.entrySet()) {
|
||||
if (snap.getWarns() != null) {
|
||||
for (Map.Entry<String, List<WarnEntry>> e : snap.getWarns().entrySet()) {
|
||||
try {
|
||||
warns.put(UUID.fromString(e.getKey()), Collections.synchronizedList(new ArrayList<>(e.getValue())));
|
||||
} catch (IllegalArgumentException ignored) {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (snap.bans != null) {
|
||||
for (Map.Entry<String, BanRecord> e : snap.bans.entrySet()) {
|
||||
if (snap.getBans() != null) {
|
||||
for (Map.Entry<String, BanRecord> e : snap.getBans().entrySet()) {
|
||||
try {
|
||||
UUID id = UUID.fromString(e.getKey());
|
||||
BanRecord br = e.getValue();
|
||||
|
|
@ -202,7 +214,15 @@ public class PunishmentServiceImpl implements PunishmentService {
|
|||
}
|
||||
|
||||
private static class PunishmentSnapshot {
|
||||
Map<String, List<WarnEntry>> warns = new HashMap<>();
|
||||
Map<String, BanRecord> bans = new HashMap<>();
|
||||
private Map<String, List<WarnEntry>> warns = new HashMap<>();
|
||||
private Map<String, BanRecord> bans = new HashMap<>();
|
||||
|
||||
Map<String, List<WarnEntry>> getWarns() {
|
||||
return warns;
|
||||
}
|
||||
|
||||
Map<String, BanRecord> getBans() {
|
||||
return bans;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,12 @@ import org.bukkit.plugin.java.JavaPlugin;
|
|||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -8,9 +8,16 @@ import com.loki.lochat.utils.platform.FoliaUtil;
|
|||
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.io.*;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.Reader;
|
||||
import java.io.Writer;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.*;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -11,7 +11,11 @@ import java.io.FileReader;
|
|||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public class MuteHistoryManager {
|
||||
|
|
@ -33,7 +37,6 @@ public class MuteHistoryManager {
|
|||
reason,
|
||||
mutedBy,
|
||||
System.currentTimeMillis(),
|
||||
false,
|
||||
null,
|
||||
0
|
||||
));
|
||||
|
|
|
|||
|
|
@ -78,14 +78,14 @@ public class MuteData {
|
|||
} // For JSON deserialization
|
||||
|
||||
public MuteHistoryEntry(String playerName, long duration, String reason,
|
||||
String mutedBy, long mutedAt, boolean unmuted,
|
||||
String mutedBy, long mutedAt,
|
||||
String unmutedBy, long unmutedAt) {
|
||||
this.playerName = playerName;
|
||||
this.duration = duration;
|
||||
this.reason = reason;
|
||||
this.mutedBy = mutedBy;
|
||||
this.mutedAt = mutedAt;
|
||||
this.unmuted = unmuted;
|
||||
this.unmuted = unmutedBy != null;
|
||||
this.unmutedBy = unmutedBy;
|
||||
this.unmutedAt = unmutedAt;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,12 @@ package com.loki.lochat.gradient.commands;
|
|||
|
||||
import com.loki.lochat.config.RatConfig;
|
||||
import com.loki.lochat.gradient.GradientModule;
|
||||
import com.loki.lochat.gradient.commands.handlers.color.*;
|
||||
import com.loki.lochat.gradient.commands.handlers.color.ColorCopyHandler;
|
||||
import com.loki.lochat.gradient.commands.handlers.color.ColorOffHandler;
|
||||
import com.loki.lochat.gradient.commands.handlers.color.ColorOnHandler;
|
||||
import com.loki.lochat.gradient.commands.handlers.color.ColorResetHandler;
|
||||
import com.loki.lochat.gradient.commands.handlers.color.ColorSetHandler;
|
||||
import com.loki.lochat.gradient.commands.handlers.color.SubCommandHandler;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.Command;
|
||||
|
|
@ -13,7 +18,11 @@ import org.bukkit.entity.Player;
|
|||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Команда /color для установки градиента ника
|
||||
|
|
|
|||
|
|
@ -1,7 +1,11 @@
|
|||
package com.loki.lochat.gradient.commands;
|
||||
|
||||
import com.loki.lochat.gradient.GradientModule;
|
||||
import com.loki.lochat.gradient.commands.handlers.prefix.*;
|
||||
import com.loki.lochat.gradient.commands.handlers.prefix.PrefixOffHandler;
|
||||
import com.loki.lochat.gradient.commands.handlers.prefix.PrefixOnHandler;
|
||||
import com.loki.lochat.gradient.commands.handlers.prefix.PrefixResetHandler;
|
||||
import com.loki.lochat.gradient.commands.handlers.prefix.PrefixSetHandler;
|
||||
import com.loki.lochat.gradient.commands.handlers.prefix.PrefixSubCommandHandler;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
|
|
@ -11,7 +15,10 @@ import org.bukkit.entity.Player;
|
|||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Команда /prefix для установки кастомного префикса
|
||||
|
|
|
|||
|
|
@ -8,7 +8,12 @@ import org.bukkit.plugin.java.JavaPlugin;
|
|||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.sql.*;
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
package com.loki.lochat.gradient.util;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.Color;
|
||||
import java.util.List;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
|
|
|
|||
|
|
@ -55,71 +55,67 @@ public class PlaceholderAPIHook extends PlaceholderExpansion {
|
|||
}
|
||||
|
||||
UUID uuid = player.getUniqueId();
|
||||
GradientModule gradient = plugin.getGradientModule();
|
||||
|
||||
return switch (params.toLowerCase()) {
|
||||
case "ignored_count" -> String.valueOf(messagingService.getIgnoredCount(uuid));
|
||||
case "global_enabled" -> String.valueOf(!chatService.isGlobalChatDisabled(uuid));
|
||||
case "last_pm" -> {
|
||||
Optional<UUID> lastOpt = messagingService.getLastConversation(uuid);
|
||||
if (lastOpt.isEmpty()) {
|
||||
yield "";
|
||||
}
|
||||
var lastPlayer = Bukkit.getOfflinePlayer(lastOpt.get());
|
||||
yield lastPlayer.getName() != null ? lastPlayer.getName() : "";
|
||||
}
|
||||
case "last_pm" -> resolveLastPm(player, uuid);
|
||||
case "spy_enabled" -> String.valueOf(messagingService.isSpying(uuid));
|
||||
|
||||
// Gradient placeholders (совместимость с LoPreff)
|
||||
// Используем TAB формат §x§R§R§G§G§B§B для совместимости с TAB плагином
|
||||
case "gradient_full", "full" -> {
|
||||
Player onlinePlayer = player.getPlayer();
|
||||
if (onlinePlayer == null) {
|
||||
yield player.getName() != null ? player.getName() : "";
|
||||
case "gradient_full", "full" -> resolveGradient(player, GradientQuery.FULL);
|
||||
case "gradient_name", "name" -> resolveGradient(player, GradientQuery.NAME);
|
||||
case "gradient_prefix", "prefix" -> resolveGradient(player, GradientQuery.PREFIX);
|
||||
case "lp_prefix" -> resolveGradient(player, GradientQuery.LP_PREFIX);
|
||||
default -> null;
|
||||
};
|
||||
}
|
||||
|
||||
// Если gradient модуль выключен — берём только LuckPerms префикс + ник
|
||||
private enum GradientQuery { FULL, NAME, PREFIX, LP_PREFIX }
|
||||
|
||||
private String resolveGradient(OfflinePlayer player, GradientQuery query) {
|
||||
GradientModule gradient = plugin.getGradientModule();
|
||||
Player onlinePlayer = player.getPlayer();
|
||||
|
||||
if (onlinePlayer == null) {
|
||||
return switch (query) {
|
||||
case FULL, NAME -> player.getName() != null ? player.getName() : "";
|
||||
case PREFIX, LP_PREFIX -> "";
|
||||
};
|
||||
}
|
||||
|
||||
return switch (query) {
|
||||
case FULL -> {
|
||||
if (gradient == null || !gradient.isEnabled()) {
|
||||
yield player.getName() != null ? player.getName() : "";
|
||||
}
|
||||
|
||||
// Используем TAB формат для плейсхолдеров
|
||||
yield gradient.getFormattedNameForTab(onlinePlayer);
|
||||
}
|
||||
case "gradient_name", "name" -> {
|
||||
Player onlinePlayer = player.getPlayer();
|
||||
if (onlinePlayer == null) {
|
||||
yield player.getName() != null ? player.getName() : "";
|
||||
}
|
||||
|
||||
case NAME -> {
|
||||
if (gradient == null || !gradient.isEnabled()) {
|
||||
yield player.getName();
|
||||
}
|
||||
yield gradient.getGradientNick(onlinePlayer);
|
||||
}
|
||||
case "gradient_prefix", "prefix" -> {
|
||||
Player onlinePlayer = player.getPlayer();
|
||||
if (onlinePlayer == null) {
|
||||
yield "";
|
||||
}
|
||||
|
||||
case PREFIX -> {
|
||||
if (gradient == null || !gradient.isEnabled()) {
|
||||
yield "";
|
||||
}
|
||||
yield gradient.getPrefix(onlinePlayer);
|
||||
}
|
||||
case "lp_prefix" -> {
|
||||
Player onlinePlayer = player.getPlayer();
|
||||
if (onlinePlayer == null) {
|
||||
yield "";
|
||||
}
|
||||
|
||||
case LP_PREFIX -> {
|
||||
if (gradient == null || !gradient.isEnabled()) {
|
||||
yield "";
|
||||
}
|
||||
yield gradient.getLuckPermsPrefix(onlinePlayer);
|
||||
}
|
||||
default -> null;
|
||||
};
|
||||
}
|
||||
|
||||
private String resolveLastPm(OfflinePlayer player, UUID uuid) {
|
||||
Optional<UUID> lastOpt = messagingService.getLastConversation(uuid);
|
||||
if (lastOpt.isEmpty()) {
|
||||
return "";
|
||||
}
|
||||
var lastPlayer = Bukkit.getOfflinePlayer(lastOpt.get());
|
||||
return lastPlayer.getName() != null ? lastPlayer.getName() : "";
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -150,9 +150,7 @@ public class ChatEventListener implements Listener {
|
|||
private void recordStatistics(LoChat loChat, Player sender, boolean isGlobal) {
|
||||
com.loki.lochat.api.service.PlayerService playerService =
|
||||
loChat.getServiceRegistry().get(com.loki.lochat.api.service.PlayerService.class);
|
||||
if (playerService instanceof com.loki.lochat.core.service.PlayerServiceImpl impl) {
|
||||
impl.recordMessage(sender.getUniqueId(), isGlobal ? "global" : "local");
|
||||
}
|
||||
playerService.recordMessage(sender.getUniqueId(), isGlobal ? "global" : "local");
|
||||
}
|
||||
|
||||
private record ChatMode(boolean isGlobal, String message) {
|
||||
|
|
|
|||
|
|
@ -11,7 +11,11 @@ import org.bukkit.configuration.ConfigurationSection;
|
|||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import io.papermc.paper.threadedregions.scheduler.ScheduledTask;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
package com.loki.lochat.renderer;
|
||||
|
||||
import com.loki.lochat.renderer.components.*;
|
||||
import com.loki.lochat.renderer.components.EmojiComponent;
|
||||
import com.loki.lochat.renderer.components.GradientBuilder;
|
||||
import com.loki.lochat.renderer.components.UrlProcessor;
|
||||
import com.loki.lochat.utils.format.TextFormatter;
|
||||
import com.loki.lochat.utils.player.MentionHandler;
|
||||
|
||||
|
|
@ -15,6 +17,7 @@ import org.bukkit.entity.Player;
|
|||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import io.papermc.paper.chat.ChatRenderer;
|
||||
|
||||
|
|
@ -63,12 +66,18 @@ public class EnhancedChatRenderer implements ChatRenderer {
|
|||
Component playerSuffix = buildPlayerSuffix(source);
|
||||
Component player = buildPlayerComponent(source);
|
||||
|
||||
return buildFormattedMessage(format, emoji, prefix, separator, playerPrefix, playerSuffix, player, processed);
|
||||
return buildFormattedMessage(format, Map.of(
|
||||
"emoji", emoji,
|
||||
"prefix", prefix,
|
||||
"separator", separator,
|
||||
"player_prefix", playerPrefix,
|
||||
"player", player,
|
||||
"player_suffix", playerSuffix,
|
||||
"message", processed
|
||||
));
|
||||
}
|
||||
|
||||
private Component buildFormattedMessage(String format, Component emoji, Component prefix,
|
||||
Component separator, Component playerPrefix, Component playerSuffix,
|
||||
Component player, Component message) {
|
||||
private Component buildFormattedMessage(String format, Map<String, Component> parts) {
|
||||
Component result = Component.empty();
|
||||
java.util.regex.Pattern pattern = java.util.regex.Pattern.compile("\\{([^}]+)\\}");
|
||||
java.util.regex.Matcher matcher = pattern.matcher(format);
|
||||
|
|
@ -81,16 +90,7 @@ public class EnhancedChatRenderer implements ChatRenderer {
|
|||
}
|
||||
|
||||
String placeholder = matcher.group(1);
|
||||
switch (placeholder) {
|
||||
case "emoji" -> result = result.append(emoji);
|
||||
case "prefix" -> result = result.append(prefix);
|
||||
case "separator" -> result = result.append(separator);
|
||||
case "player_prefix" -> result = result.append(playerPrefix);
|
||||
case "player" -> result = result.append(player);
|
||||
case "player_suffix" -> result = result.append(playerSuffix);
|
||||
case "message" -> result = result.append(message);
|
||||
default -> result = result.append(Component.text("{" + placeholder + "}"));
|
||||
}
|
||||
result = result.append(parts.getOrDefault(placeholder, Component.text("{" + placeholder + "}")));
|
||||
|
||||
lastEnd = matcher.end();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -70,7 +70,9 @@ public class AdventureManager {
|
|||
try {
|
||||
// Используем Adventure API
|
||||
Object playerAudience = audiences.getClass().getMethod("player", Player.class).invoke(audiences, player);
|
||||
playerAudience.getClass().getMethod("sendMessage", Class.forName("net.kyori.adventure.text.Component")).invoke(playerAudience, message);
|
||||
playerAudience.getClass()
|
||||
.getMethod("sendMessage", Class.forName("net.kyori.adventure.text.Component"))
|
||||
.invoke(playerAudience, message);
|
||||
return;
|
||||
} catch (Exception e) {
|
||||
// Fallback на legacy
|
||||
|
|
|
|||
|
|
@ -55,7 +55,10 @@ public class FoliaUtil {
|
|||
// В 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);
|
||||
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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue