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