diff --git a/.github/workflows/build-nms.yml b/.github/workflows/build-nms.yml deleted file mode 100644 index 444a56f26..000000000 --- a/.github/workflows/build-nms.yml +++ /dev/null @@ -1,103 +0,0 @@ -name: Build NMS with NMSAction -on: - workflow_call: - secrets: - token: - required: true - -jobs: - check-whether-has-to-build: - name: Check whether has to build - runs-on: ubuntu-latest - outputs: - cache-hit: ${{ steps.check.outputs.cache-hit }} - steps: - - name: Check whether has to build - id: check - uses: actions/cache@v4 - with: - lookup-only: true - path: nms-build/.m2 - key: nms-maven - restore-keys: nms-maven - - name: Debug Cache Hit - run: "echo Cache hit: ${{ steps.check.outputs.cache-hit }}, ${{ steps.check.outputs.cache-hit == 'true'}}" - build-nms: - name: Build NMS with NMSAction - needs: check-whether-has-to-build - if: needs.check-whether-has-to-build.outputs.cache-hit != 'true' - strategy: - matrix: - nms-version: - - 1.17.1 # v1_17_R1 - - 1.16.5 # v1_16_R3 - - 1.16.3 # v1_16_R2 - - 1.16.1 # v1_16_R1 - - 1.15.2 # v1_15_R1 - - 1.14.4 # v1_14_R1 - - 1.13.2 # v1_13_R2 - - "1.13" # v1_13_R1 - runs-on: ubuntu-latest - steps: - - name: Cache NMS - id: cache-nms-per-version - uses: actions/cache@v4 - with: - path: nms-build/.m2 - key: nms-maven-${{ matrix.nms-version }} - lookup-only: true - - name: Build NMS if cache miss - if: steps.cache-nms-per-version.outputs.cache-hit != 'true' - uses: PeyaPeyaPeyang/nmsaction@v9 - with: - rev: ${{ matrix.nms-version }} - collect-to-one-artifact: - name: Collect to one artifact - runs-on: ubuntu-latest - needs: build-nms - if: needs.check-whether-has-to-build.outputs.cache-hit != 'true' - steps: - - uses: actions/setup-node@v4 - with: - node-version: '20.x' - - run: npm install @actions/cache @actions/github - - uses: actions/github-script@v7 - with: - script: | - const cache = require('@actions/cache'); - const gh = require('@actions/github'); - const path = require('path'); - const nmsVersions = [ - '1.17.1', - '1.16.5', - '1.16.3', - '1.16.1', - '1.15.2', - '1.14.4', - '1.13.2', - '1.13' - ]; - - const octokit = gh.getOctokit(process.env.GITHUB_TOKEN); - - for (const nmsVersion of nmsVersions) { - const key = `nms-maven-${nmsVersion}`; - const cacheKey = await cache.restoreCache( - ['nms-build/.m2'], - key, - nmsVersions - ); - if (cacheKey) { - console.log(`Cache restored from key: ${cacheKey}`); - } else { - console.error(`Cache not found for key: ${key}`); - process.exit(1); - } - } - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Save caches - uses: actions/cache/save@v4 - with: - path: nms-build/.m2 - key: nms-maven diff --git a/.github/workflows/build-scenamatica.yml b/.github/workflows/build-scenamatica.yml index a0d697338..52b1123df 100644 --- a/.github/workflows/build-scenamatica.yml +++ b/.github/workflows/build-scenamatica.yml @@ -13,27 +13,54 @@ jobs: - uses: actions/checkout@v4 - name: Change directory to scenamatica run: cd Scenamatica - - name: Set up JDK 17 + - name: Set up JDK 22 uses: actions/setup-java@v4 - id: maven-cache with: - java-version: 17 + java-version: 22 distribution: zulu - cache: maven - name: Set up Maven uses: stCarolas/setup-maven@v5 with: maven-version: 3.8.2 - - name: Restore NMS cache - uses: actions/cache@v4 +##### NMS 以外のキャッシュを利かせる ##### + - name: Try to restore cache + uses: actions/cache/restore@v4 + id: restore-cache with: - path: nms-build/.m2 - key: nms-maven - restore-keys: nms-maven - - name: Deploy NMS cache - if: steps.maven-cache.outputs.cache-hit != 'true' + key: maven-cache-${{ hashFiles('**/pom.xml') }} + path: ~/.m2/repository + enableCrossOsArchive: true + - name: Collect dependencies without NMS + if: steps.restore-cache.outputs.cache-hit != 'true' run: | - mv -f nms-build/.m2/repository/repository $HOME/.m2/ -v + mvn dependency:go-offline -f Scenamatica/pom.xml + mvn dependency:go-offline -f Bookkeeper/pom.xml + # 失敗することが前提なので↓ + continue-on-error: true + - name: Cache dependencies without NMS + if: steps.restore-cache.outputs.cache-hit != 'true' + uses: actions/cache/save@v4 + id: cache-dependencies + with: + key: maven-cache-${{ hashFiles('**/pom.xml') }} + path: ~/.m2/repository + enableCrossOsArchive: true +##### おわり of NMS 以外のキャッシュを利かせる ##### + - name: Deploy NMS + uses: TeamKun/NMSAccess@v2 + with: + access-token: ${{ secrets.token }} + versions: | + 1.18.1 # v1_18_R1 + 1.18.1 # v1_18_R1 + 1.17.1 # v1_17_R1 + 1.16.5 # v1_16_R3 + 1.16.3 # v1_16_R2 + 1.16.1 # v1_16_R1 + 1.15.2 # v1_15_R1 + 1.14.4 # v1_14_R1 + 1.13.2 # v1_13_R2 + 1.13 # v1_13_R1 - name: Build with Maven run: | cd Scenamatica diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 31998e1f9..ab706a484 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -12,10 +12,6 @@ name: "CodeQL" on: - push: - branches: [main, develop] - paths: - - "Scenamatica/**" pull_request: # The branches below must be a subset of the branches above branches: [develop] @@ -26,45 +22,65 @@ on: workflow_dispatch: jobs: - setup-nms: - name: Setup NMS - uses: "./.github/workflows/build-nms.yml" - secrets: - token: ${{ secrets.GITHUB_TOKEN }} build-and-analyze: name: Build with Maven runs-on: ubuntu-latest - needs: setup-nms steps: - uses: actions/checkout@v4 - name: Change directory to scenamatica run: cd Scenamatica - - name: Set up JDK 8 + - name: Set up JDK 22 uses: actions/setup-java@v4 id: maven-cache with: - java-version: 8 + java-version: 22 distribution: zulu - cache: maven - name: Set up Maven uses: stCarolas/setup-maven@v5 with: maven-version: 3.8.2 - - name: Restore NMS cache - uses: actions/cache@v4 - with: - path: nms-build/.m2 - key: nms-maven - restore-keys: nms-maven - - name: Deploy NMS cache - if: steps.maven-cache.outputs.cache-hit != 'true' - run: | - mv -f nms-build/.m2/repository $HOME/.m2/ -v # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL uses: github/codeql-action/init@v3 with: languages: java +##### NMS 以外のキャッシュを利かせる ##### + - name: Try to restore cache + uses: actions/cache/restore@v4 + id: restore-cache + with: + key: maven-cache-${{ hashFiles('**/pom.xml') }} + path: ~/.m2/repository + enableCrossOsArchive: true + - name: Collect dependencies without NMS + if: steps.restore-cache.outputs.cache-hit != 'true' + run: | + mvn dependency:go-offline -f Scenamatica/pom.xml + mvn dependency:go-offline -f Bookkeeper/pom.xml + # 失敗することが前提なので↓ + continue-on-error: true + - name: Cache dependencies without NMS + if: steps.restore-cache.outputs.cache-hit != 'true' + uses: actions/cache/save@v4 + id: cache-dependencies + with: + key: maven-cache-${{ hashFiles('**/pom.xml') }} + path: ~/.m2/repository + enableCrossOsArchive: true +##### おわり of NMS 以外のキャッシュを利かせる ##### + - name: Deploy NMS + uses: TeamKun/NMSAccess@v2 + with: + access-token: ${{ secrets.token }} + versions: | + 1.17.1 # v1_17_R1 + 1.16.5 # v1_16_R3 + 1.16.3 # v1_16_R2 + 1.16.1 # v1_16_R1 + 1.15.2 # v1_15_R1 + 1.14.4 # v1_14_R1 + 1.13.2 # v1_13_R2 + 1.13 # v1_13_R1 - name: Build with Maven run: | cd Scenamatica diff --git a/.github/workflows/docs-deploy.yml b/.github/workflows/docs-deploy.yml index cf467d115..bac8e0019 100644 --- a/.github/workflows/docs-deploy.yml +++ b/.github/workflows/docs-deploy.yml @@ -53,11 +53,11 @@ jobs: uses: pnpm/action-setup@v3 with: package_json_file: docs/package.json - - name: Set up JDK 11 + - name: Set up JDK 17 uses: actions/setup-java@v4 id: maven-cache with: - java-version: 11 + java-version: 17 distribution: zulu cache: maven - name: Set up Maven diff --git a/.github/workflows/scenamatica-build-and-test.yml b/.github/workflows/scenamatica-build-and-test.yml index 80c7ebda5..6c76aaeee 100644 --- a/.github/workflows/scenamatica-build-and-test.yml +++ b/.github/workflows/scenamatica-build-and-test.yml @@ -15,17 +15,11 @@ concurrency: group: ${{ github.workflow }}-scenamatica-${{ github.ref }} cancel-in-progress: true jobs: - setup-nms: - name: Setup NMS - uses: "./.github/workflows/build-nms.yml" - secrets: - token: ${{ secrets.GITHUB_TOKEN }} build: name: Build with Maven - needs: setup-nms uses: "./.github/workflows/build-scenamatica.yml" secrets: - token: ${{ secrets.GITHUB_TOKEN }} + token: ${{ secrets.GH_PAT }} self-tests: name: Self-test with Scenamatica runs-on: ubuntu-latest diff --git a/Bookkeeper/annotations/src/main/java/org/kunlab/scenamatica/bookkeeper/annotations/TypeDoc.java b/Bookkeeper/annotations/src/main/java/org/kunlab/scenamatica/bookkeeper/annotations/TypeDoc.java index 7d5afc741..7284dc0c4 100644 --- a/Bookkeeper/annotations/src/main/java/org/kunlab/scenamatica/bookkeeper/annotations/TypeDoc.java +++ b/Bookkeeper/annotations/src/main/java/org/kunlab/scenamatica/bookkeeper/annotations/TypeDoc.java @@ -53,6 +53,7 @@ * * @return サポートする Minecraft バージョンの終了バージョン */ + @Nullable MCVersion supportsUntil() default MCVersion.UNSET; /** diff --git a/Bookkeeper/annotations/src/main/java/org/kunlab/scenamatica/bookkeeper/annotations/TypeProperty.java b/Bookkeeper/annotations/src/main/java/org/kunlab/scenamatica/bookkeeper/annotations/TypeProperty.java index 88ceb1273..15eb41736 100644 --- a/Bookkeeper/annotations/src/main/java/org/kunlab/scenamatica/bookkeeper/annotations/TypeProperty.java +++ b/Bookkeeper/annotations/src/main/java/org/kunlab/scenamatica/bookkeeper/annotations/TypeProperty.java @@ -1,6 +1,8 @@ package org.kunlab.scenamatica.bookkeeper.annotations; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.kunlab.scenamatica.bookkeeper.enums.MCVersion; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; @@ -78,6 +80,22 @@ */ double min() default Integer.MIN_VALUE; + /** + * サポートする Minecraft バージョンの開始バージョンを返します。 + * + * @return サポートする Minecraft バージョンの開始バージョン + */ + @Nullable + MCVersion supportsSince() default MCVersion.UNSET; + + /** + * サポートする Minecraft バージョンの終了バージョンを返します。 + * + * @return サポートする Minecraft バージョンの終了バージョン + */ + @Nullable + MCVersion supportsUntil() default MCVersion.UNSET; + /** * 型プロパティのアドモ二ションを取得します。 * diff --git a/Bookkeeper/core/src/main/java/org/kunlab/scenamatica/bookkeeper/compiler/TypeCompiler.java b/Bookkeeper/core/src/main/java/org/kunlab/scenamatica/bookkeeper/compiler/TypeCompiler.java index b67adc625..4fd5f1298 100644 --- a/Bookkeeper/core/src/main/java/org/kunlab/scenamatica/bookkeeper/compiler/TypeCompiler.java +++ b/Bookkeeper/core/src/main/java/org/kunlab/scenamatica/bookkeeper/compiler/TypeCompiler.java @@ -121,7 +121,9 @@ protected TypeReference doCompile(TypeDefinition definition) definition.getClazz().name, definition.getMappingOf() != null ? definition.getMappingOf().getClassName().replace('.', '/'): null, compileProperties(definition.getProperties(), parentCompiled), - admonitions.toArray(new GenericAdmonition[0]) + admonitions.toArray(new GenericAdmonition[0]), + definition.getSupportsSince(), + definition.getSupportsUntil() ) ); } @@ -159,7 +161,9 @@ private Map compileProperties(TypePropertyDefinit property.getMin(), property.getMax(), property.getDefaultValue(), - property.getAdmonitions() + property.getAdmonitions(), + property.getSupportsSince(), + property.getSupportsUntil() ) ); } @@ -292,7 +296,9 @@ private TypeReference getEnumReference(Type type, @NotNull ClassNode classNode) classNameSimple, null, category, - className + className, + null, + null ), enumValues ); @@ -371,7 +377,7 @@ public static class PrimitiveType extends CompiledType implements IPrimitiveType { private PrimitiveType(String primitiveName, Class clazz) { - super(primitiveName, primitiveName, null, null, clazz.getName()); + super(primitiveName, primitiveName, null, null, clazz.getName(), null, null); } @Override diff --git a/Bookkeeper/core/src/main/java/org/kunlab/scenamatica/bookkeeper/compiler/models/CompiledSpecifierType.java b/Bookkeeper/core/src/main/java/org/kunlab/scenamatica/bookkeeper/compiler/models/CompiledSpecifierType.java index 969848760..233cf2a7c 100644 --- a/Bookkeeper/core/src/main/java/org/kunlab/scenamatica/bookkeeper/compiler/models/CompiledSpecifierType.java +++ b/Bookkeeper/core/src/main/java/org/kunlab/scenamatica/bookkeeper/compiler/models/CompiledSpecifierType.java @@ -36,7 +36,9 @@ private CompiledSpecifierType(String type, String className) type.substring(0, 1).toUpperCase() + type.substring(1) + "Specifier", null, null, - className + className, + null, + null ); } diff --git a/Bookkeeper/core/src/main/java/org/kunlab/scenamatica/bookkeeper/compiler/models/CompiledStringType.java b/Bookkeeper/core/src/main/java/org/kunlab/scenamatica/bookkeeper/compiler/models/CompiledStringType.java index 23dfdcd76..336d0a088 100644 --- a/Bookkeeper/core/src/main/java/org/kunlab/scenamatica/bookkeeper/compiler/models/CompiledStringType.java +++ b/Bookkeeper/core/src/main/java/org/kunlab/scenamatica/bookkeeper/compiler/models/CompiledStringType.java @@ -29,7 +29,7 @@ public class CompiledStringType extends CompiledType implements IPrimitiveType public static final TypeReference REF_UUID = new TypeReference( NAME_UUID, new CompiledStringType( - new CompiledType(NAME_UUID, "UUID", null, null, UUID.class.getName()), Format.UUID) + new CompiledType(NAME_UUID, "UUID", null, null, UUID.class.getName(), null, null), Format.UUID) ); public static final String NAME_NAMESPACED = "namespaced"; @@ -37,7 +37,7 @@ public class CompiledStringType extends CompiledType implements IPrimitiveType public static final TypeReference REF_NAMESPACED = new TypeReference( NAME_NAMESPACED, new CompiledStringType( - new CompiledType(NAME_NAMESPACED, "Namespaced", null, null, "com.destroystokyo.paper.Namespaced"), null, + new CompiledType(NAME_NAMESPACED, "Namespaced", null, null, "com.destroystokyo.paper.Namespaced", null, null), null, "^([a-z0-9_/]+:)?[a-z0-9_/]+$", null ) ); @@ -47,7 +47,7 @@ public class CompiledStringType extends CompiledType implements IPrimitiveType public static final TypeReference REF_NAMESPACED_KEY = new TypeReference( NAME_NAMESPACED_KEY, new CompiledStringType( - new CompiledType(NAME_NAMESPACED_KEY, "NamespacedKey", null, null, "org.bukkit.NamespacedKey"), null, + new CompiledType(NAME_NAMESPACED_KEY, "NamespacedKey", null, null, "org.bukkit.NamespacedKey", null, null), null, "^([a-z0-9_/]+:)?[a-z0-9_/]+$", null ) ); @@ -61,7 +61,9 @@ public class CompiledStringType extends CompiledType implements IPrimitiveType public CompiledStringType(CompiledType original, Format format, String pattern, Map enums) { - super(original.getId(), original.getName(), original.getDescription(), original.getCategory(), original.getClassName(), original.getMappingOf()); + super(original.getId(), original.getName(), original.getDescription(), original.getCategory(), + original.getClassName(), original.getMappingOf(), original.getSupportsSince(), original.getSupportsUntil() + ); this.format = format; this.enums = enums; this.pattern = pattern; diff --git a/Bookkeeper/core/src/main/java/org/kunlab/scenamatica/bookkeeper/compiler/models/CompiledType.java b/Bookkeeper/core/src/main/java/org/kunlab/scenamatica/bookkeeper/compiler/models/CompiledType.java index 4d886acde..3fdeb83af 100644 --- a/Bookkeeper/core/src/main/java/org/kunlab/scenamatica/bookkeeper/compiler/models/CompiledType.java +++ b/Bookkeeper/core/src/main/java/org/kunlab/scenamatica/bookkeeper/compiler/models/CompiledType.java @@ -9,6 +9,7 @@ import org.kunlab.scenamatica.bookkeeper.compiler.SerializingContext; import org.kunlab.scenamatica.bookkeeper.compiler.models.refs.ActionReference; import org.kunlab.scenamatica.bookkeeper.compiler.models.refs.TypeReference; +import org.kunlab.scenamatica.bookkeeper.enums.MCVersion; import org.kunlab.scenamatica.bookkeeper.utils.MapUtils; import java.util.ArrayList; @@ -31,6 +32,8 @@ public class CompiledType implements ICompiled protected static final String KEY_MAPPING_OF = "mapping_of"; protected static final String KEY_PROPERTIES = "properties"; protected static final String KEY_ADMONITIONS = "admonitions"; + protected static final String KEY_SUPPORTS_SINCE = "supportsSince"; + protected static final String KEY_SUPPORTS_UNTIL = "supportsUntil"; private final String id; private final String name; @@ -40,8 +43,11 @@ public class CompiledType implements ICompiled private final String mappingOf; private final Map properties; private final GenericAdmonition[] admonitions; + private final MCVersion supportsSince; + private final MCVersion supportsUntil; - public CompiledType(String id, String name, String description, CategoryManager.CategoryEntry category, String className, GenericAdmonition[] admonitions) + public CompiledType(String id, String name, String description, CategoryManager.CategoryEntry category, + String className, GenericAdmonition[] admonitions, MCVersion supportsSince, MCVersion supportsUntil) { this.id = id; this.name = name; @@ -51,9 +57,12 @@ public CompiledType(String id, String name, String description, CategoryManager. this.mappingOf = null; this.properties = null; this.admonitions = admonitions; + this.supportsSince = supportsSince; + this.supportsUntil = supportsUntil; } - public CompiledType(String id, String name, String description, CategoryManager.CategoryEntry category, String className, String mappingOf) + public CompiledType(String id, String name, String description, CategoryManager.CategoryEntry category, String className, String mappingOf, + MCVersion supportsSince, MCVersion supportsUntil) { this.id = id; this.name = name; @@ -63,9 +72,12 @@ public CompiledType(String id, String name, String description, CategoryManager. this.mappingOf = mappingOf; this.properties = null; this.admonitions = null; + this.supportsSince = supportsSince; + this.supportsUntil = supportsUntil; } - public CompiledType(String id, String name, String description, CategoryManager.CategoryEntry category, String className) + public CompiledType(String id, String name, String description, CategoryManager.CategoryEntry category, + String className, MCVersion supportsSince, MCVersion supportsUntil) { this.id = id; this.name = name; @@ -75,6 +87,8 @@ public CompiledType(String id, String name, String description, CategoryManager. this.mappingOf = null; this.properties = null; this.admonitions = null; + this.supportsSince = supportsSince; + this.supportsUntil = supportsUntil; } @Override @@ -99,6 +113,9 @@ public Map serialize(@NotNull SerializingContext ctxt) if (!(this.properties == null || this.properties.isEmpty())) map.put(KEY_PROPERTIES, serializeProperties(ctxt)); + MapUtils.putIfNotNull(map, KEY_SUPPORTS_SINCE, this.supportsSince); + MapUtils.putIfNotNull(map, KEY_SUPPORTS_UNTIL, this.supportsUntil); + if (ctxt.isJSONSchema() && this.shouldEmbedActionMeta()) this.embedActionMeta(ctxt, map); return map; @@ -187,6 +204,8 @@ public static class Property private static final String KEY_REQUIRED = "required"; private static final String KEY_DEFAULT_VALUE = "default"; private static final String KEY_ADMONITIONS = "admonitions"; + private static final String KEY_SUPPORTS_SINCE = "supportsSince"; + private static final String KEY_SUPPORTS_UNTIL = "supportsUntil"; String name; TypeReference type; @@ -198,6 +217,8 @@ public static class Property Double max; Object defaultValue; GenericAdmonition[] admonitions; + MCVersion supportsSince; + MCVersion supportsUntil; public Map serialize(@NotNull SerializingContext ctxt) { @@ -240,6 +261,10 @@ else if (resolvedType.getClass() == CompiledType.class) // プリミティブを MapUtils.putIfNotNull(map, KEY_MIN, this.min); MapUtils.putIfNotNull(map, KEY_MAX, this.max); MapUtils.putIfNotNull(map, KEY_DEFAULT_VALUE, this.defaultValue); + + MapUtils.putIfNotNull(map, KEY_SUPPORTS_SINCE, this.supportsSince); + MapUtils.putIfNotNull(map, KEY_SUPPORTS_UNTIL, this.supportsUntil); + return map; } } diff --git a/Bookkeeper/core/src/main/java/org/kunlab/scenamatica/bookkeeper/definitions/TypeDefinition.java b/Bookkeeper/core/src/main/java/org/kunlab/scenamatica/bookkeeper/definitions/TypeDefinition.java index bab82b4cd..8ced4a528 100644 --- a/Bookkeeper/core/src/main/java/org/kunlab/scenamatica/bookkeeper/definitions/TypeDefinition.java +++ b/Bookkeeper/core/src/main/java/org/kunlab/scenamatica/bookkeeper/definitions/TypeDefinition.java @@ -6,6 +6,7 @@ import org.kunlab.scenamatica.bookkeeper.ScenamaticaClassLoader; import org.kunlab.scenamatica.bookkeeper.annotations.TypeDoc; import org.kunlab.scenamatica.bookkeeper.compiler.models.GenericAdmonition; +import org.kunlab.scenamatica.bookkeeper.enums.MCVersion; import org.objectweb.asm.Type; import org.objectweb.asm.tree.ClassNode; @@ -23,10 +24,13 @@ public class TypeDefinition implements IDefinition TypePropertyDefinition[] properties; Type mappingOf; - Type extending; + GenericAdmonition[] admonitions; + MCVersion supportsSince; + MCVersion supportsUntil; + @Override public ClassNode getAnnotatedClass() { diff --git a/Bookkeeper/core/src/main/java/org/kunlab/scenamatica/bookkeeper/definitions/TypePropertyDefinition.java b/Bookkeeper/core/src/main/java/org/kunlab/scenamatica/bookkeeper/definitions/TypePropertyDefinition.java index 8faf6e1c4..5b7611698 100644 --- a/Bookkeeper/core/src/main/java/org/kunlab/scenamatica/bookkeeper/definitions/TypePropertyDefinition.java +++ b/Bookkeeper/core/src/main/java/org/kunlab/scenamatica/bookkeeper/definitions/TypePropertyDefinition.java @@ -6,6 +6,7 @@ import org.kunlab.scenamatica.bookkeeper.ScenamaticaClassLoader; import org.kunlab.scenamatica.bookkeeper.annotations.TypeProperty; import org.kunlab.scenamatica.bookkeeper.compiler.models.GenericAdmonition; +import org.kunlab.scenamatica.bookkeeper.enums.MCVersion; import org.kunlab.scenamatica.bookkeeper.utils.Descriptors; import org.objectweb.asm.Type; import org.objectweb.asm.tree.ClassNode; @@ -24,6 +25,9 @@ public class TypePropertyDefinition implements IDefinition Double max; GenericAdmonition[] admonitions; + MCVersion supportsSince; + MCVersion supportsUntil; + @Override public ClassNode getAnnotatedClass() { diff --git a/Bookkeeper/core/src/main/java/org/kunlab/scenamatica/bookkeeper/reader/TypeDefinitionReader.java b/Bookkeeper/core/src/main/java/org/kunlab/scenamatica/bookkeeper/reader/TypeDefinitionReader.java index f0146bb19..fcfe8e4ef 100644 --- a/Bookkeeper/core/src/main/java/org/kunlab/scenamatica/bookkeeper/reader/TypeDefinitionReader.java +++ b/Bookkeeper/core/src/main/java/org/kunlab/scenamatica/bookkeeper/reader/TypeDefinitionReader.java @@ -7,6 +7,7 @@ import org.kunlab.scenamatica.bookkeeper.compiler.models.GenericAdmonition; import org.kunlab.scenamatica.bookkeeper.definitions.TypeDefinition; import org.kunlab.scenamatica.bookkeeper.definitions.TypePropertyDefinition; +import org.kunlab.scenamatica.bookkeeper.enums.MCVersion; import org.kunlab.scenamatica.bookkeeper.utils.Descriptors; import org.objectweb.asm.Type; import org.objectweb.asm.tree.AnnotationNode; @@ -20,6 +21,8 @@ public class TypeDefinitionReader implements IAnnotationReader private static final String KEY_MAPPING_OF = "mappingOf"; private static final String KEY_EXTENDING = "extending"; private static final String KEY_ADMONITIONS = "admonitions"; + private static final String KEY_SUPPORTS_SINCE = "supportsSince"; + private static final String KEY_SUPPORTS_UNTIL = "supportsUntil"; private static final String DESC = Descriptors.getDescriptor(TypeDoc.class); @@ -53,7 +56,9 @@ public TypeDefinition buildAnnotation(@Nullable ClassNode clazz, @NotNull Annota }), values.get(KEY_MAPPING_OF, Type.class), values.get(KEY_EXTENDING, Type.class), - GenericAdmonition.byAnnotationValues(values.getAsArray(KEY_ADMONITIONS, AnnotationNode.class)) + GenericAdmonition.byAnnotationValues(values.getAsArray(KEY_ADMONITIONS, AnnotationNode.class)), + values.getAsEnum(KEY_SUPPORTS_SINCE, MCVersion.class), + values.getAsEnum(KEY_SUPPORTS_UNTIL, MCVersion.class) ); } diff --git a/Bookkeeper/core/src/main/java/org/kunlab/scenamatica/bookkeeper/reader/TypePropertyDefinitionReader.java b/Bookkeeper/core/src/main/java/org/kunlab/scenamatica/bookkeeper/reader/TypePropertyDefinitionReader.java index 8e325ef43..2fd5e9d3b 100644 --- a/Bookkeeper/core/src/main/java/org/kunlab/scenamatica/bookkeeper/reader/TypePropertyDefinitionReader.java +++ b/Bookkeeper/core/src/main/java/org/kunlab/scenamatica/bookkeeper/reader/TypePropertyDefinitionReader.java @@ -6,6 +6,7 @@ import org.kunlab.scenamatica.bookkeeper.annotations.TypeProperty; import org.kunlab.scenamatica.bookkeeper.compiler.models.GenericAdmonition; import org.kunlab.scenamatica.bookkeeper.definitions.TypePropertyDefinition; +import org.kunlab.scenamatica.bookkeeper.enums.MCVersion; import org.kunlab.scenamatica.bookkeeper.utils.Descriptors; import org.objectweb.asm.Type; import org.objectweb.asm.tree.AnnotationNode; @@ -22,6 +23,8 @@ public class TypePropertyDefinitionReader implements IAnnotationReader { + Handlebars.registerHelper("groupingWith", (array: any[], size: number) => { const result = [] while (true) { const group = array.splice(0, size) @@ -487,6 +489,15 @@ class LedgerSession { return result }) + + Handlebars.registerHelper("normalizeMCVersion", (version?: string) => { + if (!version) + return undefined + if (version.startsWith("V")) + version = version.substring(1) + + return version.replace(/_/g, ".") + }) } private getCategory(categoryReference: string): Category { diff --git a/Scenamatica/.idea/compiler.xml b/Scenamatica/.idea/compiler.xml index 897b6bc81..1927b1a6a 100644 --- a/Scenamatica/.idea/compiler.xml +++ b/Scenamatica/.idea/compiler.xml @@ -14,7 +14,6 @@ - @@ -26,7 +25,10 @@ + + + @@ -36,6 +38,7 @@ + @@ -44,5 +47,13 @@ + + + + + + + + - + \ No newline at end of file diff --git a/Scenamatica/.idea/encodings.xml b/Scenamatica/.idea/encodings.xml index cccbcda30..87010320a 100644 --- a/Scenamatica/.idea/encodings.xml +++ b/Scenamatica/.idea/encodings.xml @@ -23,6 +23,12 @@ + + + + + + @@ -37,6 +43,8 @@ + + @@ -63,6 +71,12 @@ + + + + + + @@ -77,8 +91,6 @@ - - @@ -90,4 +102,4 @@ - + \ No newline at end of file diff --git a/Scenamatica/.idea/git_toolbox_blame.xml b/Scenamatica/.idea/git_toolbox_blame.xml new file mode 100644 index 000000000..7dc124965 --- /dev/null +++ b/Scenamatica/.idea/git_toolbox_blame.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/Scenamatica/.idea/misc.xml b/Scenamatica/.idea/misc.xml index e2dba60fc..038c7f154 100644 --- a/Scenamatica/.idea/misc.xml +++ b/Scenamatica/.idea/misc.xml @@ -16,8 +16,21 @@ + + + + - +