mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-04-09 17:26:07 +00:00
MetaNumberPreprocessor fixes
This commit is contained in:
@@ -12,10 +12,11 @@ import com.dfsek.terra.api.util.reflection.TypeKey;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.lang.reflect.AnnotatedType;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
|
||||
public class MetaNumberPreprocessor extends MetaPreprocessor<Meta> {
|
||||
public static final TypeKey<@Meta String> META_STRING_KEY = new TypeKey<>() {};
|
||||
public static final TypeKey<String> META_STRING_KEY = new TypeKey<@Meta String>() {};
|
||||
|
||||
public MetaNumberPreprocessor(Map<String, Configuration> configs) {
|
||||
super(configs);
|
||||
|
||||
@@ -24,10 +24,10 @@ public class MetaStringPreprocessor extends MetaPreprocessor<Meta> {
|
||||
String candidate = (String) c;
|
||||
StringSubstitutor substitutor = new StringSubstitutor(key -> {
|
||||
Object meta = getMetaValue(key);
|
||||
if(!(meta instanceof String)) {
|
||||
throw new LoadException("MetaString template injection candidate must be string, is type " + meta.getClass().getCanonicalName());
|
||||
if(!(meta instanceof String) && !(meta instanceof Number) && !(meta instanceof Character) && !(meta instanceof Boolean)) {
|
||||
throw new LoadException("MetaString template injection candidate must be string or primitive, is type " + meta.getClass().getCanonicalName());
|
||||
}
|
||||
return (String) meta;
|
||||
return meta.toString();
|
||||
});
|
||||
return (Result<T>) Result.overwrite(substitutor.replace(candidate));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user