From af1060584c91031ee5de87ea9f91d474b251b235 Mon Sep 17 00:00:00 2001 From: Ashton Storks Date: Sat, 8 Feb 2020 20:57:18 -0700 Subject: [PATCH 1/2] Set plugin config.yml api-version to 1.13 to remove warning on start. --- src/main/resources/plugin.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 6d9d6553..51a70b6a 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -1,6 +1,7 @@ name: ScriptableMC description: 'Run JavaScript/TypeScript plugins for Bukkit/Spigot/Paper Minecraft 1.15' version: '1.1.7' +api-version: '1.13' author: AStorks main: com.pixlfox.scriptablemc.ScriptablePluginMain depend: [] From 32c58a68faafcd7167d88845c97c286b18622925 Mon Sep 17 00:00:00 2001 From: Ashton Storks Date: Sun, 9 Feb 2020 12:10:13 -0700 Subject: [PATCH 2/2] Fixed v1.12.2 'java.lang.NoSuchFieldException: knownCommands' exception on script engine unload --- .gitignore | 3 ++- build.gradle.kts | 2 +- .../scriptablemc/core/ScriptablePluginContext.kt | 10 +++++----- src/main/resources/plugin.yml | 2 +- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/.gitignore b/.gitignore index 929cb5f1..e307cdbe 100644 --- a/.gitignore +++ b/.gitignore @@ -42,4 +42,5 @@ node_modules/ .rpt2_cache/ libraries/tools/kotlin-test-nodejs-runner/lib/ local.properties -lib \ No newline at end of file +lib +libraries \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts index 780a2604..8f40fc31 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -6,7 +6,7 @@ plugins { } group = "com.pixlfox.scriptablemc" -version = "1.1.7" +version = "1.1.8" java { sourceCompatibility = JavaVersion.VERSION_1_8 diff --git a/src/main/kotlin/com/pixlfox/scriptablemc/core/ScriptablePluginContext.kt b/src/main/kotlin/com/pixlfox/scriptablemc/core/ScriptablePluginContext.kt index 5979de92..b86ba53e 100644 --- a/src/main/kotlin/com/pixlfox/scriptablemc/core/ScriptablePluginContext.kt +++ b/src/main/kotlin/com/pixlfox/scriptablemc/core/ScriptablePluginContext.kt @@ -128,17 +128,17 @@ class ScriptablePluginContext(private val engine: ScriptablePluginEngine, val pl commandMapField.isAccessible = true val commandMap = commandMapField.get(Bukkit.getServer()) as CommandMap - val knownCommandsField = commandMap.javaClass.superclass.getDeclaredField("knownCommands") - knownCommandsField.isAccessible = true - val knownCommands = knownCommandsField.get(commandMap) as HashMap<*, *> + val knownCommandsField = commandMap.javaClass.superclass.declaredFields.firstOrNull { it.name.equals("knownCommands", false) } + knownCommandsField?.isAccessible = true + val knownCommands = knownCommandsField?.get(commandMap) as HashMap<*, *>? command.unregister(commandMap) - knownCommands.remove(command.name) + knownCommands?.remove(command.name) commands.remove(command) commandMapField.isAccessible = false - knownCommandsField.isAccessible = false + knownCommandsField?.isAccessible = false } fun getFile(pathName: String): FileWrapper { diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 51a70b6a..53e870dd 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -1,6 +1,6 @@ name: ScriptableMC description: 'Run JavaScript/TypeScript plugins for Bukkit/Spigot/Paper Minecraft 1.15' -version: '1.1.7' +version: '1.1.8' api-version: '1.13' author: AStorks main: com.pixlfox.scriptablemc.ScriptablePluginMain