mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-04-05 07:16:10 +00:00
Registry#add -> #register
This commit is contained in:
@@ -7,7 +7,7 @@ public interface CheckedRegistry<T> extends Registry<T> {
|
||||
* Add a value to this registry, checking whether it is present first.
|
||||
*
|
||||
* @param identifier Identifier to assign value.
|
||||
* @param value Value to add.
|
||||
* @param value Value to register.
|
||||
* @throws DuplicateEntryException If an entry with the same identifier is already present.
|
||||
*/
|
||||
void add(String identifier, T value) throws DuplicateEntryException;
|
||||
@@ -18,7 +18,7 @@ public interface CheckedRegistry<T> extends Registry<T> {
|
||||
* Use of this method is generally discouraged, as it is bad practice to overwrite registry values.
|
||||
*
|
||||
* @param identifier Identifier to assign value.
|
||||
* @param value Value to add.
|
||||
* @param value Value to register.
|
||||
* @deprecated Use of {@link #add(String, Object)} is encouraged.
|
||||
*/
|
||||
@Deprecated
|
||||
|
||||
@@ -7,15 +7,15 @@ public interface OpenRegistry<T> extends Registry<T> {
|
||||
* Add a value to this registry.
|
||||
*
|
||||
* @param identifier Identifier to assign value.
|
||||
* @param value Value to add.
|
||||
* @param value Value to register.
|
||||
*/
|
||||
boolean add(String identifier, T value);
|
||||
boolean register(String identifier, T value);
|
||||
|
||||
/**
|
||||
* Add a value to this registry, checking whether it is present first.
|
||||
*
|
||||
* @param identifier Identifier to assign value.
|
||||
* @param value Value to add.
|
||||
* @param value Value to register.
|
||||
* @throws DuplicateEntryException If an entry with the same identifier is already present.
|
||||
*/
|
||||
void addChecked(String identifier, T value) throws DuplicateEntryException;
|
||||
|
||||
@@ -30,7 +30,6 @@ import com.dfsek.terra.api.util.generic.pair.ImmutablePair;
|
||||
import com.dfsek.terra.api.util.seeded.NoiseProvider;
|
||||
import com.dfsek.terra.api.world.TerraWorld;
|
||||
import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
|
||||
import com.dfsek.terra.config.GenericLoaders;
|
||||
import com.dfsek.terra.config.dummy.DummyWorld;
|
||||
import com.dfsek.terra.config.fileloaders.FolderLoader;
|
||||
import com.dfsek.terra.config.fileloaders.ZIPLoader;
|
||||
@@ -231,7 +230,7 @@ public class ConfigPackImpl implements ConfigPack {
|
||||
|
||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
private void load(long start, TerraPlugin main) throws ConfigException {
|
||||
configTypes.values().forEach(list -> list.forEach(pair -> configTypeRegistry.add(pair.getLeft(), pair.getRight())));
|
||||
configTypes.values().forEach(list -> list.forEach(pair -> configTypeRegistry.register(pair.getLeft(), pair.getRight())));
|
||||
|
||||
for(Map.Entry<String, Double> var : template.getVariables().entrySet()) {
|
||||
varScope.create(var.getKey(), var.getValue());
|
||||
|
||||
@@ -34,7 +34,7 @@ public class WorldConfigImpl implements WorldConfig {
|
||||
pack.getRegistryMap().forEach((clazz, pair) -> registryMap.put(clazz, new LockedRegistryImpl<>(pair.getLeft())));
|
||||
|
||||
OpenRegistry<TerraBiome> biomeOpenRegistry = new OpenRegistryImpl<>();
|
||||
pack.getRegistry(BiomeBuilder.class).forEach((id, biome) -> biomeOpenRegistry.add(id, biome.apply(world.getWorld().getSeed())));
|
||||
pack.getRegistry(BiomeBuilder.class).forEach((id, biome) -> biomeOpenRegistry.register(id, biome.apply(world.getWorld().getSeed())));
|
||||
registryMap.put(TerraBiome.class, new LockedRegistryImpl<>(biomeOpenRegistry));
|
||||
|
||||
this.provider = pack.getBiomeProviderBuilder().build(world.getWorld().getSeed());
|
||||
|
||||
@@ -32,7 +32,7 @@ public class CheckedRegistryImpl<T> implements CheckedRegistry<T> {
|
||||
@Override
|
||||
@Deprecated
|
||||
public void addUnchecked(String identifier, T value) {
|
||||
registry.add(identifier, value);
|
||||
registry.register(identifier, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -41,7 +41,7 @@ public class OpenRegistryImpl<T> implements OpenRegistry<T> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean add(String identifier, T value) {
|
||||
public boolean register(String identifier, T value) {
|
||||
return add(identifier, new Entry<>(value));
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ public class OpenRegistryImpl<T> implements OpenRegistry<T> {
|
||||
public void addChecked(String identifier, T value) throws DuplicateEntryException {
|
||||
if(objects.containsKey(identifier))
|
||||
throw new DuplicateEntryException("Value with identifier \"" + identifier + "\" is already defined in registry.");
|
||||
add(identifier, value);
|
||||
register(identifier, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -27,15 +27,15 @@ public class AddonRegistry extends OpenRegistryImpl<TerraAddon> {
|
||||
|
||||
public AddonRegistry(TerraAddon addon, TerraPlugin main) {
|
||||
this.main = main;
|
||||
add(addon.getName(), addon);
|
||||
register(addon.getName(), addon);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean add(String identifier, TerraAddon addon) {
|
||||
public boolean register(String identifier, TerraAddon addon) {
|
||||
if(contains(identifier)) throw new IllegalArgumentException("Addon " + identifier + " is already registered.");
|
||||
addon.initialize();
|
||||
main.logger().info("Loaded com.dfsek.terra.addon " + addon.getName() + " v" + addon.getVersion() + ", by " + addon.getAuthor());
|
||||
return super.add(identifier, addon);
|
||||
return super.register(identifier, addon);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -16,7 +16,7 @@ import java.util.zip.ZipFile;
|
||||
public class ConfigRegistry extends OpenRegistryImpl<ConfigPack> {
|
||||
public void load(File folder, TerraPlugin main) throws ConfigException {
|
||||
ConfigPack pack = new ConfigPackImpl(folder, main);
|
||||
add(pack.getID(), pack);
|
||||
register(pack.getID(), pack);
|
||||
}
|
||||
|
||||
public boolean loadAll(TerraPlugin main) {
|
||||
@@ -45,6 +45,6 @@ public class ConfigRegistry extends OpenRegistryImpl<ConfigPack> {
|
||||
|
||||
public void load(ZipFile file, TerraPlugin main) throws ConfigException {
|
||||
ConfigPackImpl pack = new ConfigPackImpl(file, main);
|
||||
add(pack.getTemplate().getID(), pack);
|
||||
register(pack.getTemplate().getID(), pack);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user