Features fixed: - Added chat filter functionality (block/warn/censor modes) - Fixed spy command to monitor all chat messages - Added proper spy notifications for global/local chat Code quality improvements: - Created PlayerUtil to eliminate code duplication in player lookup - Refactored ChatListener into smaller, focused methods - Added Constants class to replace magic numbers - Improved SOLID principles compliance - Fixed all compilation warnings All features from README are now implemented and working.
36 lines
1.2 KiB
Java
36 lines
1.2 KiB
Java
package com.loki.lochat.commands;
|
|
|
|
import com.loki.lochat.LoChat;
|
|
import com.loki.lochat.utils.ChatFormatter;
|
|
import org.bukkit.Bukkit;
|
|
import org.bukkit.command.Command;
|
|
import org.bukkit.command.CommandExecutor;
|
|
import org.bukkit.command.CommandSender;
|
|
import org.bukkit.entity.Player;
|
|
import org.jetbrains.annotations.NotNull;
|
|
|
|
public class ClearChatCommand implements CommandExecutor {
|
|
|
|
private final LoChat plugin;
|
|
|
|
public ClearChatCommand(LoChat plugin) {
|
|
this.plugin = plugin;
|
|
}
|
|
|
|
@Override
|
|
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
|
// Отправляем пустые строки всем игрокам для очистки чата
|
|
for (Player player : Bukkit.getOnlinePlayers()) {
|
|
for (int i = 0; i < com.loki.lochat.utils.Constants.CLEAR_CHAT_LINES; i++) {
|
|
player.sendMessage("");
|
|
}
|
|
|
|
// Уведомление
|
|
player.sendMessage(ChatFormatter.parse(
|
|
plugin.getMessageConfig().get("clearchat.cleared", "{player}", sender.getName())
|
|
));
|
|
}
|
|
|
|
return true;
|
|
}
|
|
}
|