diff --git a/src/main/java/com/hackclub/hccore/listeners/PlayerListener.java b/src/main/java/com/hackclub/hccore/listeners/PlayerListener.java index 3e1d776..a00f9d5 100644 --- a/src/main/java/com/hackclub/hccore/listeners/PlayerListener.java +++ b/src/main/java/com/hackclub/hccore/listeners/PlayerListener.java @@ -92,15 +92,20 @@ public void onAsyncPlayerChat(final AsyncPlayerChatEvent event) { } public static boolean isSlackJoinAllowed(PlayerData data) { - if (!HCCorePlugin.getPlugin(HCCorePlugin.class).getConfig() + HCCorePlugin plugin = HCCorePlugin.getPlugin(HCCorePlugin.class); + + if (!plugin.getConfig() .getBoolean("settings.slack-link.enabled", false)) { return true; } - if (!HCCorePlugin.getPlugin(HCCorePlugin.class).getConfig() + if (!plugin.getConfig() .getBoolean("settings.slack-link.required", false)) { return true; } - return data.getSlackId() != null; + + String id = data.getSlackId(); + + return !plugin.getSlackBot().isDeactivated(id); } diff --git a/src/main/java/com/hackclub/hccore/slack/SlackBot.java b/src/main/java/com/hackclub/hccore/slack/SlackBot.java index 0c9709e..2cd6741 100644 --- a/src/main/java/com/hackclub/hccore/slack/SlackBot.java +++ b/src/main/java/com/hackclub/hccore/slack/SlackBot.java @@ -460,6 +460,21 @@ public void onCustomAdvancementProgressed(ProgressionUpdateEvent e) { } } + public boolean isDeactivated(String id) { + MethodsClient client = app.getClient(); + + try { + var res = client.usersInfo(r -> r.token(getBotToken()).user(id)); + + return res.getUser().isDeleted(); + } catch (SlackApiException e) { + return true; + } catch (IOException e) { + e.printStackTrace(); + return true; + } + } + private String getSlackChannel() { String id = this.plugin.getConfig().getString("settings.slack-link.channel-id");