Initial commit: LoChat v1.0.0 with Gradient module
This commit is contained in:
commit
252b0a60db
86 changed files with 8922 additions and 0 deletions
61
src/main/java/com/loki/lochat/commands/AnnounceCommand.java
Normal file
61
src/main/java/com/loki/lochat/commands/AnnounceCommand.java
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
package com.loki.lochat.commands;
|
||||
|
||||
import com.loki.lochat.LoChat;
|
||||
import com.loki.lochat.utils.ChatFormatter;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.title.Title;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.time.Duration;
|
||||
|
||||
public class AnnounceCommand implements CommandExecutor {
|
||||
|
||||
private final LoChat plugin;
|
||||
|
||||
public AnnounceCommand(LoChat plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@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 <сообщение>")));
|
||||
return true;
|
||||
}
|
||||
|
||||
// /announce reload
|
||||
if (args[0].equalsIgnoreCase("reload") && sender.hasPermission("chat.announce.reload")) {
|
||||
plugin.reload();
|
||||
sender.sendMessage(ChatFormatter.parse(plugin.getMessageConfig().get("announce.reloaded")));
|
||||
return true;
|
||||
}
|
||||
|
||||
String message = String.join(" ", args);
|
||||
String format = plugin.getConfigManager().getAnnouncementFormat();
|
||||
Component formatted = ChatFormatter.formatAnnouncement(format, message);
|
||||
|
||||
// Отправка в чат
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
player.sendMessage(formatted);
|
||||
|
||||
// ActionBar
|
||||
player.sendActionBar(formatted);
|
||||
|
||||
// Title
|
||||
Title title = Title.title(
|
||||
ChatFormatter.parse("<gold>ОБЪЯВЛЕНИЕ</gold>"),
|
||||
ChatFormatter.parse(message),
|
||||
Title.Times.times(Duration.ofMillis(500), Duration.ofSeconds(3), Duration.ofMillis(500))
|
||||
);
|
||||
player.showTitle(title);
|
||||
}
|
||||
|
||||
plugin.getLogger().info("[ANNOUNCE] " + sender.getName() + ": " + ChatFormatter.stripTags(message));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
32
src/main/java/com/loki/lochat/commands/ChatSpyCommand.java
Normal file
32
src/main/java/com/loki/lochat/commands/ChatSpyCommand.java
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
package com.loki.lochat.commands;
|
||||
|
||||
import com.loki.lochat.LoChat;
|
||||
import com.loki.lochat.utils.ChatFormatter;
|
||||
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 ChatSpyCommand implements CommandExecutor {
|
||||
|
||||
private final LoChat plugin;
|
||||
|
||||
public ChatSpyCommand(LoChat plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||
if (!(sender instanceof Player player)) {
|
||||
sender.sendMessage("Только для игроков!");
|
||||
return true;
|
||||
}
|
||||
|
||||
boolean enabled = plugin.getSpyManager().toggleSpy(player.getUniqueId());
|
||||
String msgKey = enabled ? "spy.enabled" : "spy.disabled";
|
||||
player.sendMessage(ChatFormatter.parse(plugin.getMessageConfig().get(msgKey)));
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
36
src/main/java/com/loki/lochat/commands/ClearChatCommand.java
Normal file
36
src/main/java/com/loki/lochat/commands/ClearChatCommand.java
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
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) {
|
||||
// Отправляем 100 пустых строк всем игрокам
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
for (int i = 0; i < 100; i++) {
|
||||
player.sendMessage("");
|
||||
}
|
||||
|
||||
// Уведомление
|
||||
player.sendMessage(ChatFormatter.parse(
|
||||
plugin.getMessageConfig().get("clearchat.cleared", "{player}", sender.getName())
|
||||
));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
package com.loki.lochat.commands;
|
||||
|
||||
import com.loki.lochat.LoChat;
|
||||
import com.loki.lochat.utils.ChatFormatter;
|
||||
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 GlobalChatCommand implements CommandExecutor {
|
||||
|
||||
private final LoChat plugin;
|
||||
|
||||
public GlobalChatCommand(LoChat plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||
if (!(sender instanceof Player player)) {
|
||||
sender.sendMessage("Только для игроков!");
|
||||
return true;
|
||||
}
|
||||
|
||||
// /globalchat toggle
|
||||
if (command.getName().equalsIgnoreCase("globalchat")) {
|
||||
if (args.length > 0 && args[0].equalsIgnoreCase("toggle")) {
|
||||
boolean enabled = plugin.getChatManager().toggleGlobalChat(player.getUniqueId());
|
||||
String msgKey = enabled ? "global.toggled-on" : "global.toggled-off";
|
||||
player.sendMessage(ChatFormatter.parse(plugin.getMessageConfig().get(msgKey)));
|
||||
} else {
|
||||
player.sendMessage(ChatFormatter.parse(plugin.getMessageConfig().getInvalidUsage("/globalchat toggle")));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// /g <message>
|
||||
if (args.length == 0) {
|
||||
player.sendMessage(ChatFormatter.parse(plugin.getMessageConfig().getInvalidUsage("/g <сообщение>")));
|
||||
return true;
|
||||
}
|
||||
|
||||
String message = String.join(" ", args);
|
||||
plugin.getChatManager().sendGlobalMessage(player, message);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
55
src/main/java/com/loki/lochat/commands/IgnoreCommand.java
Normal file
55
src/main/java/com/loki/lochat/commands/IgnoreCommand.java
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
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 IgnoreCommand implements CommandExecutor {
|
||||
|
||||
private final LoChat plugin;
|
||||
|
||||
public IgnoreCommand(LoChat plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||
if (!(sender instanceof Player player)) {
|
||||
sender.sendMessage("Только для игроков!");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args.length == 0) {
|
||||
player.sendMessage(ChatFormatter.parse(plugin.getMessageConfig().getInvalidUsage("/ignore <ник>")));
|
||||
return true;
|
||||
}
|
||||
|
||||
Player target = Bukkit.getPlayer(args[0]);
|
||||
if (target == null) {
|
||||
player.sendMessage(ChatFormatter.parse(plugin.getMessageConfig().getPlayerNotFound()));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (target.equals(player)) {
|
||||
player.sendMessage(ChatFormatter.parse(plugin.getMessageConfig().get("ignore.self")));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (plugin.getIgnoreManager().isIgnoring(player.getUniqueId(), target.getUniqueId())) {
|
||||
player.sendMessage(ChatFormatter.parse(plugin.getMessageConfig().get("ignore.already-ignored")));
|
||||
return true;
|
||||
}
|
||||
|
||||
plugin.getIgnoreManager().addIgnore(player.getUniqueId(), target.getUniqueId());
|
||||
player.sendMessage(ChatFormatter.parse(
|
||||
plugin.getMessageConfig().get("ignore.added", "{player}", target.getName())
|
||||
));
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
35
src/main/java/com/loki/lochat/commands/LocalChatCommand.java
Normal file
35
src/main/java/com/loki/lochat/commands/LocalChatCommand.java
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
package com.loki.lochat.commands;
|
||||
|
||||
import com.loki.lochat.LoChat;
|
||||
import com.loki.lochat.utils.ChatFormatter;
|
||||
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 LocalChatCommand implements CommandExecutor {
|
||||
|
||||
private final LoChat plugin;
|
||||
|
||||
public LocalChatCommand(LoChat plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||
if (!(sender instanceof Player player)) {
|
||||
sender.sendMessage("Только для игроков!");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args.length == 0) {
|
||||
player.sendMessage(ChatFormatter.parse(plugin.getMessageConfig().getInvalidUsage("/l <сообщение>")));
|
||||
return true;
|
||||
}
|
||||
|
||||
String message = String.join(" ", args);
|
||||
plugin.getChatManager().sendLocalMessage(player, message);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
97
src/main/java/com/loki/lochat/commands/MsgCommand.java
Normal file
97
src/main/java/com/loki/lochat/commands/MsgCommand.java
Normal file
|
|
@ -0,0 +1,97 @@
|
|||
package com.loki.lochat.commands;
|
||||
|
||||
import com.loki.lochat.LoChat;
|
||||
import com.loki.lochat.utils.ChatFormatter;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Sound;
|
||||
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 MsgCommand implements CommandExecutor {
|
||||
|
||||
private final LoChat plugin;
|
||||
|
||||
public MsgCommand(LoChat plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||
if (!(sender instanceof Player player)) {
|
||||
sender.sendMessage("Только для игроков!");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!plugin.getConfigManager().isPmEnabled()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args.length < 2) {
|
||||
player.sendMessage(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")));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (target.equals(player)) {
|
||||
player.sendMessage(ChatFormatter.parse(plugin.getMessageConfig().get("pm.self")));
|
||||
return true;
|
||||
}
|
||||
|
||||
// Проверка игнора
|
||||
if (plugin.getIgnoreManager().isIgnoring(target.getUniqueId(), player.getUniqueId())) {
|
||||
player.sendMessage(ChatFormatter.parse(plugin.getMessageConfig().get("pm.ignored")));
|
||||
return true;
|
||||
}
|
||||
|
||||
// Собираем сообщение
|
||||
StringBuilder messageBuilder = new StringBuilder();
|
||||
for (int i = 1; i < args.length; i++) {
|
||||
if (i > 1) messageBuilder.append(" ");
|
||||
messageBuilder.append(args[i]);
|
||||
}
|
||||
String message = messageBuilder.toString();
|
||||
|
||||
// Отправляем сообщения
|
||||
player.sendMessage(ChatFormatter.formatPmSent(
|
||||
plugin.getMessageConfig().get("pm.sent"),
|
||||
target.getName(),
|
||||
message
|
||||
));
|
||||
|
||||
target.sendMessage(ChatFormatter.formatPmReceived(
|
||||
plugin.getMessageConfig().get("pm.received"),
|
||||
player.getName(),
|
||||
message
|
||||
));
|
||||
|
||||
// Звук для получателя
|
||||
if (plugin.getConfigManager().isPmSoundEnabled()) {
|
||||
try {
|
||||
Sound sound = Sound.valueOf(plugin.getConfigManager().getPmSoundType());
|
||||
target.playSound(target.getLocation(), sound, 1.0f, 1.0f);
|
||||
} catch (IllegalArgumentException ignored) {}
|
||||
}
|
||||
|
||||
// Шпион
|
||||
plugin.getSpyManager().broadcastPM(player, target, message);
|
||||
|
||||
// Сохраняем последнего собеседника
|
||||
plugin.getPmManager().setLastConversation(player.getUniqueId(), target.getUniqueId());
|
||||
plugin.getPmManager().setLastConversation(target.getUniqueId(), player.getUniqueId());
|
||||
|
||||
// Логирование
|
||||
if (plugin.getConfigManager().isPmLogEnabled()) {
|
||||
plugin.getLogger().info("[PM] " + player.getName() + " -> " + target.getName() + ": " + message);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
56
src/main/java/com/loki/lochat/commands/MuteCommand.java
Normal file
56
src/main/java/com/loki/lochat/commands/MuteCommand.java
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
package com.loki.lochat.commands;
|
||||
|
||||
import com.loki.lochat.LoChat;
|
||||
import com.loki.lochat.managers.MuteManager;
|
||||
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 MuteCommand implements CommandExecutor {
|
||||
|
||||
private final LoChat plugin;
|
||||
|
||||
public MuteCommand(LoChat plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||
if (args.length < 2) {
|
||||
sender.sendMessage(ChatFormatter.parse(plugin.getMessageConfig().getInvalidUsage("/mute <ник> <время> [причина]")));
|
||||
return true;
|
||||
}
|
||||
|
||||
Player target = Bukkit.getPlayer(args[0]);
|
||||
if (target == null) {
|
||||
sender.sendMessage(ChatFormatter.parse(plugin.getMessageConfig().getPlayerNotFound()));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (plugin.getMuteManager().isAlreadyMuted(target.getUniqueId())) {
|
||||
sender.sendMessage(ChatFormatter.parse(plugin.getMessageConfig().get("mute.already-muted")));
|
||||
return true;
|
||||
}
|
||||
|
||||
long duration = MuteManager.parseTime(args[1]);
|
||||
String reason = args.length > 2 ? String.join(" ", java.util.Arrays.copyOfRange(args, 2, args.length)) : null;
|
||||
|
||||
plugin.getMuteManager().mute(target.getUniqueId(), duration, reason);
|
||||
|
||||
String timeStr = duration <= 0 ? "навсегда" : args[1];
|
||||
sender.sendMessage(ChatFormatter.parse(
|
||||
plugin.getMessageConfig().get("mute.muted", "{player}", target.getName(), "{time}", timeStr)
|
||||
));
|
||||
|
||||
// Уведомляем игрока
|
||||
target.sendMessage(ChatFormatter.parse(
|
||||
plugin.getMessageConfig().get("mute.you-muted", "{time}", timeStr)
|
||||
));
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
93
src/main/java/com/loki/lochat/commands/ReplyCommand.java
Normal file
93
src/main/java/com/loki/lochat/commands/ReplyCommand.java
Normal file
|
|
@ -0,0 +1,93 @@
|
|||
package com.loki.lochat.commands;
|
||||
|
||||
import com.loki.lochat.LoChat;
|
||||
import com.loki.lochat.utils.ChatFormatter;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class ReplyCommand implements CommandExecutor {
|
||||
|
||||
private final LoChat plugin;
|
||||
|
||||
public ReplyCommand(LoChat plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||
if (!(sender instanceof Player player)) {
|
||||
sender.sendMessage("Только для игроков!");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!plugin.getConfigManager().isPmEnabled()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args.length == 0) {
|
||||
player.sendMessage(ChatFormatter.parse(plugin.getMessageConfig().getInvalidUsage("/reply <сообщение>")));
|
||||
return true;
|
||||
}
|
||||
|
||||
UUID lastUuid = plugin.getPmManager().getLastConversation(player.getUniqueId());
|
||||
if (lastUuid == null) {
|
||||
player.sendMessage(ChatFormatter.parse(plugin.getMessageConfig().get("pm.no-reply")));
|
||||
return true;
|
||||
}
|
||||
|
||||
Player target = Bukkit.getPlayer(lastUuid);
|
||||
if (target == null) {
|
||||
player.sendMessage(ChatFormatter.parse(plugin.getMessageConfig().get("pm.player-offline")));
|
||||
return true;
|
||||
}
|
||||
|
||||
// Проверка игнора
|
||||
if (plugin.getIgnoreManager().isIgnoring(target.getUniqueId(), player.getUniqueId())) {
|
||||
player.sendMessage(ChatFormatter.parse(plugin.getMessageConfig().get("pm.ignored")));
|
||||
return true;
|
||||
}
|
||||
|
||||
String message = String.join(" ", args);
|
||||
|
||||
// Отправляем сообщения
|
||||
player.sendMessage(ChatFormatter.formatPmSent(
|
||||
plugin.getMessageConfig().get("pm.sent"),
|
||||
target.getName(),
|
||||
message
|
||||
));
|
||||
|
||||
target.sendMessage(ChatFormatter.formatPmReceived(
|
||||
plugin.getMessageConfig().get("pm.received"),
|
||||
player.getName(),
|
||||
message
|
||||
));
|
||||
|
||||
// Звук для получателя
|
||||
if (plugin.getConfigManager().isPmSoundEnabled()) {
|
||||
try {
|
||||
Sound sound = Sound.valueOf(plugin.getConfigManager().getPmSoundType());
|
||||
target.playSound(target.getLocation(), sound, 1.0f, 1.0f);
|
||||
} catch (IllegalArgumentException ignored) {}
|
||||
}
|
||||
|
||||
// Шпион
|
||||
plugin.getSpyManager().broadcastPM(player, target, message);
|
||||
|
||||
// Обновляем последнего собеседника
|
||||
plugin.getPmManager().setLastConversation(target.getUniqueId(), player.getUniqueId());
|
||||
|
||||
// Логирование
|
||||
if (plugin.getConfigManager().isPmLogEnabled()) {
|
||||
plugin.getLogger().info("[PM] " + player.getName() + " -> " + target.getName() + ": " + message);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
50
src/main/java/com/loki/lochat/commands/UnignoreCommand.java
Normal file
50
src/main/java/com/loki/lochat/commands/UnignoreCommand.java
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
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 UnignoreCommand implements CommandExecutor {
|
||||
|
||||
private final LoChat plugin;
|
||||
|
||||
public UnignoreCommand(LoChat plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||
if (!(sender instanceof Player player)) {
|
||||
sender.sendMessage("Только для игроков!");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args.length == 0) {
|
||||
player.sendMessage(ChatFormatter.parse(plugin.getMessageConfig().getInvalidUsage("/unignore <ник>")));
|
||||
return true;
|
||||
}
|
||||
|
||||
Player target = Bukkit.getPlayer(args[0]);
|
||||
if (target == null) {
|
||||
player.sendMessage(ChatFormatter.parse(plugin.getMessageConfig().getPlayerNotFound()));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!plugin.getIgnoreManager().isIgnoring(player.getUniqueId(), target.getUniqueId())) {
|
||||
player.sendMessage(ChatFormatter.parse(plugin.getMessageConfig().get("ignore.not-ignored")));
|
||||
return true;
|
||||
}
|
||||
|
||||
plugin.getIgnoreManager().removeIgnore(player.getUniqueId(), target.getUniqueId());
|
||||
player.sendMessage(ChatFormatter.parse(
|
||||
plugin.getMessageConfig().get("ignore.removed", "{player}", target.getName())
|
||||
));
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
45
src/main/java/com/loki/lochat/commands/UnmuteCommand.java
Normal file
45
src/main/java/com/loki/lochat/commands/UnmuteCommand.java
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
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 UnmuteCommand implements CommandExecutor {
|
||||
|
||||
private final LoChat plugin;
|
||||
|
||||
public UnmuteCommand(LoChat plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||
if (args.length < 1) {
|
||||
sender.sendMessage(ChatFormatter.parse(plugin.getMessageConfig().getInvalidUsage("/unmute <ник>")));
|
||||
return true;
|
||||
}
|
||||
|
||||
Player target = Bukkit.getPlayer(args[0]);
|
||||
if (target == null) {
|
||||
sender.sendMessage(ChatFormatter.parse(plugin.getMessageConfig().getPlayerNotFound()));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!plugin.getMuteManager().isMuted(target.getUniqueId())) {
|
||||
sender.sendMessage(ChatFormatter.parse(plugin.getMessageConfig().get("mute.not-muted")));
|
||||
return true;
|
||||
}
|
||||
|
||||
plugin.getMuteManager().unmute(target.getUniqueId());
|
||||
sender.sendMessage(ChatFormatter.parse(
|
||||
plugin.getMessageConfig().get("mute.unmuted", "{player}", target.getName())
|
||||
));
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue