fix a VERY MINOR "exploit"

`chayapak: /whatever whatever whatever /cc` triggers the message
This commit is contained in:
Chayapak 2023-05-28 15:25:59 +07:00
parent 082e1c4468
commit 7c522b222d

View file

@ -1,20 +1,15 @@
package land.chipmunk.chayapak.chomens_bot.plugins;
import land.chipmunk.chayapak.chomens_bot.data.chat.PlayerMessage;
import land.chipmunk.chayapak.chomens_bot.Bot;
import land.chipmunk.chayapak.chomens_bot.data.chat.PlayerMessage;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.TextComponent;
import net.kyori.adventure.text.format.NamedTextColor;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
// idea totallynotskidded from chipmunkbot (the js one)
public class ClearChatUsernamePlugin extends ChatPlugin.Listener {
private final Bot bot;
public static final Pattern PATTERN = Pattern.compile("/clearchat.*|/cc.*|/extras:clearchat.*|/extras:cc.*");
public ClearChatUsernamePlugin(Bot bot) {
this.bot = bot;
@ -26,9 +21,12 @@ public class ClearChatUsernamePlugin extends ChatPlugin.Listener {
final String username = message.sender().profile().getName();
final String command = ((TextComponent) message.contents()).content();
final Matcher matcher = PATTERN.matcher(command);
if (matcher.find()) {
if (
command.startsWith("/cc") ||
command.startsWith("/clearchat") ||
command.startsWith("/extras:cc") ||
command.startsWith("/extras:clearchat")
) {
bot.chat().tellraw(
Component.empty()
.append(Component.text(username))