Context Values
Context values are contextual values that you’ll most likely only interact with when writing scripts.
Accessing (via script functions)
Context values can be accessed and changed with the following script functions:
Function | Description | Return Type |
---|---|---|
getContextValue(name) | Gets a context value, or null if the value is not set. | any |
requireContextValue(name) | Gets a context value, or throws an error if the value is not present. | any |
listContextValues() | Gets an array of context value names. | string[] |
setContextValue(name, value) | Sets the value of a context entry. | void |
hasContextValue(name) | Tests if a context value is present. | boolean |
Context Values
Value | Description | Type |
---|---|---|
General values | ||
"player" | The player interacting with the usable | org.bukkit.entity.Player |
"silent" | Silence state. Determines if the usable sends error messages or announces commands. | boolean |
Block and Entity Values | ||
"location" | Location of the usable. | Location |
"world" | World the usable is in. | World |
"cancel_vanilla" | Vanilla interaction cancellation state. | string, one of: "true" , "false" , "if_tests_fail" , "if_tests_succeed" |
"hand" | Interaction hand. | string, one of: "hand" , "off_hand" |
Block specific Values | ||
"block" | Bukkit Block. | Block |
"useBlock" | Sets if the block the player clicked on will be used. | string, one of: "allow" , "deny" , "default" |
"useItem" | Sets if the item the player is holding will be used. | string, one of: "allow" , "deny" , "default" |
Entity specific Values | ||
"entity" | Bukkit Entity. | Entity |
Item specific Values | ||
"item" | Bukkit ItemStack. | ItemStack |
"useBlock" | Sets if the block the player clicked on will be used. | string, one of: "allow" , "deny" , "default" |
"useItem" | Sets if the item the player is holding will be used. | string, one of: "allow" , "deny" , "default" |
Area Trigger specific Values | ||
"area" | The area the trigger represents. | WorldBounds3i |
"triggerName" | The name of the trigger. | string |
"location" | Center of the trigger. | Location |
"world" | World the trigger is in. | World |
"regionAction" | Action that triggered the interaction. | string, one of: enter , exit , move_inside |
Last modified: 01.11.2024
commit: Port stuff over from tail-arc theme
commit: Port stuff over from tail-arc theme