mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2025-07-03 08:25:31 +00:00
implement FunctionalEventHandler
This commit is contained in:
parent
6f1938ef82
commit
953318d9c0
@ -26,6 +26,7 @@ import com.dfsek.terra.api.addon.annotations.Addon;
|
|||||||
import com.dfsek.terra.api.addon.annotations.Author;
|
import com.dfsek.terra.api.addon.annotations.Author;
|
||||||
import com.dfsek.terra.api.addon.annotations.Version;
|
import com.dfsek.terra.api.addon.annotations.Version;
|
||||||
import com.dfsek.terra.api.event.events.config.pack.ConfigPackPreLoadEvent;
|
import com.dfsek.terra.api.event.events.config.pack.ConfigPackPreLoadEvent;
|
||||||
|
import com.dfsek.terra.api.event.functional.FunctionalEventHandler;
|
||||||
import com.dfsek.terra.api.injection.annotations.Inject;
|
import com.dfsek.terra.api.injection.annotations.Inject;
|
||||||
import com.dfsek.terra.api.util.reflection.TypeKey;
|
import com.dfsek.terra.api.util.reflection.TypeKey;
|
||||||
import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
|
import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
|
||||||
@ -44,7 +45,8 @@ public class BiomePipelineAddon extends TerraAddon {
|
|||||||
@Override
|
@Override
|
||||||
public void initialize() {
|
public void initialize() {
|
||||||
main.getEventManager()
|
main.getEventManager()
|
||||||
.register(ConfigPackPreLoadEvent.class)
|
.getHandler(FunctionalEventHandler.class)
|
||||||
|
.register(this, ConfigPackPreLoadEvent.class)
|
||||||
.then(event -> event.getPack().applyLoader(BIOME_SOURCE_BUILDER_TOKEN.getType(), new SourceLoader())
|
.then(event -> event.getPack().applyLoader(BIOME_SOURCE_BUILDER_TOKEN.getType(), new SourceLoader())
|
||||||
.applyLoader(Stage.class, new StageLoader())
|
.applyLoader(Stage.class, new StageLoader())
|
||||||
.applyLoader(ExpanderStage.Type.class, (c, o, l) -> ExpanderStage.Type.valueOf((String) o))
|
.applyLoader(ExpanderStage.Type.class, (c, o, l) -> ExpanderStage.Type.valueOf((String) o))
|
||||||
|
@ -12,6 +12,7 @@ import com.dfsek.terra.api.addon.annotations.Author;
|
|||||||
import com.dfsek.terra.api.addon.annotations.Version;
|
import com.dfsek.terra.api.addon.annotations.Version;
|
||||||
import com.dfsek.terra.api.event.events.config.ConfigurationLoadEvent;
|
import com.dfsek.terra.api.event.events.config.ConfigurationLoadEvent;
|
||||||
import com.dfsek.terra.api.event.events.config.pack.ConfigPackPreLoadEvent;
|
import com.dfsek.terra.api.event.events.config.pack.ConfigPackPreLoadEvent;
|
||||||
|
import com.dfsek.terra.api.event.functional.FunctionalEventHandler;
|
||||||
import com.dfsek.terra.api.injection.annotations.Inject;
|
import com.dfsek.terra.api.injection.annotations.Inject;
|
||||||
import com.dfsek.terra.api.world.biome.TerraBiome;
|
import com.dfsek.terra.api.world.biome.TerraBiome;
|
||||||
import com.dfsek.terra.api.world.generator.ChunkGeneratorProvider;
|
import com.dfsek.terra.api.world.generator.ChunkGeneratorProvider;
|
||||||
@ -26,7 +27,8 @@ public class NoiseChunkGenerator3DAddon extends TerraAddon {
|
|||||||
@Override
|
@Override
|
||||||
public void initialize() {
|
public void initialize() {
|
||||||
main.getEventManager()
|
main.getEventManager()
|
||||||
.register(ConfigPackPreLoadEvent.class)
|
.getHandler(FunctionalEventHandler.class)
|
||||||
|
.register(this, ConfigPackPreLoadEvent.class)
|
||||||
.then(event -> {
|
.then(event -> {
|
||||||
event.getPack().getOrCreateRegistry(ChunkGeneratorProvider.class).register("NOISE_3D", pack -> new NoiseChunkGenerator3D(pack, main));
|
event.getPack().getOrCreateRegistry(ChunkGeneratorProvider.class).register("NOISE_3D", pack -> new NoiseChunkGenerator3D(pack, main));
|
||||||
event.getPack()
|
event.getPack()
|
||||||
@ -36,7 +38,8 @@ public class NoiseChunkGenerator3DAddon extends TerraAddon {
|
|||||||
.failThrough();
|
.failThrough();
|
||||||
|
|
||||||
main.getEventManager()
|
main.getEventManager()
|
||||||
.register(ConfigurationLoadEvent.class)
|
.getHandler(FunctionalEventHandler.class)
|
||||||
|
.register(this, ConfigurationLoadEvent.class)
|
||||||
.then(event -> {
|
.then(event -> {
|
||||||
if(event.is(TerraBiome.class)) {
|
if(event.is(TerraBiome.class)) {
|
||||||
event.getLoadedObject(TerraBiome.class).getContext().put(event.load(new BiomePaletteTemplate()).get());
|
event.getLoadedObject(TerraBiome.class).getContext().put(event.load(new BiomePaletteTemplate()).get());
|
||||||
|
@ -8,6 +8,7 @@ import com.dfsek.terra.api.addon.annotations.Addon;
|
|||||||
import com.dfsek.terra.api.addon.annotations.Author;
|
import com.dfsek.terra.api.addon.annotations.Author;
|
||||||
import com.dfsek.terra.api.addon.annotations.Version;
|
import com.dfsek.terra.api.addon.annotations.Version;
|
||||||
import com.dfsek.terra.api.event.events.config.pack.ConfigPackPreLoadEvent;
|
import com.dfsek.terra.api.event.events.config.pack.ConfigPackPreLoadEvent;
|
||||||
|
import com.dfsek.terra.api.event.functional.FunctionalEventHandler;
|
||||||
import com.dfsek.terra.api.injection.annotations.Inject;
|
import com.dfsek.terra.api.injection.annotations.Inject;
|
||||||
|
|
||||||
@Addon("config-biome")
|
@Addon("config-biome")
|
||||||
@ -20,7 +21,8 @@ public class BiomeAddon extends TerraAddon {
|
|||||||
@Override
|
@Override
|
||||||
public void initialize() {
|
public void initialize() {
|
||||||
main.getEventManager()
|
main.getEventManager()
|
||||||
.register(ConfigPackPreLoadEvent.class)
|
.getHandler(FunctionalEventHandler.class)
|
||||||
|
.register(this, ConfigPackPreLoadEvent.class)
|
||||||
.then(event -> {
|
.then(event -> {
|
||||||
event.getPack().registerConfigType(new BiomeConfigType(event.getPack()), "BIOME", 5);
|
event.getPack().registerConfigType(new BiomeConfigType(event.getPack()), "BIOME", 5);
|
||||||
event.getPack().applyLoader(PaletteHolder.class, new PaletteHolderLoader());
|
event.getPack().applyLoader(PaletteHolder.class, new PaletteHolderLoader());
|
||||||
|
@ -11,6 +11,7 @@ import com.dfsek.terra.api.addon.annotations.Addon;
|
|||||||
import com.dfsek.terra.api.addon.annotations.Author;
|
import com.dfsek.terra.api.addon.annotations.Author;
|
||||||
import com.dfsek.terra.api.addon.annotations.Version;
|
import com.dfsek.terra.api.addon.annotations.Version;
|
||||||
import com.dfsek.terra.api.event.events.config.pack.ConfigPackPreLoadEvent;
|
import com.dfsek.terra.api.event.events.config.pack.ConfigPackPreLoadEvent;
|
||||||
|
import com.dfsek.terra.api.event.functional.FunctionalEventHandler;
|
||||||
import com.dfsek.terra.api.injection.annotations.Inject;
|
import com.dfsek.terra.api.injection.annotations.Inject;
|
||||||
import com.dfsek.terra.api.registry.CheckedRegistry;
|
import com.dfsek.terra.api.registry.CheckedRegistry;
|
||||||
import com.dfsek.terra.api.structure.feature.Distributor;
|
import com.dfsek.terra.api.structure.feature.Distributor;
|
||||||
@ -29,7 +30,8 @@ public class DistributorAddon extends TerraAddon {
|
|||||||
@Override
|
@Override
|
||||||
public void initialize() {
|
public void initialize() {
|
||||||
main.getEventManager()
|
main.getEventManager()
|
||||||
.register(ConfigPackPreLoadEvent.class)
|
.getHandler(FunctionalEventHandler.class)
|
||||||
|
.register(this, ConfigPackPreLoadEvent.class)
|
||||||
.then(event -> {
|
.then(event -> {
|
||||||
CheckedRegistry<Supplier<ObjectTemplate<Distributor>>> distributorRegistry = event.getPack().getOrCreateRegistry(DISTRIBUTOR_TOKEN);
|
CheckedRegistry<Supplier<ObjectTemplate<Distributor>>> distributorRegistry = event.getPack().getOrCreateRegistry(DISTRIBUTOR_TOKEN);
|
||||||
distributorRegistry.register("NOISE", NoiseDistributorTemplate::new);
|
distributorRegistry.register("NOISE", NoiseDistributorTemplate::new);
|
||||||
|
@ -6,6 +6,7 @@ import com.dfsek.terra.api.addon.annotations.Addon;
|
|||||||
import com.dfsek.terra.api.addon.annotations.Author;
|
import com.dfsek.terra.api.addon.annotations.Author;
|
||||||
import com.dfsek.terra.api.addon.annotations.Version;
|
import com.dfsek.terra.api.addon.annotations.Version;
|
||||||
import com.dfsek.terra.api.event.events.config.pack.ConfigPackPreLoadEvent;
|
import com.dfsek.terra.api.event.events.config.pack.ConfigPackPreLoadEvent;
|
||||||
|
import com.dfsek.terra.api.event.functional.FunctionalEventHandler;
|
||||||
import com.dfsek.terra.api.injection.annotations.Inject;
|
import com.dfsek.terra.api.injection.annotations.Inject;
|
||||||
|
|
||||||
@Addon("config-feature")
|
@Addon("config-feature")
|
||||||
@ -18,7 +19,8 @@ public class FeatureAddon extends TerraAddon {
|
|||||||
@Override
|
@Override
|
||||||
public void initialize() {
|
public void initialize() {
|
||||||
main.getEventManager()
|
main.getEventManager()
|
||||||
.register(ConfigPackPreLoadEvent.class)
|
.getHandler(FunctionalEventHandler.class)
|
||||||
|
.register(this, ConfigPackPreLoadEvent.class)
|
||||||
.then(event -> event.getPack().registerConfigType(new FeatureConfigType(), "FEATURE", 2));
|
.then(event -> event.getPack().registerConfigType(new FeatureConfigType(), "FEATURE", 2));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@ import com.dfsek.terra.api.addon.annotations.Addon;
|
|||||||
import com.dfsek.terra.api.addon.annotations.Author;
|
import com.dfsek.terra.api.addon.annotations.Author;
|
||||||
import com.dfsek.terra.api.addon.annotations.Version;
|
import com.dfsek.terra.api.addon.annotations.Version;
|
||||||
import com.dfsek.terra.api.event.events.config.pack.ConfigPackPreLoadEvent;
|
import com.dfsek.terra.api.event.events.config.pack.ConfigPackPreLoadEvent;
|
||||||
|
import com.dfsek.terra.api.event.functional.FunctionalEventHandler;
|
||||||
import com.dfsek.terra.api.injection.annotations.Inject;
|
import com.dfsek.terra.api.injection.annotations.Inject;
|
||||||
|
|
||||||
@Addon("config-flora")
|
@Addon("config-flora")
|
||||||
@ -20,7 +21,8 @@ public class FloraAddon extends TerraAddon {
|
|||||||
@Override
|
@Override
|
||||||
public void initialize() {
|
public void initialize() {
|
||||||
main.getEventManager()
|
main.getEventManager()
|
||||||
.register(ConfigPackPreLoadEvent.class)
|
.getHandler(FunctionalEventHandler.class)
|
||||||
|
.register(this, ConfigPackPreLoadEvent.class)
|
||||||
.then(event -> {
|
.then(event -> {
|
||||||
event.getPack().registerConfigType(new FloraConfigType(), "FLORA", 2);
|
event.getPack().registerConfigType(new FloraConfigType(), "FLORA", 2);
|
||||||
event.getPack().applyLoader(BlockLayer.class, BlockLayerTemplate::new);
|
event.getPack().applyLoader(BlockLayer.class, BlockLayerTemplate::new);
|
||||||
|
@ -9,6 +9,7 @@ import com.dfsek.terra.api.addon.annotations.Addon;
|
|||||||
import com.dfsek.terra.api.addon.annotations.Author;
|
import com.dfsek.terra.api.addon.annotations.Author;
|
||||||
import com.dfsek.terra.api.addon.annotations.Version;
|
import com.dfsek.terra.api.addon.annotations.Version;
|
||||||
import com.dfsek.terra.api.event.events.config.pack.ConfigPackPreLoadEvent;
|
import com.dfsek.terra.api.event.events.config.pack.ConfigPackPreLoadEvent;
|
||||||
|
import com.dfsek.terra.api.event.functional.FunctionalEventHandler;
|
||||||
import com.dfsek.terra.api.injection.annotations.Inject;
|
import com.dfsek.terra.api.injection.annotations.Inject;
|
||||||
import com.dfsek.terra.api.registry.CheckedRegistry;
|
import com.dfsek.terra.api.registry.CheckedRegistry;
|
||||||
import com.dfsek.terra.api.structure.feature.Locator;
|
import com.dfsek.terra.api.structure.feature.Locator;
|
||||||
@ -28,7 +29,8 @@ public class LocatorAddon extends TerraAddon {
|
|||||||
@Override
|
@Override
|
||||||
public void initialize() {
|
public void initialize() {
|
||||||
main.getEventManager()
|
main.getEventManager()
|
||||||
.register(ConfigPackPreLoadEvent.class)
|
.getHandler(FunctionalEventHandler.class)
|
||||||
|
.register(this, ConfigPackPreLoadEvent.class)
|
||||||
.then(event -> {
|
.then(event -> {
|
||||||
CheckedRegistry<Supplier<ObjectTemplate<Locator>>> locatorRegistry = event.getPack().getOrCreateRegistry(LOCATOR_TOKEN);
|
CheckedRegistry<Supplier<ObjectTemplate<Locator>>> locatorRegistry = event.getPack().getOrCreateRegistry(LOCATOR_TOKEN);
|
||||||
locatorRegistry.register("SURFACE", () -> new SurfaceLocatorTemplate(main));
|
locatorRegistry.register("SURFACE", () -> new SurfaceLocatorTemplate(main));
|
||||||
|
@ -31,6 +31,7 @@ import com.dfsek.terra.api.addon.annotations.Addon;
|
|||||||
import com.dfsek.terra.api.addon.annotations.Author;
|
import com.dfsek.terra.api.addon.annotations.Author;
|
||||||
import com.dfsek.terra.api.addon.annotations.Version;
|
import com.dfsek.terra.api.addon.annotations.Version;
|
||||||
import com.dfsek.terra.api.event.events.config.pack.ConfigPackPreLoadEvent;
|
import com.dfsek.terra.api.event.events.config.pack.ConfigPackPreLoadEvent;
|
||||||
|
import com.dfsek.terra.api.event.functional.FunctionalEventHandler;
|
||||||
import com.dfsek.terra.api.injection.annotations.Inject;
|
import com.dfsek.terra.api.injection.annotations.Inject;
|
||||||
import com.dfsek.terra.api.noise.NoiseSampler;
|
import com.dfsek.terra.api.noise.NoiseSampler;
|
||||||
import com.dfsek.terra.api.registry.CheckedRegistry;
|
import com.dfsek.terra.api.registry.CheckedRegistry;
|
||||||
@ -52,7 +53,8 @@ public class NoiseAddon extends TerraAddon {
|
|||||||
@Override
|
@Override
|
||||||
public void initialize() {
|
public void initialize() {
|
||||||
plugin.getEventManager()
|
plugin.getEventManager()
|
||||||
.register(ConfigPackPreLoadEvent.class)
|
.getHandler(FunctionalEventHandler.class)
|
||||||
|
.register(this, ConfigPackPreLoadEvent.class)
|
||||||
.then(event -> {
|
.then(event -> {
|
||||||
CheckedRegistry<Supplier<ObjectTemplate<NoiseSampler>>> noiseRegistry = event.getPack().getOrCreateRegistry(NOISE_SAMPLER_TOKEN);
|
CheckedRegistry<Supplier<ObjectTemplate<NoiseSampler>>> noiseRegistry = event.getPack().getOrCreateRegistry(NOISE_SAMPLER_TOKEN);
|
||||||
event.getPack()
|
event.getPack()
|
||||||
|
@ -6,6 +6,7 @@ import com.dfsek.terra.api.addon.annotations.Addon;
|
|||||||
import com.dfsek.terra.api.addon.annotations.Author;
|
import com.dfsek.terra.api.addon.annotations.Author;
|
||||||
import com.dfsek.terra.api.addon.annotations.Version;
|
import com.dfsek.terra.api.addon.annotations.Version;
|
||||||
import com.dfsek.terra.api.event.events.config.pack.ConfigPackPreLoadEvent;
|
import com.dfsek.terra.api.event.events.config.pack.ConfigPackPreLoadEvent;
|
||||||
|
import com.dfsek.terra.api.event.functional.FunctionalEventHandler;
|
||||||
import com.dfsek.terra.api.injection.annotations.Inject;
|
import com.dfsek.terra.api.injection.annotations.Inject;
|
||||||
import com.dfsek.terra.api.world.generator.GenerationStageProvider;
|
import com.dfsek.terra.api.world.generator.GenerationStageProvider;
|
||||||
|
|
||||||
@ -20,7 +21,8 @@ public class OreAddon extends TerraAddon {
|
|||||||
@Override
|
@Override
|
||||||
public void initialize() {
|
public void initialize() {
|
||||||
main.getEventManager()
|
main.getEventManager()
|
||||||
.register(ConfigPackPreLoadEvent.class)
|
.getHandler(FunctionalEventHandler.class)
|
||||||
|
.register(this, ConfigPackPreLoadEvent.class)
|
||||||
.then(event -> {
|
.then(event -> {
|
||||||
event.getPack().registerConfigType(new OreConfigType(), "ORE", 1);
|
event.getPack().registerConfigType(new OreConfigType(), "ORE", 1);
|
||||||
event.getPack().getOrCreateRegistry(GenerationStageProvider.class).register("ORE", pack -> new OrePopulator(main));
|
event.getPack().getOrCreateRegistry(GenerationStageProvider.class).register("ORE", pack -> new OrePopulator(main));
|
||||||
|
@ -8,6 +8,7 @@ import com.dfsek.terra.api.addon.annotations.Addon;
|
|||||||
import com.dfsek.terra.api.addon.annotations.Author;
|
import com.dfsek.terra.api.addon.annotations.Author;
|
||||||
import com.dfsek.terra.api.addon.annotations.Version;
|
import com.dfsek.terra.api.addon.annotations.Version;
|
||||||
import com.dfsek.terra.api.event.events.config.pack.ConfigPackPreLoadEvent;
|
import com.dfsek.terra.api.event.events.config.pack.ConfigPackPreLoadEvent;
|
||||||
|
import com.dfsek.terra.api.event.functional.FunctionalEventHandler;
|
||||||
import com.dfsek.terra.api.injection.annotations.Inject;
|
import com.dfsek.terra.api.injection.annotations.Inject;
|
||||||
|
|
||||||
@Addon("config-palette")
|
@Addon("config-palette")
|
||||||
@ -20,7 +21,8 @@ public class PaletteAddon extends TerraAddon {
|
|||||||
@Override
|
@Override
|
||||||
public void initialize() {
|
public void initialize() {
|
||||||
main.getEventManager()
|
main.getEventManager()
|
||||||
.register(ConfigPackPreLoadEvent.class)
|
.getHandler(FunctionalEventHandler.class)
|
||||||
|
.register(this, ConfigPackPreLoadEvent.class)
|
||||||
.then(event -> {
|
.then(event -> {
|
||||||
event.getPack().registerConfigType(new PaletteConfigType(main), "PALETTE", 2);
|
event.getPack().registerConfigType(new PaletteConfigType(main), "PALETTE", 2);
|
||||||
event.getPack().applyLoader(PaletteLayerHolder.class, new PaletteLayerLoader());
|
event.getPack().applyLoader(PaletteLayerHolder.class, new PaletteLayerLoader());
|
||||||
|
@ -6,6 +6,7 @@ import com.dfsek.terra.api.addon.annotations.Addon;
|
|||||||
import com.dfsek.terra.api.addon.annotations.Author;
|
import com.dfsek.terra.api.addon.annotations.Author;
|
||||||
import com.dfsek.terra.api.addon.annotations.Version;
|
import com.dfsek.terra.api.addon.annotations.Version;
|
||||||
import com.dfsek.terra.api.event.events.config.pack.ConfigPackPreLoadEvent;
|
import com.dfsek.terra.api.event.events.config.pack.ConfigPackPreLoadEvent;
|
||||||
|
import com.dfsek.terra.api.event.functional.FunctionalEventHandler;
|
||||||
import com.dfsek.terra.api.injection.annotations.Inject;
|
import com.dfsek.terra.api.injection.annotations.Inject;
|
||||||
import com.dfsek.terra.api.structure.configured.ConfiguredStructure;
|
import com.dfsek.terra.api.structure.configured.ConfiguredStructure;
|
||||||
|
|
||||||
@ -19,7 +20,8 @@ public class StructureAddon extends TerraAddon {
|
|||||||
@Override
|
@Override
|
||||||
public void initialize() {
|
public void initialize() {
|
||||||
main.getEventManager()
|
main.getEventManager()
|
||||||
.register(ConfigPackPreLoadEvent.class)
|
.getHandler(FunctionalEventHandler.class)
|
||||||
|
.register(this, ConfigPackPreLoadEvent.class)
|
||||||
.then(event -> event.getPack().applyLoader(ConfiguredStructure.class, (t, o, l) -> null));
|
.then(event -> event.getPack().applyLoader(ConfiguredStructure.class, (t, o, l) -> null));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@ import com.dfsek.terra.api.addon.annotations.Author;
|
|||||||
import com.dfsek.terra.api.addon.annotations.Version;
|
import com.dfsek.terra.api.addon.annotations.Version;
|
||||||
import com.dfsek.terra.api.event.events.config.ConfigurationLoadEvent;
|
import com.dfsek.terra.api.event.events.config.ConfigurationLoadEvent;
|
||||||
import com.dfsek.terra.api.event.events.config.pack.ConfigPackPreLoadEvent;
|
import com.dfsek.terra.api.event.events.config.pack.ConfigPackPreLoadEvent;
|
||||||
|
import com.dfsek.terra.api.event.functional.FunctionalEventHandler;
|
||||||
import com.dfsek.terra.api.injection.annotations.Inject;
|
import com.dfsek.terra.api.injection.annotations.Inject;
|
||||||
import com.dfsek.terra.api.world.biome.TerraBiome;
|
import com.dfsek.terra.api.world.biome.TerraBiome;
|
||||||
import com.dfsek.terra.api.world.generator.GenerationStageProvider;
|
import com.dfsek.terra.api.world.generator.GenerationStageProvider;
|
||||||
@ -22,11 +23,13 @@ public class FeatureGenerationAddon extends TerraAddon {
|
|||||||
@Override
|
@Override
|
||||||
public void initialize() {
|
public void initialize() {
|
||||||
main.getEventManager()
|
main.getEventManager()
|
||||||
.register(ConfigPackPreLoadEvent.class)
|
.getHandler(FunctionalEventHandler.class)
|
||||||
|
.register(this, ConfigPackPreLoadEvent.class)
|
||||||
.then(event -> event.getPack().getOrCreateRegistry(GenerationStageProvider.class).register("FEATURE", pack -> new FeatureGenerationStage(main)));
|
.then(event -> event.getPack().getOrCreateRegistry(GenerationStageProvider.class).register("FEATURE", pack -> new FeatureGenerationStage(main)));
|
||||||
|
|
||||||
main.getEventManager()
|
main.getEventManager()
|
||||||
.register(ConfigurationLoadEvent.class)
|
.getHandler(FunctionalEventHandler.class)
|
||||||
|
.register(this, ConfigurationLoadEvent.class)
|
||||||
.then(event -> {
|
.then(event -> {
|
||||||
if(event.is(TerraBiome.class)) {
|
if(event.is(TerraBiome.class)) {
|
||||||
event.getLoadedObject(TerraBiome.class).getContext().put(event.load(new BiomeFeaturesTemplate()).get());
|
event.getLoadedObject(TerraBiome.class).getContext().put(event.load(new BiomeFeaturesTemplate()).get());
|
||||||
|
@ -7,6 +7,7 @@ import com.dfsek.terra.api.addon.annotations.Author;
|
|||||||
import com.dfsek.terra.api.addon.annotations.Version;
|
import com.dfsek.terra.api.addon.annotations.Version;
|
||||||
import com.dfsek.terra.api.event.events.config.ConfigurationLoadEvent;
|
import com.dfsek.terra.api.event.events.config.ConfigurationLoadEvent;
|
||||||
import com.dfsek.terra.api.event.events.config.pack.ConfigPackPreLoadEvent;
|
import com.dfsek.terra.api.event.events.config.pack.ConfigPackPreLoadEvent;
|
||||||
|
import com.dfsek.terra.api.event.functional.FunctionalEventHandler;
|
||||||
import com.dfsek.terra.api.injection.annotations.Inject;
|
import com.dfsek.terra.api.injection.annotations.Inject;
|
||||||
import com.dfsek.terra.api.world.biome.TerraBiome;
|
import com.dfsek.terra.api.world.biome.TerraBiome;
|
||||||
import com.dfsek.terra.api.world.generator.GenerationStageProvider;
|
import com.dfsek.terra.api.world.generator.GenerationStageProvider;
|
||||||
@ -22,14 +23,16 @@ public class FloraGenerationAddon extends TerraAddon {
|
|||||||
@Override
|
@Override
|
||||||
public void initialize() {
|
public void initialize() {
|
||||||
main.getEventManager()
|
main.getEventManager()
|
||||||
.register(ConfigPackPreLoadEvent.class)
|
.getHandler(FunctionalEventHandler.class)
|
||||||
|
.register(this, ConfigPackPreLoadEvent.class)
|
||||||
.then(event -> {
|
.then(event -> {
|
||||||
event.getPack().applyLoader(FloraLayer.class, FloraLayerLoader::new);
|
event.getPack().applyLoader(FloraLayer.class, FloraLayerLoader::new);
|
||||||
event.getPack().getOrCreateRegistry(GenerationStageProvider.class).register("FLORA", pack -> new FloraGenerationStage(main));
|
event.getPack().getOrCreateRegistry(GenerationStageProvider.class).register("FLORA", pack -> new FloraGenerationStage(main));
|
||||||
});
|
});
|
||||||
|
|
||||||
main.getEventManager()
|
main.getEventManager()
|
||||||
.register(ConfigurationLoadEvent.class)
|
.getHandler(FunctionalEventHandler.class)
|
||||||
|
.register(this, ConfigurationLoadEvent.class)
|
||||||
.then(event -> {
|
.then(event -> {
|
||||||
if(event.is(TerraBiome.class)) {
|
if(event.is(TerraBiome.class)) {
|
||||||
event.getLoadedObject(TerraBiome.class).getContext().put(event.load(new BiomeFloraTemplate()).get());
|
event.getLoadedObject(TerraBiome.class).getContext().put(event.load(new BiomeFloraTemplate()).get());
|
||||||
|
@ -7,6 +7,7 @@ import com.dfsek.terra.api.addon.annotations.Addon;
|
|||||||
import com.dfsek.terra.api.addon.annotations.Author;
|
import com.dfsek.terra.api.addon.annotations.Author;
|
||||||
import com.dfsek.terra.api.addon.annotations.Version;
|
import com.dfsek.terra.api.addon.annotations.Version;
|
||||||
import com.dfsek.terra.api.event.events.config.ConfigurationDiscoveryEvent;
|
import com.dfsek.terra.api.event.events.config.ConfigurationDiscoveryEvent;
|
||||||
|
import com.dfsek.terra.api.event.functional.FunctionalEventHandler;
|
||||||
import com.dfsek.terra.api.injection.annotations.Inject;
|
import com.dfsek.terra.api.injection.annotations.Inject;
|
||||||
|
|
||||||
@Addon("language-yaml")
|
@Addon("language-yaml")
|
||||||
@ -19,7 +20,8 @@ public class YamlAddon extends TerraAddon {
|
|||||||
@Override
|
@Override
|
||||||
public void initialize() {
|
public void initialize() {
|
||||||
main.getEventManager()
|
main.getEventManager()
|
||||||
.register(ConfigurationDiscoveryEvent.class)
|
.getHandler(FunctionalEventHandler.class)
|
||||||
|
.register(this, ConfigurationDiscoveryEvent.class)
|
||||||
.then(event -> event.getLoader().open("", ".yml").thenEntries(entries -> entries.forEach(entry -> {
|
.then(event -> event.getLoader().open("", ".yml").thenEntries(entries -> entries.forEach(entry -> {
|
||||||
main.getDebugLogger().info("Discovered config " + entry.getKey());
|
main.getDebugLogger().info("Discovered config " + entry.getKey());
|
||||||
event.register(entry.getKey(), new YamlConfiguration(entry.getValue(), entry.getKey()));
|
event.register(entry.getKey(), new YamlConfiguration(entry.getValue(), entry.getKey()));
|
||||||
|
@ -9,6 +9,7 @@ import com.dfsek.terra.api.addon.annotations.Addon;
|
|||||||
import com.dfsek.terra.api.addon.annotations.Author;
|
import com.dfsek.terra.api.addon.annotations.Author;
|
||||||
import com.dfsek.terra.api.addon.annotations.Version;
|
import com.dfsek.terra.api.addon.annotations.Version;
|
||||||
import com.dfsek.terra.api.event.events.config.pack.ConfigPackPreLoadEvent;
|
import com.dfsek.terra.api.event.events.config.pack.ConfigPackPreLoadEvent;
|
||||||
|
import com.dfsek.terra.api.event.functional.FunctionalEventHandler;
|
||||||
import com.dfsek.terra.api.injection.annotations.Inject;
|
import com.dfsek.terra.api.injection.annotations.Inject;
|
||||||
import com.dfsek.terra.api.registry.CheckedRegistry;
|
import com.dfsek.terra.api.registry.CheckedRegistry;
|
||||||
import com.dfsek.terra.api.structure.LootTable;
|
import com.dfsek.terra.api.structure.LootTable;
|
||||||
@ -27,7 +28,8 @@ public class TerraScriptAddon extends TerraAddon {
|
|||||||
@Override
|
@Override
|
||||||
public void initialize() {
|
public void initialize() {
|
||||||
main.getEventManager()
|
main.getEventManager()
|
||||||
.register(ConfigPackPreLoadEvent.class)
|
.getHandler(FunctionalEventHandler.class)
|
||||||
|
.register(this, ConfigPackPreLoadEvent.class)
|
||||||
.then(event -> {
|
.then(event -> {
|
||||||
CheckedRegistry<Structure> structureRegistry = event.getPack().getOrCreateRegistry(Structure.class);
|
CheckedRegistry<Structure> structureRegistry = event.getPack().getOrCreateRegistry(Structure.class);
|
||||||
CheckedRegistry<LootTable> lootRegistry = event.getPack().getOrCreateRegistry(LootTable.class);
|
CheckedRegistry<LootTable> lootRegistry = event.getPack().getOrCreateRegistry(LootTable.class);
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package com.dfsek.terra.api.event;
|
package com.dfsek.terra.api.event;
|
||||||
|
|
||||||
import com.dfsek.terra.api.addon.TerraAddon;
|
|
||||||
import com.dfsek.terra.api.event.events.Event;
|
import com.dfsek.terra.api.event.events.Event;
|
||||||
import com.dfsek.terra.api.event.functional.EventContext;
|
import com.dfsek.terra.api.event.functional.EventContext;
|
||||||
import com.dfsek.terra.api.util.reflection.TypeKey;
|
import com.dfsek.terra.api.util.reflection.TypeKey;
|
||||||
@ -13,21 +12,10 @@ public interface EventManager {
|
|||||||
* Call an event, and return the execution status.
|
* Call an event, and return the execution status.
|
||||||
*
|
*
|
||||||
* @param event Event to pass to all registered EventListeners.
|
* @param event Event to pass to all registered EventListeners.
|
||||||
* @return False if the event is cancellable and has been cancelled, otherwise true.
|
|
||||||
*/
|
*/
|
||||||
boolean callEvent(Event event);
|
void callEvent(Event event);
|
||||||
|
|
||||||
/**
|
<T extends EventHandler> void registerHandler(Class<T> clazz, T handler);
|
||||||
* Register an {@link EventListener} under an {@link TerraAddon}.
|
|
||||||
*
|
|
||||||
* @param addon Addon to register listener for.
|
|
||||||
* @param listener Listener to register.
|
|
||||||
*/
|
|
||||||
void registerListener(TerraAddon addon, EventListener listener);
|
|
||||||
|
|
||||||
<T extends Event> EventContext<T> register(Class<T> clazz);
|
<T extends EventHandler> T getHandler(Class<T> clazz);
|
||||||
|
|
||||||
<T extends Event> EventContext<T> register(TypeKey<T> clazz);
|
|
||||||
|
|
||||||
void registerHandler(EventHandler handler);
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,12 @@
|
|||||||
|
package com.dfsek.terra.api.event.functional;
|
||||||
|
|
||||||
|
import com.dfsek.terra.api.addon.TerraAddon;
|
||||||
|
import com.dfsek.terra.api.event.EventHandler;
|
||||||
|
import com.dfsek.terra.api.event.events.Event;
|
||||||
|
import com.dfsek.terra.api.util.reflection.TypeKey;
|
||||||
|
|
||||||
|
public interface FunctionalEventHandler extends EventHandler {
|
||||||
|
<T extends Event> EventContext<T> register(TerraAddon addon, Class<T> clazz);
|
||||||
|
|
||||||
|
<T extends Event> EventContext<T> register(TerraAddon addon, TypeKey<T> clazz);
|
||||||
|
}
|
@ -0,0 +1,76 @@
|
|||||||
|
package com.dfsek.terra.event;
|
||||||
|
|
||||||
|
import com.dfsek.terra.api.addon.TerraAddon;
|
||||||
|
import com.dfsek.terra.api.event.events.Event;
|
||||||
|
import com.dfsek.terra.api.event.events.PackEvent;
|
||||||
|
import com.dfsek.terra.api.event.functional.EventContext;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
|
public class EventContextImpl<T extends Event> implements EventContext<T>, Comparable<EventContextImpl<T>> {
|
||||||
|
private final List<Consumer<T>> actions = new ArrayList<>();
|
||||||
|
private int priority;
|
||||||
|
private boolean failThrough = false;
|
||||||
|
private boolean global = false;
|
||||||
|
|
||||||
|
private final TerraAddon addon;
|
||||||
|
|
||||||
|
public EventContextImpl(TerraAddon addon) {
|
||||||
|
this.addon = addon;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void handle(T event) {
|
||||||
|
if(event instanceof PackEvent) {
|
||||||
|
|
||||||
|
}
|
||||||
|
actions.forEach(action -> action.accept(event));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public EventContext<T> then(Consumer<T> action) {
|
||||||
|
actions.add(action);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public EventContext<T> priority(int priority) {
|
||||||
|
this.priority = priority;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public EventContext<T> failThrough() {
|
||||||
|
this.failThrough = true;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public EventContext<T> global() {
|
||||||
|
this.global = true;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int compareTo(@NotNull EventContextImpl<T> o) {
|
||||||
|
return this.priority - o.priority;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isGlobal() {
|
||||||
|
return global;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getPriority() {
|
||||||
|
return priority;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TerraAddon getAddon() {
|
||||||
|
return addon;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isFailThrough() {
|
||||||
|
return failThrough;
|
||||||
|
}
|
||||||
|
}
|
@ -2,110 +2,45 @@ package com.dfsek.terra.event;
|
|||||||
|
|
||||||
import com.dfsek.terra.api.TerraPlugin;
|
import com.dfsek.terra.api.TerraPlugin;
|
||||||
import com.dfsek.terra.api.addon.TerraAddon;
|
import com.dfsek.terra.api.addon.TerraAddon;
|
||||||
|
import com.dfsek.terra.api.event.EventHandler;
|
||||||
import com.dfsek.terra.api.event.EventListener;
|
import com.dfsek.terra.api.event.EventListener;
|
||||||
import com.dfsek.terra.api.event.EventManager;
|
import com.dfsek.terra.api.event.EventManager;
|
||||||
import com.dfsek.terra.api.event.annotations.Global;
|
|
||||||
import com.dfsek.terra.api.event.annotations.Priority;
|
|
||||||
import com.dfsek.terra.api.event.events.Cancellable;
|
|
||||||
import com.dfsek.terra.api.event.events.Event;
|
import com.dfsek.terra.api.event.events.Event;
|
||||||
import com.dfsek.terra.api.event.events.PackEvent;
|
import com.dfsek.terra.api.event.functional.EventContext;
|
||||||
import com.dfsek.terra.api.util.reflection.ReflectionUtil;
|
import com.dfsek.terra.api.event.functional.FunctionalEventHandler;
|
||||||
|
import com.dfsek.terra.api.util.reflection.TypeKey;
|
||||||
|
|
||||||
import java.io.PrintWriter;
|
|
||||||
import java.io.StringWriter;
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
|
import java.lang.reflect.Type;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Comparator;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class EventManagerImpl implements EventManager {
|
public class EventManagerImpl implements EventManager {
|
||||||
private final Map<Class<? extends Event>, List<ListenerHolder>> listeners = new HashMap<>();
|
private final Map<Class<?>, EventHandler> handlers = new HashMap<>();
|
||||||
private final TerraPlugin main;
|
private final TerraPlugin main;
|
||||||
|
|
||||||
public EventManagerImpl(TerraPlugin main) {
|
public EventManagerImpl(TerraPlugin main) {
|
||||||
this.main = main;
|
this.main = main;
|
||||||
|
registerHandler(FunctionalEventHandler.class, new FunctionalEventHandlerImpl(main)); // default handler
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean callEvent(Event event) {
|
public void callEvent(Event event) {
|
||||||
listeners.getOrDefault(event.getClass(), Collections.emptyList()).forEach(listenerHolder -> {
|
handlers.values().forEach(handler -> handler.handle(event));
|
||||||
try {
|
}
|
||||||
if(event instanceof PackEvent && !listenerHolder.global) {
|
|
||||||
PackEvent packEvent = (PackEvent) event;
|
@Override
|
||||||
if(packEvent
|
public <T extends EventHandler> void registerHandler(Class<T> clazz, T handler) {
|
||||||
.getPack()
|
handlers.put(clazz, handler);
|
||||||
.addons()
|
|
||||||
.contains(listenerHolder.addon)) {
|
|
||||||
listenerHolder.method.invoke(listenerHolder.listener, event);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
listenerHolder.method.invoke(listenerHolder.listener, event);
|
|
||||||
}
|
|
||||||
} catch(InvocationTargetException e) {
|
|
||||||
StringWriter writer = new StringWriter();
|
|
||||||
e.getTargetException().printStackTrace(new PrintWriter(writer));
|
|
||||||
main.logger().warning("Exception occurred during event handling:");
|
|
||||||
main.logger().warning(writer.toString());
|
|
||||||
main.logger().warning("Report this to the maintainers of " + listenerHolder.method.getName());
|
|
||||||
} catch(Exception e) {
|
|
||||||
StringWriter writer = new StringWriter();
|
|
||||||
e.printStackTrace(new PrintWriter(writer));
|
|
||||||
main.logger().warning("Exception occurred during event handling:");
|
|
||||||
main.logger().warning(writer.toString());
|
|
||||||
main.logger().warning("Report this to the maintainers of " + listenerHolder.method.getName());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
if(event instanceof Cancellable) return !((Cancellable) event).isCancelled();
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@Override
|
@Override
|
||||||
public void registerListener(TerraAddon addon, EventListener listener) {
|
public <T extends EventHandler> T getHandler(Class<T> clazz) {
|
||||||
Class<? extends EventListener> listenerClass = listener.getClass();
|
return (T) handlers.computeIfAbsent(clazz, c -> {
|
||||||
Method[] methods = ReflectionUtil.getMethods(listenerClass);
|
throw new IllegalArgumentException("No event handler registered for class " + clazz.getCanonicalName());
|
||||||
|
});
|
||||||
for(Method method : methods) {
|
|
||||||
if(method.getParameterCount() != 1) continue; // Check that parameter count is only 1.
|
|
||||||
Class<?> eventParam = method.getParameterTypes()[0];
|
|
||||||
if(!Event.class.isAssignableFrom(eventParam)) continue; // Check that parameter is an Event.
|
|
||||||
|
|
||||||
Priority p = method.getAnnotation(Priority.class);
|
|
||||||
|
|
||||||
int priority = p == null ? 0 : p.value();
|
|
||||||
|
|
||||||
method.setAccessible(true);
|
|
||||||
|
|
||||||
List<ListenerHolder> holders = listeners.computeIfAbsent((Class<? extends Event>) eventParam, e -> new ArrayList<>());
|
|
||||||
|
|
||||||
holders.add(new ListenerHolder(method, listener, priority, addon, method.getAnnotation(Global.class) != null));
|
|
||||||
|
|
||||||
holders.sort(Comparator.comparingInt(ListenerHolder::getPriority)); // Sort priorities.
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final class ListenerHolder {
|
|
||||||
private final Method method;
|
|
||||||
private final EventListener listener;
|
|
||||||
private final int priority;
|
|
||||||
private final TerraAddon addon;
|
|
||||||
private final boolean global;
|
|
||||||
|
|
||||||
private ListenerHolder(Method method, EventListener listener, int priority, TerraAddon addon, boolean global) {
|
|
||||||
this.method = method;
|
|
||||||
this.listener = listener;
|
|
||||||
this.priority = priority;
|
|
||||||
this.addon = addon;
|
|
||||||
this.global = global;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getPriority() {
|
|
||||||
return priority;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,65 @@
|
|||||||
|
package com.dfsek.terra.event;
|
||||||
|
|
||||||
|
import com.dfsek.terra.api.TerraPlugin;
|
||||||
|
import com.dfsek.terra.api.addon.TerraAddon;
|
||||||
|
import com.dfsek.terra.api.event.events.Event;
|
||||||
|
import com.dfsek.terra.api.event.events.PackEvent;
|
||||||
|
import com.dfsek.terra.api.event.functional.EventContext;
|
||||||
|
import com.dfsek.terra.api.event.functional.FunctionalEventHandler;
|
||||||
|
import com.dfsek.terra.api.util.reflection.TypeKey;
|
||||||
|
|
||||||
|
import java.io.PrintWriter;
|
||||||
|
import java.io.StringWriter;
|
||||||
|
import java.lang.reflect.Type;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class FunctionalEventHandlerImpl implements FunctionalEventHandler {
|
||||||
|
private final Map<Type, List<EventContextImpl<?>>> contextMap = new HashMap<>();
|
||||||
|
|
||||||
|
private final TerraPlugin main;
|
||||||
|
|
||||||
|
public FunctionalEventHandlerImpl(TerraPlugin main) {
|
||||||
|
this.main = main;
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
@Override
|
||||||
|
public void handle(Event event) {
|
||||||
|
contextMap.getOrDefault(event.getClass(), Collections.emptyList()).forEach(context -> {
|
||||||
|
try {
|
||||||
|
if(event instanceof PackEvent) {
|
||||||
|
if((context.isGlobal() || ((PackEvent) event).getPack().addons().contains(context.getAddon()))) {
|
||||||
|
((EventContextImpl<Event>) context).handle(event);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
((EventContextImpl<Event>) context).handle(event);
|
||||||
|
}
|
||||||
|
} catch(Exception e) {
|
||||||
|
if(context.isFailThrough()) throw e; // Rethrow if it's fail-through.
|
||||||
|
StringWriter writer = new StringWriter();
|
||||||
|
e.printStackTrace(new PrintWriter(writer));
|
||||||
|
main.logger().warning("Exception occurred during event handling:");
|
||||||
|
main.logger().warning(writer.toString());
|
||||||
|
main.logger().warning("Report this to the maintainers of " + context.getAddon().getName() + ", " + context.getAddon().getAuthor());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <T extends Event> EventContext<T> register(TerraAddon addon, Class<T> clazz) {
|
||||||
|
EventContextImpl<T> eventContext = new EventContextImpl<>(addon);
|
||||||
|
contextMap.computeIfAbsent(clazz, c -> new ArrayList<>()).add(eventContext);
|
||||||
|
return eventContext;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <T extends Event> EventContext<T> register(TerraAddon addon, TypeKey<T> clazz) {
|
||||||
|
EventContextImpl<T> eventContext = new EventContextImpl<>(addon);
|
||||||
|
contextMap.computeIfAbsent(clazz.getType(), c -> new ArrayList<>()).add(eventContext);
|
||||||
|
return eventContext;
|
||||||
|
}
|
||||||
|
}
|
@ -17,6 +17,7 @@ import com.dfsek.terra.api.config.PluginConfig;
|
|||||||
import com.dfsek.terra.api.event.EventManager;
|
import com.dfsek.terra.api.event.EventManager;
|
||||||
import com.dfsek.terra.api.event.events.config.pack.ConfigPackPostLoadEvent;
|
import com.dfsek.terra.api.event.events.config.pack.ConfigPackPostLoadEvent;
|
||||||
import com.dfsek.terra.api.event.events.config.pack.ConfigPackPreLoadEvent;
|
import com.dfsek.terra.api.event.events.config.pack.ConfigPackPreLoadEvent;
|
||||||
|
import com.dfsek.terra.api.event.functional.FunctionalEventHandler;
|
||||||
import com.dfsek.terra.api.handle.ItemHandle;
|
import com.dfsek.terra.api.handle.ItemHandle;
|
||||||
import com.dfsek.terra.api.handle.WorldHandle;
|
import com.dfsek.terra.api.handle.WorldHandle;
|
||||||
import com.dfsek.terra.api.lang.Language;
|
import com.dfsek.terra.api.lang.Language;
|
||||||
@ -289,7 +290,8 @@ public class TerraFabricPlugin implements TerraPlugin, ModInitializer {
|
|||||||
@Override
|
@Override
|
||||||
public void initialize() {
|
public void initialize() {
|
||||||
eventManager
|
eventManager
|
||||||
.register(ConfigPackPreLoadEvent.class)
|
.getHandler(FunctionalEventHandler.class)
|
||||||
|
.register(this, ConfigPackPreLoadEvent.class)
|
||||||
.then(event -> {
|
.then(event -> {
|
||||||
PreLoadCompatibilityOptions template = new PreLoadCompatibilityOptions();
|
PreLoadCompatibilityOptions template = new PreLoadCompatibilityOptions();
|
||||||
try {
|
try {
|
||||||
@ -314,7 +316,8 @@ public class TerraFabricPlugin implements TerraPlugin, ModInitializer {
|
|||||||
.global();
|
.global();
|
||||||
|
|
||||||
eventManager
|
eventManager
|
||||||
.register(ConfigPackPostLoadEvent.class)
|
.getHandler(FunctionalEventHandler.class)
|
||||||
|
.register(this, ConfigPackPostLoadEvent.class)
|
||||||
.then(event -> {
|
.then(event -> {
|
||||||
PostLoadCompatibilityOptions template = new PostLoadCompatibilityOptions();
|
PostLoadCompatibilityOptions template = new PostLoadCompatibilityOptions();
|
||||||
|
|
||||||
@ -330,7 +333,8 @@ public class TerraFabricPlugin implements TerraPlugin, ModInitializer {
|
|||||||
.global();
|
.global();
|
||||||
|
|
||||||
eventManager
|
eventManager
|
||||||
.register(BiomeRegistrationEvent.class)
|
.getHandler(FunctionalEventHandler.class)
|
||||||
|
.register(this, BiomeRegistrationEvent.class)
|
||||||
.then(event -> {
|
.then(event -> {
|
||||||
logger.info("Registering biomes...");
|
logger.info("Registering biomes...");
|
||||||
Registry<Biome> biomeRegistry = event.getRegistryManager().get(Registry.BIOME_KEY);
|
Registry<Biome> biomeRegistry = event.getRegistryManager().get(Registry.BIOME_KEY);
|
||||||
@ -340,7 +344,8 @@ public class TerraFabricPlugin implements TerraPlugin, ModInitializer {
|
|||||||
.global();
|
.global();
|
||||||
|
|
||||||
eventManager
|
eventManager
|
||||||
.register(GameInitializationEvent.class)
|
.getHandler(FunctionalEventHandler.class)
|
||||||
|
.register(this, GameInitializationEvent.class)
|
||||||
.then(event -> {
|
.then(event -> {
|
||||||
TerraFabricPlugin main = TerraFabricPlugin.getInstance();
|
TerraFabricPlugin main = TerraFabricPlugin.getInstance();
|
||||||
main.logger().info("Loading config packs...");
|
main.logger().info("Loading config packs...");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user