optimize or make it worse
This commit is contained in:
parent
3dd65b15cf
commit
91d418ea8c
3 changed files with 30 additions and 5 deletions
|
@ -14,7 +14,7 @@ public class Configuration {
|
|||
|
||||
@Getter public Map<String, String> consolePrefixes;
|
||||
|
||||
@Getter public Map<String, String> 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();
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue