diff --git a/.github/workflows/build-dev.yml b/.github/workflows/build-dev.yml
index 917d309e..52cf9739 100644
--- a/.github/workflows/build-dev.yml
+++ b/.github/workflows/build-dev.yml
@@ -52,8 +52,6 @@ jobs:
mkdir artifacts
cp ./build/ScriptableMC-Engine-JS.jar ./artifacts/
cp ./build/ScriptableMC-Engine-JS-Bundled.jar ./artifacts/
- cp ./build/ScriptableMC-Engine-PY.jar ./artifacts/
- cp ./build/ScriptableMC-Engine-PY-Bundled.jar ./artifacts/
cp ./ScriptableMC-Tools-TS/lib/ScriptableMC-TypeScript-Lib.zip ./artifacts/
cp ./ScriptableMC-Tools-TS/lib/ScriptableMC-JavaScript-Lib.zip ./artifacts/
cp ./ScriptableMC-Tools-TS/lib-smc/Lib-SMC.zip ./artifacts/
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 20a98845..8ab1ec29 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -50,24 +50,12 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
args: 'ScriptableMC-Engine-JS/build/libs/ScriptableMC-Engine-JS.jar'
- - name: Upload Python Engine Plugin Jar
- uses: skx/github-action-publish-binaries@master
- env:
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- with:
- args: 'ScriptableMC-Engine-PY/build/libs/ScriptableMC-Engine-PY.jar'
- name: Upload Bundled JavaScript Engine Plugin Jar
uses: skx/github-action-publish-binaries@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
args: 'ScriptableMC-Engine-JS/Bundled/build/libs/ScriptableMC-Engine-JS-Bundled.jar'
- - name: Upload Bundled Python Engine Plugin Jar
- uses: skx/github-action-publish-binaries@master
- env:
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- with:
- args: 'ScriptableMC-Engine-PY/Bundled/build/libs/ScriptableMC-Engine-PY-Bundled.jar'
- name: Upload TypeScript Libraries
uses: skx/github-action-publish-binaries@master
env:
diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml
index 2eebef07..f0221557 100644
--- a/.idea/jarRepositories.xml
+++ b/.idea/jarRepositories.xml
@@ -61,5 +61,10 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/README.md b/README.md
index 69f12399..70822008 100644
--- a/README.md
+++ b/README.md
@@ -5,7 +5,7 @@

Run JavaScript/TypeScript plugins for Minecraft 1.15 using the GraalJS script engine.
-Supported Minecraft Versions: Bukkit/Spigot/Paper 1.12, 1.13, 1.14, **1.15**
+Supported Minecraft Versions: Bukkit/Spigot/Paper 1.13, 1.14, 1.15, **1.16**
Untested but should work: 1.8+
**This plugin is in a preview state, there may be breaking changes, missing features, and possibly a few bugs.**
@@ -69,5 +69,6 @@ https://github.com/MinusKube/SmartInvs - Inventory helper library
https://github.com/lucko/helper - MinecraftVersions helper library
https://github.com/jkcclemens/khttp - HTTP helper library
https://github.com/aikar/commands - Built-in commands and auto-completion
+https://github.com/tr7zw/Item-NBT-API - NBT helper library
https://github.com/apache/commons-io - FileUtils helper library
https://github.com/graalvm/graaljs - JavaScript engine
diff --git a/ScriptableMC-Engine-Core/build.gradle.kts b/ScriptableMC-Engine-Core/build.gradle.kts
index 4260a3fe..17331743 100644
--- a/ScriptableMC-Engine-Core/build.gradle.kts
+++ b/ScriptableMC-Engine-Core/build.gradle.kts
@@ -18,17 +18,18 @@ idea {
dependencies {
// GraalVM SDK & GraalJS Engine
- compileOnly("org.graalvm.sdk:graal-sdk:20.0.0")
- compileOnly("org.graalvm.truffle:truffle-api:20.0.0")
+ compileOnly("org.graalvm.sdk:graal-sdk:20.1.0")
+ compileOnly("org.graalvm.truffle:truffle-api:20.1.0")
implementation("com.github.jkcclemens:khttp:-SNAPSHOT")
- compileOnly("org.spigotmc:spigot-api:1.15.2-R0.1-SNAPSHOT")
+ compileOnly("org.spigotmc:spigot-api:1.16.1-R0.1-SNAPSHOT")
implementation("co.aikar:acf-paper:0.5.0-SNAPSHOT")
implementation("fr.minuskube.inv:smart-invs:1.2.7")
compileOnly("me.clip:placeholderapi:2.10.4")
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
implementation("org.jetbrains.kotlin:kotlin-reflect")
implementation("commons-io:commons-io:2.6")
+ implementation("de.tr7zw:item-nbt-api:2.2.0")
testImplementation("junit", "junit", "4.12")
}
diff --git a/ScriptableMC-Engine-Core/src/main/kotlin/com/pixlfox/scriptablemc/ScriptEngineGlobalCommands.kt b/ScriptableMC-Engine-Core/src/main/kotlin/com/pixlfox/scriptablemc/ScriptEngineGlobalCommands.kt
index 67802efb..351f1e4e 100644
--- a/ScriptableMC-Engine-Core/src/main/kotlin/com/pixlfox/scriptablemc/ScriptEngineGlobalCommands.kt
+++ b/ScriptableMC-Engine-Core/src/main/kotlin/com/pixlfox/scriptablemc/ScriptEngineGlobalCommands.kt
@@ -30,13 +30,13 @@ class ScriptEngineGlobalCommands(private val basePlugin: ScriptEngineMain) : Bas
sender.sendMessage("${ChatColor.GREEN}GraalJS Version: ${scriptEngine?.eval("Graal.versionJS")}")
}
else {
- sender.sendMessage("- ${ChatColor.GREEN}GraalJS Engine Version: v20.0.0")
+ sender.sendMessage("- ${ChatColor.GREEN}GraalJS Engine Version: v20.1.0")
}
sender.sendMessage("-----------------------------------------------------")
}
else if(scriptEngineMain.scriptLanguage == "python") {
sender.sendMessage("- ${ChatColor.DARK_BLUE}ScriptableMC Python Engine: ${scriptEngineMain.pluginVersion}")
- sender.sendMessage("- ${ChatColor.BLUE}GraalPython Version: v20.0.0")
+ sender.sendMessage("- ${ChatColor.BLUE}GraalPython Version: v20.1.0")
sender.sendMessage("-----------------------------------------------------")
}
diff --git a/ScriptableMC-Engine-Core/src/main/kotlin/com/pixlfox/scriptablemc/core/ScriptablePluginContext.kt b/ScriptableMC-Engine-Core/src/main/kotlin/com/pixlfox/scriptablemc/core/ScriptablePluginContext.kt
index 1e0ff017..61d2e64e 100644
--- a/ScriptableMC-Engine-Core/src/main/kotlin/com/pixlfox/scriptablemc/core/ScriptablePluginContext.kt
+++ b/ScriptableMC-Engine-Core/src/main/kotlin/com/pixlfox/scriptablemc/core/ScriptablePluginContext.kt
@@ -4,6 +4,7 @@ import com.smc.version.Version
import fr.minuskube.inv.InventoryManager
import me.clip.placeholderapi.PlaceholderAPI
import org.bukkit.Bukkit
+import org.bukkit.Material
import org.bukkit.OfflinePlayer
import org.bukkit.Server
import org.bukkit.command.CommandMap
@@ -28,6 +29,7 @@ abstract class ScriptablePluginContext: Listener {
abstract val pluginInstance: Value
abstract val inventoryManager: InventoryManager
abstract val pluginVersion: Version
+ open val pluginIcon: Material = Material.STONE
var isEnabled: Boolean = false
internal set
diff --git a/ScriptableMC-Engine-Core/src/main/kotlin/com/pixlfox/scriptablemc/core/ScriptablePluginEngine.kt b/ScriptableMC-Engine-Core/src/main/kotlin/com/pixlfox/scriptablemc/core/ScriptablePluginEngine.kt
index 9c8ea70e..5396643d 100644
--- a/ScriptableMC-Engine-Core/src/main/kotlin/com/pixlfox/scriptablemc/core/ScriptablePluginEngine.kt
+++ b/ScriptableMC-Engine-Core/src/main/kotlin/com/pixlfox/scriptablemc/core/ScriptablePluginEngine.kt
@@ -104,6 +104,14 @@ abstract class ScriptablePluginEngine {
}
}
+ open fun getPluginInstance(name: String): Value? {
+ return getPluginInstance(scriptablePlugins.firstOrNull { it.pluginName == name })
+ }
+
+ open fun getPluginInstance(pluginContext: ScriptablePluginContext?): Value? {
+ return pluginContext?.pluginInstance
+ }
+
open fun eval(source: Source): Value {
return graalContext.eval(source)
}
@@ -173,7 +181,38 @@ abstract class ScriptablePluginEngine {
)
}
- abstract fun loadMainScript(path: String)
+ open fun loadMainScript(path: String) {
+ try {
+ val mainScriptFile = File(path)
+ if(!mainScriptFile.parentFile.exists()) {
+ mainScriptFile.parentFile.mkdirs()
+ }
+
+ if(mainScriptFile.exists()) {
+ val mainReturn = eval(
+ Source.newBuilder(languageName, mainScriptFile)
+ .name(mainScriptFile.name)
+ .mimeType(config.scriptMimeType)
+ .interactive(false)
+ .build()
+ )
+
+ // Load all plugin types returned as an array
+ if(mainReturn.hasArrayElements()) {
+ for (i in 0 until mainReturn.arraySize) {
+ this.loadPlugin(mainReturn.getArrayElement(i))
+ }
+ }
+ }
+ else {
+ throw ScriptNotFoundException(mainScriptFile)
+ }
+ }
+ catch(ex: Exception) {
+ startupErrors.add(ex)
+ }
+ }
+
abstract fun loadPlugin(scriptableClass: Value): ScriptablePluginContext
companion object {
diff --git a/ScriptableMC-Engine-JS/Bundled/build.gradle.kts b/ScriptableMC-Engine-JS/Bundled/build.gradle.kts
index 838ea444..ea552f1e 100644
--- a/ScriptableMC-Engine-JS/Bundled/build.gradle.kts
+++ b/ScriptableMC-Engine-JS/Bundled/build.gradle.kts
@@ -21,15 +21,15 @@ dependencies {
implementation(project(":ScriptableMC-Engine-JS"))
// GraalVM SDK & GraalJS Engine
- implementation("org.graalvm.sdk:graal-sdk:20.0.0")
- implementation("org.graalvm.js:js:20.0.0")
- implementation("org.graalvm.js:js-scriptengine:20.0.0")
- implementation("org.graalvm.truffle:truffle-api:20.0.0")
- implementation("org.graalvm.tools:chromeinspector:20.0.0")
- implementation("org.graalvm.tools:profiler:20.0.0")
+ implementation("org.graalvm.sdk:graal-sdk:20.1.0")
+ implementation("org.graalvm.js:js:20.1.0")
+ implementation("org.graalvm.js:js-scriptengine:20.1.0")
+ implementation("org.graalvm.truffle:truffle-api:20.1.0")
+ implementation("org.graalvm.tools:chromeinspector:20.1.0")
+ implementation("org.graalvm.tools:profiler:20.1.0")
implementation("com.github.jkcclemens:khttp:-SNAPSHOT")
- compileOnly("org.spigotmc:spigot-api:1.15.2-R0.1-SNAPSHOT")
+ compileOnly("org.spigotmc:spigot-api:1.16.1-R0.1-SNAPSHOT")
implementation("co.aikar:acf-paper:0.5.0-SNAPSHOT")
implementation("fr.minuskube.inv:smart-invs:1.2.7")
compileOnly("me.clip:placeholderapi:2.10.4")
@@ -56,5 +56,6 @@ tasks.jar {
tasks.shadowJar {
archiveFileName.set("ScriptableMC-Engine-JS-Bundled.jar")
relocate("co.aikar.commands", "com.pixlfox.scriptablemc.acf")
+ relocate("de.tr7zw.changeme.nbtapi", "com.smc.nbtapi")
mergeServiceFiles()
}
\ No newline at end of file
diff --git a/ScriptableMC-Engine-JS/build.gradle.kts b/ScriptableMC-Engine-JS/build.gradle.kts
index 27711155..ddcd1363 100644
--- a/ScriptableMC-Engine-JS/build.gradle.kts
+++ b/ScriptableMC-Engine-JS/build.gradle.kts
@@ -22,17 +22,18 @@ dependencies {
// GraalVM SDK & GraalJS Engine
- compileOnly("org.graalvm.sdk:graal-sdk:20.0.0")
- compileOnly("org.graalvm.truffle:truffle-api:20.0.0")
+ compileOnly("org.graalvm.sdk:graal-sdk:20.1.0")
+ compileOnly("org.graalvm.truffle:truffle-api:20.1.0")
implementation("com.github.jkcclemens:khttp:-SNAPSHOT")
- compileOnly("org.spigotmc:spigot-api:1.15.2-R0.1-SNAPSHOT")
+ compileOnly("org.spigotmc:spigot-api:1.16.1-R0.1-SNAPSHOT")
implementation("co.aikar:acf-paper:0.5.0-SNAPSHOT")
implementation("fr.minuskube.inv:smart-invs:1.2.7")
compileOnly("me.clip:placeholderapi:2.10.4")
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
implementation("org.jetbrains.kotlin:kotlin-reflect")
implementation("commons-io:commons-io:2.6")
+ implementation("de.tr7zw:item-nbt-api:2.2.0")
testImplementation("junit", "junit", "4.12")
}
@@ -53,5 +54,6 @@ tasks.jar {
tasks.shadowJar {
archiveFileName.set("ScriptableMC-Engine-JS.jar")
relocate("co.aikar.commands", "com.pixlfox.scriptablemc.acf")
+ relocate("de.tr7zw.changeme.nbtapi", "com.smc.nbtapi")
mergeServiceFiles()
}
\ No newline at end of file
diff --git a/ScriptableMC-Engine-JS/src/main/kotlin/com/pixlfox/scriptablemc/core/JavaScriptPluginContext.kt b/ScriptableMC-Engine-JS/src/main/kotlin/com/pixlfox/scriptablemc/core/JavaScriptPluginContext.kt
index 84988681..3f260137 100644
--- a/ScriptableMC-Engine-JS/src/main/kotlin/com/pixlfox/scriptablemc/core/JavaScriptPluginContext.kt
+++ b/ScriptableMC-Engine-JS/src/main/kotlin/com/pixlfox/scriptablemc/core/JavaScriptPluginContext.kt
@@ -2,12 +2,13 @@ package com.pixlfox.scriptablemc.core
import com.smc.version.Version
import fr.minuskube.inv.InventoryManager
+import org.bukkit.Material
import org.bukkit.event.HandlerList
import org.graalvm.polyglot.Value
@Suppress("MemberVisibilityCanBePrivate", "unused")
-class JavaScriptPluginContext(override val engine: ScriptablePluginEngine, override val pluginName: String, override val pluginInstance: Value) : ScriptablePluginContext() {
+class JavaScriptPluginContext(override val engine: ScriptablePluginEngine, override val pluginName: String, override val pluginIcon: Material, override val pluginInstance: Value) : ScriptablePluginContext() {
override val inventoryManager: InventoryManager
get() = engine.inventoryManager
@@ -48,12 +49,12 @@ class JavaScriptPluginContext(override val engine: ScriptablePluginEngine, overr
}
companion object {
- fun newInstance(pluginName: String, engine: ScriptablePluginEngine, pluginInstance: Value): ScriptablePluginContext {
+ fun newInstance(pluginName: String, pluginIcon: Material, engine: ScriptablePluginEngine, pluginInstance: Value): ScriptablePluginContext {
if(engine.debugEnabled) {
engine.bootstrapPlugin.logger.info("[$pluginName] Creating new JavaScript plugin context.")
}
- return JavaScriptPluginContext(engine, pluginName, pluginInstance)
+ return JavaScriptPluginContext(engine, pluginName, pluginIcon, pluginInstance)
}
}
}
\ No newline at end of file
diff --git a/ScriptableMC-Engine-JS/src/main/kotlin/com/pixlfox/scriptablemc/core/JavaScriptPluginEngine.kt b/ScriptableMC-Engine-JS/src/main/kotlin/com/pixlfox/scriptablemc/core/JavaScriptPluginEngine.kt
index 3baf2458..44b15e4a 100644
--- a/ScriptableMC-Engine-JS/src/main/kotlin/com/pixlfox/scriptablemc/core/JavaScriptPluginEngine.kt
+++ b/ScriptableMC-Engine-JS/src/main/kotlin/com/pixlfox/scriptablemc/core/JavaScriptPluginEngine.kt
@@ -5,6 +5,7 @@ import com.pixlfox.scriptablemc.ScriptEngineMain
import com.smc.exceptions.ScriptNotFoundException
import com.pixlfox.scriptablemc.utils.UnzipUtility
import fr.minuskube.inv.InventoryManager
+import org.bukkit.Material
import org.graalvm.polyglot.*
import java.io.File
@@ -92,38 +93,6 @@ class JavaScriptPluginEngine(override val bootstrapPlugin: ScriptEngineMain, ove
globalBindings = graalContext.getBindings(languageName)
}
- override fun loadMainScript(path: String) {
- try {
- val mainScriptFile = File(path)
- if(!mainScriptFile.parentFile.exists()) {
- mainScriptFile.parentFile.mkdirs()
- }
-
- if(mainScriptFile.exists()) {
- val mainReturn = eval(
- Source.newBuilder(languageName, mainScriptFile)
- .name(mainScriptFile.name)
- .mimeType(config.scriptMimeType)
- .interactive(false)
- .build()
- )
-
- // Load all plugin types returned as an array
- if(mainReturn.hasArrayElements()) {
- for (i in 0 until mainReturn.arraySize) {
- this.loadPlugin(mainReturn.getArrayElement(i))
- }
- }
- }
- else {
- throw ScriptNotFoundException(mainScriptFile)
- }
- }
- catch(ex: Exception) {
- startupErrors.add(ex)
- }
- }
-
override fun start() {
instance = this
super.start()
@@ -137,7 +106,16 @@ class JavaScriptPluginEngine(override val bootstrapPlugin: ScriptEngineMain, ove
override fun loadPlugin(scriptableClass: Value): ScriptablePluginContext {
val pluginInstance = scriptableClass.newInstance()
val pluginName = pluginInstance.getMember("pluginName").asString()
- val pluginContext = JavaScriptPluginContext.newInstance(pluginName, this, pluginInstance)
+ var pluginIcon = Material.STONE
+ if(pluginInstance.hasMember("pluginIcon")) {
+ try {
+ pluginIcon = pluginInstance.getMember("pluginIcon").`as`(Material::class.java)
+ }
+ catch(e: Exception) {
+ e.printStackTrace()
+ }
+ }
+ val pluginContext = JavaScriptPluginContext.newInstance(pluginName, pluginIcon, this, pluginInstance)
pluginInstance.putMember("context", pluginContext)
scriptablePlugins.add(pluginContext)
pluginContext.load()
diff --git a/ScriptableMC-Engine-JS/src/main/resources/plugin.yml b/ScriptableMC-Engine-JS/src/main/resources/plugin.yml
index 40b1e83a..17887b54 100644
--- a/ScriptableMC-Engine-JS/src/main/resources/plugin.yml
+++ b/ScriptableMC-Engine-JS/src/main/resources/plugin.yml
@@ -1,6 +1,6 @@
name: ScriptableMC-Engine-JS
description: 'Run JavaScript/TypeScript plugins for Bukkit/Spigot/Paper Minecraft 1.15'
-version: '1.2.1'
+version: '1.3.0'
api-version: '1.13'
author: AStorks
main: com.pixlfox.scriptablemc.SMCJavaScriptEngineMain
diff --git a/ScriptableMC-Engine-PY/Bundled/build.gradle.kts b/ScriptableMC-Engine-PY/Bundled/build.gradle.kts
index a348d81c..b432b22d 100644
--- a/ScriptableMC-Engine-PY/Bundled/build.gradle.kts
+++ b/ScriptableMC-Engine-PY/Bundled/build.gradle.kts
@@ -21,15 +21,15 @@ dependencies {
implementation(project(":ScriptableMC-Engine-PY"))
// GraalVM SDK & GraalPython Engine
- implementation("org.graalvm.sdk:graal-sdk:20.0.0")
- implementation("org.graalvm.truffle:truffle-api:20.0.0")
+ implementation("org.graalvm.sdk:graal-sdk:20.1.0")
+ implementation("org.graalvm.truffle:truffle-api:20.1.0")
implementation(files("libraries/graalpython.jar"))
implementation(files("libraries/sulong-api.jar"))
implementation(files("libraries/sulong.jar"))
implementation("com.github.jkcclemens:khttp:-SNAPSHOT")
- compileOnly("org.spigotmc:spigot-api:1.15.2-R0.1-SNAPSHOT")
+ compileOnly("org.spigotmc:spigot-api:1.16.1-R0.1-SNAPSHOT")
implementation("co.aikar:acf-paper:0.5.0-SNAPSHOT")
implementation("fr.minuskube.inv:smart-invs:1.2.7")
compileOnly("me.clip:placeholderapi:2.10.4")
@@ -56,5 +56,6 @@ tasks.jar {
tasks.shadowJar {
archiveFileName.set("ScriptableMC-Engine-PY-Bundled.jar")
relocate("co.aikar.commands", "com.pixlfox.scriptablemc.acf")
+ relocate("de.tr7zw.changeme.nbtapi", "com.smc.nbtapi")
mergeServiceFiles()
}
\ No newline at end of file
diff --git a/ScriptableMC-Engine-PY/build.gradle.kts b/ScriptableMC-Engine-PY/build.gradle.kts
index 31978e98..13a2a96c 100644
--- a/ScriptableMC-Engine-PY/build.gradle.kts
+++ b/ScriptableMC-Engine-PY/build.gradle.kts
@@ -21,18 +21,19 @@ dependencies {
implementation(project(":ScriptableMC-Engine-Core"))
// GraalVM SDK & GraalPython Engine
- compileOnly("org.graalvm.sdk:graal-sdk:20.0.0")
- compileOnly("org.graalvm.truffle:truffle-api:20.0.0")
+ compileOnly("org.graalvm.sdk:graal-sdk:20.1.0")
+ compileOnly("org.graalvm.truffle:truffle-api:20.1.0")
implementation("com.github.jkcclemens:khttp:-SNAPSHOT")
- compileOnly("org.spigotmc:spigot-api:1.15.2-R0.1-SNAPSHOT")
+ compileOnly("org.spigotmc:spigot-api:1.16.1-R0.1-SNAPSHOT")
implementation("co.aikar:acf-paper:0.5.0-SNAPSHOT")
implementation("fr.minuskube.inv:smart-invs:1.2.7")
compileOnly("me.clip:placeholderapi:2.10.4")
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
implementation("org.jetbrains.kotlin:kotlin-reflect")
implementation("commons-io:commons-io:2.6")
+ implementation("de.tr7zw:item-nbt-api:2.2.0")
testImplementation("junit", "junit", "4.12")
}
@@ -53,5 +54,6 @@ tasks.jar {
tasks.shadowJar {
archiveFileName.set("ScriptableMC-Engine-PY.jar")
relocate("co.aikar.commands", "com.pixlfox.scriptablemc.acf")
+ relocate("de.tr7zw.changeme.nbtapi", "com.smc.nbtapi")
mergeServiceFiles()
}
\ No newline at end of file
diff --git a/ScriptableMC-Engine-PY/src/main/kotlin/com/pixlfox/scriptablemc/core/PythonPluginEngine.kt b/ScriptableMC-Engine-PY/src/main/kotlin/com/pixlfox/scriptablemc/core/PythonPluginEngine.kt
index 22f77fa2..d28554c4 100644
--- a/ScriptableMC-Engine-PY/src/main/kotlin/com/pixlfox/scriptablemc/core/PythonPluginEngine.kt
+++ b/ScriptableMC-Engine-PY/src/main/kotlin/com/pixlfox/scriptablemc/core/PythonPluginEngine.kt
@@ -2,7 +2,6 @@ package com.pixlfox.scriptablemc.core
import com.pixlfox.scriptablemc.SMCPythonConfig
import com.pixlfox.scriptablemc.ScriptEngineMain
-import com.smc.exceptions.ScriptNotFoundException
import com.pixlfox.scriptablemc.utils.UnzipUtility
import fr.minuskube.inv.InventoryManager
import org.graalvm.polyglot.*
@@ -53,41 +52,6 @@ class PythonPluginEngine(override val bootstrapPlugin: ScriptEngineMain, overrid
globalBindings = graalContext.getBindings(languageName)
}
- override fun loadMainScript(path: String) {
- try {
- val mainScriptFile = File(path)
- if(!mainScriptFile.parentFile.exists()) {
- mainScriptFile.parentFile.mkdirs()
- }
-
- if(mainScriptFile.exists()) {
- val mainReturn = eval(
- Source.newBuilder(languageName, mainScriptFile)
- .name(mainScriptFile.name)
- .interactive(false)
- .build()
- )
-
- // Load all plugin types returned as an array
- if(mainReturn.hasArrayElements()) {
- for (i in 0 until mainReturn.arraySize) {
- this.loadPlugin(mainReturn.getArrayElement(i))
- }
-
- // Enable all plugins if not already enabled
- if(!enabledAllPlugins) {
- enableAllPlugins()
- }
- }
- }
- else {
- throw ScriptNotFoundException(mainScriptFile)
- }
- }
- catch(ex: Exception) {
- startupErrors.add(ex)
- }
- }
override fun start() {
instance = this
diff --git a/ScriptableMC-Engine-PY/src/main/resources/plugin.yml b/ScriptableMC-Engine-PY/src/main/resources/plugin.yml
index 59101626..b0c0c6cb 100644
--- a/ScriptableMC-Engine-PY/src/main/resources/plugin.yml
+++ b/ScriptableMC-Engine-PY/src/main/resources/plugin.yml
@@ -1,6 +1,6 @@
name: ScriptableMC-Engine-PY
description: 'Run Python plugins for Bukkit/Spigot/Paper Minecraft 1.15'
-version: '1.2.1'
+version: '1.3.0'
api-version: '1.13'
author: AStorks
main: com.pixlfox.scriptablemc.SMCPythonEngineMain
diff --git a/ScriptableMC-Tools-TS/build.gradle.kts b/ScriptableMC-Tools-TS/build.gradle.kts
index 5e3f17a3..a932b495 100644
--- a/ScriptableMC-Tools-TS/build.gradle.kts
+++ b/ScriptableMC-Tools-TS/build.gradle.kts
@@ -21,13 +21,14 @@ dependencies {
implementation(project(":ScriptableMC-Engine-JS"))
// GraalVM SDK & GraalJS Engine
- implementation("org.graalvm.sdk:graal-sdk:20.0.0")
- implementation("org.graalvm.js:js:20.0.0")
- implementation("org.graalvm.js:js-scriptengine:20.0.0")
- implementation("org.graalvm.truffle:truffle-api:20.0.0")
+ implementation("org.graalvm.sdk:graal-sdk:20.1.0")
+ implementation("org.graalvm.js:js:20.1.0")
+ implementation("org.graalvm.js:js-scriptengine:20.1.0")
+ implementation("org.graalvm.truffle:truffle-api:20.1.0")
implementation("com.github.jkcclemens:khttp:-SNAPSHOT")
- implementation("org.spigotmc:spigot-api:1.15.2-R0.1-SNAPSHOT")
+ implementation("org.spigotmc:spigot-api:1.16.1-R0.1-SNAPSHOT")
+ implementation("net.md-5:bungeecord-api:1.15-SNAPSHOT")
implementation("co.aikar:acf-paper:0.5.0-SNAPSHOT")
implementation("fr.minuskube.inv:smart-invs:1.2.7")
compileOnly("me.clip:placeholderapi:2.10.4")
@@ -35,6 +36,7 @@ dependencies {
implementation("com.beust:klaxon:5.2")
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
implementation("commons-io:commons-io:2.6")
+ implementation("de.tr7zw:item-nbt-api:2.2.0")
testImplementation("junit", "junit", "4.12")
}
diff --git a/ScriptableMC-Tools-TS/src/main/kotlin/com/pixlfox/scriptablemc/TypescriptLibraryExporter.kt b/ScriptableMC-Tools-TS/src/main/kotlin/com/pixlfox/scriptablemc/TypescriptLibraryExporter.kt
index f6d05e41..5a68ca45 100644
--- a/ScriptableMC-Tools-TS/src/main/kotlin/com/pixlfox/scriptablemc/TypescriptLibraryExporter.kt
+++ b/ScriptableMC-Tools-TS/src/main/kotlin/com/pixlfox/scriptablemc/TypescriptLibraryExporter.kt
@@ -14,9 +14,35 @@ import java.lang.reflect.*
class TypescriptLibraryExporter(args: Array = arrayOf()) {
private var basePath: String = "./lib"
private val classList = mutableListOf>()
- private var allowedPackagesRegex: Regex = Regex("(org\\.bukkit|com\\.pixlfox|com\\.smc|fr\\.minuskube\\.inv|com\\.google|java\\.sql|java\\.io|java\\.nio|khttp|org\\.apache\\.commons\\.io)(.*)?")
private val paranamer: Paranamer = BytecodeReadingParanamer()
private val isRelease: Boolean = args.contains("--release")
+ private val packageWhitelist: MutableList = mutableListOf(
+ "org.bukkit",
+ "net.md_5.bungee.api",
+ "com.pixlfox.scriptablemc",
+ "com.smc",
+ "fr.minuskube.inv",
+ "com.google",
+ "java.sql",
+ "java.io",
+ "java.nio",
+ "khttp",
+ "org.apache.commons.io",
+ "de.tr7zw"
+ )
+ private val packageRedirects: MutableMap = mutableMapOf(
+ "de.tr7zw.changeme" to "com.smc"
+ )
+
+ private val allowedPackagesRegex: Regex
+ get() {
+ val fixedPackages: MutableList = mutableListOf()
+ for(packageName in packageWhitelist) {
+ fixedPackages.add(packageName.replace(".", "\\."))
+ }
+
+ return Regex("(${fixedPackages.joinToString("|")})(.*)?")
+ }
private fun safeName(name: String): String = when {
name.equals("function", true) -> "_function"
@@ -25,6 +51,7 @@ class TypescriptLibraryExporter(args: Array = arrayOf()) {
name.equals("name", true) -> "_name"
name.equals("", true) -> "value"
name.equals("in", true) -> "_in"
+ name.equals("with", true) -> "_with"
else -> name
}
@@ -45,11 +72,28 @@ class TypescriptLibraryExporter(args: Array = arrayOf()) {
return "Array<${javaClassToTypescript(_class.componentType)}>"
}
- if(className.equals("List", false)) {
+ if(className.equals("List", false) || className.equals("Collection", false)) {
if(genericType != null && genericType is ParameterizedType) {
val actualTypeArg = genericType.actualTypeArguments.firstOrNull()
- if(actualTypeArg != null && actualTypeArg is Class<*>) {
- return "Array<${javaClassToTypescript(actualTypeArg)}>"
+ if(actualTypeArg != null) {
+ when (actualTypeArg) {
+ is Class<*> -> {
+ return "Array<${javaClassToTypescript(actualTypeArg)}>"
+ }
+ else -> {
+ if(actualTypeArg.typeName.startsWith("? extends ")) {
+ try {
+ val extendsClass = javaClass.classLoader.loadClass(actualTypeArg.typeName.substring(10))
+ return "Array<${javaClassToTypescript(extendsClass)}>"
+ } catch(e: Exception) {
+ e.printStackTrace()
+ }
+ }
+ else {
+ println("Unknown reflection type ${actualTypeArg.javaClass.name}, name: ${actualTypeArg.typeName}")
+ }
+ }
+ }
}
}
@@ -69,8 +113,18 @@ class TypescriptLibraryExporter(args: Array = arrayOf()) {
else className
}
- fun allowPackages(regex: String): TypescriptLibraryExporter {
- this.allowedPackagesRegex = Regex(regex)
+ fun addWhitelistPackage(packageName: String): TypescriptLibraryExporter {
+ packageWhitelist.add(packageName)
+ return this
+ }
+
+ fun removeWhitelistPackage(packageName: String): TypescriptLibraryExporter {
+ packageWhitelist.remove(packageName)
+ return this
+ }
+
+ fun clearWhitelistPackages(): TypescriptLibraryExporter {
+ packageWhitelist.clear()
return this
}
@@ -90,6 +144,17 @@ class TypescriptLibraryExporter(args: Array = arrayOf()) {
com.pixlfox.scriptablemc.core.ScriptablePluginEngine::class.java,
ScriptEngineMain::class.java,
+ net.md_5.bungee.api.chat.BaseComponent::class.java,
+ net.md_5.bungee.api.chat.TextComponent::class.java,
+ net.md_5.bungee.api.chat.ComponentBuilder::class.java,
+ net.md_5.bungee.api.chat.ClickEvent::class.java,
+ net.md_5.bungee.api.chat.HoverEvent::class.java,
+ net.md_5.bungee.api.chat.KeybindComponent::class.java,
+ net.md_5.bungee.api.chat.ScoreComponent::class.java,
+ net.md_5.bungee.api.chat.SelectorComponent::class.java,
+ net.md_5.bungee.api.chat.TranslatableComponent::class.java,
+ net.md_5.bungee.api.chat.Keybinds::class.java,
+
com.smc.utils.ItemBuilder::class.java,
com.smc.utils.MysqlWrapper::class.java,
com.smc.utils.Http::class.java,
@@ -117,6 +182,11 @@ class TypescriptLibraryExporter(args: Array = arrayOf()) {
khttp.responses.GenericResponse::class.java,
khttp.responses.Response::class.java,
+ de.tr7zw.changeme.nbtapi.NBTItem::class.java,
+ de.tr7zw.changeme.nbtapi.NBTEntity::class.java,
+ de.tr7zw.changeme.nbtapi.NBTFile::class.java,
+ de.tr7zw.changeme.nbtapi.NBTContainer::class.java,
+
java.io.File::class.java
)
return this
@@ -207,7 +277,7 @@ class TypescriptLibraryExporter(args: Array = arrayOf()) {
return this
}
- private fun buildClassList(_class: Class<*>): Array> {
+ private fun buildClassList(_class: Class<*>, ignoreWhitelist: Boolean = false): Array> {
val classList = mutableListOf>()
for (_method in _class.methods) {
@@ -217,12 +287,32 @@ class TypescriptLibraryExporter(args: Array = arrayOf()) {
}
val genericType = _method.genericReturnType
- if(stripPackageName(returnType.name).equals("List", false)) {
+ val className = stripPackageName(returnType.name)
+ if(className.equals("List", false) || className.equals("Collection", false)) {
if(genericType != null && genericType is ParameterizedType) {
val actualTypeArg = genericType.actualTypeArguments.firstOrNull()
- if(actualTypeArg != null && actualTypeArg is Class<*>) {
- if (!classList.contains(actualTypeArg)) {
- classList.add(actualTypeArg)
+ if(actualTypeArg != null) {
+ when (actualTypeArg) {
+ is Class<*> -> {
+ if (!classList.contains(actualTypeArg)) {
+ classList.add(actualTypeArg)
+ }
+ }
+ else -> {
+ if(actualTypeArg.typeName.startsWith("? extends ")) {
+ try {
+ val extendsClass = javaClass.classLoader.loadClass(actualTypeArg.typeName.substring(10))
+ if (!classList.contains(extendsClass)) {
+ classList.add(extendsClass)
+ }
+ } catch(e: Exception) {
+ e.printStackTrace()
+ }
+ }
+ else {
+ println("Unknown reflection type ${actualTypeArg.javaClass.name}, name: ${actualTypeArg.typeName}")
+ }
+ }
}
}
}
@@ -259,7 +349,7 @@ class TypescriptLibraryExporter(args: Array = arrayOf()) {
}
}
- val blacklistRegex = Regex("(spigot|wait|equals|toString|hashCode|getClass|notify|notifyAll|Companion)")
+ val blacklistRegex = Regex("(wait|equals|toString|hashCode|getClass|notify|notifyAll|Companion)")
for (_field in _class.fields.filter { Modifier.isStatic(it.modifiers) &&Modifier.isPublic(it.modifiers) && !it.name.matches(blacklistRegex) }) {
val type = fixClass(_field.type)
if (!classList.contains(type) && type.name.matches(allowedPackagesRegex)) {
@@ -267,49 +357,18 @@ class TypescriptLibraryExporter(args: Array = arrayOf()) {
}
}
- return classList.toTypedArray()
+ return if(ignoreWhitelist) {
+ classList.toTypedArray()
+ } else {
+ classList.filter { allowedPackagesRegex.matches(getPackageName(it.name)) }.toTypedArray()
+ }
}
private fun buildClassList(_classes: Array>): Array> {
val classList = mutableListOf>()
for(_class in _classes) {
- for (_method in _class.methods) {
- val returnType = fixClass(_method.returnType)
- if (!classList.contains(returnType)) {
- classList.add(returnType)
- }
-
- for (_parameter in _method.parameters) {
- val type = fixClass(_parameter.type)
- if (!classList.contains(type)) {
- classList.add(type)
- }
- }
- }
-
- for (_constructor in _class.constructors) {
- for (_parameter in _constructor.parameters) {
- val type = fixClass(_parameter.type)
- if (!classList.contains(type) && type.name.matches(allowedPackagesRegex)) {
- classList.add(type)
- }
- }
- }
-
- for (_interface in _class.interfaces) {
- if (!classList.contains(_interface)) {
- if (_interface.name.matches(allowedPackagesRegex)) {
- classList.add(_interface)
- }
- }
- }
-
- if (_class.superclass != null && _class.superclass.name.matches(allowedPackagesRegex)) {
- if (!classList.contains(_class.superclass)) {
- classList.add(_class.superclass)
- }
- }
+ classList.addAll(buildClassList(_class))
}
return classList.toTypedArray()
@@ -320,7 +379,7 @@ class TypescriptLibraryExporter(args: Array = arrayOf()) {
for ((packageName, classes) in classList.sortedBy { stripPackageName(it.name) }.groupBy { getPackageName(it.name) }) {
for (_class in classes) {
- if(_class.name.matches(allowedPackagesRegex) && !_class.name.endsWith("\$Spigot")) {
+ if(_class.name.matches(allowedPackagesRegex)) {
count++
val file = File("$basePath/ts/${getPackageName(_class.name).replace('.', '/')}/${stripPackageName(_class.name)}.ts")
@@ -351,6 +410,18 @@ class TypescriptLibraryExporter(args: Array = arrayOf()) {
return this
}
+ fun exportIndexDefinition(): TypescriptLibraryExporter {
+ val file = File("$basePath/ts/index.ts")
+ if(!file.exists()) {
+ file.parentFile.mkdirs()
+ file.createNewFile()
+ file.writeText(generateTypescriptIndexDefinition())
+ println("Exported index.ts.")
+ }
+
+ return this
+ }
+
fun exportIndexLibrary(): TypescriptLibraryExporter {
val file = File("$basePath/ts/index.ts")
if(!file.exists()) {
@@ -482,16 +553,23 @@ class TypescriptLibraryExporter(args: Array = arrayOf()) {
private fun generateTypescriptImports(_class: Class<*>): String {
var tsImportsSource = ""
+ val packageFolderUri = File("$basePath/ts/${getPackageName(_class.name).replace('.', '/')}").absoluteFile.toURI()
val classList = buildClassList(_class)
for(requiredClass in classList.sortedBy { safeClassName(stripPackageName(it.name)) }) {
val packageName = getPackageName(requiredClass.name)
if(!stripPackageName(_class.name).equals(stripPackageName(requiredClass.name), true)) {
- if (packageName.matches(allowedPackagesRegex) && !requiredClass.name.endsWith("\$Spigot")) {
- val upDirCount = getPackageName(_class.name).split('.').count()
-
- tsImportsSource += "import ${safeClassName(stripPackageName(requiredClass.name))} from '${"../".repeat(upDirCount)}${getPackageName(requiredClass.name).replace('.', '/')}/${stripPackageName(requiredClass.name)}.js'\n"
+ if (packageName.matches(allowedPackagesRegex)) {
+ val scriptPathUri = File("$basePath/ts/${getPackageName(requiredClass.name).replace('.', '/')}/${stripPackageName(requiredClass.name)}.js").absoluteFile.toURI()
+ val relativeScriptUri = packageFolderUri.relativize(scriptPathUri)
+
+ tsImportsSource += if(!relativeScriptUri.isAbsolute) {
+ "import ${safeClassName(stripPackageName(requiredClass.name))} from './${relativeScriptUri.path}'\n"
+ } else {
+ val upDirCount = getPackageName(_class.name).split('.').count()
+ "import ${safeClassName(stripPackageName(requiredClass.name))} from '${"../".repeat(upDirCount)}${getPackageName(requiredClass.name).replace('.', '/')}/${stripPackageName(requiredClass.name)}.js'\n"
+ }
}
}
}
@@ -507,7 +585,7 @@ class TypescriptLibraryExporter(args: Array = arrayOf()) {
var tsGlobalExportsSource = ""
for (_class in classList.sortedBy { safeClassName(stripPackageName(it.name)) }) {
- if(_class.name.matches(allowedPackagesRegex) && !_class.name.endsWith("\$Spigot")) {
+ if(_class.name.matches(allowedPackagesRegex)) {
tsGlobalExportsSource += generateTypescriptImportForClass(_class)
}
}
@@ -515,7 +593,7 @@ class TypescriptLibraryExporter(args: Array = arrayOf()) {
for((packageName, classes) in this.classList.sortedBy { safeClassName(stripPackageName(it.name)) }.groupBy { getPackageName(it.name) }) {
tsGlobalExportsSource += "export namespace $packageName {\n"
for (_class in classes) {
- if(_class.name.matches(allowedPackagesRegex) && !_class.name.endsWith("\$Spigot")) {
+ if(_class.name.matches(allowedPackagesRegex)) {
tsGlobalExportsSource += "\texport const ${safeClassName(stripPackageName(_class.name))} = ${getPackageName(_class.name).replace('.', '_')}_${safeClassName(stripPackageName(_class.name))};\n"
}
}
@@ -525,6 +603,39 @@ class TypescriptLibraryExporter(args: Array = arrayOf()) {
return tsGlobalExportsSource + "\n"
}
+ private fun generateTypescriptIndexDefinition(): String {
+ var tsGlobalExportsSource = ""
+
+ for (_class in classList.sortedBy { safeClassName(stripPackageName(it.name)) }) {
+ if(_class.name.matches(allowedPackagesRegex)) {
+ tsGlobalExportsSource += generateTypescriptImportForClass(_class)
+ }
+ }
+
+ for((packageName, classes) in this.classList.sortedBy { safeClassName(stripPackageName(it.name)) }.groupBy { getPackageName(it.name) }) {
+ tsGlobalExportsSource += "export namespace Packages.$packageName {\n"
+ for (_class in classes) {
+ if(_class.name.matches(allowedPackagesRegex)) {
+ tsGlobalExportsSource += "\texport const ${safeClassName(stripPackageName(_class.name))} = ${getPackageName(_class.name).replace('.', '_')}_${safeClassName(stripPackageName(_class.name))};\n"
+ }
+ }
+ tsGlobalExportsSource += "}\n\n"
+ }
+
+ tsGlobalExportsSource += "export declare const Java: JavaPolyglotInterface;\n"
+ tsGlobalExportsSource += "export interface JavaPolyglotInterface {\n"
+ for(_class in this.classList.sortedBy { safeClassName(stripPackageName(it.name)) }) {
+ if(_class.name.matches(allowedPackagesRegex)) {
+ tsGlobalExportsSource += "\ttype(className: \"${_class.name}\"): typeof Packages.${getPackageName(_class.name)}.${safeClassName(stripPackageName(_class.name))};\n"
+ }
+ }
+ tsGlobalExportsSource += "\ttype(className: string): any;\n"
+ tsGlobalExportsSource += "}\n"
+
+
+ return tsGlobalExportsSource + "\n"
+ }
+
private fun generateTypescriptInterface(_class: Class<*>): String {
var methodCount = 0
var tsInterfaceSource = "export default interface ${safeClassName(stripPackageName(_class.name))}"
@@ -537,7 +648,7 @@ class TypescriptLibraryExporter(args: Array = arrayOf()) {
tsInterfaceSource += " {\n"
- val blacklistRegex = Regex("(spigot|wait|equals|toString|hashCode|getClass|notify|notifyAll|(.*?)\\\$(.*?))")
+ val blacklistRegex = Regex("(wait|equals|toString|hashCode|getClass|notify|notifyAll|(.*?)\\\$(.*?))")
for (_method in _class.methods.sortedWith(compareBy({it.name}, {it.parameterCount}))) {
if(!Modifier.isStatic(_method.modifiers) && Modifier.isPublic(_method.modifiers) && !_method.name.matches(blacklistRegex)) {
methodCount++
@@ -563,7 +674,7 @@ class TypescriptLibraryExporter(args: Array = arrayOf()) {
var tsClassSource = "export default class $className {\n"
tsClassSource += "\tpublic static get \$javaClass(): any {\n"
- tsClassSource += "\t\treturn Java.type('${_class.name}');\n"
+ tsClassSource += "\t\treturn Java.type('${getPackageName(_class.name)}.${stripPackageName(_class.name)}');\n"
tsClassSource += "\t}\n\n"
for ((index, constructor) in _class.constructors.sortedBy { it.parameterCount }.withIndex()) {
@@ -576,7 +687,7 @@ class TypescriptLibraryExporter(args: Array = arrayOf()) {
}
val countMap = mutableMapOf()
- val blacklistRegex = Regex("(spigot|wait|equals|toString|hashCode|getClass|notify|notifyAll|Companion)")
+ val blacklistRegex = Regex("(wait|equals|toString|hashCode|getClass|notify|notifyAll|Companion)")
for (_field in _class.fields.sortedBy { it.name }) {
var jsFieldName: String = _field.name
@@ -651,7 +762,7 @@ class TypescriptLibraryExporter(args: Array = arrayOf()) {
}
for(_interface in _class.interfaces) {
- if(_interface.name.startsWith("org.bukkit")) {
+ if(_interface.name.matches(allowedPackagesRegex)) {
interfaceNames.add(stripPackageName(_interface.name))
}
}
@@ -671,10 +782,10 @@ class TypescriptLibraryExporter(args: Array = arrayOf()) {
private fun getParameters(_method: Method): Array {
val parameterNames = mutableListOf()
- val paranames = paranamer.lookupParameterNames(_method, false)
+ val parameterNamesLookup = paranamer.lookupParameterNames(_method, false)
for((index, _parameter) in _method.parameters.withIndex()) {
- parameterNames.add("${safeName(paranames.getOrElse(index) { _parameter.name })}: ${safeClassName(javaClassToTypescript(_parameter.type))}")
+ parameterNames.add("${safeName(parameterNamesLookup.getOrElse(index) { _parameter.name })}: ${safeClassName(javaClassToTypescript(_parameter.type))}")
}
return parameterNames.toTypedArray()
@@ -712,7 +823,14 @@ class TypescriptLibraryExporter(args: Array = arrayOf()) {
packages.remove(packages.last())
}
- return packages.joinToString(".")
+ val packageName = packages.joinToString(".")
+
+ for((oldPackageName, newPackageName) in packageRedirects) {
+ if(packageName.startsWith(oldPackageName))
+ return packageName.replace(oldPackageName, newPackageName)
+ }
+
+ return packageName
}
private fun fixClass(_class: Class<*>): Class<*> {
diff --git a/ScriptableMC-Tools-TS/src/main/ts/JsPlugin.ts b/ScriptableMC-Tools-TS/src/main/ts/JsPlugin.ts
index 604108f5..3222c7c2 100644
--- a/ScriptableMC-Tools-TS/src/main/ts/JsPlugin.ts
+++ b/ScriptableMC-Tools-TS/src/main/ts/JsPlugin.ts
@@ -7,8 +7,11 @@ import PluginMessageListenerRegistration from "./org/bukkit/plugin/messaging/Plu
import OfflinePlayer from "./org/bukkit/OfflinePlayer.js";
import MysqlWrapper from "./com/smc/utils/MysqlWrapper.js";
import File from "./java/io/File.js";
+import ScriptablePluginEngine from "./com/pixlfox/scriptablemc/core/ScriptablePluginEngine.js";
+import ScriptEngineConfig from "./com/pixlfox/scriptablemc/ScriptEngineConfig.js";
declare type Type = { new (...args: any[]): T; };
+declare const engine: ScriptablePluginEngine;
export default class JsPlugin {
public context: ScriptablePluginContext;
@@ -17,6 +20,10 @@ export default class JsPlugin {
return this.constructor.name;
}
+ get engineConfig(): ScriptEngineConfig {
+ return engine.getConfig();
+ }
+
get server(): Server {
return this.context.getServer();
}
@@ -69,6 +76,10 @@ export default class JsPlugin {
return this.context.setPlaceholders(player, placeholderText);
}
+ getPluginInstance(pluginName: string): T {
+ return engine.getPluginInstance(pluginName);
+ }
+
onLoad(): void { console.log("[" + this.pluginName + "] onLoad()"); }
onEnable(): void { console.log("[" + this.pluginName + "] onEnable()"); }
onDisable(): void { console.log("[" + this.pluginName + "] onDisable()"); }
diff --git a/build.gradle.kts b/build.gradle.kts
index e1c0ce13..6d356680 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -7,7 +7,7 @@ plugins {
allprojects {
group = "com.pixlfox.scriptablemc"
- version = "1.2.1"
+ version = "1.3.0"
repositories {
mavenCentral()
@@ -40,6 +40,10 @@ allprojects {
name = "aikar-acf"
url = uri("https://repo.aikar.co/content/groups/aikar/")
}
+ maven {
+ name = "codemc-repo"
+ url = uri("https://repo.codemc.org/repository/maven-public/")
+ }
}
}
@@ -48,22 +52,22 @@ tasks.register("shadowJarAll") {
dependsOn(":ScriptableMC-Engine-JS:shadowJar")
dependsOn(":ScriptableMC-Engine-JS:Bundled:shadowJar")
- dependsOn(":ScriptableMC-Engine-PY:shadowJar")
- dependsOn(":ScriptableMC-Engine-PY:Bundled:shadowJar")
+// dependsOn(":ScriptableMC-Engine-PY:shadowJar")
+// dependsOn(":ScriptableMC-Engine-PY:Bundled:shadowJar")
doFirst {
if(!file("./build").exists()) file("./build").mkdirs()
if(file("./build/ScriptableMC-Engine-JS.jar").exists()) file("./build/ScriptableMC-Engine-JS.jar").delete()
if(file("./build/ScriptableMC-Engine-JS-Bundled.jar").exists()) file("./build/ScriptableMC-Engine-JS-Bundled.jar").delete()
- if(file("./build/ScriptableMC-Engine-PY.jar").exists()) file("./build/ScriptableMC-Engine-PY.jar").delete()
- if(file("./build/ScriptableMC-Engine-PY-Bundled.jar").exists()) file("./build/ScriptableMC-Engine-PY-Bundled.jar").delete()
+// if(file("./build/ScriptableMC-Engine-PY.jar").exists()) file("./build/ScriptableMC-Engine-PY.jar").delete()
+// if(file("./build/ScriptableMC-Engine-PY-Bundled.jar").exists()) file("./build/ScriptableMC-Engine-PY-Bundled.jar").delete()
}
doLast {
file("./ScriptableMC-Engine-JS/build/libs/ScriptableMC-Engine-JS.jar").copyTo(file("./build/ScriptableMC-Engine-JS.jar"), overwrite = true)
file("./ScriptableMC-Engine-JS/Bundled/build/libs/ScriptableMC-Engine-JS-Bundled.jar").copyTo(file("./build/ScriptableMC-Engine-JS-Bundled.jar"), overwrite = true)
- file("./ScriptableMC-Engine-PY/build/libs/ScriptableMC-Engine-PY.jar").copyTo(file("./build/ScriptableMC-Engine-PY.jar"), overwrite = true)
- file("./ScriptableMC-Engine-PY/Bundled/build/libs/ScriptableMC-Engine-PY-Bundled.jar").copyTo(file("./build/ScriptableMC-Engine-PY-Bundled.jar"), overwrite = true)
+// file("./ScriptableMC-Engine-PY/build/libs/ScriptableMC-Engine-PY.jar").copyTo(file("./build/ScriptableMC-Engine-PY.jar"), overwrite = true)
+// file("./ScriptableMC-Engine-PY/Bundled/build/libs/ScriptableMC-Engine-PY-Bundled.jar").copyTo(file("./build/ScriptableMC-Engine-PY-Bundled.jar"), overwrite = true)
}
}