diff --git a/examples/typescript/README.md b/examples/typescript/README.md new file mode 100644 index 0000000..1d2011b --- /dev/null +++ b/examples/typescript/README.md @@ -0,0 +1,9 @@ +# TypeScript Example +This is an example of a Minecraft mod made in TypeScript using ScriptCraft. + +#### Files +- ```src/main/ts```: Contains TypeScript Code +- ```src/main/java```: Contains Bootstrap Java Code + +#### Note +When updating Minecraft, make sure to update the ```src/main/ts/package.json``` file as well. \ No newline at end of file diff --git a/examples/typescript/scripts/setup.sh b/examples/typescript/scripts/setup.sh deleted file mode 100644 index a68ac13..0000000 --- a/examples/typescript/scripts/setup.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/sh - -set -e - -SCRIPTCRAFT_BRANCH='master' - -if [ -d ../libs ]; then - rm -rf ../libs -fi -mkdir ../libs - -curl -L -o ../libs/scriptcraft.jar "https://jenkins.thebrokenrail.com/job/ScriptCraft/job/${SCRIPTCRAFT_BRANCH}/lastSuccessfulBuild/artifact/build/libs/scriptcraft-1.0.0-SNAPSHOT.jar" -curl -L -o ../libs/scriptcraft-api.tar.gz "https://jenkins.thebrokenrail.com/job/ScriptCraft/job/${SCRIPTCRAFT_BRANCH}/lastSuccessfulBuild/artifact/build/distributions/scriptcraft-1.0.0-SNAPSHOT-api.tar.gz" - -cd ../src/main/ts -npm install \ No newline at end of file diff --git a/examples/typescript/src/main/ts/package.json b/examples/typescript/src/main/ts/package.json index 26b28e7..035e8f7 100644 --- a/examples/typescript/src/main/ts/package.json +++ b/examples/typescript/src/main/ts/package.json @@ -3,7 +3,7 @@ "typescript": "latest" }, "dependencies": { - "scriptcraft-api": "file:../../../libs/scriptcraft-api.tar.gz" + "scriptcraft-api": "https://maven.thebrokenrail.com/com/thebrokenrail/scriptcraft/1.15.2/scriptcraft-1.15.2-api.tar.gz" }, "scripts": { "build": "tsc" diff --git a/examples/typescript/src/main/ts/src/modid/index.ts b/examples/typescript/src/main/ts/src/modid/index.ts index f804dc7..c4628a2 100644 --- a/examples/typescript/src/main/ts/src/modid/index.ts +++ b/examples/typescript/src/main/ts/src/modid/index.ts @@ -44,8 +44,8 @@ class MyBlock extends CustomBlockWithEntity { } } -Registry.register(Registry.BLOCK, new Identifier('test', 'my_block'), new MyBlock()); -Registry.register(Registry.ITEM, new Identifier('test', 'my_block'), new BlockItem(new Identifier('test', 'my_block'), new ItemSettings())); +Registry.register(Registry.BLOCK, new Identifier('modid', 'my_block'), new MyBlock()); +Registry.register(Registry.ITEM, new Identifier('modid', 'my_block'), new BlockItem(new Identifier('modid', 'my_block'), new ItemSettings())); class MyItem extends CustomItem { constructor() { diff --git a/examples/typescript/typescript.build.gradle b/examples/typescript/typescript.build.gradle index 0e75ac6..fd245f9 100644 --- a/examples/typescript/typescript.build.gradle +++ b/examples/typescript/typescript.build.gradle @@ -3,6 +3,25 @@ def typescriptRootFile = new File(rootDir.absolutePath, typescriptRoot) def typescriptOut = new File(typescriptRootFile, 'lib/ts') +def nodeModules = new File(typescriptRoot, 'node_modules') + +task typescriptInstall(group: 'typescript', type: Exec) { + inputs.file new File(typescriptRootFile, 'package.json') + outputs.dir nodeModules + + workingDir typescriptRootFile + + executable 'npm' + + args 'install' + + doFirst { + project.delete { + delete nodeModules + } + } +} + task typescript(group: 'typescript', type: Exec) { inputs.dir typescriptRootFile outputs.dirs typescriptOut @@ -20,6 +39,8 @@ task typescript(group: 'typescript', type: Exec) { } } +typescript.dependsOn typescriptInstall + processResources.dependsOn typescript processResources { diff --git a/scripts/setup.sh b/scripts/setup.sh index 175e832..2cb3844 100755 --- a/scripts/setup.sh +++ b/scripts/setup.sh @@ -3,7 +3,4 @@ set -e ./download-quickjs.sh -./download-jni-headers.sh - -cd ../src/main/ts -npm install \ No newline at end of file +./download-jni-headers.sh \ No newline at end of file diff --git a/src/main/java/com/thebrokenrail/scriptcraft/Test.java b/src/main/java/com/thebrokenrail/scriptcraft/Test.java deleted file mode 100644 index 7f46a70..0000000 --- a/src/main/java/com/thebrokenrail/scriptcraft/Test.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.thebrokenrail.scriptcraft; - -import com.thebrokenrail.scriptcraft.core.ScriptCraftEntrypoint; - -public class Test implements ScriptCraftEntrypoint { - @Override - public String getModID() { - return "test"; - } - - @Override - public String getModIndex() { - return "index.js"; - } -} diff --git a/typescript.build.gradle b/typescript.build.gradle index 6e92761..c6b0db3 100644 --- a/typescript.build.gradle +++ b/typescript.build.gradle @@ -1,6 +1,25 @@ def typescriptRoot = 'src/main/ts' def typescriptRootFile = new File(rootDir.absolutePath, typescriptRoot) +def nodeModules = new File(typescriptRoot, 'node_modules') + +task typescriptInstall(group: 'typescript', type: Exec) { + inputs.file new File(typescriptRootFile, 'package.json') + outputs.dir nodeModules + + workingDir typescriptRootFile + + executable 'npm' + + args 'install' + + doFirst { + project.delete { + delete nodeModules + } + } +} + def typescriptOut = new File(typescriptRootFile, 'lib/ts') def dtsOut = new File(typescriptRootFile, 'lib/dts') @@ -21,6 +40,8 @@ task typescript(group: 'typescript', type: Exec) { } } +typescript.dependsOn typescriptInstall + task typescriptAPI(group: 'typescript', type: Tar) { into('/package') { into('types') { @@ -53,6 +74,8 @@ task eslint(group: 'typescript', type: Exec) { args 'run', 'eslint' } +eslint.dependsOn typescriptInstall + processResources.dependsOn typescript def typedocOut = new File(typescriptRootFile, 'lib/typedoc') @@ -74,6 +97,8 @@ task typedoc(group: 'typescript', type: Exec) { } } +typedoc.dependsOn typescriptInstall + processResources { from(typescriptOut.absolutePath) { into 'scriptcraft'