Addon in alpha:
This Addon is in alpha, so cause probrems please use at your own risk.
Features:
Web API Server feature:
Note:
Same as other common addons.
Example and syntax has provided in Skript Hub.
Important:
If you use reply effect in if statement, you need exit after reponse for avoid error
Also you need reply %httpexchange% as not found in last line of event
Example:
Todo:
Todo is found in my github readme.
Contributors:
Rily_: wrote the addon icon.
This Addon is in alpha, so cause probrems please use at your own risk.
Features:
Web API Server feature:
- Handle DELETE, GET, POST, PUT request.
- Send DELETE, GET, POST, PUT request.
Note:
- Current version (0.0.1) is can only work with paper server. Im plan to make it work with Spigot in the future.
- Current version (0.0.1) is only run with Minecraft version 1.19.3. Older version is supporting soon.
Same as other common addons.
- Download SkriptWebAPI-<Version>.jar from here. Lager number mean recent.
- Put your downloaded jar to server plugins folder
- Run and ready to use
Example and syntax has provided in Skript Hub.
Important:
If you use reply effect in if statement, you need exit after reponse for avoid error
code_language.skript:
if (something):
reply %httpexchange% with body %string% and response code 200
exit
code_language.skript:
on receive get request:
set {_request} to event-request
if (something):
reply {_request} with body %string% and response code 200
exit
reply {_request} as not found
Example:
code_language.skript:
# Written in plugin version 0.0.1
on skript load:
start http server in port 8080
on skript unload:
stop http server
command get:
trigger:
set {_header} to blank header
set {_header}'s properties "Content-Type" to "applicaiton/json"
set {_header}'s properties "User-Agent" to "SkriptWebAPI/0.0.1"
set {_header}'s properties "Custom" to "Custom header"
set {_a} to response of get request to "http://httpbin.org/get" with header {_header}
broadcast "response: %{_a}%"
command put:
trigger:
set {_header} to blank header
set {_header}'s properties "Content-Type" to "applicaiton/json"
set {_header}'s properties "User-Agent" to "SkriptWebAPI/0.0.1"
set {_header}'s properties "Custom" to "Custom header"
set {_a} to response of put request to "http://httpbin.org/put" with header {_header} and body "{""json"":""value""}"
broadcast "response: %{_a}%"
command post:
trigger:
set {_header} to blank header
set {_header}'s properties "Content-Type" to "applicaiton/json"
set {_header}'s properties "User-Agent" to "SkriptWebAPI/0.0.1"
set {_header}'s properties "Custom" to "Custom header"
set {_a} to response of post request to "http://httpbin.org/post" with header {_header} and body "{""json"":""value""}"
broadcast "response: %{_a}%"
command delete:
trigger:
set {_header} to blank header
set {_header}'s properties "Content-Type" to "applicaiton/json"
set {_header}'s properties "User-Agent" to "SkriptWebAPI/0.0.1"
set {_header}'s properties "Custom" to "Custom header"
set {_a} to response of delete request to "http://httpbin.org/delete" with header {_header} and body "{""json"":""value""}"
broadcast "response: %{_a}%"
on receive get request:
set {_request} to event-request
set {_path} to event-path parsed as text
if ({_path} is "/user"):
set {_user} to number of all players
set {_body} to "{""user"":""%{_user}%""}"
set {_request}'s response header "Content-Type" to "application/json"
reply {_request} with body {_body} and response code 200
exit
reply {_request} as not found
on receive put request:
set {_request} to event-request
set {_path} to event-path parsed as text
if ({_path} contains "/send/"):
set {_query} to {_path}
replace "/send/" in {_query} with ""
set {_query::*} to split {_query} at "/"
set {_user} to {_query::1} parsed as offline player
set {_message} to {_query::2}
if ({_user} is online):
send {_message} to {_user}
set {_body} to "{""sent"":true}"
else:
set {_body} to "{""sent"":false}"
set {_request}'s response header "Content-Type" to "application/json"
reply {_request} with body {_body} and response code 200
exit
reply {_request} as not found
on receive post request:
set {_request} to event-request
set {_path} to event-path parsed as text
set {_body} to ""
# If URI is http://domain/add-value/list/value
if ({_path} contains "/add-value/"):
set {_query} to {_path}
replace "/add-value/" in {_query} with ""
set {_query::*} to split {_query} at "/"
if (size of {_query::*} >= 3):
set {_body} to "{""error"":""To may arguments""}"
reply {_request} with body {_body} and response code 400
exit
# {_query::1} is "list"
# {_query::2} is "value"
if ({%{_query::1}%::*} is not set):
set {_body} to "{""list"":""not found""}"
else:
# add "value" to {list::*}
add {_query::2} to {%{_query::1}%::*}
set {_body} to "{""list"":""added""}"
set {_request}'s response header "Content-Type" to "application/json"
reply {_request} with body {_body} and response code 200
exit
reply {_request} as not found
on receive delete request:
set {_request} to event-request
set {_path} to event-path parsed as text
if ({_path} contains "/delete-variable/"):
set {_query} to {_path}
replace "/delete-variable/" in {_query} with ""
set {_query::*} to split {_query} at "/"
if ({%{_query::1}%} is not set):
set {_body} to "{""variable"":""not found""}"
else:
delete {%{_query::1}%}
set {_body} to "{""variable"":""removed""}"
set {_request}'s response header "Content-Type" to "application/json"
reply {_request} with body {_body} and response code 200
exit
reply {_request} as not found
Todo:
Todo is found in my github readme.
Contributors:
Rily_: wrote the addon icon.