Search in sources :

Example 1 with SpongePortalAgentType

use of org.spongepowered.common.world.SpongePortalAgentType in project SpongeCommon by SpongePowered.

the class PortalAgentRegistryModule method validatePortalAgent.

@SuppressWarnings("unchecked")
public PortalAgentType validatePortalAgent(Class<? extends Teleporter> clazz) {
    PortalAgentType portalAgentType = this.portalAgentClassToTypeMappings.get(clazz);
    if (portalAgentType != null) {
        return portalAgentType;
    }
    String modId = SpongeImplHooks.getModIdFromClass(clazz);
    if (modId.isEmpty()) {
        return PortalAgentTypes.DEFAULT;
    }
    // used for mods only as plugins register in PreInit
    String teleporterName = clazz.getSimpleName().toLowerCase(Locale.ENGLISH);
    String id = modId.toLowerCase(Locale.ENGLISH) + ":" + teleporterName;
    if (this.portalAgentTypeMappings.get(id) == null) {
        portalAgentType = new SpongePortalAgentType(teleporterName, id, clazz);
        this.portalAgentTypeMappings.put(id, portalAgentType);
        this.portalAgentClassToTypeMappings.put((Class<? extends PortalAgent>) clazz, portalAgentType);
    }
    return this.portalAgentTypeMappings.get(id);
}
Also used : SpongePortalAgentType(org.spongepowered.common.world.SpongePortalAgentType) PortalAgentType(org.spongepowered.api.world.PortalAgentType) SpongePortalAgentType(org.spongepowered.common.world.SpongePortalAgentType)

Aggregations

PortalAgentType (org.spongepowered.api.world.PortalAgentType)1 SpongePortalAgentType (org.spongepowered.common.world.SpongePortalAgentType)1