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);
}
Aggregations