Skip to content

Commit

Permalink
fixed inner class packet catalogues
Browse files Browse the repository at this point in the history
  • Loading branch information
Pesekjak committed Jun 7, 2024
1 parent 23b1d1c commit cc5196d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Group and version
group = org.machinemc.paklet
version = 1.2
version = 1.2.1

# Dependency versions
jetbrainsAnnotations = 24.1.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ private CatalogueUtils() {
* @return json catalogue
*/
public static JsonObject getCatalogueForClass(Class<?> catalogueClass, Function<String, InputStream> resourcesAccessor) {
String path = "/" + catalogueClass.getName().replace('.', '/') + "_catalogue.json";
String path = "/" + catalogueClass.getPackageName().replace('.', '/');
String fileName = catalogueClass.getCanonicalName().replace(catalogueClass.getPackageName() + ".", "");
path = path + "/" + fileName + "_catalogue.json";
try (InputStream is = resourcesAccessor.apply(path)) {
if (is == null) throw new NullPointerException("There is no catalogue data for class " + catalogueClass.getName());
return JsonParser.parseReader(new InputStreamReader(is)).getAsJsonObject();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,14 @@ public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment
catalogues: {
for (TypeMirror catalogue : data.keySet()) {
CatalogueData catalogueData = data.get(catalogue);
Element element = processingEnv.getTypeUtils().asElement(catalogue);
TypeElement element = (TypeElement) processingEnv.getTypeUtils().asElement(catalogue);
PackageElement pkg = processingEnv.getElementUtils().getPackageOf(element);
try {
String fileName = element.getQualifiedName().toString().replace(pkg.getQualifiedName() + ".", "");
FileObject file = processingEnv.getFiler().createResource(
StandardLocation.CLASS_OUTPUT,
pkg.getQualifiedName(),
element.getSimpleName() + "_catalogue.json"
fileName + "_catalogue.json"
);
try (Writer writer = new BufferedWriter(file.openWriter())) {
new Gson().toJson(catalogueData.asJSON(), writer);
Expand Down

0 comments on commit cc5196d

Please sign in to comment.