### Skript: Example Script Load with Skungee Initialization Source: https://docs.skunity.com/addons/Skungee This example Skript illustrates common tasks performed on script load using Skungee. It includes waiting for Skungee to connect, setting and getting BungeeCord YAML configuration values, and asynchronously updating network variables. This setup ensures Skungee is ready before essential operations. ```skript on script load: wait until skungee has connected set bungee yaml value "test" from "plugins/Test/config.yml" to 5 set {_value} to bungeecord yaml value "test" from "plugins/Test/config.yml" set async variable {_example} to the network variable {some::example} broadcast "%{_value}%" ``` -------------------------------- ### Create a Java Project in Eclipse Source: https://docs.skunity.com/guides/guide/addon-development Instructions for creating a new Java project in Eclipse, which serves as the foundation for a Skript addon. This step is crucial for organizing your addon's code and resources. ```text File -> New -> Java Project ``` -------------------------------- ### Manage Merchant Recipes List Source: https://docs.skunity.com/addons/MiSK This example illustrates using MerchantUtils to create and manage lists of merchant recipes. It shows how to get an empty list or a list pre-populated with existing recipes, returning a Java List. ```skript import: com.moderocky.misk.utils.MerchantUtils set {list} to MerchantUtils.tradeList() set {list} to MerchantUtils.tradeList({recipes}) # returns a mutable Java List for MerchantRecipes # the second allows you to add a pre-existing collection ``` -------------------------------- ### Skript - Global Chat Server Setup and Command Source: https://docs.skunity.com/guides/tutorial/6289 This Skript code sets up the server-side logic for a global chat. It includes a command to enable/disable the chat, defines chat handling, and starts a WebSocket server. It relies on a global variable {GlobalChatEnabled} to track the chat status. ```skript set {GlobalChatEnabled} to false command /enableglobalchat: trigger: if {GlobalChatEnabled}: send "&2GlobalChat is already enabled!" stop trigger set {GlobalChatEnabled} to true start websocket server "global chat" at port 25000 send "&2GlobalChat has been enabled!" on chat: if {GlobalChatEnabled}: cancel event sendGlobalMessage("%player%", message) ``` -------------------------------- ### WebSK Basic Setup with Skript Source: https://docs.skunity.com/addons/WebSK This snippet demonstrates the basic setup for the WebSK addon in Skript. It defines a webserver and listens for the 'on request' event to execute custom Skript code. ```skript define webserver: port: 8000 on request: # your code ``` -------------------------------- ### Executing BungeeCord Commands and Actions Source: https://docs.skunity.com/guides/tutorial/3595 Shows how to execute commands directly on the BungeeCord console and how to evaluate expressions on all connected servers using SkellettProxy. ```skript # Execute bungeecord commands skellettcord execute bungeecord console command "end" # Execute an action in every connected server loop all bungeecord servers: evaluate "broadcast \"&cJust a tutorial!\"" on bungeecord server "%loop-value%" ``` -------------------------------- ### Example: Get Antonyms in Skript Source: https://docs.skunity.com/addons/SkriptLanguage An example illustrating how to get antonyms for the word 'yes' and store them in a list variable `_notyes::*` using the SkriptLanguage addon. ```skript get antonyms of "yes" and store them in {_notyes::*} ``` -------------------------------- ### Skript GUI Slot Formatting Examples Source: https://docs.skunity.com/guides/tutorial/2349 This Skript code showcases how to format GUI slots with various actions. It includes examples for opening inventories, setting item names, closing inventories, running player or console commands, executing functions, and handling GUI events. ```Skript command /guiExample: trigger: open virtual chest inventory to player format gui slot 0 of player with stone named "It won't do anything" format gui slot 1 of player with stone named "It will just close" to close format gui slot 2 of player with stone named "It will just close but only with pressing a number key" to close using number key format gui slot 3 of player with stone named "It will make the player execute a command, but he might not have permission" to run player command "/gui" format gui slot 4 of player with stone named "It will make the player execute a command with \"*\" permission" to run player command "/gui" with permission "*" format gui slot 5 of player with stone named "It will make the console execute a command" to run console command "/gui" format gui slot 6 of player with stone named "It will run the function doSomething()" to run function doSomething() format gui slot 7 of player with stone named "It will close and then run the function doSomething()" to close then run function doSomething() format gui slot 8 of player with stone named "It will run doSomething() if you click on it with a stone" to run function doSomething() with cursor stone format gui slot 9 of player with stone named "It will run the gui event" to run gui event ``` -------------------------------- ### Example: Get Definition in Skript Source: https://docs.skunity.com/addons/SkriptLanguage An example demonstrating how to get the definition of the word 'lobby' and store it in a Skript variable `_lobbydefinition` using the SkriptLanguage addon. ```skript get the definition of "lobby" and store it in {_lobbydefinition} ``` -------------------------------- ### Debugging Metadata Usage in Skript Source: https://docs.skunity.com/guides/guide/debug This snippet shows a common mistake when trying to read multiple metadata keys at once and how to debug it. It suggests starting with a simpler example to verify basic functionality before attempting more complex operations. ```skript command /debug: trigger: set {_metadata} to metadata ("lastchat" or "2ndlastchat") of player send "%{_metadata}%" ``` -------------------------------- ### Complete Command Example with Trigger Source: https://docs.skunity.com/guides/guide/general-skript-tutorial A comprehensive example of a custom command including all its options and a trigger block. The trigger defines the actions that occur when the command is executed, utilizing indented code blocks. ```skript command /help []: description: Shows the help menus usage: /help [page] permission: help.permission permission message: &cYou don't have the help permission! executable by: players and console aliases: /h, /helpmerightnow trigger: message "This is a help command!" ``` -------------------------------- ### Example: Get Random Word in Skript Source: https://docs.skunity.com/addons/SkriptLanguage An example demonstrating how to get a random English word and store it in the Skript variable `_word` using the SkriptLanguage addon. ```skript get a random english word and store it in {_word} ``` -------------------------------- ### Define a Basic Command Source: https://docs.skunity.com/guides/guide/general-skript-tutorial This snippet shows the fundamental syntax for defining a command named '/test'. It sets the stage for adding arguments and defining the command's behavior. ```skript command /test: ``` -------------------------------- ### Add Skript and Spigot as External Jars in Eclipse Source: https://docs.skunity.com/guides/guide/addon-development Details the process of adding Skript and Spigot/PaperSpigot JAR files as external dependencies to your Java project in Eclipse. This ensures your addon can interface with Skript and the Spigot API. ```text Right-click project -> Properties -> Java build path -> Libraries -> Add external jars ``` -------------------------------- ### Skent Async System Example Source: https://docs.skunity.com/addons/Skent Demonstrates the new async/sync system in Skent for handling operations like downloading, unzipping, and file deletion. It shows how to use 'sync' and allows 'async' operations to be omitted, executing them by default. This system requires Skript 2.6.2+ and uses libraries like ch.eitchnet:cron and com.coreoz:wisp. ```skript command test: trigger: set {_download_link} to "https://github.com/Olyno/skent/archive/refs/tags/3.1.0.zip" sync download file from {_download_link} to file path "plugins/abc.zip" sync unzip all files from file path "plugins/abc.zip" to dir path "plugins/abc" delete file path "plugins/abc.zip" # This line is executed in async by default, i can omit the "async" prefix. ``` -------------------------------- ### Example YAML Configuration for Kits Source: https://docs.skunity.com/guides/tutorial/33 This is an example of a `yamlkits.yml` file used in conjunction with the skUnity script. It demonstrates the structure for defining multiple kits, each with an 'enabled' status and a list of items. ```yaml ## Spoiler: yamlkits.yml This is the yaml file. You can put this anywhere you want in your server, as long as you change the file path in the script options. kits: redstone: enabled: true items: - 64 redstone - 64 redstone torch on - 64 redstone repeaters - 64 redstone comparators - 64 redstone blocks - 64 sticky pistons - 64 pistons - 64 stone button - 64 lever pet: enabled: true items: - a wolf spawn egg - 10 bones - 1 name tag custom-1: enabled: false items: - a diamond pickaxe - a diamond sword - a bow - 64 arrows ``` -------------------------------- ### Essential plugin.yml Structure Source: https://docs.skunity.com/guides/guide/addon-development Defines the mandatory 'plugin.yml' file required for any Spigot plugin, including Skript addons. It specifies essential fields like 'version', 'name', and 'main', along with optional fields like 'authors'. ```yaml name: MySkriptAddon version: 1.0.0 main: com.example.myskriptaddon.Main authors: - YourName ``` -------------------------------- ### Skript Example: Testing skScraft Source: https://docs.skunity.com/addons/skScraft This Skript example demonstrates how to use skScraft syntaxes and provides instructions to enable debug mode in the configuration file for troubleshooting. It includes a loop that appears incomplete in the provided text. ```skript command /test: trigger: send "" send "&eskScraft &e» &6TO SEE THE REAL MAGIC IN CONSOLE:" send "&eskScraft &e» &6SET &dDEBUG MODE &6TO &dTRUE &6IN CONFIG" send "" loop 5 times: ``` -------------------------------- ### Get Placeholder Values with Ersatz Source: https://docs.skunity.com/addons/Ersatz This snippet illustrates how to fetch the value of an existing PlaceholderAPI placeholder within Skript using the Ersatz addon. It shows how to store the placeholder's value in a variable and then use it, for example, in a broadcast message. This requires the Ersatz addon to be installed. ```skript on join: set {_ping} to placeholder "player_ping" # placeholder "%%player_ping%%" is also valid broadcast "your ping is %{_ping}%" ``` -------------------------------- ### Start WebSocket Server Source: https://docs.skunity.com/guides/tutorial/6289 Starts a WebSocket server instance using a specified template ID and listens on a given port. The port must be available and not in use by other services. ```MundoSK start websocket server %string% at port %number% ``` -------------------------------- ### Skript Invalid Indentation Example (Error) Source: https://docs.skunity.com/guides/guide/how-to-get-indentations-right Presents an example of incorrect indentation in Skript that will lead to an indentation error. This typically occurs when code that should be indented is not, or vice versa. ```skript # will throw an indentation error command /test: trigger: tool of player is dirt send "you have dirt" ``` -------------------------------- ### Skript: Basic Recursive Function (Potentially Unsafe) Source: https://docs.skunity.com/guides/guide/debug An example of a basic recursive function without safety measures. This is presented as a 'bad example' to highlight the risks of uncontrolled recursion, which can lead to server crashes. ```skript function factorial(n: number) :: number: return 1 if {_n} = 1 return {_n} * factorial({_n} - 1) ``` -------------------------------- ### Create and Apply Equippable Component (Skript) Source: https://docs.skunity.com/addons/Skript Shows how to create a blank equippable component, modify its properties like camera overlay and sounds, and then apply it to an item. ```skript set {_component} to a blank equippable component: set the camera overlay to "custom_overlay" set the allowed entities to a zombie and a skeleton set the equip sound to "block.note_block.pling" set the equipped model id to "custom_model" set the shear sound to "ui.toast.in" set the equipment slot to chest slot allow event-equippable component to be damage when hurt allow event-equippable component to be dispensed allow event-equippable component to be equipped onto entities allow event-equippable component to be sheared off allow event-equippable component to swap equipment set the equippable component of {_item} to {_ component} ``` -------------------------------- ### Unreliable 'send' Effect Example in Skript Source: https://docs.skunity.com/guides/guide/debug This example demonstrates the unreliability of the 'send' effect for debugging, especially when interacting with players. It shows how 'send' might not deliver messages to the activating player, unlike 'broadcast'. ```skript on right click: send "fired" on projectile hit: send "hit" ``` -------------------------------- ### Skript Example: Loading YAML Source: https://docs.skunity.com/addons/skript-yaml Provides a basic Skript example for loading a YAML file into memory. This is a foundational step for manipulating and saving YAML data within Skript scripts. ```skript # Load a YAML file load yaml "plugins/skript-yaml/test/test.yml" as "test" ``` -------------------------------- ### Skript Suppressed Error Indentation Example Source: https://docs.skunity.com/guides/guide/how-to-get-indentations-right Shows a Skript code structure that might appear to have incorrect indentation but is designed to suppress errors, often by implicitly handling conditions. This example demonstrates a scenario where a colon might be used to avoid an error. ```skript # will suppress the error. command /test2: trigger: tool of player is dirt: send "you have dirt" ``` -------------------------------- ### Getting Region Members and Owners Source: https://docs.skunity.com/syntax/search/from%3Askjade These expressions retrieve lists of members or owners for specified regions. This feature depends on a supported regions plugin being installed. ```skript set {_members} to members of region "main_area" ``` ```skript set {_owners} to owners of {%regions%} ``` -------------------------------- ### Skript: Playback and Manipulation of Noteblock Songs Source: https://docs.skunity.com/addons/FunkySk This Skript example demonstrates how to play songs from files or URLs, manage song players, and handle song playback based on boolean arguments. It shows how to play a song directly, set a song from a file, and retrieve multiple songs from different files. ```skript command /testing []: trigger: if the argument 1 is true: message "&5Playing track" if argument 2 is set: play song from file string-argument to player else: play song file "plugins/FunkySk/test.nbs" to player else: message "&6Testing the second method" if argument 2 is set: set {_song} to song from file string-argument else: set {_song} to song from file "plugins/FunkySk/test.nbs" set {_songs::*} to songs from file "plugins/FunkySk/test.nbs" and "plugins/FunkySk/test2.nbs" play noteblock song {_song} to player ``` -------------------------------- ### Skript Command Example for skUnity Source: https://docs.skunity.com/guides/guide/help-request-layout A basic Skript command demonstrating how to display a message to a player. This example is used within the skUnity help request layout to showcase the 'Full Code' section. ```skript command /skunity: trigger: message "&6&lskUnity... go here! http">://skunity.com" to person ``` -------------------------------- ### Get Player Count on a Specific BungeeCord Server Source: https://docs.skunity.com/addons/skScraft This code fetches the number of players currently connected to a specified BungeeCord server ('servername2' in this example). The result is stored and then displayed. ```skUnity set {_online} to number of players on bungeecord server "servername2" send "&eskScraft &e» &6The server should be offline, and give ." send "&eskScraft &e» &6Result %{_online}%." ``` -------------------------------- ### Simple Skript ID Command Example Source: https://docs.skunity.com/guides/guide/commands A practical example of a Skript command that retrieves and displays the ID of a held item. It utilizes an optional item argument that defaults to the player's currently held item ('tool'). The 'id of arg 1' expression is used to get the item's ID. ```skript #A simple ID command to get the id of the held item command /id : description: Find the ID of the item you're holding, or any given one. usage: /id [type] executable by: players trigger: message "The ID of %arg 1% is %id of arg 1%" ``` -------------------------------- ### Java: Skript Addon Registration and Syntax Loading Source: https://docs.skunity.com/guides/guide/registering-your-addon This Java code demonstrates the core logic for registering a Skript addon and loading its syntax elements. The `onEnable` method is automatically called by Spigot on server startup. It initializes the addon instance and then uses `addon.loadClasses` to register all syntax defined within the specified package ('me.limeglass.addon.elements'). Error handling for `IOException` is included. ```java package me.limeglass.addon; import java.io.IOException; import org.bukkit.plugin.java.JavaPlugin; import ch.njol.skript.Skript; import ch.njol.skript.SkriptAddon; public class ExampleMain extends JavaPlugin { ExampleMain instance; SkriptAddon addon; public void onEnable() { instance = this; addon = Skript.registerAddon(this); try { //This will register all our syntax for us. Explained below addon.loadClasses("me.limeglass.addon", "elements"); } catch (IOException e) { e.printStackTrace(); } Bukkit.getLogger().info("[ExampleAddon] has been enabled!"); } public ExampleMain getInstance() { return instance; } public SkriptAddon getAddonInstance() { return addon; } } ``` -------------------------------- ### Create and Open Vanilla GUI using Metadata (Skript) Source: https://docs.skunity.com/guides/tutorial/8939 Demonstrates creating a vanilla GUI by storing the inventory in player metadata, setting items in specific slots, and opening the inventory to the player. Handles inventory clicks to cancel the event and provides specific logic for interacting with items in slot 0 and slot 1. ```skript command /vanillaGUI: description: The best way of doing something. trigger: set metadata tag "vanillaGUI" of player to chest inventory with 3 rows"sk-comment"># named "&7Hello There" set slot 0 of metadata tag "vanillaGUI" of player to stone named "&6General Kenobi" set slot 1 of metadata tag "vanillaGUI" of player to player's skull named "&6%player%" with lore "&7Right click me to receive my head!" open (metadata tag "vanillaGUI" of player) to player on inventory click: if event-inventory = (metadata tag "vanillaGUI" of player)"sk-var">: #check if the clicked inventory is the one we just created cancel event #cancel the clicking. This makes the Item unstealable if index of event-slot is 0: #check if the clicked slot is the stone, so 0 give event-slot to player #give the clicked item to the player. else if index of event-slot is 1: #check if the clicked slot is the skull, so 1 if event-click type is right mouse button: #check if the player right clicks the item set {_playerHead} to uncolored name of event-slot parsed as player give event-slot to player send "&6Player %player% has received a skull of you!" to {_playerHead} #since we can't use arguments, we just parse the name of the event-slot and get the skull by doing that. #you can use the variable as you like. I simply sent a plain text to the player. #ban {_playerHead} would also work #using NBT will work as well! ``` -------------------------------- ### Get Max Durability - TuSKe Source: https://docs.skunity.com/syntax/search/addon%3Atuske Returns the maximum durability value for an item stack. This value can be modified. For example, a diamond sword has a max durability of 1561. ```skript set {_max_durability} to max durability of player's held item ``` -------------------------------- ### Points Command Example (Skript) Source: https://docs.skunity.com/guides/tutorial/10951 An example Skript command demonstrating how to utilize the player data management functions (getPoints, setPoints, addPoints, removePoints). It parses arguments to perform specific actions on player points. ```skript command /points [] []: trigger: if arg-1 = "get""sk-var"> send "Points for %arg-2%">: %getPoints(arg-2)%" else if arg-1 = "set""sk-var"> setPoints(arg-2, arg-3) else if arg-1 = "add""sk-var"> addPoints(arg-2, arg-3) else if arg-1 = "remove""sk-var"> removePoints(arg-2, arg-3) ``` -------------------------------- ### Java get() Method for Retrieving Player Name Source: https://docs.skunity.com/guides/guide/creating-an-expression This Java code implements the 'get()' method, which is the core logic for retrieving data in Skript expressions. It fetches a single player using the player expression, checks if the player is not null, and then returns the player's display name as a String array. If no player is found, it returns null. ```java @Override @Nullable protected String[] get(Event event) { Player p = player.getSingle(event); if (p != null) { return new String[] {p.getDisplayName()}; } return null; } ``` -------------------------------- ### Initialize LootTableUtils Source: https://docs.skunity.com/addons/MiSK This example demonstrates how to import and use the LootTableUtils class from the MISK plugin. It shows how to generate a new random seed for loot table operations. ```skript import: com.moderocky.misk.utils.LootTableUtils set {variable} to LootTableUtils.newSeed() # returns a Java Random ``` -------------------------------- ### Skript Boss Bar Creation and Customization Example Source: https://docs.skunity.com/addons/skript-bossbar This Skript code demonstrates how to create a new boss bar, set its title, color, and add all players to it. It requires the skript-bossbar addon to be installed. ```skript command /bossbar: trigger: set {bossbar} to new bossbar set name of bossbar {bossbar} to "&a&lBoss bar titles support Minecraft color coding!" set color of bossbar {bossbar} to red add all players to bossbar {bossbar} ```