|
1 | 1 | package io.papermc.generator.types.registry; |
2 | 2 |
|
| 3 | +import com.squareup.javapoet.ClassName; |
3 | 4 | import com.squareup.javapoet.FieldSpec; |
4 | 5 | import com.squareup.javapoet.JavaFile; |
5 | 6 | import com.squareup.javapoet.MethodSpec; |
6 | 7 | import com.squareup.javapoet.ParameterSpec; |
7 | 8 | import com.squareup.javapoet.ParameterizedTypeName; |
8 | 9 | import com.squareup.javapoet.TypeName; |
9 | 10 | import com.squareup.javapoet.TypeSpec; |
| 11 | +import com.squareup.javapoet.WildcardTypeName; |
10 | 12 | import io.papermc.generator.Main; |
11 | 13 | import io.papermc.generator.registry.RegistryEntry; |
12 | 14 | import io.papermc.generator.types.SimpleGenerator; |
@@ -67,7 +69,17 @@ private TypeSpec.Builder keyHolderType() { |
67 | 69 |
|
68 | 70 | @Override |
69 | 71 | protected TypeSpec getTypeSpec() { |
70 | | - TypeName tagKeyType = ParameterizedTypeName.get(TagKey.class, this.entry.apiClass()); |
| 72 | + final TypeName apiType; |
| 73 | + if (this.entry.genericArgCount() > 0) { |
| 74 | + final TypeName[] args = new TypeName[this.entry.genericArgCount()]; |
| 75 | + for (int i = 0; i < args.length; i++) { |
| 76 | + args[i] = WildcardTypeName.subtypeOf(Object.class); |
| 77 | + } |
| 78 | + apiType = ParameterizedTypeName.get(ClassName.get(this.entry.apiClass()), args); |
| 79 | + } else { |
| 80 | + apiType = ClassName.get(this.entry.apiClass()); |
| 81 | + } |
| 82 | + TypeName tagKeyType = ParameterizedTypeName.get(ClassName.get(TagKey.class), apiType); |
71 | 83 |
|
72 | 84 | TypeSpec.Builder typeBuilder = this.keyHolderType(); |
73 | 85 | MethodSpec.Builder createMethod = this.createMethod(tagKeyType); |
|
0 commit comments