From 41f92400c75d92fe7dcc7c1e39adf2080b922d7d Mon Sep 17 00:00:00 2001 From: Lee Date: Sat, 6 Jul 2024 23:57:58 +0000 Subject: [PATCH 1/2] Update src/main/java/cc/fascinated/bat/features/base/BaseFeature.java --- src/main/java/cc/fascinated/bat/features/base/BaseFeature.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/cc/fascinated/bat/features/base/BaseFeature.java b/src/main/java/cc/fascinated/bat/features/base/BaseFeature.java index 14bdc9c..8e79f62 100644 --- a/src/main/java/cc/fascinated/bat/features/base/BaseFeature.java +++ b/src/main/java/cc/fascinated/bat/features/base/BaseFeature.java @@ -26,7 +26,7 @@ import org.springframework.stereotype.Component; public class BaseFeature extends Feature { @Autowired public BaseFeature(@NonNull ApplicationContext context, @NonNull CommandService commandService) { - super("Base", FeatureProfile.FeatureState.DISABLED, false); + super("Base", FeatureProfile.FeatureState.ENABLED, false); super.registerCommand(commandService, context.getBean(PremiumCommand.class)); super.registerCommand(commandService, context.getBean(BotAdminCommand.class)); From 93f232805e8a2958d3a53eacc01d51519eef9e6a Mon Sep 17 00:00:00 2001 From: Lee Date: Sat, 6 Jul 2024 23:58:09 +0000 Subject: [PATCH 2/2] revert 585d3e079390a9dd5f24d87499b0da27556ca617 revert add version number to the embeds --- pom.xml | 33 +----------- .../cc/fascinated/bat/BatApplication.java | 2 - .../cc/fascinated/bat/common/BuildData.java | 52 ------------------- .../cc/fascinated/bat/common/EmbedUtils.java | 4 -- .../messagesnipe/MessageSnipeFeature.java | 18 +++---- 5 files changed, 10 insertions(+), 99 deletions(-) delete mode 100644 src/main/java/cc/fascinated/bat/common/BuildData.java diff --git a/pom.xml b/pom.xml index 2a6c854..19bd24b 100644 --- a/pom.xml +++ b/pom.xml @@ -11,7 +11,7 @@ cc.fascinated Bat - 0.1 + 0.0.1-SNAPSHOT Bat Bat Bot for Discord @@ -67,37 +67,6 @@ - - - - pl.project13.maven - git-commit-id-plugin - 4.9.10 - - - - revision - - - - - git - $PROJECT.BASEDIR$/.git - true - true - src/main/resources/git.properties - full - $USER.TIMEZONE$ - MM-dd-yyyy@HH:mm:ss - - ^git.branch$ - ^git.build.(time|version)$ - ^git.commit.id.(abbrev|full)$ - ^git.build.user.name$ - - - - diff --git a/src/main/java/cc/fascinated/bat/BatApplication.java b/src/main/java/cc/fascinated/bat/BatApplication.java index 17c1220..da73e4c 100644 --- a/src/main/java/cc/fascinated/bat/BatApplication.java +++ b/src/main/java/cc/fascinated/bat/BatApplication.java @@ -1,6 +1,5 @@ package cc.fascinated.bat; -import cc.fascinated.bat.common.BuildData; import cc.fascinated.bat.config.Config; import cc.fascinated.bat.event.EventListener; import cc.fascinated.bat.service.EventService; @@ -26,7 +25,6 @@ import java.util.Objects; @Log4j2(topic = "Bat") public class BatApplication { public static Gson GSON = new GsonBuilder().create(); - public static BuildData BUILD_DATA = new BuildData(); @SneakyThrows public static void main(@NonNull String[] args) { diff --git a/src/main/java/cc/fascinated/bat/common/BuildData.java b/src/main/java/cc/fascinated/bat/common/BuildData.java deleted file mode 100644 index 4b2cbfc..0000000 --- a/src/main/java/cc/fascinated/bat/common/BuildData.java +++ /dev/null @@ -1,52 +0,0 @@ -package cc.fascinated.bat.common; - -import lombok.Getter; -import lombok.extern.log4j.Log4j2; - -import java.io.IOException; -import java.util.Properties; - -/** - * @author Fascinated (fascinated7) - */ -@Getter -@Log4j2(topic = "Build Data") -public class BuildData { - /** - * The commit hash of the build - */ - private final String buildId; - - /** - * The version of the build - */ - private final String buildVersion; - - /** - * The date of the build - */ - private final String buildDate; - - public BuildData() { - // get git.properties from resources - Properties properties = new Properties(); - try { - properties.load(getClass().getClassLoader().getResourceAsStream("git.properties")); - } catch (IOException ex) { - log.error("Failed to load git.properties", ex); - } - - this.buildId = properties.getProperty("git.commit.id.abbrev"); - this.buildVersion = properties.getProperty("git.build.version"); - this.buildDate = properties.getProperty("git.build.time"); - } - - /** - * Gets the version of the bot - * - * @return the version - */ - public String getVersion() { - return "Bat - v%s-%s".formatted(buildVersion, buildId); - } -} diff --git a/src/main/java/cc/fascinated/bat/common/EmbedUtils.java b/src/main/java/cc/fascinated/bat/common/EmbedUtils.java index b611747..09b5bfa 100644 --- a/src/main/java/cc/fascinated/bat/common/EmbedUtils.java +++ b/src/main/java/cc/fascinated/bat/common/EmbedUtils.java @@ -1,6 +1,5 @@ package cc.fascinated.bat.common; -import cc.fascinated.bat.BatApplication; import cc.fascinated.bat.config.Config; import lombok.experimental.UtilityClass; import net.dv8tion.jda.api.EmbedBuilder; @@ -21,7 +20,6 @@ public class EmbedUtils { public static EmbedBuilder genericEmbed() { return new EmbedBuilder() .setTimestamp(LocalDateTime.now()) - .setFooter(BatApplication.BUILD_DATA.getVersion()) .setColor(Colors.DEFAULT); } @@ -33,7 +31,6 @@ public class EmbedUtils { public static EmbedBuilder errorEmbed() { return new EmbedBuilder() .setTimestamp(LocalDateTime.now()) - .setFooter(BatApplication.BUILD_DATA.getVersion()) .setColor(Colors.ERROR); } @@ -45,7 +42,6 @@ public class EmbedUtils { public static EmbedBuilder successEmbed() { return new EmbedBuilder() .setTimestamp(LocalDateTime.now()) - .setFooter(BatApplication.BUILD_DATA.getVersion()) .setColor(Colors.SUCCESS); } diff --git a/src/main/java/cc/fascinated/bat/features/messagesnipe/MessageSnipeFeature.java b/src/main/java/cc/fascinated/bat/features/messagesnipe/MessageSnipeFeature.java index 7a80195..fbf2c76 100644 --- a/src/main/java/cc/fascinated/bat/features/messagesnipe/MessageSnipeFeature.java +++ b/src/main/java/cc/fascinated/bat/features/messagesnipe/MessageSnipeFeature.java @@ -27,7 +27,7 @@ public class MessageSnipeFeature extends Feature implements EventListener { /** * The sniped messages for each guild */ - private static final Map> SNIPED_MESSAGES = new HashMap<>(); + private static final Map> snipedMessages = new HashMap<>(); private static final long SNIPED_MESSAGE_EXPIRATION = TimeUnit.HOURS.toMillis(1); @Autowired @@ -44,8 +44,8 @@ public class MessageSnipeFeature extends Feature implements EventListener { * @return if the sniped messages were cleared */ public static boolean clearSnipedMessages(BatGuild guild) { - if (SNIPED_MESSAGES.containsKey(guild)) { - SNIPED_MESSAGES.remove(guild); + if (snipedMessages.containsKey(guild)) { + snipedMessages.remove(guild); return true; } return false; @@ -58,7 +58,7 @@ public class MessageSnipeFeature extends Feature implements EventListener { * @return the sniped messages for the given guild */ public static SnipedMessage getDeletedMessage(BatGuild guild, String channelId) { - List messages = SNIPED_MESSAGES.getOrDefault(guild, new ArrayList<>()).stream() + List messages = snipedMessages.getOrDefault(guild, new ArrayList<>()).stream() .filter(message -> message.getDeletedDate() != null && message.getDeletedDate().getTime() + SNIPED_MESSAGE_EXPIRATION > System.currentTimeMillis()) .sorted(Comparator.comparing(SnipedMessage::getDeletedDate).reversed()).toList(); @@ -79,7 +79,7 @@ public class MessageSnipeFeature extends Feature implements EventListener { * @return the sniped message with the given id */ private SnipedMessage getSnipedMessage(BatGuild guild, String messageId) { - List messages = SNIPED_MESSAGES.getOrDefault(guild, new ArrayList<>()); + List messages = snipedMessages.getOrDefault(guild, new ArrayList<>()); for (SnipedMessage message : messages) { if (message.getMessage().getId().equals(messageId)) { return message; @@ -94,12 +94,12 @@ public class MessageSnipeFeature extends Feature implements EventListener { return; } - List messages = SNIPED_MESSAGES.getOrDefault(guild, new ArrayList<>()); + List messages = snipedMessages.getOrDefault(guild, new ArrayList<>()); if (messages.size() >= 10) { // Only store the last 10 messages messages.remove(0); } messages.add(new SnipedMessage(event.getMessage(), null)); - SNIPED_MESSAGES.put(guild, messages); + snipedMessages.put(guild, messages); } @Override @@ -107,7 +107,7 @@ public class MessageSnipeFeature extends Feature implements EventListener { if (guild.getFeatureProfile().isFeatureDisabled(this)) { return; } - List messages = SNIPED_MESSAGES.getOrDefault(guild, new ArrayList<>()); + List messages = snipedMessages.getOrDefault(guild, new ArrayList<>()); if (messages.size() >= 10) { messages.remove(0); } @@ -124,7 +124,7 @@ public class MessageSnipeFeature extends Feature implements EventListener { if (guild.getFeatureProfile().isFeatureDisabled(this)) { return; } - List messages = SNIPED_MESSAGES.getOrDefault(guild, new ArrayList<>()); + List messages = snipedMessages.getOrDefault(guild, new ArrayList<>()); if (messages.size() >= 10) { messages.remove(0); }