mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-06-15 21:31:05 +00:00
getFromID -> getByID
This commit is contained in:
+1
-1
@@ -24,7 +24,7 @@ public class BiomeDelegateLoader implements TypeLoader<BiomeDelegate> {
|
||||
public BiomeDelegate load(@NotNull AnnotatedType t, @NotNull Object c, @NotNull ConfigLoader loader) throws LoadException {
|
||||
if(c.equals("SELF")) return BiomeDelegate.self();
|
||||
return biomeRegistry
|
||||
.getFromID((String) c)
|
||||
.getByID((String) c)
|
||||
.map(BiomeDelegate::from)
|
||||
.orElseGet(() -> BiomeDelegate.ephemeral((String) c));
|
||||
}
|
||||
|
||||
+1
-1
@@ -68,7 +68,7 @@ public class StructureFunction implements Function<Boolean> {
|
||||
|
||||
|
||||
String app = id.apply(implementationArguments, variableMap);
|
||||
return registry.getFromID(app).map(script -> {
|
||||
return registry.getByID(app).map(script -> {
|
||||
Rotation rotation1;
|
||||
String rotString = rotations.get(arguments.getRandom().nextInt(rotations.size())).apply(implementationArguments, variableMap);
|
||||
try {
|
||||
|
||||
@@ -79,8 +79,8 @@ public interface Registry<T> extends TypeLoader<T> {
|
||||
|
||||
TypeKey<T> getType();
|
||||
|
||||
default Optional<T> getFromID(String id) {
|
||||
return getFromID(id, map -> {
|
||||
default Optional<T> getByID(String id) {
|
||||
return getByID(id, map -> {
|
||||
if(map.isEmpty()) return Optional.empty();
|
||||
if(map.size() == 1) {
|
||||
return map.values().stream().findFirst(); // only one value.
|
||||
@@ -93,12 +93,12 @@ public interface Registry<T> extends TypeLoader<T> {
|
||||
});
|
||||
}
|
||||
|
||||
Map<RegistryKey, T> getIDMatches(String id);
|
||||
Map<RegistryKey, T> getMatches(String id);
|
||||
|
||||
default Optional<T> getFromID(String attempt, Function<Map<RegistryKey, T>, Optional<T>> reduction) {
|
||||
default Optional<T> getByID(String attempt, Function<Map<RegistryKey, T>, Optional<T>> reduction) {
|
||||
if(attempt.contains(":")) {
|
||||
return get(RegistryKey.parse(attempt));
|
||||
}
|
||||
return reduction.apply(getIDMatches(attempt));
|
||||
return reduction.apply(getMatches(attempt));
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -46,7 +46,7 @@ public class GenericTemplateSupplierLoader<T> implements TypeLoader<T> {
|
||||
Map<String, Object> map = (Map<String, Object>) c;
|
||||
try {
|
||||
return loader
|
||||
.load(registry.getFromID(((String) map.get("type")))
|
||||
.load(registry.getByID(((String) map.get("type")))
|
||||
.orElseThrow(() -> new LoadException("No such entry: " + map.get("type")))
|
||||
.get(), new MapConfiguration(map)).get();
|
||||
} catch(ConfigException e) {
|
||||
|
||||
+2
-2
@@ -97,8 +97,8 @@ public class CheckedRegistryImpl<T> implements CheckedRegistry<T> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<RegistryKey, T> getIDMatches(String id) {
|
||||
return registry.getIDMatches(id);
|
||||
public Map<RegistryKey, T> getMatches(String id) {
|
||||
return registry.getMatches(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+2
-2
@@ -84,8 +84,8 @@ public class LockedRegistryImpl<T> implements Registry<T> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<RegistryKey, T> getIDMatches(String id) {
|
||||
return registry.getIDMatches(id);
|
||||
public Map<RegistryKey, T> getMatches(String id) {
|
||||
return registry.getMatches(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+4
-4
@@ -66,9 +66,9 @@ public class OpenRegistryImpl<T> implements OpenRegistry<T> {
|
||||
|
||||
@Override
|
||||
public T load(@NotNull AnnotatedType type, @NotNull Object o, @NotNull ConfigLoader configLoader) throws LoadException {
|
||||
return getFromID((String) o).orElseThrow(() -> new LoadException("No such " + type.getType().getTypeName() + " matching \"" + o +
|
||||
"\" was found in this registry. Registry contains items: " +
|
||||
getItemsFormatted()));
|
||||
return getByID((String) o).orElseThrow(() -> new LoadException("No such " + type.getType().getTypeName() + " matching \"" + o +
|
||||
"\" was found in this registry. Registry contains items: " +
|
||||
getItemsFormatted()));
|
||||
}
|
||||
|
||||
private String getItemsFormatted() {
|
||||
@@ -144,7 +144,7 @@ public class OpenRegistryImpl<T> implements OpenRegistry<T> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<RegistryKey, T> getIDMatches(String id) {
|
||||
public Map<RegistryKey, T> getMatches(String id) {
|
||||
return objectIDs
|
||||
.get(id)
|
||||
.stream()
|
||||
|
||||
Reference in New Issue
Block a user