### Skript Proxy Example (Function Reference) Source: https://tpgamesnl.gitbook.io/skript-reflect/advanced/reflection/proxies Demonstrates how to create a proxy instance for the Runnable interface and link its 'run' method to a Skript function named 'do_something'. The example shows calling the proxy directly and via Bukkit's scheduler. ```skript import: org.bukkit.Bukkit ch.njol.skript.Skript java.lang.Runnable function do_something(): broadcast "It does something!" command /proxy: trigger: # As you can see on https://docs.oracle.com/javase/8/docs/api/java/lang/Runnable.html # the Runnable interface has one method: run set {_functions::run} to function reference "do_something" set {_proxy} to new proxy instance of Runnable using {_functions::*} {_proxy}.run() # will broadcast 'It does something!' Bukkit.getScheduler().runTask(Skript.getInstance(), {_proxy}) # also broadcasts 'It does something!' ``` -------------------------------- ### Skript Proxy Example (Section) Source: https://tpgamesnl.gitbook.io/skript-reflect/advanced/reflection/proxies Provides an example of creating a proxy instance for the Runnable interface, this time using a Skript section to implement the 'run' method. The section's code is executed when the proxy's 'run' method is invoked. ```skript import: org.bukkit.Bukkit ch.njol.skript.Skript java.lang.Runnable command /proxy: trigger: # As you can see on https://docs.oracle.com/javase/8/docs/api/java/lang/Runnable.html # the Runnable interface has one method: run create section with {_proxy} stored in {_functions::run}: broadcast "It does something!" set {_proxy} to new proxy instance of Runnable using {_functions::*} {_proxy}.run() # will broadcast 'It does something!' Bukkit.getScheduler().runTask(Skript.getInstance(), {_proxy}) # also broadcasts 'It does something!' ``` -------------------------------- ### Skript Parse Section Example Source: https://tpgamesnl.gitbook.io/skript-reflect/advanced/custom-syntax/conditions An example demonstrating the 'parse' section in a Skript condition. It shows how local variables set in 'parse' are available in the 'check' section, illustrating state persistence between sections. ```skript condition example: parse: set {_test} to 1 continue check: # {_test} always starts at 1 here add 1 to {_test} # 2 is always broadcast broadcast "%{_test}%" ``` -------------------------------- ### Section Creation and Execution Example - Skript Reflect Source: https://tpgamesnl.gitbook.io/skript-reflect/advanced/reflection/sections An example demonstrating the creation and execution of a section in Skript Reflect. It shows how to define a section with an argument, use a local variable within the section, and then run the section asynchronously, storing and displaying its result. ```skript set {_i} to 2 create new section with {_x} stored in {_section}: return {_x} * {_i} run section {_section} async with 3 and store result in {_result} and wait broadcast "Result: %{_result}%" ``` -------------------------------- ### Skript Reflect: Parse Section Example Source: https://tpgamesnl.gitbook.io/skript-reflect/advanced/custom-syntax/expressions Shows an example of the 'parse' section in Skript Reflect expressions. This section is executed during parsing and can be used for validation. It demonstrates the use of 'continue' upon successful parsing and how local variables are copied by value to other sections. ```skript expression example: parse: set {_test} to 1 continue get: # {_test} always starts at 1 here add 1 to {_test} # 2 is always returned return {_test} ``` -------------------------------- ### Parse Section Example (Skript) Source: https://tpgamesnl.gitbook.io/skript-reflect/advanced/custom-syntax/events An example demonstrating the use of the 'parse' section in a custom event. Code within 'parse' is executed when the event is parsed. Local variables created here are copied by-value to other sections. A 'continue' statement is required if the event is parsed successfully. ```skript event "example": pattern: example parse: set {_test} to 1 continue check: # {_test} always starts at 1 here add 1 to {_test} # broadcasts 2 broadcast "%{"_test"}%" continue ``` -------------------------------- ### Get Plugin Instance Source: https://tpgamesnl.gitbook.io/skript-reflect/basics/utilities Returns the instance of a specified plugin. The plugin can be identified either by its Java class name or by its name as a string. ```Skript [(an|the)] instance of [the] plugin %javatype/string% ``` -------------------------------- ### Skript Reflect: Return Syntax Source: https://tpgamesnl.gitbook.io/skript-reflect/advanced/custom-syntax/expressions Provides the syntax for the 'return' statement within the 'get' section of Skript Reflect expressions. This is used to specify the value that the expression will provide when its value is read. ```skript return [%objects%] ``` -------------------------------- ### Get Object Member Names Source: https://tpgamesnl.gitbook.io/skript-reflect/basics/utilities Returns a list containing only the names of fields or methods of an object, without details about modifiers or parameters. This is a simpler way to get member identifiers. ```Skript [the] (field|method) names of %objects% %objects%'[s] (field|method) names ``` -------------------------------- ### Skript Effect Parse Section Example Source: https://tpgamesnl.gitbook.io/skript-reflect/advanced/custom-syntax/effects Demonstrates the use of the 'parse' section in a Skript effect to initialize a local variable and ensure it is passed correctly to the 'trigger' section. The 'continue' statement is necessary after successful parsing. This example shows that local variables in 'parse' are copied by value. ```skript effect example: parse: set {_test} to 1 continue trigger: # {_test} always starts at 1 here add 1 to {_test} # 2 is always broadcast broadcast "%{_test}%" ``` -------------------------------- ### Define a Computed Option in Skript Source: https://tpgamesnl.gitbook.io/skript-reflect/advanced/computed-options Defines a computed option in Skript. The 'get' section contains code that is executed upon parsing, and must return a value. Computed options are accessed using the syntax {@