Hey working on a super cool new Admin Panel to make it way easier to set EE3 related values/settings on items. Woo!

This commit is contained in:
pahimar 2016-05-12 22:59:56 -04:00
parent 7833ab87ff
commit 0e9f732a0b

View file

@ -6,6 +6,7 @@ import com.pahimar.ee3.exchange.NewEnergyValueRegistry;
import com.pahimar.ee3.exchange.WrappedStack;
import java.lang.reflect.Type;
import java.util.Iterator;
import java.util.Map;
public class NewEnergyValueRegistrySerializer implements JsonSerializer<NewEnergyValueRegistry>, JsonDeserializer<NewEnergyValueRegistry> {
@ -16,7 +17,29 @@ public class NewEnergyValueRegistrySerializer implements JsonSerializer<NewEnerg
@Override
public NewEnergyValueRegistry deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
// TODO This
if (json.isJsonObject()) {
JsonObject jsonObject = json.getAsJsonObject();
if (jsonObject.has(PRE_CALCULATION_ASSIGNMENTS) && jsonObject.get(PRE_CALCULATION_ASSIGNMENTS).isJsonArray()) {
JsonArray preCalculationArray = jsonObject.get(PRE_CALCULATION_ASSIGNMENTS).getAsJsonArray();
Iterator<JsonElement> iterator = preCalculationArray.iterator();
while (iterator.hasNext()) {
JsonElement jsonElement = iterator.next();
if (jsonElement.isJsonObject()) {
JsonObject jsonMapping = jsonElement.getAsJsonObject();
// TODO This
}
}
}
if (jsonObject.has(POST_CALCULATION_ASSIGNMENTS) && jsonObject.get(POST_CALCULATION_ASSIGNMENTS).isJsonArray()) {
}
}
return null;
}
@ -26,8 +49,8 @@ public class NewEnergyValueRegistrySerializer implements JsonSerializer<NewEnerg
if (src != null) {
JsonObject registryObject = new JsonObject();
registryObject.add(PRE_CALCULATION_ASSIGNMENTS, test(src.preCalculationMappings, context));
registryObject.add(POST_CALCULATION_ASSIGNMENTS, test(src.postCalculationMappings, context));
registryObject.add(PRE_CALCULATION_ASSIGNMENTS, serialize(src.preCalculationMappings, context));
registryObject.add(POST_CALCULATION_ASSIGNMENTS, serialize(src.postCalculationMappings, context));
return registryObject;
}
@ -35,7 +58,7 @@ public class NewEnergyValueRegistrySerializer implements JsonSerializer<NewEnerg
return null;
}
private static JsonArray test(Map<WrappedStack, EnergyValue> valueMap, JsonSerializationContext context) {
private static JsonArray serialize(Map<WrappedStack, EnergyValue> valueMap, JsonSerializationContext context) {
JsonArray jsonArray = new JsonArray();