Skip to content

Commit 44daf86

Browse files
committed
Typo + class proxy documentation (#6)
1 parent 72914a4 commit 44daf86

File tree

2 files changed

+62
-1
lines changed

2 files changed

+62
-1
lines changed

docs/advanced/custom-syntax/events.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ call custom event %string% [(with|using) [[event-]values] %-objects%] [[and] [(w
9595
{% endcode-tabs-item %}
9696
{% endcode-tabs %}
9797

98-
The first argument should contain the name of the event you want to call. The second argument is a list variable, with each element of the following format: `{list::%type%} = %value%`. The second argument is almost the same, the only difference is that `%type%` is replaced with a string, which is just the index.
98+
The first argument should contain the name of the event you want to call. The second argument is a list variable, with each element of the following format: `{list::%type%} = %value%`. The third argument is almost the same, the only difference is that `%type%` is replaced with a string, which is just the index.
9999
The first list variable is for [the event-values](#option-event-values), while the second is for [the extra data](#extra-data).
100100

101101
### Extra data

docs/advanced/experiments.md

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,67 @@ Individual features may be enabled by adding the codename of the feature on new
2020

2121
## `proxies`
2222

23+
{% code-tabs %}
24+
{% code-tabs-item title="Syntax" %}
25+
```text
26+
[a] [new] proxy [instance] of %javatypes% (using|from) %objects%
27+
```
28+
{% endcode-tabs-item %}
29+
{% endcode-tabs %}
30+
31+
The first argument \(`%javatypes%`\) is a list of imported interfaces (whether a class is an interface can be found on the javadoc).
32+
33+
The second argument is an indexed list variable, with each element in the form `{list::%method name%} = %function%`.
34+
`%method name%` is the name of one of the methods from one of the interfaces.
35+
`%function%` is a function reference, which can be created with the following syntax:
36+
{% code-tabs %}
37+
{% code-tabs-item title="Function reference syntax" %}
38+
```text
39+
[the] function(s| [reference[s]]) %strings% [called with [[the] [arg[ument][s]]] %-objects%]
40+
```
41+
{% endcode-tabs-item %}
42+
{% endcode-tabs %}
43+
44+
The first argument \(`%strings%`\) is the name of the function you want to reference. This is enough for the function reference to be completed,
45+
but you can also add some argument values.
46+
47+
When a method from the proxy is ran, it is passed on to the function corresponding to the method name.
48+
The arguments of this function are defined in the following way:
49+
1. The argument values specified in the function reference \(if there are any\)
50+
2. The proxy instance object itself.
51+
3. The argument values from the method call.
52+
53+
Here's an example to help you understand it:
54+
{% code-tabs %}
55+
{% code-tabs-item title="Function reference syntax" %}
56+
```text
57+
import:
58+
java.lang.Runnable
59+
60+
skript-mirror, I know what I'm doing:
61+
I understand that the following features are experimental and may change in the future.
62+
I have read about this at https://skript-mirror.gitbook.io/docs/advanced/experiments
63+
proxies
64+
65+
function do_something():
66+
broadcast "It does something!"
67+
68+
command /proxy:
69+
trigger:
70+
# As you can see on https://docs.oracle.com/javase/8/docs/api/java/lang/Runnable.html
71+
# the Runnable interface has one method: run
72+
set {_functions::run} to function reference "do_something"
73+
set {_proxy} to new proxy instance of Runnable using {_functions::*}
74+
{_proxy}.run() # will broadcast 'It does something!'
75+
Bukkit.getScheduler().runTask(Skript.getInstance(), {_proxy}) # also broadcasts 'It does something!'
76+
```
77+
{% endcode-tabs-item %}
78+
{% endcode-tabs %}
79+
80+
{% hint style="info" %}
81+
Class proxies are most useful for more interaction with Java code, for example when methods require some implementation of an interface.
82+
{% endhint %}
83+
2384
## `deferred-parsing`
2485

2586
Deferred parsing allows you to prefix any line with `(parse[d] later)` to defer parsing until the first execution of the line. This allows you to circumvent issues where custom syntaxes are used before they are defined.

0 commit comments

Comments
 (0)