ConfigType#getTypeClass -> getTypeKey

This commit is contained in:
dfsek
2021-07-22 13:04:33 -07:00
parent 9359ba0c97
commit 82169f0921
10 changed files with 19 additions and 19 deletions

View File

@@ -32,7 +32,7 @@ public class BiomeConfigType implements ConfigType<BiomeTemplate, TerraBiome> {
}
@Override
public TypeKey<TerraBiome> getTypeClass() {
public TypeKey<TerraBiome> getTypeKey() {
return BIOME_TYPE_TOKEN;
}

View File

@@ -26,7 +26,7 @@ public class FeatureConfigType implements ConfigType<FeatureTemplate, Feature> {
}
@Override
public TypeKey<Feature> getTypeClass() {
public TypeKey<Feature> getTypeKey() {
return FEATURE_TYPE_KEY;
}

View File

@@ -26,7 +26,7 @@ public class FloraConfigType implements ConfigType<FloraTemplate, Flora> {
}
@Override
public TypeKey<Flora> getTypeClass() {
public TypeKey<Flora> getTypeKey() {
return FLORA_TYPE_TOKEN;
}

View File

@@ -25,7 +25,7 @@ public class OreConfigType implements ConfigType<OreTemplate, Ore> {
}
@Override
public TypeKey<Ore> getTypeClass() {
public TypeKey<Ore> getTypeKey() {
return ORE_TYPE_TOKEN;
}

View File

@@ -34,7 +34,7 @@ public class PaletteConfigType implements ConfigType<PaletteTemplate, Palette> {
}
@Override
public TypeKey<Palette> getTypeClass() {
public TypeKey<Palette> getTypeKey() {
return PALETTE_TYPE_TOKEN;
}

View File

@@ -11,7 +11,7 @@ public interface ConfigType<T extends AbstractableTemplate, R> {
ConfigFactory<T, R> getFactory();
TypeKey<R> getTypeClass();
TypeKey<R> getTypeKey();
Supplier<OpenRegistry<R>> registrySupplier(ConfigPack pack);
}

View File

@@ -51,13 +51,13 @@ public class ConfigurationLoadEvent implements PackEvent, FailThroughEvent {
}
public boolean is(Class<?> clazz) {
return clazz.isAssignableFrom(type.getTypeClass().getRawType());
return clazz.isAssignableFrom(type.getTypeKey().getRawType());
}
@SuppressWarnings("unchecked")
public <T> T getLoadedObject(Class<T> clazz) {
if(!clazz.isAssignableFrom(type.getTypeClass().getRawType()))
throw new ClassCastException("Cannot assign object from loader of type " + ReflectionUtil.typeToString(type.getTypeClass().getType()) + " to class " + clazz.getCanonicalName());
if(!clazz.isAssignableFrom(type.getTypeKey().getRawType()))
throw new ClassCastException("Cannot assign object from loader of type " + ReflectionUtil.typeToString(type.getTypeKey().getType()) + " to class " + clazz.getCanonicalName());
return (T) loaded;
}

View File

@@ -25,13 +25,13 @@ public abstract class ConfigTypeLoadEvent implements PackEvent, FailThroughEvent
}
public boolean is(Class<?> clazz) {
return clazz.isAssignableFrom(type.getTypeClass().getRawType());
return clazz.isAssignableFrom(type.getTypeKey().getRawType());
}
@SuppressWarnings("unchecked")
public <T> CheckedRegistry<T> getRegistry(Class<T> clazz) {
if(!clazz.isAssignableFrom(type.getTypeClass().getRawType()))
throw new ClassCastException("Cannot assign object from loader of type " + ReflectionUtil.typeToString(type.getTypeClass().getType()) + " to class " + clazz.getCanonicalName());
if(!clazz.isAssignableFrom(type.getTypeKey().getRawType()))
throw new ClassCastException("Cannot assign object from loader of type " + ReflectionUtil.typeToString(type.getTypeKey().getType()) + " to class " + clazz.getCanonicalName());
return (CheckedRegistry<T>) registry;
}
}

View File

@@ -199,12 +199,12 @@ public class ConfigPackImpl implements ConfigPack {
private ConfigTypeRegistry createRegistry() {
return new ConfigTypeRegistry(main, (id, configType) -> {
OpenRegistry<?> openRegistry = configType.registrySupplier(this).get();
if(registryMap.containsKey(configType.getTypeClass().getType())) { // Someone already registered something; we need to copy things to the new registry.
registryMap.get(configType.getTypeClass().getType()).getLeft().forEach(((OpenRegistry<Object>) openRegistry)::register);
if(registryMap.containsKey(configType.getTypeKey().getType())) { // Someone already registered something; we need to copy things to the new registry.
registryMap.get(configType.getTypeKey().getType()).getLeft().forEach(((OpenRegistry<Object>) openRegistry)::register);
}
selfLoader.registerLoader(configType.getTypeClass().getType(), openRegistry);
abstractConfigLoader.registerLoader(configType.getTypeClass().getType(), openRegistry);
registryMap.put(configType.getTypeClass().getType(), ImmutablePair.of(openRegistry, new CheckedRegistryImpl<>(openRegistry)));
selfLoader.registerLoader(configType.getTypeKey().getType(), openRegistry);
abstractConfigLoader.registerLoader(configType.getTypeKey().getType(), openRegistry);
registryMap.put(configType.getTypeKey().getType(), ImmutablePair.of(openRegistry, new CheckedRegistryImpl<>(openRegistry)));
});
}
@@ -265,7 +265,7 @@ public class ConfigPackImpl implements ConfigPack {
}
for(ConfigType<?, ?> configType : configTypeRegistry.entries()) { // Load the configs
CheckedRegistry registry = getCheckedRegistry(configType.getTypeClass());
CheckedRegistry registry = getCheckedRegistry(configType.getTypeKey());
main.getEventManager().callEvent(new ConfigTypePreLoadEvent(configType, registry, this));
for(AbstractConfiguration config : abstractConfigLoader.loadConfigs(configs.getOrDefault(configType, Collections.emptyList()))) {
try {

View File

@@ -22,7 +22,7 @@ public class ConfigTypeRegistry extends OpenRegistryImpl<ConfigType<?, ?>> {
@Override
public boolean register(String identifier, Entry<ConfigType<?, ?>> value) {
callback.accept(identifier, value.getValue());
main.getDebugLogger().info("Registered config registry with ID " + identifier + " to type " + ReflectionUtil.typeToString(value.getValue().getTypeClass().getType()));
main.getDebugLogger().info("Registered config registry with ID " + identifier + " to type " + ReflectionUtil.typeToString(value.getValue().getTypeKey().getType()));
return super.register(identifier, value);
}
}