probably a good idea to actually register variables

This commit is contained in:
dfsek
2020-11-27 14:32:31 -07:00
parent 538000ed32
commit 2f9f89042c
6 changed files with 147 additions and 11 deletions

View File

@@ -1,5 +1,6 @@
package com.dfsek.terra.registry;
import com.dfsek.tectonic.exception.LoadException;
import com.dfsek.tectonic.loading.ConfigLoader;
import com.dfsek.tectonic.loading.TypeLoader;
@@ -14,8 +15,11 @@ public abstract class TerraRegistry<T> implements TypeLoader<T> {
private final Map<String, T> objects = new HashMap<>();
@Override
public T load(Type type, Object o, ConfigLoader configLoader) {
return get((String) o);
public T load(Type type, Object o, ConfigLoader configLoader) throws LoadException {
T obj = get((String) o);
if(obj == null)
throw new LoadException("No such " + type + " matching \"" + o + "\" was found in this registry.");
return obj;
}
/**