create RegistrationEvent

This commit is contained in:
dfsek
2021-12-04 20:29:38 -07:00
parent 709b41aceb
commit 6c69e3fad1
3 changed files with 46 additions and 2 deletions

View File

@@ -29,7 +29,7 @@ import com.dfsek.terra.api.world.chunk.generation.util.provider.GenerationStageP
public interface ConfigPack extends LoaderRegistrar, LoaderHolder, RegistryHolder, StringIdentifiable {
void registerConfigType(ConfigType<?, ?> type, String id, int priority);
ConfigPack registerConfigType(ConfigType<?, ?> type, String id, int priority);
Map<BaseAddon, VersionRange> addons();

View File

@@ -0,0 +1,40 @@
package com.dfsek.terra.api.event.events.config;
import com.dfsek.tectonic.loading.TypeLoader;
import com.dfsek.tectonic.loading.object.ObjectTemplate;
import com.dfsek.terra.api.config.ConfigPack;
import com.dfsek.terra.api.config.ConfigType;
import com.dfsek.terra.api.event.events.PackEvent;
import java.lang.reflect.Type;
import java.util.function.Supplier;
public class RegistrationEvent implements PackEvent {
private final ConfigPack pack;
public RegistrationEvent(ConfigPack pack) {
this.pack = pack;
}
@Override
public ConfigPack getPack() {
return pack;
}
public RegistrationEvent registerConfigType(ConfigType<?, ?> type, String id, int priority) {
pack.registerConfigType(type, id, priority);
return this;
}
public <T> RegistrationEvent applyLoader(Type type, Supplier<ObjectTemplate<T>> loader) {
pack.applyLoader(type, loader);
return this;
}
public <T> RegistrationEvent applyLoader(Type type, TypeLoader<T> loader) {
pack.applyLoader(type, loader);
return this;
}
}