use pattern variables

This commit is contained in:
dfsek
2021-11-27 08:34:03 -07:00
parent 2d316fa042
commit 2307897b31
16 changed files with 33 additions and 58 deletions

View File

@@ -34,8 +34,6 @@ public class AddonsCommand implements CommandTemplate {
@Override
public void execute(CommandSender sender) {
sender.sendMessage("Installed Addons:");
platform.getAddons().forEach(addon -> {
sender.sendMessage(" - " + addon.getID());
});
platform.getAddons().forEach(addon -> sender.sendMessage(" - " + addon.getID()));
}
}

View File

@@ -33,8 +33,7 @@ public class LinkedHashMapLoader implements TypeLoader<LinkedHashMap<Object, Obj
public LinkedHashMap<Object, Object> load(AnnotatedType t, Object c, ConfigLoader loader) throws LoadException {
Map<String, Object> config = (Map<String, Object>) c;
LinkedHashMap<Object, Object> map = new LinkedHashMap<>();
if(t instanceof AnnotatedParameterizedType) {
AnnotatedParameterizedType pType = (AnnotatedParameterizedType) t;
if(t instanceof AnnotatedParameterizedType pType) {
AnnotatedType key = pType.getAnnotatedActualTypeArguments()[0];
AnnotatedType value = pType.getAnnotatedActualTypeArguments()[1];
for(Map.Entry<String, Object> entry : config.entrySet()) {

View File

@@ -35,8 +35,7 @@ public class ProbabilityCollectionLoader implements TypeLoader<ProbabilityCollec
public ProbabilityCollection<Object> load(AnnotatedType type, Object o, ConfigLoader configLoader) throws LoadException {
ProbabilityCollection<Object> collection = new ProbabilityCollection<>();
if(type instanceof AnnotatedParameterizedType) {
AnnotatedParameterizedType pType = (AnnotatedParameterizedType) type;
if(type instanceof AnnotatedParameterizedType pType) {
AnnotatedType generic = pType.getAnnotatedActualTypeArguments()[0];
if(o instanceof Map) {
Map<Object, Integer> map = (Map<Object, Integer>) o;

View File

@@ -41,11 +41,9 @@ public class MetaListLikePreprocessor extends MetaPreprocessor<Meta> {
@SuppressWarnings("unchecked")
@Override
public @NotNull <T> Result<T> process(AnnotatedType t, T c, ConfigLoader loader, Meta annotation) {
if(t.getType() instanceof ParameterizedType) {
ParameterizedType parameterizedType = (ParameterizedType) t.getType();
if(parameterizedType.getRawType() instanceof Class) { // Should always be true but we check anyways
Class<?> baseClass = (Class<?>) parameterizedType.getRawType();
if(t.getType() instanceof ParameterizedType parameterizedType) {
if(parameterizedType.getRawType() instanceof Class<?> baseClass) { // Should always be true but we check anyways
if((List.class.isAssignableFrom(baseClass) || Set.class.isAssignableFrom(baseClass)) &&
c instanceof List) { // List or set metaconfig
List<Object> list = (List<Object>) c;

View File

@@ -44,11 +44,9 @@ public class MetaMapPreprocessor extends MetaPreprocessor<Meta> {
@SuppressWarnings("unchecked")
@Override
public @NotNull <T> Result<T> process(AnnotatedType t, T c, ConfigLoader loader, Meta annotation) {
if(t.getType() instanceof ParameterizedType) {
ParameterizedType parameterizedType = (ParameterizedType) t.getType();
if(parameterizedType.getRawType() instanceof Class) { // Should always be true but we check anyways
Class<?> baseClass = (Class<?>) parameterizedType.getRawType();
if(t.getType() instanceof ParameterizedType parameterizedType) {
if(parameterizedType.getRawType() instanceof Class<?> baseClass) { // Should always be true but we check anyways
if(Map.class.isAssignableFrom(baseClass) && c instanceof Map) { // Map metaconfig
Map<Object, Object> map = (Map<Object, Object>) c;