Search in sources :

Example 1 with CatalogRegistryModule

use of org.spongepowered.api.registry.CatalogRegistryModule in project SpongeCommon by SpongePowered.

the class SpongeGameRegistry method preRegistryInit.

public void preRegistryInit() {
    CommonModuleRegistry.getInstance().registerDefaultModules();
    final DirectedGraph<Class<? extends RegistryModule>> graph = new DirectedGraph<>();
    for (RegistryModule module : this.registryModules) {
        this.classMap.put(module.getClass(), module);
        addToGraph(module, graph);
    }
    // Now we need ot do the catalog ones
    for (CatalogRegistryModule<?> module : this.catalogRegistryMap.values()) {
        this.classMap.put(module.getClass(), module);
        addToGraph(module, graph);
    }
    try {
        this.orderedModules.addAll(TopologicalOrder.createOrderedLoad(graph));
    } catch (CyclicGraphException e) {
        StringBuilder msg = new StringBuilder();
        msg.append("Registry module dependencies are cyclical!\n");
        msg.append("Dependency loops are:\n");
        for (DataNode<?>[] cycle : e.getCycles()) {
            msg.append("[");
            for (DataNode<?> node : cycle) {
                msg.append(node.getData().toString()).append(" ");
            }
            msg.append("]\n");
        }
        SpongeImpl.getLogger().fatal(msg.toString());
        throw new RuntimeException("Registry modules dependencies error.");
    }
    registerModulePhase();
    SpongeVillagerRegistry.registerVanillaTrades();
    DataRegistrar.setupSerialization();
    final List<Tuple<Class<? extends CatalogType>, CatalogRegistryModule<?>>> modules = new ArrayList<>();
    for (Map.Entry<Class<? extends CatalogType>, CatalogRegistryModule<?>> entry : this.catalogRegistryMap.entrySet()) {
        modules.add(new Tuple<>(entry.getKey(), entry.getValue()));
    }
    modules.sort(Comparator.comparing(tuple -> tuple.getFirst().getSimpleName()));
    if (PRINT_CATALOG_TYPES) {
        // Lol... this gets spammy really fast.... Probably at some point should be put to file.
        final PrettyPrinter printer = new PrettyPrinter(100).add("Printing all Catalogs and their ID's").centre().hr().addWrapped("This is a test to print out all registered catalogs during initialization for their mapping, id's, and objects themselves.");
        for (Tuple<Class<? extends CatalogType>, CatalogRegistryModule<?>> module : modules) {
            printer.add(" %s : %s", "CatalogType", module.getFirst().getSimpleName());
            final Collection<? extends CatalogType> all = module.getSecond().getAll();
            final List<CatalogType> catalogTypes = new ArrayList<>(all);
            catalogTypes.sort(Comparator.comparing(CatalogType::getId));
            for (CatalogType catalogType : catalogTypes) {
                printer.add("  -%s", catalogType.getId());
            }
            printer.hr();
        }
        printer.trace(System.err, SpongeImpl.getLogger(), Level.DEBUG);
    }
}
Also used : DataNode(org.spongepowered.common.util.graph.DirectedGraph.DataNode) ValueFactory(org.spongepowered.api.data.value.ValueFactory) BlockStatistic(org.spongepowered.api.statistic.BlockStatistic) TextSerializerFactory(org.spongepowered.api.text.serializer.TextSerializerFactory) Level(org.apache.logging.log4j.Level) FurnaceRecipes(net.minecraft.item.crafting.FurnaceRecipes) CyclicGraphException(org.spongepowered.common.util.graph.CyclicGraphException) BookView(org.spongepowered.api.text.BookView) ExtentBufferFactory(org.spongepowered.api.world.extent.ExtentBufferFactory) Block(net.minecraft.block.Block) TextColor(org.spongepowered.api.text.format.TextColor) RegistryModuleAlreadyRegisteredException(org.spongepowered.api.registry.RegistryModuleAlreadyRegisteredException) SpongeSelectorFactory(org.spongepowered.common.text.selector.SpongeSelectorFactory) Map(java.util.Map) Path(java.nio.file.Path) SpongeTextSerializerFactory(org.spongepowered.common.text.serializer.SpongeTextSerializerFactory) ItemStatistic(org.spongepowered.api.statistic.ItemStatistic) EntityList(net.minecraft.entity.EntityList) DisplaySlotRegistryModule(org.spongepowered.common.registry.type.scoreboard.DisplaySlotRegistryModule) AITaskTypeModule(org.spongepowered.common.registry.type.entity.AITaskTypeModule) RegistryModuleLoader(org.spongepowered.common.registry.util.RegistryModuleLoader) Set(java.util.Set) DisplaySlot(org.spongepowered.api.scoreboard.displayslot.DisplaySlot) DirectedGraph(org.spongepowered.common.util.graph.DirectedGraph) AITaskType(org.spongepowered.api.entity.ai.task.AITaskType) Favicon(org.spongepowered.api.network.status.Favicon) Singleton(com.google.inject.Singleton) DataRegistration(org.spongepowered.api.data.DataRegistration) Agent(org.spongepowered.api.entity.living.Agent) PrettyPrinter(org.spongepowered.asm.util.PrettyPrinter) Supplier(java.util.function.Supplier) SpongeDataManager(org.spongepowered.common.data.SpongeDataManager) ArrayList(java.util.ArrayList) AdditionalCatalogRegistryModule(org.spongepowered.api.registry.AdditionalCatalogRegistryModule) Rotation(org.spongepowered.api.util.rotation.Rotation) Text(org.spongepowered.api.text.Text) SmeltingRecipeRegistry(org.spongepowered.api.item.recipe.smelting.SmeltingRecipeRegistry) TopologicalOrder(org.spongepowered.common.util.graph.TopologicalOrder) Nullable(javax.annotation.Nullable) StatList(net.minecraft.stats.StatList) CraftingRecipeRegistry(org.spongepowered.api.item.recipe.crafting.CraftingRecipeRegistry) IOException(java.io.IOException) Field(java.lang.reflect.Field) EntityStatistic(org.spongepowered.api.statistic.EntityStatistic) SpongeTranslation(org.spongepowered.common.text.translation.SpongeTranslation) AbstractAITask(org.spongepowered.api.entity.ai.task.AbstractAITask) ResettableBuilder(org.spongepowered.api.util.ResettableBuilder) TypeSerializers(ninja.leaping.configurate.objectmapping.serialize.TypeSerializers) ResourceLocation(net.minecraft.util.ResourceLocation) RegistryModule(org.spongepowered.api.registry.RegistryModule) PluginProvidedRegistryModule(org.spongepowered.api.registry.util.PluginProvidedRegistryModule) SpongePropertyRegistry(org.spongepowered.common.data.property.SpongePropertyRegistry) Item(net.minecraft.item.Item) ExtraClassCatalogRegistryModule(org.spongepowered.api.registry.ExtraClassCatalogRegistryModule) URL(java.net.URL) Inject(com.google.inject.Inject) DefaultGameRules(org.spongepowered.api.world.gamerule.DefaultGameRules) LocaleCache(org.spongepowered.common.util.LocaleCache) GameRegistry(org.spongepowered.api.GameRegistry) CatalogRegistryModule(org.spongepowered.api.registry.CatalogRegistryModule) Preconditions.checkArgument(com.google.common.base.Preconditions.checkArgument) RotationRegistryModule(org.spongepowered.common.registry.type.block.RotationRegistryModule) Locale(java.util.Locale) RegistrationDependency(org.spongepowered.api.registry.util.RegistrationDependency) StatisticTypes(org.spongepowered.api.statistic.StatisticTypes) BookViewDataBuilder(org.spongepowered.api.text.serializer.BookViewDataBuilder) IdentityHashMap(java.util.IdentityHashMap) BufferedImage(java.awt.image.BufferedImage) Collection(java.util.Collection) RegistrationPhase(org.spongepowered.api.registry.RegistrationPhase) CatalogType(org.spongepowered.api.CatalogType) Sponge(org.spongepowered.api.Sponge) ResourcePack(org.spongepowered.api.resourcepack.ResourcePack) Tuple(org.spongepowered.api.util.Tuple) SpongeFavicon(org.spongepowered.common.network.status.SpongeFavicon) SetSerializer(org.spongepowered.common.util.SetSerializer) SpongeGameRegistryRegisterEvent(org.spongepowered.common.event.registry.SpongeGameRegistryRegisterEvent) Cause(org.spongepowered.api.event.cause.Cause) List(java.util.List) BlockType(org.spongepowered.api.block.BlockType) Optional(java.util.Optional) EventContext(org.spongepowered.api.event.cause.EventContext) SpongeImpl(org.spongepowered.common.SpongeImpl) CatalogTypeTypeSerializer(org.spongepowered.common.config.CatalogTypeTypeSerializer) TextTemplate(org.spongepowered.api.text.TextTemplate) SpongeCraftingRecipeRegistry(org.spongepowered.common.item.recipe.crafting.SpongeCraftingRecipeRegistry) TypeToken(com.google.common.reflect.TypeToken) HashSet(java.util.HashSet) ImmutableList(com.google.common.collect.ImmutableList) TextConfigSerializer(org.spongepowered.api.text.serializer.TextConfigSerializer) VillagerRegistry(org.spongepowered.api.item.merchant.VillagerRegistry) DataRegistrar(org.spongepowered.common.data.DataRegistrar) Translation(org.spongepowered.api.text.translation.Translation) TextTemplateConfigSerializer(org.spongepowered.api.text.serializer.TextTemplateConfigSerializer) Preconditions.checkNotNull(com.google.common.base.Preconditions.checkNotNull) SpongeExtentBufferFactory(org.spongepowered.common.world.extent.SpongeExtentBufferFactory) StatisticType(org.spongepowered.api.statistic.StatisticType) SpongeValueFactory(org.spongepowered.common.data.value.SpongeValueFactory) EntityType(org.spongepowered.api.entity.EntityType) Comparator(java.util.Comparator) ItemType(org.spongepowered.api.item.ItemType) Collections(java.util.Collections) InputStream(java.io.InputStream) DisplaySlotRegistryModule(org.spongepowered.common.registry.type.scoreboard.DisplaySlotRegistryModule) AdditionalCatalogRegistryModule(org.spongepowered.api.registry.AdditionalCatalogRegistryModule) RegistryModule(org.spongepowered.api.registry.RegistryModule) PluginProvidedRegistryModule(org.spongepowered.api.registry.util.PluginProvidedRegistryModule) ExtraClassCatalogRegistryModule(org.spongepowered.api.registry.ExtraClassCatalogRegistryModule) CatalogRegistryModule(org.spongepowered.api.registry.CatalogRegistryModule) RotationRegistryModule(org.spongepowered.common.registry.type.block.RotationRegistryModule) ArrayList(java.util.ArrayList) CyclicGraphException(org.spongepowered.common.util.graph.CyclicGraphException) CatalogType(org.spongepowered.api.CatalogType) PrettyPrinter(org.spongepowered.asm.util.PrettyPrinter) AdditionalCatalogRegistryModule(org.spongepowered.api.registry.AdditionalCatalogRegistryModule) ExtraClassCatalogRegistryModule(org.spongepowered.api.registry.ExtraClassCatalogRegistryModule) CatalogRegistryModule(org.spongepowered.api.registry.CatalogRegistryModule) DirectedGraph(org.spongepowered.common.util.graph.DirectedGraph) DataNode(org.spongepowered.common.util.graph.DirectedGraph.DataNode) Map(java.util.Map) IdentityHashMap(java.util.IdentityHashMap) Tuple(org.spongepowered.api.util.Tuple)

Example 2 with CatalogRegistryModule

use of org.spongepowered.api.registry.CatalogRegistryModule 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)

Example 3 with CatalogRegistryModule

use of org.spongepowered.api.registry.CatalogRegistryModule in project SpongeCommon by SpongePowered.

the class RegistryTestUtil method generateCatalogContainerTestObjects.

static Iterable<Object[]> generateCatalogContainerTestObjects() {
    final SpongeGameRegistry registry = (SpongeGameRegistry) Sponge.getGame().getRegistry();
    final ArrayList<Object[]> objects = new ArrayList<>();
    for (Map.Entry<Class<? extends CatalogType>, CatalogRegistryModule<?>> entry : registry.catalogRegistryMap.entrySet()) {
        final Class<? extends CatalogType> key = entry.getKey();
        final CatalogedBy catalogedBy = key.getAnnotation(CatalogedBy.class);
        if (catalogedBy != null) {
            for (Class<?> containerClass : catalogedBy.value()) {
                for (Field field : containerClass.getFields()) {
                    if (Modifier.isStatic(field.getModifiers())) {
                        objects.add(new Object[] { field.getName(), entry.getKey(), containerClass, entry.getValue(), field });
                    }
                }
            }
        }
    }
    return objects;
}
Also used : Field(java.lang.reflect.Field) CatalogType(org.spongepowered.api.CatalogType) CatalogRegistryModule(org.spongepowered.api.registry.CatalogRegistryModule) CatalogedBy(org.spongepowered.api.util.annotation.CatalogedBy) ArrayList(java.util.ArrayList) Map(java.util.Map)

Example 4 with CatalogRegistryModule

use of org.spongepowered.api.registry.CatalogRegistryModule in project SpongeCommon by SpongePowered.

the class RegistryTestUtil method generateRegistryTestObjects.

static Iterable<Object[]> generateRegistryTestObjects() {
    final SpongeGameRegistry registry = (SpongeGameRegistry) Sponge.getGame().getRegistry();
    final ArrayList<Object[]> array = new ArrayList<>();
    for (Map.Entry<Class<? extends CatalogType>, CatalogRegistryModule<?>> entry : registry.catalogRegistryMap.entrySet()) {
        for (CatalogType catalogType : entry.getValue().getAll()) {
            array.add(new Object[] { entry.getKey().getSimpleName(), entry.getKey(), entry.getValue(), catalogType, catalogType.getId() });
        }
    }
    return array;
}
Also used : CatalogType(org.spongepowered.api.CatalogType) CatalogRegistryModule(org.spongepowered.api.registry.CatalogRegistryModule) ArrayList(java.util.ArrayList) Map(java.util.Map)

Example 5 with CatalogRegistryModule

use of org.spongepowered.api.registry.CatalogRegistryModule in project SpongeCommon by SpongePowered.

the class RegistryTestUtil method generateCatalogTypeMethodTestObjects.

static Iterable<Object[]> generateCatalogTypeMethodTestObjects() {
    final SpongeGameRegistry registry = (SpongeGameRegistry) Sponge.getGame().getRegistry();
    final ArrayList<Object[]> array = new ArrayList<>();
    for (Map.Entry<Class<? extends CatalogType>, CatalogRegistryModule<?>> entry : registry.catalogRegistryMap.entrySet()) {
        for (CatalogType catalogType : entry.getValue().getAll()) {
            for (Method method : getTestableApiMethods(getApplicableApiCatalogTypeInterfaces(catalogType))) {
                array.add(new Object[] { entry.getKey().getSimpleName(), entry.getKey(), catalogType, catalogType.getId(), method, method.getDeclaringClass().getSimpleName() + "#" + method.getName() + "()", catalogType.getClass().getName() });
            }
        }
    }
    return array;
}
Also used : CatalogType(org.spongepowered.api.CatalogType) CatalogRegistryModule(org.spongepowered.api.registry.CatalogRegistryModule) ArrayList(java.util.ArrayList) Method(java.lang.reflect.Method) Map(java.util.Map)

Aggregations

CatalogRegistryModule (org.spongepowered.api.registry.CatalogRegistryModule)8 Map (java.util.Map)6 CatalogType (org.spongepowered.api.CatalogType)5 AdditionalCatalogRegistryModule (org.spongepowered.api.registry.AdditionalCatalogRegistryModule)5 ArrayList (java.util.ArrayList)4 IdentityHashMap (java.util.IdentityHashMap)3 RegistryModule (org.spongepowered.api.registry.RegistryModule)3 IOException (java.io.IOException)2 Field (java.lang.reflect.Field)2 ExtraClassCatalogRegistryModule (org.spongepowered.api.registry.ExtraClassCatalogRegistryModule)2 CyclicGraphException (org.spongepowered.common.util.graph.CyclicGraphException)2 Preconditions.checkArgument (com.google.common.base.Preconditions.checkArgument)1 Preconditions.checkNotNull (com.google.common.base.Preconditions.checkNotNull)1 ImmutableList (com.google.common.collect.ImmutableList)1 TypeToken (com.google.common.reflect.TypeToken)1 Inject (com.google.inject.Inject)1 Singleton (com.google.inject.Singleton)1 BufferedImage (java.awt.image.BufferedImage)1 InputStream (java.io.InputStream)1 Method (java.lang.reflect.Method)1