- In MagicSpells, you can use variables to store information. Variables are defined by their name and the type of information they contain.
- Variables can be defined in the
general.yml
file or any spell file. The main configuration looks like this:
variables:
varName:
# (Variable configuration)
- The variable name (
varName
) should follow a naming convention:
- The name should be meaningful in indicating its use.
- It should not start with numbers or symbols, but a letter.
- It should not contain certain special characters to avoid systems processing the variable name assuming that the special character is some sort of operation. For instance, if the name contains
-
, something might assume that you're trying to do subtraction.
- It should follow
lowerCamelCase
, UpperCamelCase
or snake_case
format. (Example: meta_location_x
)
- Learn how to modify variables here.
Option |
Description |
Type |
Default |
type |
Defines the information the variable can contain. Valid types can be found below.
|
String |
"global" |
permanent |
Defines if this variable's value should be saved during reloads/restarts. |
Boolean |
true |
scoreboard-title |
If not defined, this feature will remain being disabled. The scoreboard feature only works for player type variables. Now supports color codes. |
String |
|
scoreboard-position |
Defines the position of the scoreboard display. Valid positions: sidebar , nameplate , or playerlist . |
String |
|
exp-bar |
Defines whether to display this variable on the experience bar. This does not modify the real experience. The feature only works for global and player variable types. |
Boolean |
false |
boss-bar |
If anything is defined here, the variable value will be displayed as the progress of a boss bar. This can be a boss bar title (string), or a BossBar configuration section (map). |
String or Section |
|
Option |
Description |
Type |
Default |
title |
Defines the title of the boss bar. |
String |
|
style |
Defines the boss bar style. |
String |
"solid" |
color |
Defines the boss bar color. |
String |
"purple" |
namespace-key |
Defines the namespaced key of this boss bar, with the default magicspells namespace. If this is unique, this boss bar will display separately. |
String |
"ms_variable" |
Meta variables are special variables that help you access or modify special data regarding an entity, player, server, or other. An example is getting the server's player count, setting a player's compass target location, etc. A list of these variables can be found here.
global
- The
global
variable type has no defined owner. If you're modifying it through the ms variable modify
command, you can specify the <player>
parameter as -
or any string which isn't a valid player name.
- The Java variable type of this variable is Double.
Option |
Description |
Type |
Default |
default |
Defines the default variable value. |
Double |
0 |
min |
Defines min bounds. |
Double |
0 |
max |
Defines max bounds. |
Double |
Double.MAX_VALUE = (2-2-52)·21023
|
player
The player
variable type is bound to players. All other properties of this variable type are shared with the global
variable type.
globalstring
- The
globalstring
variable type is a global type too - with no defined owner. When using the ms variable modify
, use -
as the <player>
argument.
- The Java variable type of this variable is String.
- This variable type only has the
default-value
property.
playerstring
The playerstring
is player-bound. All other properties are shared with the globalstring
variable type.
distancetolocation
- This variable cannot be modified. It returns distance calculated by the defined configuration.
- The Java variable type of this variable is String.
Option |
Description |
Type |
Default |
default |
Defines the default value to return if something failed. |
Double |
0 |
cross-world |
Defines whether the distance can be calculated across worlds. |
Boolean |
false |
target-location |
Define location to calculate distance from. Format: "world,x,y,z" . |
String |
"world,0,0,0" |
cross-world-distance-multiplier |
Defines cross-world multiplier. |
Double |
1 |
squareddistancetolocation
- The
squareddistancetolocation
variable type shares the same properties as the distancetolocation
variable type, but the result is distance squared.