Region Flags - SkriptLang/skript-worldguard GitHub Wiki

skript-worldguard provides full control over WorldGuard's region flags with complete type support.

[!NOTE] While skript-worldguard supports all vanilla region flags, it is possible that those added by other plugins may not work.

Getting Region Flags

Getting the value of a flag is simple. The syntax for doing so is:

[the] [region] flag %string% of %worldguardregions%

[!NOTE] If a flag is not explicitly set on a region, its default value will be returned instead.

Consider the following expressions:

the flag "greeting" of the regions at the player
the flag "feed-max-hunger" of the regions at the player

image

The returned values will be properly typed. For example, you could perform arithmetic:

set {_region} to the region "my_region" in world "my_world"
set {_number} to the flag "feed-max-hunger" of {_region}
send "The value of the flag 'feed-max-hunger' doubled is %{_number} * 2%"

image

Region Group Flags

WorldGuard also supports specifying the type of players (groups) that a flag applies to (click here to read more).

This feature is supported by modifying the group flag of a flag. The syntax for doing so is:

[the] [region] group flag of [the] flag %string% of %worldguardregions%

The value of a region group flag is always a text/string.

Considering one of our examples from above:

the group flag of the flag "greeting" of the regions at the player

image

In the screenshot above, the group flag for the greeting flag has not been set, so it returns the default value: all (meaning it applies to all players). However, if I use the region flag command to set the value to something else, say owners, we can see this value reflected when evaluating the expression again: image

Changing Region Flags

skript-worldguard also supports changing flags, though which change operations are supported depends on what type of value a flag holds. Each change operation, and what types of flags it supports, is covered below.

Setting

Every flag supports the set change operation.

Once again considering the flags from above, setting a new value for them is trivial:

set the flag "greeting" of the regions at the player to "Welcome to my region!"
set the flag "feed-max-hunger" of the regions at the player to 5

We can print the flags again to view their updated values:

image

Setting Group Flags

We can also set the group flag of a flag to control who it applies to.

set the group flag of the flag "greeting" of the regions at the player to "nonowners"

We can print the flags again to view their updated values:

image

Deleting/Resetting

Every flag supports the delete and reset change operations. For flags, these operations function the exact same. That is, it does not matter which you use.

Perhaps we no longer want the greeting we set above. We can easily remove it:

delete the flag "greeting" of the regions at the player

After executing that statement, we can re-evaluate the flag and see that it has been cleared:

image

Deleting/Resetting Group Flags

It is also possible to delete only the group flag of a flag.

[!NOTE] Deleting/resetting a flag also clears its group flag. That is, if you delete a flag and then set it again, the group flag value is not preserved.

It turns out we did want to keep our greeting, but we did not want to explicitly restrict who it applies to. If that is the case, we reset only the group flag:

reset the group flag of the flag "greeting" of the regions at the player

After running that statement and evaluating the expression again, we see that the flag once again applies to everyone:

image

Adding/Removing

Only flags that return numeric values or lists support the add and remove operations. For numeric values, this is adding and subtracting a number from the flag's value. For lists, this is adding and removing values from the list.

We consider a flag for each type. feed-max-hunger represents a numeric value and deny-spawn represents a list. Consider the following statements to update these flags:

add 5 to the flag "feed-max-hunger" of the regions at the player
add guardian to the flag "deny-spawn" of the regions at the player

We can evaluate the expressions, execute the statements, and then evaluate the expressions again:

image

To undo those additions, removing is just as easy:

remove 5 from the flag "feed-max-hunger" of the regions at the player
remove guardian from the flag "deny-spawn" of the regions at the player

We can evaluate the expressions, execute the statements, and then evaluate the expressions again:

image


That is about it when it comes to working with flags! Have any ideas or suggestions? Feel free to open an issue.