mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2025-07-03 08:25:31 +00:00
tree addon impl
This commit is contained in:
parent
1ad08a599d
commit
32b0cd0b26
@ -0,0 +1,27 @@
|
||||
package com.dfsek.terra.addons.tree;
|
||||
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.addon.TerraAddon;
|
||||
import com.dfsek.terra.api.addon.annotations.Addon;
|
||||
import com.dfsek.terra.api.addon.annotations.Author;
|
||||
import com.dfsek.terra.api.addon.annotations.Version;
|
||||
import com.dfsek.terra.api.event.EventListener;
|
||||
import com.dfsek.terra.api.event.events.config.ConfigPackPreLoadEvent;
|
||||
import com.dfsek.terra.api.injection.annotations.Inject;
|
||||
|
||||
@Addon("core-tree-config")
|
||||
@Author("Terra")
|
||||
@Version("1.0.0")
|
||||
public class TreeAddon extends TerraAddon implements EventListener {
|
||||
@Inject
|
||||
private TerraPlugin main;
|
||||
|
||||
@Override
|
||||
public void initialize() {
|
||||
main.getEventManager().registerListener(this, this);
|
||||
}
|
||||
|
||||
public void onPackLoad(ConfigPackPreLoadEvent event) {
|
||||
event.getPack().registerConfigType(new TreeConfigType(event.getPack()), "TREE", 2);
|
||||
}
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
package com.dfsek.terra.addons.tree;
|
||||
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
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.world.Tree;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class TreeConfigType implements ConfigType<TreeTemplate, Tree> {
|
||||
private final TreeFactory factory = new TreeFactory();
|
||||
private final ConfigPack pack;
|
||||
|
||||
public TreeConfigType(ConfigPack pack) {
|
||||
this.pack = pack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TreeTemplate getTemplate(ConfigPack pack, TerraPlugin main) {
|
||||
return new TreeTemplate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConfigFactory<TreeTemplate, Tree> getFactory() {
|
||||
return factory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<Tree> getTypeClass() {
|
||||
return Tree.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Supplier<OpenRegistry<Tree>> registrySupplier() {
|
||||
return pack.getRegistryFactory()::create;
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user