From 25b696f7f6f9643e11b7f611d41f409ac78810b4 Mon Sep 17 00:00:00 2001 From: Tzesh Date: Tue, 17 Oct 2023 20:14:17 +0300 Subject: [PATCH] v5.0.0 - db/local saving strategy support --- .../tzebot/commands/abstracts/AbstractCommand.java | 2 +- .../tzebot/commands/abstracts/CommandContext.java | 1 - .../com/tzesh/tzebot/commands/moderation/Clear.java | 2 +- .../com/tzesh/tzebot/commands/moderation/Help.java | 1 + .../com/tzesh/tzebot/commands/moderation/Prefix.java | 2 +- .../com/tzesh/tzebot/commands/moderation/VoteRole.java | 1 + .../java/com/tzesh/tzebot/commands/music/Channel.java | 2 +- .../java/com/tzesh/tzebot/commands/music/Queue.java | 2 +- .../commands/music/abstracts/AbstractMusicCommand.java | 2 +- .../com/tzesh/tzebot/core/adapter/EventAdapter.java | 2 +- .../core/channel/abstracts/AbstractGuildChannel.java | 1 - .../com/tzesh/tzebot/core/command/CommandManager.java | 1 - .../tzesh/tzebot/core/config/ConfigurationManager.java | 8 +++++--- .../tzebot/core/database/impl/MongoChannelManager.java | 10 ---------- .../tzesh/tzebot/core/music/audio/PlayerManager.java | 1 + .../music/client/abstracts/AbstractPlatformClient.java | 1 - .../tzesh/tzebot/core/version/VersionController.java | 1 - .../listeners/abstracts/AbstractEventListener.java | 2 -- .../tzebot/listeners/guild/GuildJoinEventListener.java | 3 --- .../listeners/guild/GuildLeaveEventListener.java | 2 -- .../listeners/guild/voice/VoiceUpdateListener.java | 2 +- .../music/MusicChannelReactionListener.java | 2 +- 22 files changed, 17 insertions(+), 34 deletions(-) diff --git a/src/main/java/com/tzesh/tzebot/commands/abstracts/AbstractCommand.java b/src/main/java/com/tzesh/tzebot/commands/abstracts/AbstractCommand.java index 0a6299d..160b6d2 100644 --- a/src/main/java/com/tzesh/tzebot/commands/abstracts/AbstractCommand.java +++ b/src/main/java/com/tzesh/tzebot/commands/abstracts/AbstractCommand.java @@ -1,7 +1,7 @@ package com.tzesh.tzebot.commands.abstracts; -import com.tzesh.tzebot.core.command.CommandContextImpl; import com.tzesh.tzebot.core.channel.abstracts.GuildChannel; +import com.tzesh.tzebot.core.command.CommandContextImpl; import com.tzesh.tzebot.core.inventory.Inventory; import com.tzesh.tzebot.utils.EmbedMessageBuilder; import net.dv8tion.jda.api.entities.*; diff --git a/src/main/java/com/tzesh/tzebot/commands/abstracts/CommandContext.java b/src/main/java/com/tzesh/tzebot/commands/abstracts/CommandContext.java index fcc4f6d..f5a5a50 100644 --- a/src/main/java/com/tzesh/tzebot/commands/abstracts/CommandContext.java +++ b/src/main/java/com/tzesh/tzebot/commands/abstracts/CommandContext.java @@ -3,7 +3,6 @@ import com.tzesh.tzebot.core.channel.abstracts.GuildChannel; import net.dv8tion.jda.api.entities.Guild; import net.dv8tion.jda.api.entities.Member; -import net.dv8tion.jda.api.entities.Message; import net.dv8tion.jda.api.entities.channel.concrete.TextChannel; import net.dv8tion.jda.api.events.message.GenericMessageEvent; diff --git a/src/main/java/com/tzesh/tzebot/commands/moderation/Clear.java b/src/main/java/com/tzesh/tzebot/commands/moderation/Clear.java index 8565e46..886a5d5 100644 --- a/src/main/java/com/tzesh/tzebot/commands/moderation/Clear.java +++ b/src/main/java/com/tzesh/tzebot/commands/moderation/Clear.java @@ -3,8 +3,8 @@ import com.tzesh.tzebot.commands.abstracts.AbstractCommand; import com.tzesh.tzebot.commands.abstracts.Command; import com.tzesh.tzebot.core.language.LanguageManager; -import com.tzesh.tzebot.utils.InputControlHelper; import com.tzesh.tzebot.utils.EmbedMessageBuilder; +import com.tzesh.tzebot.utils.InputControlHelper; import net.dv8tion.jda.api.Permission; import net.dv8tion.jda.api.entities.Message; import net.dv8tion.jda.api.events.message.MessageReceivedEvent; diff --git a/src/main/java/com/tzesh/tzebot/commands/moderation/Help.java b/src/main/java/com/tzesh/tzebot/commands/moderation/Help.java index ff78211..c2ce17c 100644 --- a/src/main/java/com/tzesh/tzebot/commands/moderation/Help.java +++ b/src/main/java/com/tzesh/tzebot/commands/moderation/Help.java @@ -8,6 +8,7 @@ import net.dv8tion.jda.api.EmbedBuilder; import net.dv8tion.jda.api.events.message.MessageReceivedEvent; import net.dv8tion.jda.api.utils.messages.MessageCreateData; + import java.time.Instant; /** diff --git a/src/main/java/com/tzesh/tzebot/commands/moderation/Prefix.java b/src/main/java/com/tzesh/tzebot/commands/moderation/Prefix.java index 52d63da..71e3bcb 100644 --- a/src/main/java/com/tzesh/tzebot/commands/moderation/Prefix.java +++ b/src/main/java/com/tzesh/tzebot/commands/moderation/Prefix.java @@ -1,8 +1,8 @@ package com.tzesh.tzebot.commands.moderation; import com.tzesh.tzebot.commands.abstracts.AbstractCommand; -import com.tzesh.tzebot.core.config.ConfigurationManager; import com.tzesh.tzebot.commands.abstracts.Command; +import com.tzesh.tzebot.core.config.ConfigurationManager; import com.tzesh.tzebot.core.language.LanguageManager; import com.tzesh.tzebot.utils.EmbedMessageBuilder; import net.dv8tion.jda.api.Permission; diff --git a/src/main/java/com/tzesh/tzebot/commands/moderation/VoteRole.java b/src/main/java/com/tzesh/tzebot/commands/moderation/VoteRole.java index 2176aa0..7809bab 100644 --- a/src/main/java/com/tzesh/tzebot/commands/moderation/VoteRole.java +++ b/src/main/java/com/tzesh/tzebot/commands/moderation/VoteRole.java @@ -9,6 +9,7 @@ import net.dv8tion.jda.api.entities.emoji.Emoji; import net.dv8tion.jda.api.events.message.MessageReceivedEvent; import net.dv8tion.jda.api.utils.messages.MessageCreateData; + import java.util.LinkedList; import java.util.List; diff --git a/src/main/java/com/tzesh/tzebot/commands/music/Channel.java b/src/main/java/com/tzesh/tzebot/commands/music/Channel.java index c16f2da..956a4a9 100644 --- a/src/main/java/com/tzesh/tzebot/commands/music/Channel.java +++ b/src/main/java/com/tzesh/tzebot/commands/music/Channel.java @@ -1,8 +1,8 @@ package com.tzesh.tzebot.commands.music; import com.tzesh.tzebot.commands.music.abstracts.AbstractMusicCommand; -import com.tzesh.tzebot.utils.EmbedMessageBuilder; import com.tzesh.tzebot.core.language.LanguageManager; +import com.tzesh.tzebot.utils.EmbedMessageBuilder; import net.dv8tion.jda.api.Permission; import net.dv8tion.jda.api.entities.MessageEmbed; import net.dv8tion.jda.api.events.message.GenericMessageEvent; diff --git a/src/main/java/com/tzesh/tzebot/commands/music/Queue.java b/src/main/java/com/tzesh/tzebot/commands/music/Queue.java index 1b4683a..4d7c39d 100644 --- a/src/main/java/com/tzesh/tzebot/commands/music/Queue.java +++ b/src/main/java/com/tzesh/tzebot/commands/music/Queue.java @@ -1,7 +1,7 @@ package com.tzesh.tzebot.commands.music; -import com.tzesh.tzebot.commands.music.abstracts.AbstractMusicCommand; import com.tzesh.tzebot.commands.abstracts.Command; +import com.tzesh.tzebot.commands.music.abstracts.AbstractMusicCommand; import com.tzesh.tzebot.utils.EmbedMessageBuilder; import net.dv8tion.jda.api.events.message.GenericMessageEvent; diff --git a/src/main/java/com/tzesh/tzebot/commands/music/abstracts/AbstractMusicCommand.java b/src/main/java/com/tzesh/tzebot/commands/music/abstracts/AbstractMusicCommand.java index 2fd1ad3..b1509b4 100644 --- a/src/main/java/com/tzesh/tzebot/commands/music/abstracts/AbstractMusicCommand.java +++ b/src/main/java/com/tzesh/tzebot/commands/music/abstracts/AbstractMusicCommand.java @@ -5,10 +5,10 @@ import com.sedmelluq.discord.lavaplayer.track.AudioTrackInfo; import com.tzesh.tzebot.commands.abstracts.AbstractCommand; import com.tzesh.tzebot.core.command.CommandContextImpl; -import com.tzesh.tzebot.core.music.constants.MusicCommonConstants; import com.tzesh.tzebot.core.music.audio.GuildMusicManager; import com.tzesh.tzebot.core.music.audio.PlayerManager; import com.tzesh.tzebot.core.music.audio.TrackScheduler; +import com.tzesh.tzebot.core.music.constants.MusicCommonConstants; import net.dv8tion.jda.api.entities.GuildVoiceState; import net.dv8tion.jda.api.entities.MessageEmbed; import net.dv8tion.jda.api.entities.channel.middleman.AudioChannel; diff --git a/src/main/java/com/tzesh/tzebot/core/adapter/EventAdapter.java b/src/main/java/com/tzesh/tzebot/core/adapter/EventAdapter.java index 221ef5f..e292bed 100644 --- a/src/main/java/com/tzesh/tzebot/core/adapter/EventAdapter.java +++ b/src/main/java/com/tzesh/tzebot/core/adapter/EventAdapter.java @@ -5,9 +5,9 @@ import com.tzesh.tzebot.listeners.guild.voice.VoiceUpdateListener; import com.tzesh.tzebot.listeners.message.MessageDeleteEventListener; import com.tzesh.tzebot.listeners.message.MessageReceivedEventListener; +import com.tzesh.tzebot.listeners.message.messagereaction.music.MusicChannelReactionListener; import com.tzesh.tzebot.listeners.message.messagereaction.voterole.AddRoleEventListener; import com.tzesh.tzebot.listeners.message.messagereaction.voterole.RemoveRoleEventListener; -import com.tzesh.tzebot.listeners.message.messagereaction.music.MusicChannelReactionListener; import com.tzesh.tzebot.listeners.session.ReadyEventListener; import net.dv8tion.jda.api.events.guild.GuildJoinEvent; import net.dv8tion.jda.api.events.guild.GuildLeaveEvent; diff --git a/src/main/java/com/tzesh/tzebot/core/channel/abstracts/AbstractGuildChannel.java b/src/main/java/com/tzesh/tzebot/core/channel/abstracts/AbstractGuildChannel.java index ec2acf2..654c676 100644 --- a/src/main/java/com/tzesh/tzebot/core/channel/abstracts/AbstractGuildChannel.java +++ b/src/main/java/com/tzesh/tzebot/core/channel/abstracts/AbstractGuildChannel.java @@ -5,7 +5,6 @@ import com.tzesh.tzebot.core.inventory.Inventory; import com.tzesh.tzebot.core.music.constants.MusicCommonConstants; import org.bson.codecs.pojo.annotations.BsonCreator; -import org.bson.codecs.pojo.annotations.BsonId; import org.bson.codecs.pojo.annotations.BsonProperty; import java.io.Serializable; diff --git a/src/main/java/com/tzesh/tzebot/core/command/CommandManager.java b/src/main/java/com/tzesh/tzebot/core/command/CommandManager.java index 7d5bc82..3fd2a39 100644 --- a/src/main/java/com/tzesh/tzebot/core/command/CommandManager.java +++ b/src/main/java/com/tzesh/tzebot/core/command/CommandManager.java @@ -1,6 +1,5 @@ package com.tzesh.tzebot.core.command; -import com.tzesh.tzebot.commands.moderation.Help; import com.tzesh.tzebot.commands.abstracts.Command; import com.tzesh.tzebot.commands.moderation.*; import com.tzesh.tzebot.commands.music.*; diff --git a/src/main/java/com/tzesh/tzebot/core/config/ConfigurationManager.java b/src/main/java/com/tzesh/tzebot/core/config/ConfigurationManager.java index 53924ce..e7aceab 100644 --- a/src/main/java/com/tzesh/tzebot/core/config/ConfigurationManager.java +++ b/src/main/java/com/tzesh/tzebot/core/config/ConfigurationManager.java @@ -1,12 +1,12 @@ package com.tzesh.tzebot.core.config; +import com.tzesh.tzebot.core.adapter.EventAdapter; import com.tzesh.tzebot.core.config.properties.ConfigurationProperties; import com.tzesh.tzebot.core.inventory.Inventory; +import com.tzesh.tzebot.core.inventory.local.LocalInventoryManager; import com.tzesh.tzebot.core.inventory.strategy.LocalStoreStrategy; import com.tzesh.tzebot.core.inventory.strategy.MongoDBStoreStrategy; import com.tzesh.tzebot.core.language.LanguageManager; -import com.tzesh.tzebot.core.adapter.EventAdapter; -import com.tzesh.tzebot.core.inventory.local.LocalInventoryManager; import com.tzesh.tzebot.core.version.VersionController; import io.github.cdimascio.dotenv.Dotenv; import net.dv8tion.jda.api.JDABuilder; @@ -21,7 +21,9 @@ import org.slf4j.LoggerFactory; import javax.security.auth.login.LoginException; -import java.io.*; +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; diff --git a/src/main/java/com/tzesh/tzebot/core/database/impl/MongoChannelManager.java b/src/main/java/com/tzesh/tzebot/core/database/impl/MongoChannelManager.java index a1d4e67..91ef8e5 100644 --- a/src/main/java/com/tzesh/tzebot/core/database/impl/MongoChannelManager.java +++ b/src/main/java/com/tzesh/tzebot/core/database/impl/MongoChannelManager.java @@ -5,24 +5,14 @@ import com.mongodb.client.MongoClient; import com.mongodb.client.MongoClients; import com.mongodb.client.MongoCollection; -import com.mongodb.client.MongoDatabase; -import com.mongodb.connection.ConnectionPoolSettings; -import com.tzesh.tzebot.core.channel.abstracts.GuildChannel; import com.tzesh.tzebot.core.channel.impl.GuildChannelImpl; import com.tzesh.tzebot.core.database.abstracts.AbstractDatabaseManager; import org.bson.codecs.configuration.CodecRegistry; -import org.bson.codecs.pojo.Conventions; import org.bson.codecs.pojo.PojoCodecProvider; -import java.util.Arrays; -import java.util.List; -import java.util.concurrent.TimeUnit; - import static com.mongodb.client.model.Filters.eq; -import static java.util.Arrays.asList; import static org.bson.codecs.configuration.CodecRegistries.fromProviders; import static org.bson.codecs.configuration.CodecRegistries.fromRegistries; -import static org.bson.codecs.pojo.Conventions.ANNOTATION_CONVENTION; /** * This manager is used to manage the database for guild channels diff --git a/src/main/java/com/tzesh/tzebot/core/music/audio/PlayerManager.java b/src/main/java/com/tzesh/tzebot/core/music/audio/PlayerManager.java index 66a99d9..8b496b7 100644 --- a/src/main/java/com/tzesh/tzebot/core/music/audio/PlayerManager.java +++ b/src/main/java/com/tzesh/tzebot/core/music/audio/PlayerManager.java @@ -16,6 +16,7 @@ import net.dv8tion.jda.api.entities.User; import net.dv8tion.jda.api.entities.channel.concrete.TextChannel; import net.dv8tion.jda.api.utils.messages.MessageCreateData; + import java.util.HashMap; import java.util.Map; import java.util.concurrent.TimeUnit; diff --git a/src/main/java/com/tzesh/tzebot/core/music/client/abstracts/AbstractPlatformClient.java b/src/main/java/com/tzesh/tzebot/core/music/client/abstracts/AbstractPlatformClient.java index 9c8bbdf..2132b47 100644 --- a/src/main/java/com/tzesh/tzebot/core/music/client/abstracts/AbstractPlatformClient.java +++ b/src/main/java/com/tzesh/tzebot/core/music/client/abstracts/AbstractPlatformClient.java @@ -1,7 +1,6 @@ package com.tzesh.tzebot.core.music.client.abstracts; import java.io.IOException; -import java.security.GeneralSecurityException; /** * An abstract class to manage the platform clients (YouTube, Spotify, etc.) and their API calls diff --git a/src/main/java/com/tzesh/tzebot/core/version/VersionController.java b/src/main/java/com/tzesh/tzebot/core/version/VersionController.java index e0775c8..ba823d7 100644 --- a/src/main/java/com/tzesh/tzebot/core/version/VersionController.java +++ b/src/main/java/com/tzesh/tzebot/core/version/VersionController.java @@ -1,6 +1,5 @@ package com.tzesh.tzebot.core.version; -import com.tzesh.tzebot.core.config.ConfigurationManager; import org.json.JSONObject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/src/main/java/com/tzesh/tzebot/listeners/abstracts/AbstractEventListener.java b/src/main/java/com/tzesh/tzebot/listeners/abstracts/AbstractEventListener.java index 8f6dabb..63e123f 100644 --- a/src/main/java/com/tzesh/tzebot/listeners/abstracts/AbstractEventListener.java +++ b/src/main/java/com/tzesh/tzebot/listeners/abstracts/AbstractEventListener.java @@ -1,8 +1,6 @@ package com.tzesh.tzebot.listeners.abstracts; -import com.tzesh.tzebot.core.channel.abstracts.GuildChannel; import net.dv8tion.jda.api.events.Event; -import net.dv8tion.jda.api.events.GenericEvent; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/src/main/java/com/tzesh/tzebot/listeners/guild/GuildJoinEventListener.java b/src/main/java/com/tzesh/tzebot/listeners/guild/GuildJoinEventListener.java index cc470b1..f65388c 100644 --- a/src/main/java/com/tzesh/tzebot/listeners/guild/GuildJoinEventListener.java +++ b/src/main/java/com/tzesh/tzebot/listeners/guild/GuildJoinEventListener.java @@ -1,8 +1,5 @@ package com.tzesh.tzebot.listeners.guild; -import com.tzesh.tzebot.core.channel.abstracts.GuildChannel; -import com.tzesh.tzebot.core.channel.impl.GuildChannelImpl; -import com.tzesh.tzebot.core.inventory.Inventory; import com.tzesh.tzebot.listeners.abstracts.AbstractEventListener; import net.dv8tion.jda.api.Permission; import net.dv8tion.jda.api.entities.channel.concrete.TextChannel; diff --git a/src/main/java/com/tzesh/tzebot/listeners/guild/GuildLeaveEventListener.java b/src/main/java/com/tzesh/tzebot/listeners/guild/GuildLeaveEventListener.java index e3f28bc..5dd2738 100644 --- a/src/main/java/com/tzesh/tzebot/listeners/guild/GuildLeaveEventListener.java +++ b/src/main/java/com/tzesh/tzebot/listeners/guild/GuildLeaveEventListener.java @@ -4,8 +4,6 @@ import com.tzesh.tzebot.listeners.abstracts.AbstractEventListener; import net.dv8tion.jda.api.events.guild.GuildLeaveEvent; -import static com.tzesh.tzebot.core.inventory.Inventory.*; - /** * This is a simple class for event guild leave listeners * @author tzesh diff --git a/src/main/java/com/tzesh/tzebot/listeners/guild/voice/VoiceUpdateListener.java b/src/main/java/com/tzesh/tzebot/listeners/guild/voice/VoiceUpdateListener.java index 50592d7..cd71da5 100644 --- a/src/main/java/com/tzesh/tzebot/listeners/guild/voice/VoiceUpdateListener.java +++ b/src/main/java/com/tzesh/tzebot/listeners/guild/voice/VoiceUpdateListener.java @@ -1,10 +1,10 @@ package com.tzesh.tzebot.listeners.guild.voice; import com.sedmelluq.discord.lavaplayer.player.AudioPlayer; -import com.tzesh.tzebot.listeners.abstracts.AbstractEventListener; import com.tzesh.tzebot.core.music.audio.GuildMusicManager; import com.tzesh.tzebot.core.music.audio.PlayerManager; import com.tzesh.tzebot.core.music.audio.TrackScheduler; +import com.tzesh.tzebot.listeners.abstracts.AbstractEventListener; import net.dv8tion.jda.api.entities.Guild; import net.dv8tion.jda.api.entities.channel.unions.AudioChannelUnion; import net.dv8tion.jda.api.events.guild.voice.GuildVoiceUpdateEvent; diff --git a/src/main/java/com/tzesh/tzebot/listeners/message/messagereaction/music/MusicChannelReactionListener.java b/src/main/java/com/tzesh/tzebot/listeners/message/messagereaction/music/MusicChannelReactionListener.java index cc2e5bb..b5f70a8 100644 --- a/src/main/java/com/tzesh/tzebot/listeners/message/messagereaction/music/MusicChannelReactionListener.java +++ b/src/main/java/com/tzesh/tzebot/listeners/message/messagereaction/music/MusicChannelReactionListener.java @@ -6,10 +6,10 @@ import com.tzesh.tzebot.core.channel.abstracts.GuildChannel; import com.tzesh.tzebot.core.command.CommandContextImpl; import com.tzesh.tzebot.core.inventory.Inventory; -import com.tzesh.tzebot.listeners.message.messagereaction.GenericMessageReactionEventListener; import com.tzesh.tzebot.core.music.audio.GuildMusicManager; import com.tzesh.tzebot.core.music.audio.PlayerManager; import com.tzesh.tzebot.core.music.enums.MusicEmoteUnicodes; +import com.tzesh.tzebot.listeners.message.messagereaction.GenericMessageReactionEventListener; import net.dv8tion.jda.api.entities.emoji.UnicodeEmoji; import net.dv8tion.jda.api.events.message.react.MessageReactionAddEvent; import net.dv8tion.jda.api.managers.AudioManager;