Added entity kill operation cache.
This commit is contained in:
@ -131,6 +131,7 @@ public final class Config {
|
||||
private static void onConfigReload() {
|
||||
// Clear cache
|
||||
OperationCache.clearBlockBreakCache();
|
||||
OperationCache.clearEntityKillCache();
|
||||
|
||||
// Parse all block break global operations
|
||||
blockBreakGlobalOperationItems = new ArrayList<>();
|
||||
|
@ -7,11 +7,16 @@ import java.util.List;
|
||||
|
||||
public class OperationCache {
|
||||
private static HashMap<String, List<OperationItem>> blockBreakCache;
|
||||
private static HashMap<String, List<OperationItem>> entityKillCache;
|
||||
|
||||
public static void clearBlockBreakCache() {
|
||||
blockBreakCache = new HashMap<>();
|
||||
}
|
||||
|
||||
public static void clearEntityKillCache() {
|
||||
entityKillCache = new HashMap<>();
|
||||
}
|
||||
|
||||
public static @Nullable List<OperationItem> getBlockBreakCacheEntry(String key) {
|
||||
if (blockBreakCache.containsKey(key)) {
|
||||
return new ArrayList<>(blockBreakCache.get(key));
|
||||
@ -19,7 +24,18 @@ public class OperationCache {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static @Nullable List<OperationItem> getEntityKillCacheEntry(String key) {
|
||||
if (entityKillCache.containsKey(key)) {
|
||||
return new ArrayList<>(entityKillCache.get(key));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void addBlockBreakCacheEntry(String key, List<OperationItem> value) {
|
||||
blockBreakCache.putIfAbsent(key, new ArrayList<>(value));
|
||||
}
|
||||
|
||||
public static void addEntityKillCacheEntry(String key, List<OperationItem> value) {
|
||||
entityKillCache.putIfAbsent(key, new ArrayList<>(value));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user