equivalent-exchange-3/common/com/pahimar/ee3/emc/EmcRegistry.java

85 lines
2.3 KiB
Java
Raw Normal View History

2013-09-07 04:44:31 +02:00
package com.pahimar.ee3.emc;
import java.util.ArrayList;
import java.util.Collections;
2013-10-06 04:46:29 +02:00
import java.util.HashMap;
2013-09-07 04:44:31 +02:00
import java.util.List;
2013-10-06 04:46:29 +02:00
import java.util.Map;
import java.util.TreeMap;
import com.pahimar.ee3.core.util.LogHelper;
2013-09-07 04:44:31 +02:00
import com.pahimar.ee3.item.CustomWrappedStack;
public class EmcRegistry {
2013-09-07 04:47:12 +02:00
private static EmcRegistry emcRegistry = null;
2013-10-06 04:46:29 +02:00
private Map<CustomWrappedStack, EmcValue> stackMappings;
private TreeMap<EmcValue, List<CustomWrappedStack>> valueMappings;
2013-09-07 04:44:31 +02:00
2013-09-07 04:47:12 +02:00
private EmcRegistry() {
2013-09-07 04:44:31 +02:00
2013-10-06 04:46:29 +02:00
stackMappings = new HashMap<CustomWrappedStack, EmcValue>();
valueMappings = new TreeMap<EmcValue, List<CustomWrappedStack>>();
2013-09-07 04:47:12 +02:00
}
2013-09-07 04:44:31 +02:00
2013-09-07 04:47:12 +02:00
public static EmcRegistry getInstance() {
2013-09-07 04:44:31 +02:00
2013-09-07 04:47:12 +02:00
if (emcRegistry == null) {
emcRegistry = new EmcRegistry();
emcRegistry.init();
}
2013-09-07 04:44:31 +02:00
2013-09-07 04:47:12 +02:00
return emcRegistry;
}
2013-09-07 04:44:31 +02:00
2013-09-07 04:47:12 +02:00
private void init() {
// Grab the default value map
2013-10-06 04:46:29 +02:00
Map<CustomWrappedStack, EmcValue> defaultValueMap = EmcDefaultValues.getInstance().getDefaultValueMap();
stackMappings.putAll(defaultValueMap);
}
public boolean hasEmcValue(CustomWrappedStack wrappedStack) {
2013-09-25 06:30:00 +02:00
return stackMappings.containsKey(wrappedStack) ? stackMappings.get(wrappedStack) instanceof EmcValue : false;
}
public boolean hasStacksForValue(EmcValue emcValue) {
2013-09-25 06:30:00 +02:00
return valueMappings.containsKey(emcValue) ? valueMappings.get(emcValue).size() > 0 : false;
}
public EmcValue getEmcValue(CustomWrappedStack wrappedStack) {
2013-09-25 06:30:00 +02:00
return stackMappings.get(wrappedStack);
}
public List<CustomWrappedStack> getStacksFromValue(EmcValue emcValue) {
2013-09-25 06:30:00 +02:00
return valueMappings.get(emcValue);
}
public List<CustomWrappedStack> getStacksInEmcRange(EmcValue fromValue, EmcValue toValue) {
return null;
}
public void addEmcValueMapping(CustomWrappedStack wrappedStack, EmcValue emcValue) {
2013-09-07 04:47:12 +02:00
}
public void printDebugDump() {
List<CustomWrappedStack> keyList = new ArrayList<CustomWrappedStack>();
keyList.addAll(stackMappings.keySet());
Collections.sort(keyList);
for (CustomWrappedStack stack : keyList) {
LogHelper.debug(stack + " == " + stackMappings.get(stack));
}
}
2013-09-07 04:44:31 +02:00
}