forked from ChomeNS/chomens-bot-java
lazy fix the sus issue + add package to idea config
This commit is contained in:
parent
e1d8508cf1
commit
e1dd0748f3
4 changed files with 24 additions and 7 deletions
|
@ -13,7 +13,7 @@
|
|||
</list>
|
||||
</option>
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="jbr-17" project-jdk-type="JavaSDK">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="17" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
8
.idea/modules.xml
Normal file
8
.idea/modules.xml
Normal file
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/chomens_bot.iml" filepath="$PROJECT_DIR$/chomens_bot.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
|
@ -84,6 +84,12 @@ public class Bot {
|
|||
this.bruhify = new BruhifyPlugin(this);
|
||||
this.grepLog = new GrepLogPlugin(this);
|
||||
|
||||
try {
|
||||
Thread.sleep(1000); // real
|
||||
} catch (InterruptedException ignored) {
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
reconnect();
|
||||
}
|
||||
|
||||
|
@ -99,10 +105,13 @@ public class Bot {
|
|||
|
||||
@Override
|
||||
public void packetReceived(Session session, Packet packet) {
|
||||
for (SessionListener listener : listeners) {
|
||||
if (packet instanceof ClientboundLoginPacket) {
|
||||
for (SessionListener listener : listeners) {
|
||||
listener.connected(new ConnectedEvent(session));
|
||||
}
|
||||
}
|
||||
|
||||
for (SessionListener listener : listeners) {
|
||||
listener.packetReceived(session, packet);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -69,8 +69,6 @@ public class DiscordPlugin {
|
|||
for (Bot bot : Main.allBots) {
|
||||
String channelId = servers.get(bot.host() + ":" + bot.port());
|
||||
|
||||
bot.discord(this);
|
||||
|
||||
bot.addListener(new SessionAdapter() {
|
||||
@Override
|
||||
public void connected(ConnectedEvent event) {
|
||||
|
@ -80,8 +78,6 @@ public class DiscordPlugin {
|
|||
|
||||
if (channelAlreadyAddedListeners) return;
|
||||
|
||||
alreadyAddedListeners.put(channelId, true);
|
||||
|
||||
jda.addEventListener(new ListenerAdapter() {
|
||||
@Override
|
||||
public void onMessageReceived(@NotNull MessageReceivedEvent event) {
|
||||
|
@ -176,6 +172,8 @@ public class DiscordPlugin {
|
|||
}
|
||||
});
|
||||
|
||||
alreadyAddedListeners.put(channelId, true);
|
||||
|
||||
bot.executor().scheduleAtFixedRate(() -> onDiscordTick(channelId), 0, 50, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
|
||||
|
@ -184,6 +182,8 @@ public class DiscordPlugin {
|
|||
sendMessageInstantly("Disconnected: " + "`" + event.getReason().replace("`", "\\`") + "`", channelId);
|
||||
}
|
||||
});
|
||||
|
||||
bot.discord(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue