diff --git a/discord/src/main/java/me/totalfreedom/discord/Bot.java b/discord/src/main/java/me/totalfreedom/discord/Bot.java index d4c8bc6c..b812e3bf 100644 --- a/discord/src/main/java/me/totalfreedom/discord/Bot.java +++ b/discord/src/main/java/me/totalfreedom/discord/Bot.java @@ -1,43 +1,31 @@ package me.totalfreedom.discord; -import discord4j.common.util.Snowflake; import discord4j.core.DiscordClientBuilder; import discord4j.core.GatewayDiscordClient; import discord4j.core.event.domain.interaction.ChatInputInteractionEvent; import discord4j.core.object.entity.Guild; -import discord4j.core.object.entity.Member; -import discord4j.core.object.entity.Role; -import discord4j.core.object.entity.channel.TextChannel; import me.totalfreedom.discord.command.HelpCommand; import me.totalfreedom.discord.command.ListCommand; import me.totalfreedom.discord.command.TPSCommand; import me.totalfreedom.discord.handling.CommandHandler; import me.totalfreedom.discord.util.SnowflakeEntry; import me.totalfreedom.discord.util.TFM_Bridge; -import me.totalfreedom.totalfreedommod.admin.Admin; import me.totalfreedom.totalfreedommod.config.ConfigEntry; import me.totalfreedom.totalfreedommod.player.PlayerData; -import me.totalfreedom.totalfreedommod.rank.Rank; import me.totalfreedom.totalfreedommod.util.FLog; -import net.dv8tion.jda.internal.utils.concurrent.CountingThreadFactory; -import org.apache.commons.lang.RandomStringUtils; import org.bukkit.Bukkit; import reactor.core.publisher.Mono; import java.util.HashMap; -import java.util.List; import java.util.Map; -import java.util.concurrent.ScheduledThreadPoolExecutor; public class Bot { private final GatewayDiscordClient client; private final TFM_Bridge tfm; private final HashMap LINK_CODES = new HashMap<>(); - private ScheduledThreadPoolExecutor RATELIMIT_EXECUTOR; private Boolean enabled = false; - public Bot() { //Creates the gateway client and connects to the gateway @@ -59,25 +47,20 @@ public class Bot is overly complicated for such a simple demo and requires handling for both IDE and .jar packaging. Using SpringBoot we can avoid all of this and use their resource pattern matcher to do this for us. */ - List commands = List.of("greet.json", "ping.json"); - try { - handler.registerCommands(commands); handler.registerCommand(new HelpCommand()); handler.registerCommand(new ListCommand()); handler.registerCommand(new TPSCommand()); - } catch (Exception e) + } + catch (Exception e) { Bukkit.getLogger().severe("Error trying to register global slash commands.\n" + e.getMessage()); } //Register our slash command listener client.on(ChatInputInteractionEvent.class, handler::handle) - .then(client.onDisconnect()) - .block(); // We use .block() as there is not another non-daemon thread and the jvm would close otherwise. - - RATELIMIT_EXECUTOR = new ScheduledThreadPoolExecutor(5, new CountingThreadFactory(this::poolIdentifier, "RateLimit")); - RATELIMIT_EXECUTOR.setRemoveOnCancelPolicy(true); + .then(client.onDisconnect()); + //.block(); // We use .block() as there is not another non-daemon thread and the jvm would close otherwise. } public String formatBotTag() { @@ -131,7 +114,6 @@ public class Bot Guild server = client.getGuildById(SnowflakeEntry.serverID).block(); if (server == null) - { FLog.severe("The Discord server ID specified is invalid, or the bot is not on the server."); return false; diff --git a/discord/src/main/java/me/totalfreedom/discord/TFD4JCommonsImpl.java b/discord/src/main/java/me/totalfreedom/discord/TFD4JCommonsImpl.java index 94ae9150..4ef2a5d7 100644 --- a/discord/src/main/java/me/totalfreedom/discord/TFD4JCommonsImpl.java +++ b/discord/src/main/java/me/totalfreedom/discord/TFD4JCommonsImpl.java @@ -28,7 +28,6 @@ import reactor.core.publisher.Mono; import java.time.Instant; import java.time.ZonedDateTime; import java.util.ArrayList; -import java.util.List; import java.util.Map; import java.util.Objects; @@ -42,10 +41,7 @@ public class TFD4JCommonsImpl implements TFD4JCommons { this.tfd4J = tfd4J; this.sentMessages = Flux.fromIterable(new ArrayList<>()); - this.DISCORD_SUBDOMAINS = (ImmutableList) - List.of("discordapp.com", - "discord.com", - "discord.gg"); + this.DISCORD_SUBDOMAINS = ImmutableList.of("discordapp.com", "discord.com", "discord.gg"); } @Override diff --git a/shop/src/main/resources/plugin.yml b/shop/src/main/resources/plugin.yml index 5e9a7221..f04a2ac0 100644 --- a/shop/src/main/resources/plugin.yml +++ b/shop/src/main/resources/plugin.yml @@ -1,5 +1,5 @@ name: TF-Shoppe -main: me.totalfreedom.shop.Shop +main: me.totalfreedom.shop.TFShoppe version: ${project.version} authors: [AtlasMediaGroup, TotalFreedom] api-version: 1.19