Search in sources :

Example 1 with CyclicGraphException

use of org.lanternpowered.server.util.graph.CyclicGraphException in project LanternServer by LanternPowered.

the class LanternGameRegistry method syncModules.

private void syncModules() {
    if (this.modulesSynced) {
        return;
    }
    final DirectedGraph<Class<? extends RegistryModule>> graph = new DirectedGraph<>();
    for (RegistryModule aModule : this.registryModules) {
        if (!this.classMap.containsKey(aModule.getClass())) {
            this.classMap.put(aModule.getClass(), aModule);
        }
        addToGraph(aModule, graph);
    }
    // Now we need ot do the catalog ones
    for (CatalogRegistryModule<?> aModule : this.catalogRegistryMap.values()) {
        if (!this.classMap.containsKey(aModule.getClass())) {
            this.classMap.put(aModule.getClass(), aModule);
        }
        addToGraph(aModule, graph);
    }
    this.orderedModules.clear();
    try {
        this.orderedModules.addAll(TopologicalOrder.createOrderedLoad(graph));
    } catch (CyclicGraphException e) {
        final StringBuilder msg = new StringBuilder();
        msg.append("Registry module dependencies are cyclical!\n");
        msg.append("Dependency loops are:\n");
        for (DirectedGraph.DataNode<?>[] cycle : e.getCycles()) {
            msg.append("[");
            for (DirectedGraph.DataNode<?> node : cycle) {
                msg.append(node.getData().toString()).append(" ");
            }
            msg.append("]\n");
        }
        this.game.getLog4jLogger().fatal(msg.toString());
        throw new RuntimeException("Registry modules dependencies error.");
    }
    this.modulesSynced = true;
}
Also used : DismountTypeRegistryModule(org.lanternpowered.server.game.registry.type.cause.DismountTypeRegistryModule) SandstoneTypeRegistryModule(org.lanternpowered.server.game.registry.type.data.SandstoneTypeRegistryModule) ConditionTypeRegistryModule(org.lanternpowered.server.script.function.condition.ConditionTypeRegistryModule) InventoryArchetypeRegistryModule(org.lanternpowered.server.game.registry.type.item.inventory.InventoryArchetypeRegistryModule) PotionTypeRegistryModule(org.lanternpowered.server.game.registry.type.effect.PotionTypeRegistryModule) BlockStateRegistryModule(org.lanternpowered.server.game.registry.type.block.BlockStateRegistryModule) PotionEffectTypeRegistryModule(org.lanternpowered.server.game.registry.type.effect.PotionEffectTypeRegistryModule) InstrumentTypeRegistryModule(org.lanternpowered.server.game.registry.type.data.InstrumentTypeRegistryModule) AttributeTargetRegistryModule(org.lanternpowered.server.game.registry.type.attribute.AttributeTargetRegistryModule) IntValueProviderTypeRegistryModule(org.lanternpowered.server.script.function.value.IntValueProviderTypeRegistryModule) ItemRegistryModule(org.lanternpowered.server.game.registry.type.item.ItemRegistryModule) WeatherTypeRegistryModule(org.lanternpowered.server.game.registry.type.world.WeatherTypeRegistryModule) ActionTypeRegistryModule(org.lanternpowered.server.script.function.action.ActionTypeRegistryModule) HorseColorRegistryModule(org.lanternpowered.server.game.registry.type.data.HorseColorRegistryModule) PortalAgentTypeRegistryModule(org.lanternpowered.server.game.registry.type.world.PortalAgentTypeRegistryModule) SpawnTypeRegistryModule(org.lanternpowered.server.game.registry.type.cause.SpawnTypeRegistryModule) SerializationBehaviorRegistryModule(org.lanternpowered.server.game.registry.type.world.SerializationBehaviorRegistryModule) HandTypeRegistryModule(org.lanternpowered.server.game.registry.type.data.HandTypeRegistryModule) ParticleOptionRegistryModule(org.lanternpowered.server.game.registry.type.effect.ParticleOptionRegistryModule) DoubleValueProviderTypeRegistryModule(org.lanternpowered.server.script.function.value.DoubleValueProviderTypeRegistryModule) EquipmentTypeRegistryModule(org.lanternpowered.server.game.registry.type.item.inventory.equipment.EquipmentTypeRegistryModule) ShrubTypeRegistryModule(org.lanternpowered.server.game.registry.type.data.ShrubTypeRegistryModule) TriggerRegistryModule(org.lanternpowered.server.game.registry.type.advancement.TriggerRegistryModule) BossBarOverlayRegistryModule(org.lanternpowered.server.game.registry.type.bossbar.BossBarOverlayRegistryModule) GoldenAppleRegistryModule(org.lanternpowered.server.game.registry.type.data.GoldenAppleRegistryModule) GameModeRegistryModule(org.lanternpowered.server.game.registry.type.entity.player.GameModeRegistryModule) SoundCategoryRegistryModule(org.lanternpowered.server.game.registry.type.effect.SoundCategoryRegistryModule) NotePitchRegistryModule(org.lanternpowered.server.game.registry.type.data.NotePitchRegistryModule) VisibilityRegistryModule(org.lanternpowered.server.game.registry.type.scoreboard.VisibilityRegistryModule) CookedFishRegistryModule(org.lanternpowered.server.game.registry.type.data.CookedFishRegistryModule) BanTypeRegistryModule(org.lanternpowered.server.game.registry.type.util.BanTypeRegistryModule) LanternFuelRegistryModule(org.lanternpowered.server.item.recipe.fuel.LanternFuelRegistryModule) CriterionRegistryModule(org.lanternpowered.server.game.registry.type.scoreboard.CriterionRegistryModule) BannerPatternShapeRegistryModule(org.lanternpowered.server.game.registry.type.data.BannerPatternShapeRegistryModule) TextStyleRegistryModule(org.lanternpowered.server.game.registry.type.text.TextStyleRegistryModule) EntityProtocolTypeRegistryModule(org.lanternpowered.server.network.entity.EntityProtocolTypeRegistryModule) HorseStyleRegistryModule(org.lanternpowered.server.game.registry.type.data.HorseStyleRegistryModule) KeyRegistryModule(org.lanternpowered.server.game.registry.type.data.KeyRegistryModule) SlabTypeRegistryModule(org.lanternpowered.server.game.registry.type.data.SlabTypeRegistryModule) DimensionTypeRegistryModule(org.lanternpowered.server.game.registry.type.world.DimensionTypeRegistryModule) DirtTypeRegistryModule(org.lanternpowered.server.game.registry.type.data.DirtTypeRegistryModule) DamageModifierTypeRegistryModule(org.lanternpowered.server.game.registry.type.cause.DamageModifierTypeRegistryModule) DataFormatRegistryModule(org.lanternpowered.server.game.registry.type.data.persistence.DataFormatRegistryModule) AttributeOperationRegistryModule(org.lanternpowered.server.game.registry.type.attribute.AttributeOperationRegistryModule) DyeColorRegistryModule(org.lanternpowered.server.game.registry.type.data.DyeColorRegistryModule) AdditionalCatalogRegistryModule(org.spongepowered.api.registry.AdditionalCatalogRegistryModule) ArgumentTypeRegistryModule(org.lanternpowered.server.game.registry.type.text.ArgumentTypeRegistryModule) ParticleTypeRegistryModule(org.lanternpowered.server.game.registry.type.effect.ParticleTypeRegistryModule) ChatTypeRegistryModule(org.lanternpowered.server.game.registry.type.text.ChatTypeRegistryModule) RegistryModule(org.spongepowered.api.registry.RegistryModule) CareerRegistryModule(org.lanternpowered.server.game.registry.type.data.CareerRegistryModule) StatisticTypeRegistryModule(org.lanternpowered.server.game.registry.type.statistic.StatisticTypeRegistryModule) ArmorTypeRegistryModule(org.lanternpowered.server.game.registry.type.data.ArmorTypeRegistryModule) ConstantDamageSourceRegistryModule(org.lanternpowered.server.game.registry.type.cause.ConstantDamageSourceRegistryModule) RecordTypeRegistryModule(org.lanternpowered.server.game.registry.type.data.RecordTypeRegistryModule) QuartzTypeRegistryModule(org.lanternpowered.server.game.registry.type.data.QuartzTypeRegistryModule) TimingsFactoryRegistryModule(org.lanternpowered.server.game.registry.factory.TimingsFactoryRegistryModule) TreeTypeRegistryModule(org.lanternpowered.server.game.registry.type.data.TreeTypeRegistryModule) ItemStackComparatorRegistryModule(org.lanternpowered.server.game.registry.type.item.ItemStackComparatorRegistryModule) TransactionTypeRegistryModule(org.lanternpowered.server.game.registry.type.economy.TransactionTypeRegistryModule) RailDirectionRegistryModule(org.lanternpowered.server.game.registry.type.data.RailDirectionRegistryModule) SelectorFactoryRegistryModule(org.lanternpowered.server.game.registry.type.text.SelectorFactoryRegistryModule) SelectorTypeRegistryModule(org.lanternpowered.server.game.registry.type.text.SelectorTypeRegistryModule) SoundTypeRegistryModule(org.lanternpowered.server.game.registry.type.effect.SoundTypeRegistryModule) RotationRegistryModule(org.lanternpowered.server.game.registry.type.util.RotationRegistryModule) AdvancementRegistryModule(org.lanternpowered.server.game.registry.type.advancement.AdvancementRegistryModule) HandPreferenceRegistryModule(org.lanternpowered.server.game.registry.type.data.HandPreferenceRegistryModule) GeneratorTypeRegistryModule(org.lanternpowered.server.game.registry.type.world.GeneratorTypeRegistryModule) FishRegistryModule(org.lanternpowered.server.game.registry.type.data.FishRegistryModule) ChatVisibilityRegistryModule(org.lanternpowered.server.game.registry.type.text.ChatVisibilityRegistryModule) GeneratorModifierRegistryModule(org.lanternpowered.server.game.registry.type.world.GeneratorModifierRegistryModule) ObjectiveDisplayModeRegistryModule(org.lanternpowered.server.game.registry.type.scoreboard.ObjectiveDisplayModeRegistryModule) ConstantHealingSourceRegistryModule(org.lanternpowered.server.game.registry.type.cause.ConstantHealingSourceRegistryModule) HealingTypeRegistryModule(org.lanternpowered.server.game.registry.type.cause.HealingTypeRegistryModule) FluidTypeRegistryModule(org.lanternpowered.server.game.registry.type.fluid.FluidTypeRegistryModule) TextFormatRegistryModule(org.lanternpowered.server.game.registry.type.text.TextFormatRegistryModule) OcelotTypeRegistryModule(org.lanternpowered.server.game.registry.type.data.OcelotTypeRegistryModule) PlantTypeRegistryModule(org.lanternpowered.server.game.registry.type.data.PlantTypeRegistryModule) CollisionRuleRegistryModule(org.lanternpowered.server.game.registry.type.scoreboard.CollisionRuleRegistryModule) TileEntityTypeRegistryModule(org.lanternpowered.server.game.registry.type.block.TileEntityTypeRegistryModule) SkullTypeRegistryModule(org.lanternpowered.server.game.registry.type.data.SkullTypeRegistryModule) TextColorRegistryModule(org.lanternpowered.server.game.registry.type.text.TextColorRegistryModule) ClientContainerRegistryModule(org.lanternpowered.server.game.registry.type.item.inventory.ClientContainerRegistryModule) AlternateCatalogRegistryModule(org.spongepowered.api.registry.AlternateCatalogRegistryModule) WorldArchetypeRegistryModule(org.lanternpowered.server.game.registry.type.world.WorldArchetypeRegistryModule) EnumValueRegistryModule(org.lanternpowered.server.game.registry.EnumValueRegistryModule) SkinPartRegistryModule(org.lanternpowered.server.game.registry.type.data.SkinPartRegistryModule) DisplaySlotRegistryModule(org.lanternpowered.server.game.registry.type.scoreboard.DisplaySlotRegistryModule) ArtRegistryModule(org.lanternpowered.server.game.registry.type.data.ArtRegistryModule) TextSerializersRegistryModule(org.lanternpowered.server.game.registry.type.text.TextSerializersRegistryModule) TranslationManagerRegistryModule(org.lanternpowered.server.game.registry.type.text.TranslationManagerRegistryModule) PickupRuleRegistryModule(org.lanternpowered.server.game.registry.type.data.PickupRuleRegistryModule) LanternSmeltingRecipeRegistryModule(org.lanternpowered.server.item.recipe.smelting.LanternSmeltingRecipeRegistryModule) DataManipulatorRegistryModule(org.lanternpowered.server.game.registry.type.data.DataManipulatorRegistryModule) ToolTypeRegistryModule(org.lanternpowered.server.game.registry.type.data.ToolTypeRegistryModule) BlockRegistryModule(org.lanternpowered.server.game.registry.type.block.BlockRegistryModule) CoalTypeRegistryModule(org.lanternpowered.server.game.registry.type.data.CoalTypeRegistryModule) StoneTypeRegistryModule(org.lanternpowered.server.game.registry.type.data.StoneTypeRegistryModule) RabbitTypeRegistryModule(org.lanternpowered.server.game.registry.type.data.RabbitTypeRegistryModule) ProfessionRegistryModule(org.lanternpowered.server.game.registry.type.data.ProfessionRegistryModule) BossBarColorRegistryModule(org.lanternpowered.server.game.registry.type.bossbar.BossBarColorRegistryModule) ContextParameterRegistryModule(org.lanternpowered.server.script.context.ContextParameterRegistryModule) AdvancementTypeRegistryModule(org.lanternpowered.server.game.registry.type.advancement.AdvancementTypeRegistryModule) DamageTypeRegistryModule(org.lanternpowered.server.game.registry.type.cause.DamageTypeRegistryModule) AttributeRegistryModule(org.lanternpowered.server.game.registry.type.attribute.AttributeRegistryModule) FloatValueProviderTypeRegistryModule(org.lanternpowered.server.script.function.value.FloatValueProviderTypeRegistryModule) BlockChangeFlagRegistryModule(org.lanternpowered.server.game.registry.type.world.BlockChangeFlagRegistryModule) StatisticRegistryModule(org.lanternpowered.server.game.registry.type.statistic.StatisticRegistryModule) AccessoryRegistryModule(org.lanternpowered.server.game.registry.type.extra.AccessoryRegistryModule) CatalogRegistryModule(org.spongepowered.api.registry.CatalogRegistryModule) LanternCraftingRecipeRegistryModule(org.lanternpowered.server.item.recipe.crafting.LanternCraftingRecipeRegistryModule) BiomeRegistryModule(org.lanternpowered.server.game.registry.type.world.biome.BiomeRegistryModule) EntityTypeRegistryModule(org.lanternpowered.server.game.registry.type.entity.EntityTypeRegistryModule) FireworkShapeRegistryModule(org.lanternpowered.server.game.registry.type.item.FireworkShapeRegistryModule) DifficultyRegistryModule(org.lanternpowered.server.game.registry.type.world.DifficultyRegistryModule) SandTypeRegistryModule(org.lanternpowered.server.game.registry.type.data.SandTypeRegistryModule) LlamaVariantRegistryModule(org.lanternpowered.server.game.registry.type.data.LlamaVariantRegistryModule) QueryOperationRegistryModule(org.lanternpowered.server.game.registry.type.item.inventory.QueryOperationRegistryModule) EnchantmentTypeRegistryModule(org.lanternpowered.server.game.registry.type.item.EnchantmentTypeRegistryModule) DefaultGameRulesRegistryModule(org.lanternpowered.server.game.registry.type.world.DefaultGameRulesRegistryModule) TeleportTypeRegistryModule(org.lanternpowered.server.game.registry.type.cause.TeleportTypeRegistryModule) AdvancementTreeRegistryModule(org.lanternpowered.server.game.registry.type.advancement.AdvancementTreeRegistryModule) DirectedGraph(org.lanternpowered.server.util.graph.DirectedGraph) CyclicGraphException(org.lanternpowered.server.util.graph.CyclicGraphException)

Aggregations

EnumValueRegistryModule (org.lanternpowered.server.game.registry.EnumValueRegistryModule)1 TimingsFactoryRegistryModule (org.lanternpowered.server.game.registry.factory.TimingsFactoryRegistryModule)1 AdvancementRegistryModule (org.lanternpowered.server.game.registry.type.advancement.AdvancementRegistryModule)1 AdvancementTreeRegistryModule (org.lanternpowered.server.game.registry.type.advancement.AdvancementTreeRegistryModule)1 AdvancementTypeRegistryModule (org.lanternpowered.server.game.registry.type.advancement.AdvancementTypeRegistryModule)1 TriggerRegistryModule (org.lanternpowered.server.game.registry.type.advancement.TriggerRegistryModule)1 AttributeOperationRegistryModule (org.lanternpowered.server.game.registry.type.attribute.AttributeOperationRegistryModule)1 AttributeRegistryModule (org.lanternpowered.server.game.registry.type.attribute.AttributeRegistryModule)1 AttributeTargetRegistryModule (org.lanternpowered.server.game.registry.type.attribute.AttributeTargetRegistryModule)1 BlockRegistryModule (org.lanternpowered.server.game.registry.type.block.BlockRegistryModule)1 BlockStateRegistryModule (org.lanternpowered.server.game.registry.type.block.BlockStateRegistryModule)1 TileEntityTypeRegistryModule (org.lanternpowered.server.game.registry.type.block.TileEntityTypeRegistryModule)1 BossBarColorRegistryModule (org.lanternpowered.server.game.registry.type.bossbar.BossBarColorRegistryModule)1 BossBarOverlayRegistryModule (org.lanternpowered.server.game.registry.type.bossbar.BossBarOverlayRegistryModule)1 ConstantDamageSourceRegistryModule (org.lanternpowered.server.game.registry.type.cause.ConstantDamageSourceRegistryModule)1 ConstantHealingSourceRegistryModule (org.lanternpowered.server.game.registry.type.cause.ConstantHealingSourceRegistryModule)1 DamageModifierTypeRegistryModule (org.lanternpowered.server.game.registry.type.cause.DamageModifierTypeRegistryModule)1 DamageTypeRegistryModule (org.lanternpowered.server.game.registry.type.cause.DamageTypeRegistryModule)1 DismountTypeRegistryModule (org.lanternpowered.server.game.registry.type.cause.DismountTypeRegistryModule)1 HealingTypeRegistryModule (org.lanternpowered.server.game.registry.type.cause.HealingTypeRegistryModule)1