Player

Loading and Saving Player Data

Load

Command
Script
Command

/kit create <id> [mode] [-i]

Creates a new kit with a given ID and adds an optional kit mode (see Kit Modes)

Kit IDs are case-insensitive. Only one kit can exist with a given id.

  • -i will set the kits contents to the items in your inventory

Script

- run drustcraft.player.load def:<player>

Creates a new kit with a given ID and adds an optional kit mode (see Kit Modes)

Kit IDs are case-insensitive. Only one kit can exist with a given id.

  • items A list of items to use to set the kits contents.

Save

Command
Script
Command

/kit create <id> [mode] [-i]

Creates a new kit with a given ID and adds an optional kit mode (see Kit Modes)

Kit IDs are case-insensitive. Only one kit can exist with a given id.

  • -i will set the kits contents to the items in your inventory

Script

- run drustcraft.player.save def:<player>

Creates a new kit with a given ID and adds an optional kit mode (see Kit Modes)

Kit IDs are case-insensitive. Only one kit can exist with a given id.

  • items A list of items to use to set the kits contents.

Save All

Command
Script
Command

/kit create <id> [mode] [-i]

Creates a new kit with a given ID and adds an optional kit mode (see Kit Modes)

Kit IDs are case-insensitive. Only one kit can exist with a given id.

  • -i will set the kits contents to the items in your inventory

Script

- run drustcraft.player.save_all

Creates a new kit with a given ID and adds an optional kit mode (see Kit Modes)

Kit IDs are case-insensitive. Only one kit can exist with a given id.

  • items A list of items to use to set the kits contents.

Unload

Command
Script
Command

/kit create <id> [mode] [-i]

Creates a new kit with a given ID and adds an optional kit mode (see Kit Modes)

Kit IDs are case-insensitive. Only one kit can exist with a given id.

  • -i will set the kits contents to the items in your inventory

Script

- run drustcraft.player.unload def:<player>

Creates a new kit with a given ID and adds an optional kit mode (see Kit Modes)

Kit IDs are case-insensitive. Only one kit can exist with a given id.

  • items A list of items to use to set the kits contents.

Cooldowns

Set Cooldown

Command
Script
Command

/kit create <id> [mode] [-i]

Creates a new kit with a given ID and adds an optional kit mode (see Kit Modes)

Kit IDs are case-insensitive. Only one kit can exist with a given id.

  • -i will set the kits contents to the items in your inventory

Script

- run drustcraft.player.set_cooldown def:<player>|[duration]

Creates a new kit with a given ID and adds an optional kit mode (see Kit Modes)

Kit IDs are case-insensitive. Only one kit can exist with a given id.

  • items A list of items to use to set the kits contents.

In Cooldown

Command
Script
Command

/kit create <id> [mode] [-i]

Creates a new kit with a given ID and adds an optional kit mode (see Kit Modes)

Kit IDs are case-insensitive. Only one kit can exist with a given id.

  • -i will set the kits contents to the items in your inventory

Script

- <proc[drustcraftp.player.in_cooldown].context[<player>]>

Creates a new kit with a given ID and adds an optional kit mode (see Kit Modes)

Kit IDs are case-insensitive. Only one kit can exist with a given id.

  • items A list of items to use to set the kits contents.

Alts

Command
Script
Command

/kit create <id> [mode] [-i]

Creates a new kit with a given ID and adds an optional kit mode (see Kit Modes)

Kit IDs are case-insensitive. Only one kit can exist with a given id.

  • -i will set the kits contents to the items in your inventory

Script

- <proc[drustcraftp.player.alts].context[<player>]>

Creates a new kit with a given ID and adds an optional kit mode (see Kit Modes)

Kit IDs are case-insensitive. Only one kit can exist with a given id.

  • items A list of items to use to set the kits contents.

Account UUID

Command
Script
Command

/kit create <id> [mode] [-i]

Creates a new kit with a given ID and adds an optional kit mode (see Kit Modes)

Kit IDs are case-insensitive. Only one kit can exist with a given id.

  • -i will set the kits contents to the items in your inventory

Script

- <proc[drustcraftp.player.account_uuid].context[<player>]>

Creates a new kit with a given ID and adds an optional kit mode (see Kit Modes)

Kit IDs are case-insensitive. Only one kit can exist with a given id.

  • items A list of items to use to set the kits contents.

In Group

Command
Script
Command

/kit create <id> [mode] [-i]

Creates a new kit with a given ID and adds an optional kit mode (see Kit Modes)

Kit IDs are case-insensitive. Only one kit can exist with a given id.

  • -i will set the kits contents to the items in your inventory

Script

- <proc[drustcraftp.player.in_group].context[<group-name>|<player>]>

Creates a new kit with a given ID and adds an optional kit mode (see Kit Modes)

Kit IDs are case-insensitive. Only one kit can exist with a given id.

  • items A list of items to use to set the kits contents.

Events

Scripts can modify the behaviour of player interactions by cancelling certain events from occuring using Denizens event system.

Do not cancel an event without giving the player advice as to why their action was not permitted!

For example, to prevent a player placing blocks we can write the following Denizen script:

myexample:
type: world
events:
on player places block:
- determine cancelled

This is similar to how the Drustcraft region system works when it denies a player placing a block within the region.

However, there are some circumstances where we want to override this behaviour, for example the Drustcraft plot system inside a town (which by default denies block breaking and placing).

We can use the built-in Denizen event options to override a regions event cancellation using event priorities, the ignorecancelled:true argument and determine cancelled:false command.

By setting our event priority to a higher number, we can ensure that it runs after the Drustcraft region event script. Then we add the ignorecancelled:true argument to the event allowing it to be called, even if the region cancels the event. And finally we use the - determine cancelled:false to uncancel the event.

As a simple example (without logic to determine if the event should actually be cancelled):

myexample_world:
type: world
events:
on player places block ignorecancelled:true priority:100:
# uncancel all player places block cancellations
- determine cancelled:false

Accounts

The server uses accounts which are created on the Drustcraft website. Users then link Minecraft players to their acount. This allows a user to have multiple Minecraft players (also known as Alts) under a single account.

The account system used by Drustcraft allows the code to do some unique items such as when banning a player, or adding a player to a group, the code can also do the same task for each other Minecraft player within the same account.

This allows us to ensure that no matter what Minecraft player, a user enters Drustcraft with, each one of their Minecraft players have the same abilities or restrictions.

Just like a Minecraft player, each user account is referenced using a UUID number.

Getting a Players account UUID

A players account UUID can be retrieved from the procedure task drustcraftp.player.account_uuid

- define account_uuid:<proc[drustcraftp.player.account_uuid].context[<[player_uuid]>]>

This procedure will return <empty> if no account UUID was found for that player UUID.

Getting Alt Players List from a Player

Use can use the procedure drustcraftp.player.alts with a context of a player or player UUID.

- define alt_list:<proc[drustcraftp.player.alts].context[<player>]>

The procedure will return a list of player UUIDs or an empty list if none where found. The list will contain all player uuid associated with an account, including the player passed through the context.

Cooldown

A player can be in a damage cooldown for various reasons and usually player cooldown actions are handled by the server and do not need to be handled by any additional code.

Setting Cooldown

drustcraft_cooldown flag contains a timetag for when it expires. Set using -flag player drustcraft_cooldown:<util.time_now.add[5s]>

Flags the player to be in cooldown mode. You can pass a duration definition, however it is recommended to let the server decide the duration period.

- define cooldown_duration:<duration[5s]>
- run drustcraft.player.cooldown def:<player>|<[cooldown_duration]>

Definition

Detail

Player

Player object to apply cooldown to

Duration

The duration of the cooldown. This will override any existing cooldown (optional)

Checking for Cooldown

drustcraft_cooldown flag contains a timetag for when it expires.

- if <player.has_flag[drustcraft_cooldown]> && <player.flag[drustcraft_cooldown].is_after[<util.time_now>]||false>:
- narrate 'Player is under cooldown'
- else:
- narrate 'Player is not under cooldown'

Group

- if <proc[drustcraft.player.has_group].context[<player>|builder]>:

YML

Player data is stored in their own YML files located at /player_data/<player-uuid>.yml and is loaded when the player joins the server and alternatively unloaded when the player quits the server.

Scripts can access the loaded YML data under the key player_<player-uuid>.

Loading Player YML

If a script requires to load a players YML, they can run the following task. It is recommended for scripts to use data from a players YML file instead of flags as player data can be changed externally from the Minecraft server.

- run drustcraft.player.load def:<player>

Saving Player YML

When scripts change player YML data, they should instigate a save to disk by running the following task. This is important as player YML data is used by external sources.

- run drustcraft.player.save def:<player>