fix all problems about console and discord and logger and shits
yes i fixed EVERY single problem (mabe)
This commit is contained in:
parent
f4afd1c36e
commit
0ee70b93b9
6 changed files with 101 additions and 88 deletions
src/main/java/land/chipmunk/chayapak/chomens_bot
|
@ -32,29 +32,32 @@ public class Bot {
|
||||||
|
|
||||||
@Getter public Session session;
|
@Getter public Session session;
|
||||||
|
|
||||||
|
@Getter private boolean loggedIn = false;
|
||||||
|
|
||||||
@Getter private ScheduledExecutorService executor = Executors.newScheduledThreadPool(100);
|
@Getter private ScheduledExecutorService executor = Executors.newScheduledThreadPool(100);
|
||||||
|
|
||||||
@Getter @Setter private ConsolePlugin console;
|
@Getter @Setter private ConsolePlugin console;
|
||||||
@Getter @Setter private LoggerPlugin logger; // in ConsolePlugin
|
@Getter @Setter private LoggerPlugin logger; // in ConsolePlugin
|
||||||
@Getter @Setter private DiscordPlugin discord;
|
@Getter @Setter private DiscordPlugin discord; // same for this one too
|
||||||
@Getter private final ChatPlugin chat;
|
|
||||||
@Getter private final SelfCarePlugin selfCare;
|
@Getter private ChatPlugin chat;
|
||||||
@Getter private final PositionPlugin position;
|
@Getter private SelfCarePlugin selfCare;
|
||||||
@Getter private final CorePlugin core;
|
@Getter private PositionPlugin position;
|
||||||
@Getter private final PlayersPlugin players;
|
@Getter private CorePlugin core;
|
||||||
@Getter private final TabCompletePlugin tabComplete;
|
@Getter private PlayersPlugin players;
|
||||||
@Getter private final CommandHandlerPlugin commandHandler;
|
@Getter private TabCompletePlugin tabComplete;
|
||||||
@Getter private final ChatCommandHandlerPlugin chatCommandHandler;
|
@Getter private CommandHandlerPlugin commandHandler;
|
||||||
@Getter private final HashingPlugin hashing;
|
@Getter private ChatCommandHandlerPlugin chatCommandHandler;
|
||||||
@Getter private final BossbarManagerPlugin bossbar;
|
@Getter private HashingPlugin hashing;
|
||||||
@Getter private final MusicPlayerPlugin music;
|
@Getter private BossbarManagerPlugin bossbar;
|
||||||
@Getter private final TPSPlugin tps;
|
@Getter private MusicPlayerPlugin music;
|
||||||
@Getter private final EvalRunnerPlugin eval;
|
@Getter private TPSPlugin tps;
|
||||||
@Getter private final ClearChatUsernamePlugin clearChatUsername;
|
@Getter private EvalRunnerPlugin eval;
|
||||||
@Getter private final TrustedPlugin trusted;
|
@Getter private ClearChatUsernamePlugin clearChatUsername;
|
||||||
@Getter private final BruhifyPlugin bruhify;
|
@Getter private TrustedPlugin trusted;
|
||||||
@Getter private final GrepLogPlugin grepLog;
|
@Getter private BruhifyPlugin bruhify;
|
||||||
@Getter private final CloopPlugin cloop;
|
@Getter private GrepLogPlugin grepLog;
|
||||||
|
@Getter private CloopPlugin cloop;
|
||||||
|
|
||||||
public Bot (String host, int port, String _username, boolean kaboom, String serverName, List<Bot> allBots, Configuration config) {
|
public Bot (String host, int port, String _username, boolean kaboom, String serverName, List<Bot> allBots, Configuration config) {
|
||||||
this.host = host;
|
this.host = host;
|
||||||
|
@ -65,12 +68,15 @@ public class Bot {
|
||||||
this.allBots = allBots;
|
this.allBots = allBots;
|
||||||
this.config = config;
|
this.config = config;
|
||||||
|
|
||||||
try {
|
ConsolePlugin.addListener(new ConsolePlugin.Listener() {
|
||||||
DiscordPlugin.readyLatch().await();
|
@Override
|
||||||
|
public void ready() {
|
||||||
// Thread.sleep(2000); // prob the worst way to fix this thing
|
Bot.this.ready();
|
||||||
} catch (InterruptedException ignored) { System.exit(1); }
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ready () {
|
||||||
this.chat = new ChatPlugin(this);
|
this.chat = new ChatPlugin(this);
|
||||||
this.selfCare = new SelfCarePlugin(this);
|
this.selfCare = new SelfCarePlugin(this);
|
||||||
this.position = new PositionPlugin(this);
|
this.position = new PositionPlugin(this);
|
||||||
|
@ -112,6 +118,7 @@ public class Bot {
|
||||||
|
|
||||||
if (packet instanceof ClientboundLoginPacket) {
|
if (packet instanceof ClientboundLoginPacket) {
|
||||||
for (SessionListener listener : listeners) {
|
for (SessionListener listener : listeners) {
|
||||||
|
loggedIn = true;
|
||||||
listener.connected(new ConnectedEvent(session));
|
listener.connected(new ConnectedEvent(session));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -148,6 +155,8 @@ public class Bot {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void disconnected(DisconnectedEvent disconnectedEvent) {
|
public void disconnected(DisconnectedEvent disconnectedEvent) {
|
||||||
|
loggedIn = false;
|
||||||
|
|
||||||
final int reconnectDelay = config.reconnectDelay();
|
final int reconnectDelay = config.reconnectDelay();
|
||||||
|
|
||||||
executor.schedule(() -> reconnect(), reconnectDelay, TimeUnit.MILLISECONDS);
|
executor.schedule(() -> reconnect(), reconnectDelay, TimeUnit.MILLISECONDS);
|
||||||
|
|
|
@ -1,21 +1,20 @@
|
||||||
package land.chipmunk.chayapak.chomens_bot;
|
package land.chipmunk.chayapak.chomens_bot;
|
||||||
|
|
||||||
import land.chipmunk.chayapak.chomens_bot.plugins.ConsolePlugin;
|
import land.chipmunk.chayapak.chomens_bot.plugins.ConsolePlugin;
|
||||||
import land.chipmunk.chayapak.chomens_bot.plugins.DiscordPlugin;
|
import net.dv8tion.jda.api.JDA;
|
||||||
|
import net.dv8tion.jda.api.JDABuilder;
|
||||||
import org.yaml.snakeyaml.Yaml;
|
import org.yaml.snakeyaml.Yaml;
|
||||||
import org.yaml.snakeyaml.constructor.Constructor;
|
import org.yaml.snakeyaml.constructor.Constructor;
|
||||||
|
|
||||||
|
import javax.security.auth.login.LoginException;
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.CountDownLatch;
|
|
||||||
|
|
||||||
public class Main {
|
public class Main {
|
||||||
public static final List<Bot> allBots = new ArrayList<>();
|
public static final List<Bot> allBots = new ArrayList<>();
|
||||||
|
|
||||||
public static CountDownLatch latch = null;
|
public static void main(String[] args) throws IOException {
|
||||||
|
|
||||||
public static void main(String[] args) throws IOException, InterruptedException {
|
|
||||||
final File file = new File("config.yml");
|
final File file = new File("config.yml");
|
||||||
final Constructor constructor = new Constructor(Configuration.class);
|
final Constructor constructor = new Constructor(Configuration.class);
|
||||||
final Yaml yaml = new Yaml(constructor);
|
final Yaml yaml = new Yaml(constructor);
|
||||||
|
@ -51,7 +50,19 @@ public class Main {
|
||||||
|
|
||||||
Configuration.Bots[] botsOptions = config.bots();
|
Configuration.Bots[] botsOptions = config.bots();
|
||||||
|
|
||||||
latch = new CountDownLatch(botsOptions.length);
|
// idk if these should be here lol, but it is just the discord stuff
|
||||||
|
JDA jda = null;
|
||||||
|
JDABuilder builder = JDABuilder.createDefault(config.discord().token());
|
||||||
|
try {
|
||||||
|
jda = builder.build();
|
||||||
|
jda.awaitReady();
|
||||||
|
} catch (LoginException e) {
|
||||||
|
System.err.println("Failed to login to Discord, stacktrace:");
|
||||||
|
e.printStackTrace();
|
||||||
|
System.exit(1);
|
||||||
|
} catch (InterruptedException ignored) {
|
||||||
|
System.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
for (Configuration.Bots botOption : botsOptions) {
|
for (Configuration.Bots botOption : botsOptions) {
|
||||||
final String host = botOption.host();
|
final String host = botOption.host();
|
||||||
|
@ -60,17 +71,10 @@ public class Main {
|
||||||
final boolean kaboom = botOption.kaboom();
|
final boolean kaboom = botOption.kaboom();
|
||||||
final String serverName = botOption.serverName();
|
final String serverName = botOption.serverName();
|
||||||
|
|
||||||
new Thread(() -> {
|
final Bot bot = new Bot(host, port, username, kaboom, serverName, allBots, config);
|
||||||
final Bot bot = new Bot(host, port, username, kaboom, serverName, allBots, config);
|
allBots.add(bot);
|
||||||
allBots.add(bot);
|
|
||||||
|
|
||||||
latch.countDown();
|
|
||||||
}).start();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
new DiscordPlugin(config);
|
new ConsolePlugin(allBots, config, jda);
|
||||||
|
|
||||||
latch.await();
|
|
||||||
new ConsolePlugin(allBots);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,8 +1,10 @@
|
||||||
package land.chipmunk.chayapak.chomens_bot.plugins;
|
package land.chipmunk.chayapak.chomens_bot.plugins;
|
||||||
|
|
||||||
|
import land.chipmunk.chayapak.chomens_bot.Configuration;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import land.chipmunk.chayapak.chomens_bot.Bot;
|
import land.chipmunk.chayapak.chomens_bot.Bot;
|
||||||
import land.chipmunk.chayapak.chomens_bot.command.ConsoleCommandContext;
|
import land.chipmunk.chayapak.chomens_bot.command.ConsoleCommandContext;
|
||||||
|
import net.dv8tion.jda.api.JDA;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.TextComponent;
|
import net.kyori.adventure.text.TextComponent;
|
||||||
import net.kyori.adventure.text.format.NamedTextColor;
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
|
@ -10,6 +12,7 @@ import org.jline.reader.EndOfFileException;
|
||||||
import org.jline.reader.LineReader;
|
import org.jline.reader.LineReader;
|
||||||
import org.jline.reader.LineReaderBuilder;
|
import org.jline.reader.LineReaderBuilder;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -23,7 +26,9 @@ public class ConsolePlugin {
|
||||||
@Getter private String prefix;
|
@Getter private String prefix;
|
||||||
@Getter private String consoleServerPrefix;
|
@Getter private String consoleServerPrefix;
|
||||||
|
|
||||||
public ConsolePlugin (List<Bot> allBots) {
|
private static final List<Listener> listeners = new ArrayList<>();
|
||||||
|
|
||||||
|
public ConsolePlugin (List<Bot> allBots, Configuration discordConfig, JDA jda) {
|
||||||
this.allBots = allBots;
|
this.allBots = allBots;
|
||||||
this.reader = LineReaderBuilder.builder().build();
|
this.reader = LineReaderBuilder.builder().build();
|
||||||
|
|
||||||
|
@ -32,9 +37,12 @@ public class ConsolePlugin {
|
||||||
consoleServerPrefix = bot.config().consolePrefixes().get("consoleServerPrefix");
|
consoleServerPrefix = bot.config().consolePrefixes().get("consoleServerPrefix");
|
||||||
|
|
||||||
bot.console(this);
|
bot.console(this);
|
||||||
|
|
||||||
bot.logger(new LoggerPlugin(bot));
|
bot.logger(new LoggerPlugin(bot));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
new DiscordPlugin(discordConfig, jda);
|
||||||
|
|
||||||
String prompt = "> ";
|
String prompt = "> ";
|
||||||
|
|
||||||
new Thread(() -> {
|
new Thread(() -> {
|
||||||
|
@ -53,6 +61,8 @@ public class ConsolePlugin {
|
||||||
handleLine(line);
|
handleLine(line);
|
||||||
}
|
}
|
||||||
}).start();
|
}).start();
|
||||||
|
|
||||||
|
for (Listener listener : listeners) { listener.ready(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handleLine (String line) {
|
public void handleLine (String line) {
|
||||||
|
@ -104,4 +114,10 @@ public class ConsolePlugin {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void addListener (Listener listener) { listeners.add(listener); }
|
||||||
|
|
||||||
|
public static class Listener {
|
||||||
|
public void ready () {}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,8 @@
|
||||||
package land.chipmunk.chayapak.chomens_bot.plugins;
|
package land.chipmunk.chayapak.chomens_bot.plugins;
|
||||||
|
|
||||||
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundLoginPacket;
|
import com.github.steveice10.packetlib.event.session.ConnectedEvent;
|
||||||
import com.github.steveice10.packetlib.Session;
|
|
||||||
import com.github.steveice10.packetlib.event.session.DisconnectedEvent;
|
import com.github.steveice10.packetlib.event.session.DisconnectedEvent;
|
||||||
import com.github.steveice10.packetlib.event.session.SessionAdapter;
|
import com.github.steveice10.packetlib.event.session.SessionAdapter;
|
||||||
import com.github.steveice10.packetlib.packet.Packet;
|
|
||||||
import land.chipmunk.chayapak.chomens_bot.Bot;
|
import land.chipmunk.chayapak.chomens_bot.Bot;
|
||||||
import land.chipmunk.chayapak.chomens_bot.Configuration;
|
import land.chipmunk.chayapak.chomens_bot.Configuration;
|
||||||
import land.chipmunk.chayapak.chomens_bot.Main;
|
import land.chipmunk.chayapak.chomens_bot.Main;
|
||||||
|
@ -13,7 +11,6 @@ import land.chipmunk.chayapak.chomens_bot.util.ComponentUtilities;
|
||||||
import land.chipmunk.chayapak.chomens_bot.util.EscapeCodeBlock;
|
import land.chipmunk.chayapak.chomens_bot.util.EscapeCodeBlock;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import net.dv8tion.jda.api.JDA;
|
import net.dv8tion.jda.api.JDA;
|
||||||
import net.dv8tion.jda.api.JDABuilder;
|
|
||||||
import net.dv8tion.jda.api.entities.Message;
|
import net.dv8tion.jda.api.entities.Message;
|
||||||
import net.dv8tion.jda.api.entities.TextChannel;
|
import net.dv8tion.jda.api.entities.TextChannel;
|
||||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||||
|
@ -25,12 +22,11 @@ import net.kyori.adventure.text.event.HoverEvent;
|
||||||
import net.kyori.adventure.text.format.NamedTextColor;
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import javax.security.auth.login.LoginException;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.CountDownLatch;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
// please ignore my shitcode
|
||||||
public class DiscordPlugin {
|
public class DiscordPlugin {
|
||||||
@Getter private JDA jda;
|
@Getter private JDA jda;
|
||||||
|
|
||||||
|
@ -38,50 +34,43 @@ public class DiscordPlugin {
|
||||||
|
|
||||||
public final String prefix;
|
public final String prefix;
|
||||||
|
|
||||||
@Getter private static CountDownLatch readyLatch = new CountDownLatch(1);
|
|
||||||
|
|
||||||
private final Map<String, Boolean> alreadyAddedListeners = new HashMap<>();
|
private final Map<String, Boolean> alreadyAddedListeners = new HashMap<>();
|
||||||
|
|
||||||
public DiscordPlugin (Configuration config) {
|
public DiscordPlugin (Configuration config, JDA jda) {
|
||||||
final Configuration.Discord options = config.discord();
|
final Configuration.Discord options = config.discord();
|
||||||
this.prefix = options.prefix();
|
this.prefix = options.prefix();
|
||||||
this.servers = options.servers();
|
this.servers = options.servers();
|
||||||
|
this.jda = jda;
|
||||||
JDABuilder builder = JDABuilder.createDefault(options.token());
|
|
||||||
|
|
||||||
new Thread(() -> {
|
|
||||||
try {
|
|
||||||
jda = builder.build();
|
|
||||||
jda.awaitReady();
|
|
||||||
} catch (LoginException e) {
|
|
||||||
System.err.println("Failed to login to Discord, stacktrace:");
|
|
||||||
e.printStackTrace();
|
|
||||||
System.exit(1);
|
|
||||||
} catch (InterruptedException ignored) {
|
|
||||||
System.exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
readyLatch.countDown();
|
|
||||||
}).start();
|
|
||||||
|
|
||||||
try {
|
|
||||||
Main.latch.await();
|
|
||||||
} catch (InterruptedException ignored) { System.exit(1); }
|
|
||||||
|
|
||||||
for (Bot bot : Main.allBots) {
|
for (Bot bot : Main.allBots) {
|
||||||
String channelId = servers.get(bot.host() + ":" + bot.port());
|
String channelId = servers.get(bot.host() + ":" + bot.port());
|
||||||
|
|
||||||
|
System.out.println("bot for server " + bot.host() + ":" + bot.port());
|
||||||
|
System.out.println("adding listeners...");
|
||||||
|
|
||||||
bot.addListener(new SessionAdapter() {
|
bot.addListener(new SessionAdapter() {
|
||||||
@Override
|
@Override
|
||||||
public void packetReceived (Session session, Packet packet) {
|
public void connected (ConnectedEvent event) {
|
||||||
if (!(packet instanceof ClientboundLoginPacket)) return;
|
|
||||||
|
|
||||||
boolean channelAlreadyAddedListeners = alreadyAddedListeners.getOrDefault(channelId, false);
|
boolean channelAlreadyAddedListeners = alreadyAddedListeners.getOrDefault(channelId, false);
|
||||||
|
|
||||||
|
System.out.println("connected, added listeners is " + channelAlreadyAddedListeners);
|
||||||
|
|
||||||
sendMessageInstantly("Successfully connected to: " + "`" + bot.host() + ":" + bot.port() + "`", channelId);
|
sendMessageInstantly("Successfully connected to: " + "`" + bot.host() + ":" + bot.port() + "`", channelId);
|
||||||
|
|
||||||
|
System.out.println("sent message...");
|
||||||
|
|
||||||
if (channelAlreadyAddedListeners) return;
|
if (channelAlreadyAddedListeners) return;
|
||||||
|
|
||||||
|
bot.executor().scheduleAtFixedRate(() -> onDiscordTick(channelId), 0, 50, TimeUnit.MILLISECONDS);
|
||||||
|
|
||||||
|
bot.chat().addListener(new ChatPlugin.ChatListener() {
|
||||||
|
@Override
|
||||||
|
public void systemMessageReceived (String ignoredMessage, Component component) {
|
||||||
|
final String content = ComponentUtilities.stringifyAnsi(component);
|
||||||
|
sendMessage(EscapeCodeBlock.escape(content.replace("\u001b[9", "\u001b[3")), channelId);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
jda.addEventListener(new ListenerAdapter() {
|
jda.addEventListener(new ListenerAdapter() {
|
||||||
@Override
|
@Override
|
||||||
public void onMessageReceived(@NotNull MessageReceivedEvent event) {
|
public void onMessageReceived(@NotNull MessageReceivedEvent event) {
|
||||||
|
@ -141,7 +130,7 @@ public class DiscordPlugin {
|
||||||
)
|
)
|
||||||
.color(NamedTextColor.RED);
|
.color(NamedTextColor.RED);
|
||||||
|
|
||||||
final String discordUrl = "https://discord.gg/xdgCkUyaA4";
|
final String discordUrl = "https://discord.gg/xdgCkUyaA4"; // too lazy to make a config
|
||||||
|
|
||||||
final Component discordComponent = Component.empty()
|
final Component discordComponent = Component.empty()
|
||||||
.append(Component.text("ChomeNS ").color(NamedTextColor.YELLOW))
|
.append(Component.text("ChomeNS ").color(NamedTextColor.YELLOW))
|
||||||
|
@ -168,17 +157,7 @@ public class DiscordPlugin {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
bot.chat().addListener(new ChatPlugin.ChatListener() {
|
|
||||||
@Override
|
|
||||||
public void systemMessageReceived (String ignoredMessage, Component component) {
|
|
||||||
final String content = ComponentUtilities.stringifyAnsi(component);
|
|
||||||
sendMessage(EscapeCodeBlock.escape(content.replace("\u001b[9", "\u001b[3")), channelId);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
alreadyAddedListeners.put(channelId, true);
|
alreadyAddedListeners.put(channelId, true);
|
||||||
|
|
||||||
bot.executor().scheduleAtFixedRate(() -> onDiscordTick(channelId), 0, 50, TimeUnit.MILLISECONDS);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -11,6 +11,8 @@ import net.kyori.adventure.text.Component;
|
||||||
public class LoggerPlugin extends ChatPlugin.ChatListener {
|
public class LoggerPlugin extends ChatPlugin.ChatListener {
|
||||||
private final Bot bot;
|
private final Bot bot;
|
||||||
|
|
||||||
|
private boolean addedListener = false;
|
||||||
|
|
||||||
public LoggerPlugin(Bot bot) {
|
public LoggerPlugin(Bot bot) {
|
||||||
this.bot = bot;
|
this.bot = bot;
|
||||||
|
|
||||||
|
@ -18,16 +20,17 @@ public class LoggerPlugin extends ChatPlugin.ChatListener {
|
||||||
@Override
|
@Override
|
||||||
public void connected (ConnectedEvent event) {
|
public void connected (ConnectedEvent event) {
|
||||||
log("Successfully connected to: " + bot.host() + ":" + bot.port());
|
log("Successfully connected to: " + bot.host() + ":" + bot.port());
|
||||||
|
|
||||||
|
if (addedListener) return;
|
||||||
|
bot.chat().addListener(LoggerPlugin.this);
|
||||||
|
addedListener = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void disconnected (DisconnectedEvent event) {
|
public void disconnected (DisconnectedEvent event) {
|
||||||
log("Disconnected from " + bot.host() + ":" + bot.port() + ", reason: " + event.getReason());
|
log("Disconnected from " + bot.host() + ":" + bot.port() + ", reason: " + event.getReason());
|
||||||
event.getCause().printStackTrace();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
bot.chat().addListener(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void log (String message) {
|
public void log (String message) {
|
||||||
|
|
|
@ -23,6 +23,8 @@ public class TrustedPlugin extends PlayersPlugin.PlayerListener {
|
||||||
|
|
||||||
public void broadcast (Component message) {
|
public void broadcast (Component message) {
|
||||||
for (Bot allBot : bot.allBots()) {
|
for (Bot allBot : bot.allBots()) {
|
||||||
|
if (!allBot.loggedIn()) continue;
|
||||||
|
|
||||||
for (String player : trusted) {
|
for (String player : trusted) {
|
||||||
final Component component = Component.translatable(
|
final Component component = Component.translatable(
|
||||||
"[%s] [%s] %s",
|
"[%s] [%s] %s",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue