use of com.builtbroken.mc.lib.json.processors.JsonProcessor in project Engine by VoltzEngine-Project.
the class JsonContentLoader method processEntries.
/**
* Called to process current entries that are loaded.
* Only entries that have processors will be loaded
* and then removed from the list of entries.
*/
protected void processEntries() {
if (jsonEntries.size() > 0) {
// Collect all entries to sort
final ArrayList<String> processorKeys = new ArrayList();
for (final JsonProcessor processor : processors.values()) {
String jsonKey = processor.getJsonKey();
String loadOrder = processor.getLoadOrder();
if (loadOrder != null && !loadOrder.isEmpty()) {
jsonKey += "@" + loadOrder;
}
processorKeys.add(jsonKey);
}
// Sort entries
final List<String> sortingProcessorList = sortSortingValues(processorKeys);
// Loop threw processors in order
for (final String processorKey : sortingProcessorList) {
process(processorKey);
}
}
}
use of com.builtbroken.mc.lib.json.processors.JsonProcessor in project Engine by VoltzEngine-Project.
the class JsonContentLoader method process.
/**
* Called to process a json element entry into a
* generated object
*
* @param key - json processor key
* @param element - data
* @return true if it was processed and added to the generated object list
*/
public boolean process(String key, JsonElement element) {
final JsonProcessor processor = processors.get(key);
if (processor != null) {
if (processor.canProcess(key, element)) {
IJsonGenObject data = processor.process(element);
data.register();
if (data instanceof IRegistryInit) {
((IRegistryInit) data).onRegistered();
}
return generatedObjects.add(data);
} else {
// TODO add error handling
}
}
return false;
}
Aggregations