yeah
This commit is contained in:
parent
a5fb8a06f1
commit
abfbe8044b
2 changed files with 1 additions and 30 deletions
|
@ -63,7 +63,7 @@ public class MusicCommand extends Command {
|
|||
|
||||
ratelimit++;
|
||||
|
||||
if (ratelimit > 15) return null;
|
||||
if (ratelimit > 10) return null;
|
||||
|
||||
root = MusicPlayerPlugin.SONG_DIR;
|
||||
return switch (args[0]) {
|
||||
|
|
|
@ -3,7 +3,6 @@ package land.chipmunk.chayapak.chomens_bot.util;
|
|||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import land.chipmunk.chayapak.chomens_bot.Main;
|
||||
import net.kyori.adventure.text.*;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import net.kyori.adventure.text.format.Style;
|
||||
|
@ -15,7 +14,6 @@ import java.io.InputStream;
|
|||
import java.io.InputStreamReader;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
|
@ -33,21 +31,6 @@ public class ComponentUtilities {
|
|||
|
||||
public static final Pattern ARG_PATTERN = Pattern.compile("%(?:(\\d+)\\$)?([s%])");
|
||||
|
||||
// is having each map for each type a great idea?
|
||||
public static final Map<Component, String> stringCache = new HashMap<>();
|
||||
public static final Map<Component, String> motdCache = new HashMap<>();
|
||||
public static final Map<Component, String> ansiCache = new HashMap<>();
|
||||
|
||||
static {
|
||||
Main.executor.scheduleAtFixedRate(() -> {
|
||||
final int maxSize = 1024;
|
||||
|
||||
if (stringCache.size() > maxSize) stringCache.clear();
|
||||
else if (motdCache.size() > maxSize) motdCache.clear();
|
||||
else if (ansiCache.size() > maxSize) ansiCache.clear();
|
||||
}, 0, 1, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
public static final Map<String, String> ansiMap = new HashMap<>();
|
||||
static {
|
||||
// map totallynotskidded™ from https://github.com/PrismarineJS/prismarine-chat/blob/master/index.js#L10
|
||||
|
@ -109,8 +92,6 @@ public class ComponentUtilities {
|
|||
public static String stringify (Component message) { return stringify(message, null); }
|
||||
private static String stringify (Component message, String lastColor) {
|
||||
try {
|
||||
if (stringCache.containsKey(message)) return stringCache.get(message);
|
||||
|
||||
final StringBuilder builder = new StringBuilder();
|
||||
|
||||
final PartiallyStringified output = stringifyPartially(message, false, false, lastColor);
|
||||
|
@ -119,8 +100,6 @@ public class ComponentUtilities {
|
|||
|
||||
for (Component child : message.children()) builder.append(stringify(child, output.lastColor));
|
||||
|
||||
stringCache.put(message, builder.toString());
|
||||
|
||||
return builder.toString();
|
||||
} catch (Exception e) {
|
||||
return "";
|
||||
|
@ -130,8 +109,6 @@ public class ComponentUtilities {
|
|||
public static String stringifyMotd (Component message) { return stringifyMotd(message, null); }
|
||||
private static String stringifyMotd (Component message, String lastColor) {
|
||||
try {
|
||||
if (motdCache.containsKey(message)) return motdCache.get(message);
|
||||
|
||||
final StringBuilder builder = new StringBuilder();
|
||||
|
||||
final PartiallyStringified output = stringifyPartially(message, true, false, lastColor);
|
||||
|
@ -140,8 +117,6 @@ public class ComponentUtilities {
|
|||
|
||||
for (Component child : message.children()) builder.append(stringifyMotd(child, output.lastColor));
|
||||
|
||||
motdCache.put(message, builder.toString());
|
||||
|
||||
return builder.toString();
|
||||
} catch (Exception e) {
|
||||
return "";
|
||||
|
@ -151,8 +126,6 @@ public class ComponentUtilities {
|
|||
public static String stringifyAnsi (Component message) { return stringifyAnsi(message, null); }
|
||||
private static String stringifyAnsi (Component message, String lastColor) {
|
||||
try {
|
||||
if (ansiCache.containsKey(message)) return ansiCache.get(message);
|
||||
|
||||
final StringBuilder builder = new StringBuilder();
|
||||
|
||||
final PartiallyStringified output = stringifyPartially(message, false, true, lastColor);
|
||||
|
@ -161,8 +134,6 @@ public class ComponentUtilities {
|
|||
|
||||
for (Component child : message.children()) builder.append(stringifyAnsi(child, output.lastColor));
|
||||
|
||||
ansiCache.put(message, builder.toString());
|
||||
|
||||
return builder.toString();
|
||||
} catch (Exception e) {
|
||||
return "";
|
||||
|
|
Loading…
Reference in a new issue