"fix": my try on fixing the login spam (no work)

This commit is contained in:
Chayapak 2024-11-16 13:07:53 +07:00
parent a44cae4d3e
commit 9b824e195a
Signed by: ChomeNS
SSH key fingerprint: SHA256:0YoxhdyXsgbc0nfeB2N6FYE60mxMU7DS4uCUMaw2mvA
3 changed files with 20 additions and 16 deletions

View file

@ -84,6 +84,9 @@ public class Main {
config = yaml.load(reader);
PersistentDataUtilities.init();
ComponentUtilities.stringify(Component.empty()); // best way to initialize the class 2024
executor.scheduleAtFixedRate(() -> {
try {
checkInternet();
@ -158,9 +161,7 @@ public class Main {
bots.add(bot);
}
// fards
ComponentUtilities.stringify(Component.empty()); // best way to initialize the class 2024
// fard
new ConsolePlugin(bots, config, jda);
} catch (Exception e) {
e.printStackTrace();

View file

@ -96,11 +96,13 @@ public class FilterPlugin extends PlayersPlugin.Listener {
@Override
public void playerJoined (PlayerEntry target) {
final FilteredPlayer player = getPlayer(target.profile.getName());
bot.executorService.submit(() -> {
final FilteredPlayer player = getPlayer(target.profile.getName());
if (player == null) return;
if (player == null) return;
doAll(target);
doAll(target);
});
}
@Override

View file

@ -4,6 +4,7 @@ import com.google.gson.Gson;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonPrimitive;
import me.chayapak1.chomens_bot.Main;
import java.io.BufferedReader;
import java.io.BufferedWriter;
@ -21,11 +22,7 @@ public class PersistentDataUtilities {
private static boolean stopping = false;
static {
init();
}
private static void init () {
public static void init () {
try {
if (!Files.exists(path)) Files.createFile(path);
@ -47,12 +44,16 @@ public class PersistentDataUtilities {
private static void write (String string) {
if (stopping) return; // is this necessary?
try {
writer = Files.newBufferedWriter(path, StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING);
Main.executorService.submit(() -> {
try {
writer.close();
writer.write(string);
writer.flush();
} catch (IOException ignored) {}
writer = Files.newBufferedWriter(path, StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING);
writer.write(string);
writer.flush();
} catch (IOException ignored) {}
});
}
public static void stop () {