refactor: only do trusted broadcast in console ONCE & ignore broadcast if server is same as broadcast origin

This commit is contained in:
ChomeNS
2025-03-09 16:21:31 +07:00
parent b9381755c1
commit 2b328c3d0d
2 changed files with 12 additions and 11 deletions

View File

@@ -4,6 +4,7 @@ import me.chayapak1.chomens_bot.Bot;
import me.chayapak1.chomens_bot.data.logging.LogType;
import me.chayapak1.chomens_bot.data.player.PlayerEntry;
import me.chayapak1.chomens_bot.util.ColorUtilities;
import me.chayapak1.chomens_bot.util.LoggerUtilities;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.NamedTextColor;
@@ -26,17 +27,17 @@ public class TrustedPlugin extends PlayersPlugin.Listener {
}
public void broadcast (Component message, UUID exceptTarget) {
final Component component = Component.translatable(
"[%s] [%s] %s",
Component.text("ChomeNS Bot").color(ColorUtilities.getColorByString(this.bot.config.colorPalette.primary)),
Component.text(this.bot.options.serverName).color(NamedTextColor.GRAY),
message.color(NamedTextColor.WHITE)
).color(NamedTextColor.DARK_GRAY);
LoggerUtilities.log(LogType.TRUSTED_BROADCAST, component);
for (Bot bot : bot.bots) {
if (!bot.loggedIn) continue;
final Component component = Component.translatable(
"[%s] [%s] %s",
Component.text("ChomeNS Bot").color(ColorUtilities.getColorByString(bot.config.colorPalette.primary)),
Component.text(this.bot.options.serverName).color(NamedTextColor.GRAY),
message.color(NamedTextColor.WHITE)
).color(NamedTextColor.DARK_GRAY);
bot.logger.log(LogType.TRUSTED_BROADCAST, component);
if (bot == this.bot || !bot.loggedIn) continue;
for (String player : list) {
final PlayerEntry entry = bot.players.getEntry(player);