implement flora populator

This commit is contained in:
dfsek
2021-07-14 07:30:22 -07:00
parent 7fa2e8251e
commit 7a38284158
6 changed files with 96 additions and 9 deletions

View File

@@ -17,11 +17,14 @@ public class ConfigLoadEvent implements PackEvent {
private final Consumer<ConfigTemplate> loader;
private final ConfigType<?, ?> type;
public ConfigLoadEvent(ConfigPack pack, AbstractConfiguration configuration, Consumer<ConfigTemplate> loader, ConfigType<?, ?> type) {
private final Object loaded;
public ConfigLoadEvent(ConfigPack pack, AbstractConfiguration configuration, Consumer<ConfigTemplate> loader, ConfigType<?, ?> type, Object loaded) {
this.pack = pack;
this.configuration = configuration;
this.loader = loader;
this.type = type;
this.loaded = loaded;
}
@Override
@@ -41,4 +44,10 @@ public class ConfigLoadEvent implements PackEvent {
public ConfigType<?, ?> getType() {
return type;
}
@SuppressWarnings("unchecked")
public <T> T getLoadedObject(Class<T> clazz) {
if(!clazz.isAssignableFrom(type.getTypeClass())) throw new ClassCastException("Cannot assign object from loader of type " + type.getTypeClass().getCanonicalName() + " to class " + clazz.getCanonicalName());
return (T) loaded;
}
}