Implemented cache for fetching operations.
This commit is contained in:
@ -8,10 +8,7 @@ import net.minecraftforge.fml.config.ModConfig;
|
||||
import net.minecraftforge.fml.event.config.ModConfigEvent;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
|
||||
@Mod.EventBusSubscriber(modid = XpTools.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD)
|
||||
public final class Config {
|
||||
@ -91,6 +88,9 @@ public final class Config {
|
||||
}
|
||||
|
||||
private static void onConfigReload() {
|
||||
// Clear cache
|
||||
OperationCache.clearBlockBreakCache();
|
||||
|
||||
// Parse all block break global operations
|
||||
blockBreakGlobalOperationItems = new ArrayList<>();
|
||||
for (String s : blockBreakGlobalOperationsRaw.get()) {
|
||||
|
24
src/main/java/dev/micle/xptools/config/OperationCache.java
Normal file
24
src/main/java/dev/micle/xptools/config/OperationCache.java
Normal file
@ -0,0 +1,24 @@
|
||||
package dev.micle.xptools.config;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class OperationCache {
|
||||
private static HashMap<String, List<OperationItem>> blockBreakCache;
|
||||
|
||||
public static void clearBlockBreakCache() {
|
||||
blockBreakCache = new HashMap<>();
|
||||
}
|
||||
|
||||
public static List<OperationItem> getBlockBreakCacheEntry(String key) {
|
||||
if (blockBreakCache.containsKey(key)) {
|
||||
return new ArrayList<>(blockBreakCache.get(key));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void addBlockBreakCacheEntry(String key, List<OperationItem> value) {
|
||||
blockBreakCache.putIfAbsent(key, new ArrayList<>(value));
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user