diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index 499fa99..aba4c91 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -1,17 +1,17 @@ -# This workflow will build a Java project with Gradle -# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle +name: Build and test -name: Java CI with Gradle - -on: [push] +on: + push: + branches: + - 2.x + pull_request: jobs: build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 + - name: Checkout repo + uses: actions/checkout@v2 - name: Set up JDK 1.8 uses: actions/setup-java@v1 with: @@ -20,6 +20,24 @@ jobs: run: chmod +x gradlew - name: Build with Gradle run: ./gradlew build - - uses: actions/upload-artifact@master + - name: Upload artifacts + uses: actions/upload-artifact@master with: path: build/libs/*.jar + test: + runs-on: ubuntu-latest + needs: [build] + steps: + - name: Checkout repo + uses: actions/checkout@v2 + - name: Download artifacts + uses: actions/download-artifact@v4 + with: + path: extra-plugins/ + merge-multiple: true + - name: Run tests + uses: SkriptLang/skript-test-action@v1.0 + with: + test_script_directory: src/test/scripts + skript_repo_ref: 2.8.2 + extra_plugins_directory: extra-plugins/ diff --git a/src/main/java/com/btk5h/skriptmirror/SkriptMirror.java b/src/main/java/com/btk5h/skriptmirror/SkriptMirror.java index 74d2add..4a2365c 100644 --- a/src/main/java/com/btk5h/skriptmirror/SkriptMirror.java +++ b/src/main/java/com/btk5h/skriptmirror/SkriptMirror.java @@ -2,7 +2,8 @@ import ch.njol.skript.Skript; import ch.njol.skript.SkriptAddon; -import ch.njol.skript.lang.parser.ParserInstance; +import ch.njol.skript.classes.ClassInfo; +import ch.njol.skript.registrations.Classes; import ch.njol.skript.util.Version; import org.skriptlang.reflect.syntax.condition.elements.StructCustomCondition; import org.skriptlang.reflect.syntax.effect.elements.StructCustomEffect; @@ -14,6 +15,8 @@ import com.btk5h.skriptmirror.util.SkriptReflection; import org.bukkit.Bukkit; import org.bukkit.plugin.java.JavaPlugin; +import org.skriptlang.skript.lang.comparator.Comparators; +import org.skriptlang.skript.lang.comparator.Relation; import java.io.IOException; import java.nio.file.Path; @@ -64,6 +67,13 @@ public void onEnable() { e.printStackTrace(); } + Comparators.registerComparator(ClassInfo.class, JavaType.class, (classInfo, javaType) -> { + ClassInfo matchingClassInfo = Classes.getExactClassInfo(javaType.getJavaClass()); + if (matchingClassInfo == null) + return Relation.NOT_EQUAL; + return Comparators.compare(classInfo, matchingClassInfo); + }); + ParseOrderWorkarounds.reorderSyntax(); // Disable *all* and/or warnings diff --git a/src/test/scripts/ExprJavaCall.sk b/src/test/scripts/ExprJavaCall.sk new file mode 100644 index 0000000..f44e284 --- /dev/null +++ b/src/test/scripts/ExprJavaCall.sk @@ -0,0 +1,2 @@ +test "ExprJavaCall": + assert "123".length() is 3 with "incorrect String##length return"