structure configtype impl

This commit is contained in:
dfsek 2021-11-20 12:47:20 -07:00
parent e1dadaca6a
commit 94ee2c27eb
2 changed files with 40 additions and 1 deletions

View File

@ -28,7 +28,7 @@ public class StructureAddon implements AddonInitializer {
platform.getEventManager()
.getHandler(FunctionalEventHandler.class)
.register(addon, ConfigPackPreLoadEvent.class)
.then(event -> event.getPack().applyLoader(ConfiguredStructure.class, (t, o, l) -> null))
.then(event -> event.getPack().registerConfigType(new StructureConfigType(), "STRUCTURE", 2))
.failThrough();
}
}

View File

@ -0,0 +1,39 @@
/*
* Copyright (c) 2020-2021 Polyhedral Development
*
* The Terra Core Addons are licensed under the terms of the MIT License. For more details,
* reference the LICENSE file in this module's root directory.
*/
package com.dfsek.terra.addons.structure;
import com.dfsek.terra.api.Platform;
import com.dfsek.terra.api.config.ConfigFactory;
import com.dfsek.terra.api.config.ConfigPack;
import com.dfsek.terra.api.config.ConfigType;
import com.dfsek.terra.api.registry.OpenRegistry;
import com.dfsek.terra.api.structure.configured.ConfiguredStructure;
import com.dfsek.terra.api.util.reflection.TypeKey;
import java.util.function.Supplier;
public class StructureConfigType implements ConfigType<StructureTemplate, ConfiguredStructure> {
private final ConfigFactory<StructureTemplate, ConfiguredStructure> factory = new StructureFactory();
public static final TypeKey<ConfiguredStructure> CONFIGURED_STRUCTURE_TYPE_KEY = new TypeKey<>(){};
@Override
public StructureTemplate getTemplate(ConfigPack pack, Platform platform) {
return new StructureTemplate();
}
@Override
public ConfigFactory<StructureTemplate, ConfiguredStructure> getFactory() {
return factory;
}
@Override
public TypeKey<ConfiguredStructure> getTypeKey() {
return CONFIGURED_STRUCTURE_TYPE_KEY;
}
}