anti clearchat

totallynotskidded™ idea from chipmunkbot js
This commit is contained in:
ChomeNS 2023-03-27 11:04:28 +07:00
parent 02b736b69d
commit 379303ba69
2 changed files with 40 additions and 0 deletions

View file

@ -44,6 +44,7 @@ public class Bot {
@Getter private final MusicPlayerPlugin music; @Getter private final MusicPlayerPlugin music;
@Getter private final TPSPlugin tps; @Getter private final TPSPlugin tps;
@Getter private final EvalRunnerPlugin eval; @Getter private final EvalRunnerPlugin eval;
@Getter private final AntiClearChatPlugin antiClearChat;
public Bot (String host, int port, String _username, boolean kaboom, List<Bot> allBots, Configuration config) { public Bot (String host, int port, String _username, boolean kaboom, List<Bot> allBots, Configuration config) {
this.host = host; this.host = host;
@ -69,6 +70,7 @@ public class Bot {
this.music = new MusicPlayerPlugin(this); this.music = new MusicPlayerPlugin(this);
this.tps = new TPSPlugin(this); this.tps = new TPSPlugin(this);
this.eval = new EvalRunnerPlugin(this); this.eval = new EvalRunnerPlugin(this);
this.antiClearChat = new AntiClearChatPlugin(this);
reconnect(); reconnect();
} }

View file

@ -0,0 +1,38 @@
package me.chayapak1.chomens_bot.plugins;
import me.chayapak1.chomens_bot.Bot;
import me.chayapak1.chomens_bot.chatParsers.data.PlayerMessage;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.TextComponent;
import net.kyori.adventure.text.format.NamedTextColor;
// idea totallynotskidded from chipmunkbot (the js one)
public class AntiClearChatPlugin extends ChatPlugin.ChatListener {
private final Bot bot;
public AntiClearChatPlugin (Bot bot) {
this.bot = bot;
bot.chat().addListener(this);
}
@Override
public void commandSpyMessageReceived (PlayerMessage message) {
final String username = message.sender().profile().getName();
final String command = ((TextComponent) message.parameters().get("contents")).content();
if (
command.equals("/clearchat") ||
command.equals("/cc") ||
command.equals("/extras:clearchat") ||
command.equals("/extras:cc")
) {
bot.chat().tellraw(
Component.empty()
.append(Component.text(username))
.append(Component.text(" cleared the chat"))
.color(NamedTextColor.DARK_GREEN)
);
}
}
}