From d5e044442619e2ae0e56ef9c9a87b8111f295b10 Mon Sep 17 00:00:00 2001 From: coffeeRequired <106232282+cooffeeRequired@users.noreply.github.com> Date: Tue, 4 Jun 2024 21:37:32 +0200 Subject: [PATCH] Fix Reques HTTP sync handling, 1.20.6 Cache saving issue resolved. --- build-skbee.bat | 25 +++++++- pom.xml | 55 +++-------------- .../skjson/skript/base/NewJsonExpression.java | 61 ++++++++++--------- src/main/resources/plugin.yml | 1 - 4 files changed, 64 insertions(+), 78 deletions(-) diff --git a/build-skbee.bat b/build-skbee.bat index a3f6bd6..2c6c262 100644 --- a/build-skbee.bat +++ b/build-skbee.bat @@ -1,28 +1,49 @@ @echo off REM CHMOD 777 setlocal enabledelayedexpansion + +REM Set JAVA_HOME and PATH for JDK 20 +set "JAVA_HOME=C:\Users\nexti\.jdks\graalvm-ce-21.0.2" +set "PATH=%JAVA_HOME%\bin;%PATH%" + +REM Print Java version +java --version + REM Clone the repository from GitHub git clone https://github.com/ShaneBeee/SkBee.git + REM Change to the repository directory cd SkBee + +REM Print Gradle version +REM gradlew --version + REM Run Gradle Wrapper to build the project -call gradlew clean build +REM gradlew clean build + REM Get the name of the JAR file from the libs directory for /f %%i in ('dir /b /o-d /a-d .\build\libs\*.jar') do set "jarFileName=%%i" + REM Set the delimiter set "delimiter=SkBee-" + REM Initialize the counter set "count=0" + REM Loop to split the string for /f "tokens=1,* delims=%delimiter%" %%a in ("!jarFileName!") do ( set "token[!count!]=%%a" set /a count+=1 set "inputString=%%b" ) + set "Dversion=!token[0]:~0,-4!" + REM Install the JAR file into the local Maven repository call mvn install:install-file -Dfile=build/libs/%jarFileName% -DgroupId=com.shanebeestudios.skbee -DartifactId=skbee -Dversion=!Dversion! -Dpackaging=jar + REM Delete the SkBee directory cd .. rd /s /q SkBee -endlocal \ No newline at end of file + +endlocal diff --git a/pom.xml b/pom.xml index 049f449..29524b2 100644 --- a/pom.xml +++ b/pom.xml @@ -6,9 +6,9 @@ cz.coffee skJson - 3.0.7 + 3.0.91 jar - + SkJson @@ -21,10 +21,10 @@ maven-snapshots https://repository.apache.org/content/repositories/snapshots/ - - bytecode.space - https://repo.bytecode.space/repository/maven-public/ - + + bytecode.space + https://repo.bytecode.space/repository/maven-public/ + @@ -55,7 +55,7 @@ com.shanebeestudios.skbee skbee - 3.0.1 + 3.5.2 @@ -97,8 +97,6 @@ - - @@ -130,7 +128,7 @@ false false - + @@ -155,18 +153,10 @@ com.github.skbee cz.coffee.api.nbt - - - - org.bstats cz.coffee.api.bstats - - - - @@ -196,38 +186,13 @@ - - + + - diff --git a/src/main/java/cz/coffee/skjson/skript/base/NewJsonExpression.java b/src/main/java/cz/coffee/skjson/skript/base/NewJsonExpression.java index 90149be..4acad79 100644 --- a/src/main/java/cz/coffee/skjson/skript/base/NewJsonExpression.java +++ b/src/main/java/cz/coffee/skjson/skript/base/NewJsonExpression.java @@ -39,35 +39,35 @@ @Name("New json") @Description({ - "latest:", - "\t\t- support now also multiple items as input", - "\t\t- support json content from webpage", - "\t\t- removed empty json array/object, cause it's not necessary while", - "skJson know parsing object", - "original docs: https://skjsonteam.github.io/skJsonDocs/exprs#new-json", - "skripthub docs:", - "
", - "It's allow create json from any source also from the file" + "latest:", + "\t\t- support now also multiple items as input", + "\t\t- support json content from webpage", + "\t\t- removed empty json array/object, cause it's not necessary while", + "skJson know parsing object", + "original docs: https://skjsonteam.github.io/skJsonDocs/exprs#new-json", + "skripthub docs:", + "
", + "It's allow create json from any source also from the file" }) -@Since("2.9, 2.9.3 - Literal parsing") +@Since("2.9, 2.9.3 - Literal parsing, 3.1.0 - Request checks fix") @Examples({ - "on script load:", - "\tset {_json} to json from json file \"plugins/Skript/json-storage/database.json\"", - "\tset {_json::*} to json from \"{'test' :true}\", \"B\"", - "\tset {_json} to json from diamond tools", - "\tset {_json} to json from player's location", - "\tset {_json} to json from player's inventory", - "\tset {_json} to json from yaml file ", - "\tset {_json} to json from website file \"https://json.org/sample.json\"", - "*Literal", - "set {_json} to @{\"test\": true, \"var\": {_test}}" + "on script load:", + "\tset {_json} to json from json file \"plugins/Skript/json-storage/database.json\"", + "\tset {_json::*} to json from \"{'test' :true}\", \"B\"", + "\tset {_json} to json from diamond tools", + "\tset {_json} to json from player's location", + "\tset {_json} to json from player's inventory", + "\tset {_json} to json from yaml file ", + "\tset {_json} to json from website file \"https://json.org/sample.json\"", + "*Literal", + "set {_json} to @{\"test\": true, \"var\": {_test}}" }) public class NewJsonExpression extends SimpleExpression { static { SkJsonElements.registerExpression(NewJsonExpression.class, JsonElement.class, ExpressionType.COMBINED, - "json from [1:(text|string)|2:([json]|:yaml) file|3:web[site] [file]] [object] %objects%", - "@<^(\\{|\\[).+(\\}|\\])$>" + "json from [1:(text|string)|2:([json]|:yaml) file|3:web[site] [file]] [object] %objects%", + "@<^(\\{|\\[).+(\\}|\\])$>" ); } @@ -119,20 +119,21 @@ private File sanitizedFile(String file) { RequestResponse rp = null; try (var client = new RequestClient(url.toString())) { rp = client - .method("GET") - .addHeaders(new WeakHashMap<>(Map.of("Content-Type", "application/json"))) - .request().join(); + .method("GET") + .addHeaders(new WeakHashMap<>(Map.of("Content-Type", "application/json"))) + .request().join(); } catch (Exception ex) { error(ex, Bukkit.getConsoleSender(), getParser().getNode()); } return rp; }); - JsonElement elem = (JsonElement) ft.join().getBodyContent(false); - if (elem instanceof JsonNull nil) { - warn("You cannot get non-json content via this."); - output.add(nil); + RequestResponse joined = ft.join(); + if (joined != null && joined.isSuccessfully()) { + JsonElement element = (JsonElement) joined.getBodyContent(false); + output.add(element); } else { - output.add(elem); + warn("You cannot get non-json content via this."); + output.add(JsonNull.INSTANCE); } } else { for (Object value : values) { diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index a4d2e9f..49f9e85 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -9,7 +9,6 @@ depend: prefix: SkJson author: CoffeeRequired description: ' SkJson is module/addon for well-known programming language Skript for minecraft world. %nl% SkJson is used for parsing JSON data from any object like website api,%nl% skript object e.g. (item, location), file, yaml-file, text.' -website: https://www.skjson.xyz/ commands: skjson: description: basic skjson