当前位置: 首页>>代码示例>>Java>>正文


Java CatalogRegistryModule类代码示例

本文整理汇总了Java中org.spongepowered.api.registry.CatalogRegistryModule的典型用法代码示例。如果您正苦于以下问题:Java CatalogRegistryModule类的具体用法?Java CatalogRegistryModule怎么用?Java CatalogRegistryModule使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


CatalogRegistryModule类属于org.spongepowered.api.registry包,在下文中一共展示了CatalogRegistryModule类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getType

import org.spongepowered.api.registry.CatalogRegistryModule; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public <T extends CatalogType> Optional<T> getType(Class<T> typeClass, String id) {
    CatalogRegistryModule<T> registryModule = this.getCatalogRegistryModule(typeClass).orElse(null);
    if (registryModule == null) {
        return Optional.empty();
    } else {
        return registryModule.getById(id.toLowerCase());
    }
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:11,代码来源:LanternGameRegistry.java

示例2: getAllOf

import org.spongepowered.api.registry.CatalogRegistryModule; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public <T extends CatalogType> Collection<T> getAllOf(Class<T> typeClass) {
    CatalogRegistryModule<T> registryModule = this.getCatalogRegistryModule(typeClass).orElse(null);
    if (registryModule == null) {
        return Collections.emptyList();
    } else {
        return registryModule.getAll();
    }
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:11,代码来源:LanternGameRegistry.java

示例3: getAllFor

import org.spongepowered.api.registry.CatalogRegistryModule; //导入依赖的package包/类
@Override
public <T extends CatalogType> Collection<T> getAllFor(String pluginId, Class<T> typeClass) {
    checkNotNull(pluginId);
    final CatalogRegistryModule<T> registryModule = getCatalogRegistryModule(typeClass).orElse(null);
    if (registryModule == null) {
        return Collections.emptyList();
    } else {
        return registryModule.getAll().stream()
                .filter(type -> pluginId.equals(getPluginId(type)))
                .collect(ImmutableList.toImmutableList());
    }
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:13,代码来源:LanternGameRegistry.java

示例4: registerModule

import org.spongepowered.api.registry.CatalogRegistryModule; //导入依赖的package包/类
@Override
public <T extends CatalogType> LanternGameRegistry registerModule(Class<T> catalogClass, CatalogRegistryModule<T> registryModule)
        throws IllegalArgumentException, UnsupportedOperationException {
    checkArgument(!this.catalogRegistryMap.containsKey(catalogClass), "Already registered a registry module!");
    this.catalogRegistryMap.put(catalogClass, registryModule);
    if (this.phase != null && this.phase != RegistrationPhase.PRE_REGISTRY && catalogClass.getName().contains("org.spongepowered.api")) {
        throw new UnsupportedOperationException("Cannot register a module for an API defined class! That's the implementation's job!");
    }
    this.modulesSynced = false;
    return this;
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:12,代码来源:LanternGameRegistry.java

示例5: registerModulePhase

import org.spongepowered.api.registry.CatalogRegistryModule; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private void registerModulePhase() {
    syncModules();
    for (Class<? extends RegistryModule> moduleClass : this.orderedModules) {
        if (!this.classMap.containsKey(moduleClass)) {
            throw new IllegalStateException("Something funky happened! The module "
                    + moduleClass + " is required but seems to be missing.");
        }
        tryModulePhaseRegistration(this.classMap.get(moduleClass));
        if (this.phase == RegistrationPhase.INIT) {
            Map.Entry<Class<? extends CatalogType>, CatalogRegistryModule<?>> selectedEntry = null;
            for (Map.Entry<Class<? extends CatalogType>, CatalogRegistryModule<?>> entry : this.catalogRegistryMap.entrySet()) {
                if (entry.getValue().getClass() == moduleClass) {
                    selectedEntry = entry;
                    break;
                }
            }
            if (selectedEntry == null) {
                continue;
            }
            final CatalogRegistryModule module = selectedEntry.getValue();
            if (module instanceof AdditionalCatalogRegistryModule &&
                    module.getClass().getAnnotation(CustomRegistrationPhase.class) == null) {
                this.game.getEventManager().post(new LanternGameRegistryRegisterEvent(CauseStack.current().getCurrentCause(),
                        selectedEntry.getKey(), (AdditionalCatalogRegistryModule) module));
            }
        }
    }
    registerAdditionalPhase();
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:31,代码来源:LanternGameRegistry.java

示例6: getRegistryModule

import org.spongepowered.api.registry.CatalogRegistryModule; //导入依赖的package包/类
@Override
public CatalogRegistryModule<T> getRegistryModule() {
    return this.registryModule;
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:5,代码来源:LanternGameRegistryRegisterEvent.java

示例7: getCatalogRegistryModule

import org.spongepowered.api.registry.CatalogRegistryModule; //导入依赖的package包/类
/**
 * Gets the {@link RegistryModule} for the specified class type.
 *
 * @param catalogType the catalog type
 * @param <T> the type of the registry module
 * @return the registry module if found, otherwise {@link Optional#empty()}
 */
public <T extends CatalogType> Optional<CatalogRegistryModule<T>> getCatalogRegistryModule(Class<T> catalogType) {
    return Optional.ofNullable((CatalogRegistryModule) this.catalogRegistryMap.get(catalogType));
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:11,代码来源:LanternGameRegistry.java


注:本文中的org.spongepowered.api.registry.CatalogRegistryModule类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。