mirror of
https://github.com/darksaid98/Carbon.git
synced 2026-12-04 14:38:49 +00:00
Add chat clearing
This commit is contained in:
1 parent
e7ceac8063
commit
d1b35bd95d
3 files changed
+48
No files matched your search
@@ -0,0 +1,43 @@
|
|||||||
|
package net.draycia.simplechat.commands;
|
||||||
|
|
||||||
|
import co.aikar.commands.BaseCommand;
|
||||||
|
import co.aikar.commands.CommandIssuer;
|
||||||
|
import co.aikar.commands.annotation.CommandAlias;
|
||||||
|
import co.aikar.commands.annotation.CommandPermission;
|
||||||
|
import co.aikar.commands.annotation.Default;
|
||||||
|
import me.minidigger.minimessage.text.MiniMessageParser;
|
||||||
|
import net.draycia.simplechat.SimpleChat;
|
||||||
|
import net.kyori.adventure.audience.Audience;
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
@CommandAlias("clearchat|cc")
|
||||||
|
@CommandPermission("simplechat.clear.use")
|
||||||
|
public class CommandClearChat extends BaseCommand {
|
||||||
|
|
||||||
|
private SimpleChat simpleChat;
|
||||||
|
|
||||||
|
public CommandClearChat(SimpleChat simpleChat) {
|
||||||
|
this.simpleChat = simpleChat;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Default
|
||||||
|
public void baseCommand(CommandIssuer issuer) {
|
||||||
|
String format = simpleChat.getConfig().getString("clear-chat-message", "");
|
||||||
|
Component component = MiniMessageParser.parseFormat(format);
|
||||||
|
|
||||||
|
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||||
|
if (player.hasPermission("simplechat.clear.exempt")) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
Audience audience = simpleChat.getPlatform().player(player);
|
||||||
|
|
||||||
|
for (int i = 0; i < simpleChat.getConfig().getInt("clear-chat-amount", 100); i++) {
|
||||||
|
audience.sendMessage(component);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -5,6 +5,7 @@ import co.aikar.commands.ConditionFailedException;
|
|||||||
import net.draycia.simplechat.SimpleChat;
|
import net.draycia.simplechat.SimpleChat;
|
||||||
import net.draycia.simplechat.channels.ChatChannel;
|
import net.draycia.simplechat.channels.ChatChannel;
|
||||||
import net.draycia.simplechat.commands.ChannelCommand;
|
import net.draycia.simplechat.commands.ChannelCommand;
|
||||||
|
import net.draycia.simplechat.commands.CommandClearChat;
|
||||||
import net.draycia.simplechat.commands.IgnoreCommand;
|
import net.draycia.simplechat.commands.IgnoreCommand;
|
||||||
import net.draycia.simplechat.commands.ToggleCommand;
|
import net.draycia.simplechat.commands.ToggleCommand;
|
||||||
|
|
||||||
@@ -56,6 +57,7 @@ public class CommandManager {
|
|||||||
manager.registerCommand(new ToggleCommand(simpleChat));
|
manager.registerCommand(new ToggleCommand(simpleChat));
|
||||||
manager.registerCommand(new ChannelCommand(simpleChat));
|
manager.registerCommand(new ChannelCommand(simpleChat));
|
||||||
manager.registerCommand(new IgnoreCommand(simpleChat));
|
manager.registerCommand(new IgnoreCommand(simpleChat));
|
||||||
|
manager.registerCommand(new CommandClearChat(simpleChat));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -48,3 +48,6 @@ language:
|
|||||||
not-ignoring-user: '<green>You are no longer ignoring <gold><player><green>!'
|
not-ignoring-user: '<green>You are no longer ignoring <gold><player><green>!'
|
||||||
|
|
||||||
server-name: 'Server'
|
server-name: 'Server'
|
||||||
|
|
||||||
|
clear-chat-message: ""
|
||||||
|
clear-chat-amount: 100
|
||||||
Reference in new issue
Block a user