-
Notifications
You must be signed in to change notification settings - Fork 0
Functions (in progress..)
A function uses conditions and actions to execute custom logic in YAML format.
A simple function is used to execute one or more actions (do
).
function:
do: giveItem diamond
# Or with multiple actions
function:
do:
- giveItem diamond
- chatMessage <Hello, have a diamond>
A conditional function checks one or more conditions (if) and executes actions depending on whether they are met (do) or not (else).
function:
if:
- hasPermission best.out.of.ten
- onlinePlayers 1-10
do:
- chatMessage <Congrats you are the best player>
else:
- chatMessage <Sorry you suck>
A negative conditional function checks one or more conditions (if-not) and executes actions depending on whether they are met (else) or not (do).
function:
if-not: hasPermission best.player.ever
do:
- chatMessage <Sorry you suck>
else:
- chatMessage <You are the best player ever!>
Check if any conditions are met using if-any
.
function:
if-any:
- hasPermission best.player.ever
- hasPermission worst.player.ever
do: chatMessage <You are either the best or the worst player ever!>
You can define a list of functions to be executed in sequence. The stop action can be used to prevent any remaining functions in the list from running.
on-break:
- if-not: hasPermission orestack.generator.harvest
do:
- chatMessage <&4You have no permission to mine this generator>
- cancelEvent
- stop
- if-not: toolIsSimilar IRON_PICKAXE
do:
- chatMessage <&4You need an iron pickaxe to mine this generator>
- cancelEvent
- stop
- chance: 0.5
do: dropItemAtBlock dirt
You can add these options to any function for additional behavior.
-
repetitions
|loops
: Run the function a specific number of times.-
Value:
INTEGER
-
Value:
-
delay
: Delay the execution of the function.-
Value:
INTEGER
(in ticks, 20 ticks = 1 second)
-
Value:
-
chance
: Set a chance for the function to execute.-
Value:
PERCENTAGE
(0.0 - 1.0)
-
Value:
Is met based on probability, value must range from 0.0 (0%) to 1.0 (100%)
if: chance 0.1
Check the number of players currently online. You can specify an exact number a range, or multi.
if: onlinePlayers: 10
if: onlinePlayers: 1-10
if: onlinePlayers: 1;3;5
Checks the click type used by the player to interact with a block
if: clickTypeEquals left_click
if: clickTypeEquals right_click, physical
Verifies if a player has a specific permission node.
if: hasPermission example.permission.node
Checks if a player has a particular flag assigned to them.
if: hasFlag example_flag
Checks a player's current experience points. You can use an exact value, range or multi.
if: hasExp 500
if: hasExp 0-500
if: hasExp 100;250;500
Checks a player's current experience level. This also supports an exact value, range or multi.
if: hasExpLevel 100
Confirms if a player has a specific item in their inventory. You can define the item by its material or an item from the /items/
folder, and specify a quantity.
if: hasItem diamond:3
if: hasItem item_name:3
A simple check to see if the player has previously joined the server.
if: hasPlayedBefore
Check if the player has an empty slot in it's inventory
Detects if the player is currently flying.
if: isFlying
Detects if the player is currently sneaking.
if: isSneaking
Checks if the player is holding a specific item. Matches item amount.
- Must match: type, amount, name, lore, enchants, etc..
Checks if the player is holding a specific item. Ignores item amount.
- Must match: type, name, lore, enchants, etc..
if: toolIsSimilar iron_pickaxe
# Check for multiple items
if: toolIsSimilar iron_pickaxe, item_name
Checks if the player is holding a specific item type. Ignores everything else.
if: toolTypeEquals diamond_axe
if: toolTypeEquals stone_axe, iron_axe, diamond_axe
Checks if the player's held tool has a specific name. Ignores color codes.
# Use <> if value contains one or more spaces
if: toolNameEquals <Legendary Pickaxe>
Checks if the player's held tool has a lore line with a specific value. Ignores color codes.
if: toolLoreLineEquals <This is the first lore line> line=1
Checks if the player's held tool lore matches these values. Ignores color codes.
if: toolLoreEquals <This is the first line>, <This is the second line>, <This is the third line>
Checks if the player's held tool has a specific enchantment and level.
if: toolHasEnchant silk_touch level=1
Checks if the player's held tool has a specific custom model data.
if: toolHasCustomModel 100007
Compares a placeholder's value to a specific string or amount (fixed, ranged, multi).
if: placeholderEquals joshua id=%player_name% ignoreCase=true
if: placeholderEquals 10 id=%player_health%
if: placeholderEquals 10-20 id=%player_health%
if: placeholderEquals 10;15;20 id=%player_health%
Checks a player's current money balance. Requires vault. Supports amount (fixed, ranged, multi)
if: hasMoney 100
if: hasMoney 100-1000
if: hasMoney 100;1000;10000
Sends a chat message to all players on the server. Supports placeholders and color codes.
do: broadcast <This is a broadcast message>
Strikes lightning at a specific coordinate in a given world.
- Optional: world, doDamage
do: lightning world=world_name x=0 y=0 z=0 doDamage=true
Runs a command from the server console.
do: consoleCommand <say Hello World!>
Drops a specific item at a given coordinate.
- Optional: world
do: dropItem dirt world=world_name x=0 y=0 z=0
Drops specific exp at the given coordinate. Supports amount (fixed, ranged, multi).
- Optional: world, orbs
do: dropExp 100 orbs=100 world=world_name x=0 y=0 z=0
do: dropExp 10-100 x=0 y=0 z=0
do: dropExp 50;100 orbs=1-10 x=0 y=0 z=0
Spawns a particle effect at a specific coordinate.
- Optional: world
do: spawnParticle particle_name world=world_name x=0 y=0 z=0
Plays a sound at a specific coordinate.
- Optional: world
do: playSound sound_name world=world_name x=0 y=0 z=0
Ends function execution completely when called from anywhere.
function:
do:
- stop
- chatMessage <This message will NOT be sent!>
Even when used inside a global function:
# Global Function
giveDiamondIfFirstJoin:
if: hasPlayedBefore
do:
- chatMessage <This is the first time playing huh? Have a diamond!>
- giveItem diamond
- stop
on-break:
- giveDiamondIfFirstJoin
- do: chatMessage <This message will NOT be sent!>
Ends current function execution. It will only have effect on the function it is used in.
function:
do:
- return
- chatMessage <This message will NOT be sent!>
When used inside a global function:
# Global Function
giveDiamondIfFirstJoin:
if: hasPlayedBefore
do:
- chatMessage <This is the first time playing huh? Have a diamond!>
- giveItem diamond
- return
on-break:
- giveDiamondIfFirstJoin
- do: chatMessage <This message will be sent!>
Go to a specific line in a multi function. It is kind of pointless and I discourage you from using it.
- DANGEROUS: if used improperly it will cause a StackOverflowError and crash your server.
function:
- if-not: hasPermission example.permission
do: goto 5
- if-not: hasMoney 1000
do: goto 5
- if-not: hasExpLevel 100
do: goto 5
- do: chatMessage <&aYou met all requirements.>
- do: chatMessage <&4You are missing some requirements.>
Stops the event that triggered the function from continuing. For example, it could prevent a block from breaking.
Manually sets whether the event is cancelled (true
or false
).
Creates a lightning effect on the block that was interacted with.
Drops an item directly on the block.
Spawns a particle effect on the block.
Plays a sound directly on the block.
Advances the generator to its next defined stage.
Reverts the generator to its previous stage.
Sets the generator to a specific stage number.
Drops an item at the player's location.
Spawns a particle effect on the player.
Plays a sound for the player.
Gives a specific amount of experience points to the player.
Assigns a flag to the player.
Gives a specific item to the player.
Gives a specific amount of money to the player.
Removes a specific amount of experience points from the player.
Removes a flag from the player.
Removes a specific item from the player's inventory.
Removes a specific amount of money from the player.
Sets the player's experience points to a specific value.
Restores a specific amount of health to the player.
Deals a specific amount of damage to the player.
Runs a command as the player.
Sends a chat message to the player.
Sends a predefined message to the player.
Creates a lightning effect on the player.
Enables or disables flight for the player.
Teleports the player to a specific coordinate and rotation.
Opens the player's ender chest.