Skip to content

Commit

Permalink
Fix Reques HTTP sync handling, 1.20.6 Cache saving issue resolved.
Browse files Browse the repository at this point in the history
  • Loading branch information
cooffeeRequired committed Jun 4, 2024
1 parent 482cd17 commit d5e0444
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 78 deletions.
25 changes: 23 additions & 2 deletions build-skbee.bat
Original file line number Diff line number Diff line change
@@ -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

endlocal
55 changes: 10 additions & 45 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

<groupId>cz.coffee</groupId>
<artifactId>skJson</artifactId>
<version>3.0.7</version>
<version>3.0.91</version>
<packaging>jar</packaging>

<name>SkJson</name>

<properties>
Expand All @@ -21,10 +21,10 @@
<id>maven-snapshots</id>
<url>https://repository.apache.org/content/repositories/snapshots/</url>
</pluginRepository>
<pluginRepository>
<id>bytecode.space</id>
<url>https://repo.bytecode.space/repository/maven-public/</url>
</pluginRepository>
<pluginRepository>
<id>bytecode.space</id>
<url>https://repo.bytecode.space/repository/maven-public/</url>
</pluginRepository>
</pluginRepositories>
<repositories>
<repository>
Expand Down Expand Up @@ -55,7 +55,7 @@
<dependency>
<groupId>com.shanebeestudios.skbee</groupId>
<artifactId>skbee</artifactId>
<version>3.0.1</version>
<version>3.5.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.eclipse.jetty/jetty-client -->
<dependency>
Expand Down Expand Up @@ -97,8 +97,6 @@
</dependencies>




<build>
<plugins>
<plugin>
Expand Down Expand Up @@ -130,7 +128,7 @@
<minimizeJar>false</minimizeJar>
<shadedArtifactAttached>false</shadedArtifactAttached>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer" />
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"/>
</transformers>
<filters>
<filter>
Expand All @@ -155,18 +153,10 @@
<pattern>com.github.skbee</pattern>
<shadedPattern>cz.coffee.api.nbt</shadedPattern>
</relocation>
<!-- <relocation>-->
<!-- <pattern>de.tr7zw.annotations</pattern>-->
<!-- <shadedPattern>cz.coffee.api.nbt.annotations</shadedPattern>-->
<!-- </relocation>-->
<relocation>
<pattern>org.bstats</pattern>
<shadedPattern>cz.coffee.api.bstats</shadedPattern>
</relocation>
<!-- <relocation>-->
<!-- <pattern>org.eclipse.jetty</pattern>-->
<!-- <shadedPattern>cz.coffee.api.jetty</shadedPattern>-->
<!-- </relocation>-->
</relocations>
</configuration>
<executions>
Expand Down Expand Up @@ -196,38 +186,13 @@
<configuration>
<target>
<mkdir dir="${project.basedir}/server/plugins"/>
<copy file="${project.build.directory}/${project.artifactId}-${project.version} (shaded).jar" tofile="E:/Git/mc_server/plugins/SkJson.jar"/>
<echo message="Copied successfully" />
<copy file="${project.build.directory}/${project.artifactId}-${project.version} (shaded).jar" tofile="D:/Server/plugins/SkJson.jar"/>
<echo message="Copied successfully"/>
</target>
</configuration>
</execution>
</executions>
</plugin>
<!-- <plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.6.0</version>
<configuration>
<executable>java</executable>
<workingDirectory>${project.basedir}/gen_server</workingDirectory>
<arguments>
<argument>-Xms6G</argument>
<argument>-Xmx6G</argument>
<argument>-jar</argument>
<argument>paper.jar</argument>
<argument>-u worlds</argument>
<argument>nogui</argument>
</arguments>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
</plugin>-->
</plugins>
<resources>
<resource>
Expand Down
61 changes: 31 additions & 30 deletions src/main/java/cz/coffee/skjson/skript/base/NewJsonExpression.java
Original file line number Diff line number Diff line change
Expand Up @@ -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:",
"<br />",
"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:",
"<br />",
"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 <path>",
"\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 <path>",
"\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<JsonElement> {
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%",
"@<^(\\{|\\[).+(\\}|\\])$>"
);
}

Expand Down Expand Up @@ -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) {
Expand Down
1 change: 0 additions & 1 deletion src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit d5e0444

Please sign in to comment.