Random class casting?
cooffeeRequired opened this issue ยท 3 comments
Skript/Server Version
[18:16:18 INFO]: [Skript] Skript's aliases can be found here: https://github.com/SkriptLang/skript-aliases
[18:16:18 INFO]: [Skript] Skript's documentation can be found here: https://docs.skriptlang.org/
[18:16:18 INFO]: [Skript] Skript's tutorials can be found here: https://docs.skriptlang.org/tutorials
[18:16:18 INFO]: [Skript] Server Version: git-Purpur-2137 (MC: 1.20.4)
[18:16:18 INFO]: [Skript] Skript Version: 2.8.2 (skriptlang-github)
[18:16:18 INFO]: [Skript] Installed Skript Addons:
[18:16:18 INFO]: [Skript] - SkJson v3.0.2 (https://www.skjson.xyz/)
[18:16:18 INFO]: [Skript] - SkBee v3.2.1 (https://github.com/ShaneBeee/SkBee)
[18:16:18 INFO]: [Skript] Installed dependencies: None
>
Bug Description
The problem arises when I use for example send {_a}
or even execute {_a} which execute {_a}
shouldn't work at all because
it expects the Request
class, but for some reason despite all this the script tries to parse {_a} as Request which is impossible.
static {
SkJsonElements.registerEffect(EffSendRequest.class,
"[:sync] (send|execute) [prepared] %request%"
);
}
function test():
execute {_a}
on load:
set {_request} to prepare new GET request on "https://fortnite-api.com/v2/creatorcode"
set {_request}'s query params to "authorization:3f87c6d5-c7dd-48db-9b62-e0a58d3e1e6a" and "name:Test"
send prepared {_request}
send response content of {_request} with pretty print
test()
The Request thing works fine. i don't have a single problem with it except that everything that starts with execute / send
the script tries to parse as Request
PS: I tried to address this in #addon-develpment but nobody replied, so I'm writing it here.
send request Effect
https://github.com/SkJsonTeam/skJson/blob/main/src/main/java/cz/coffee/skjson/skript/request/EffSendRequest.java
Thanks for the reply
Debug
[18:16:42 INFO]: [Skript] Reloading skjson.sk...
[18:16:42 INFO]: Commands synced to clients
[18:16:42 INFO]: loading 'skjson.sk'
[18:16:42 INFO]: loaded 2 structures from 'skjson.sk'
[18:16:42 INFO]: Registered function signature: test
[18:16:42 INFO]: function test():
[18:16:42 INFO]: execute prepared {_a} (as cz.coffee.skjson.api.requests.Request)
[18:16:42 INFO]: load (script load):
[18:16:42 INFO]: set {_request} (as java.lang.Object) to prepare [new] [[requestmethod:get]] [request] on "https://fortnite-api.com/v2/creatorcode"
[18:16:42 INFO]: set request params of {_request} (as cz.coffee.skjson.api.requests.Request) to ("Authorization:3f87c6d5-c7dd-48db-9b62-e0a58d3e1e6a" and "name:Test")[class java.lang.String]
[18:16:42 INFO]: execute prepared {_request} (as cz.coffee.skjson.api.requests.Request)
[18:16:42 INFO]: send json with pretty print to event-command sender
[18:16:42 INFO]: Validating function test
[18:16:42 INFO]: test()
[18:16:42 INFO]: load (script load)
[18:16:42 INFO]: set {_request} (Request{ uri: https://fortnite-api.com/v2/creatorcode, method: GET, content: null, header: null, status: UNKNOWN }, as java.lang.Object) to prepare [new] [[requestmethod:get]] [request] on "https://fortnite-api.com/v2/creatorcode"
[18:16:42 INFO]: set request params of {_request} (Request{ uri: https://fortnite-api.com/v2/creatorcode, method: GET, content: null, header: null, status: UNKNOWN }, as cz.coffee.skjson.api.requests.Request) to ("Authorization:3f87c6d5-c7dd-48db-9b62-e0a58d3e1e6a" and "name:Test")[class java.lang.String]
[18:16:42 INFO]: execute prepared {_request} (Request{ uri: https://fortnite-api.com/v2/creatorcode, method: GET, content: null, header: null, status: UNKNOWN }, as cz.coffee.skjson.api.requests.Request)
[18:16:42 INFO]: [Skript] Successfully reloaded skjson.sk. (32ms)
[18:16:42 INFO]: {
[18:16:42 INFO]: "status": 404,
[18:16:42 INFO]: "error": "the requested code is invalid or was not found"
[18:16:42 INFO]: }
[18:16:42 INFO]: [Skript] send response content of {_request} (Request{ uri: https://fortnite-api.com/v2/creatorcode, method: GET, content: null, header: null, status: FAILED }, as cz.coffee.skjson.api.requests.Request) with pretty print to [commandsender:CONSOLE]
[18:16:42 INFO]: [Skript] function test (simple event)
[18:16:42 INFO]: [Skript] test()
Expected Behavior
its may not initalize the send/execute prepared request when the %object% is not a Request
Steps to Reproduce
function test():
execute {_a}
on load:
set {_request} to prepare new GET request on ""
send prepared {_request}
send response content of {_request} with pretty print
test()
Errors or Screenshots
No response
Other
No response
Agreement
- I have read the guidelines above and affirm I am following them with this report.
This seems like just a case of your syntax over-riding the existing send syntax. Skript cannot currently know the type of a variable during parse time, so there's no way of knowing whether it really is a response or not until it runs it.