diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/Configuration.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/Configuration.java index 5be9336..f7bf096 100644 --- a/src/main/java/land/chipmunk/chayapak/chomens_bot/Configuration.java +++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/Configuration.java @@ -14,7 +14,7 @@ public class Configuration { @Getter public Map consolePrefixes; - @Getter public Map keys; + @Getter public Keys keys = new Keys(); @Getter public String weatherApiKey; @@ -29,6 +29,11 @@ public class Configuration { @Getter public SelfCare selfCare = new SelfCare(); @Getter public BotOption[] bots = new BotOption[]{}; + public static class Keys { + @Getter public String normalKey; + @Getter public String ownerKey; + } + public static class Core { @Getter public Position start = new Position(); @Getter public Position end = new Position(); diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/HashingPlugin.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/HashingPlugin.java index 744c10d..c74559c 100644 --- a/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/HashingPlugin.java +++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/HashingPlugin.java @@ -12,6 +12,8 @@ public class HashingPlugin { @Getter private String hash; @Getter private String ownerHash; + private long lastTime; + public HashingPlugin (Bot bot) { this.bot = bot; @@ -24,10 +26,16 @@ public class HashingPlugin { } public void update () { - final String normalHashKey = bot.config().keys().get("normalKey"); - final String ownerHashKey = bot.config().keys().get("ownerKey"); + final long time = System.currentTimeMillis() / 5_000; - final String hashValue = (System.currentTimeMillis() / 5_000) + normalHashKey; + // mabe this will optimize it? + if (time == lastTime) return; + lastTime = time; + + final String normalHashKey = bot.config().keys().normalKey(); + final String ownerHashKey = bot.config().keys().ownerKey(); + + final String hashValue = time + normalHashKey; hash = Hashing.sha256() .hashString(hashValue, StandardCharsets.UTF_8) .toString() diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/util/ComponentUtilities.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/util/ComponentUtilities.java index 6307c01..ba04c4a 100644 --- a/src/main/java/land/chipmunk/chayapak/chomens_bot/util/ComponentUtilities.java +++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/util/ComponentUtilities.java @@ -162,7 +162,19 @@ public class ComponentUtilities { return "ยง" + code; } else if (ansi) { String ansiCode = ansiMap.get(code); - if (ansiCode == null) ansiCode = "\u001b[38;2;" + color.red() + ";" + color.green() + ";" + color.blue() + "m"; + if (ansiCode == null) { + // will using string builders use less memory or does nothing? + final StringBuilder builder = new StringBuilder(); + builder.append("\u001b[38;2;"); + builder.append(color.red()); + builder.append(";"); + builder.append(color.green()); + builder.append(";"); + builder.append(color.blue()); + builder.append("m"); + + ansiCode = builder.toString(); + } return ansiCode; } else return null;