General Gameplay
Enhance your Minecraft server by tapping into the General Gameplay features provided by the Enchanted API. Plugins can extend the Api
class to use these functionalities that offer more interaction with the game mechanics. In this section, we cover the advancement
and attribute
methods to manipulate player advancements and attributes.
The advancement
Model
The advancement
method allows plugins to grant or revoke an advancement or its criterion from players to track or reward player progress.
Method
advancement(action: string, target: string, advancement?: string, criterion?: string): Promise<string | undefined>
Parameters
- Name
action
- Type
- string
- Description
'grant'
or'revoke'
to specify what to do with the advancement.
- Name
target
- Type
- string
- Description
The player selector or name to target.
- Name
advancement
- Type
- string
- Description
The namespaced ID of the advancement to target (optional).
- Name
criterion
- Type
- string
- Description
The specific criterion within the advancement to target (optional).
The attribute
Model
Attributes define various properties of entities, such as health or armor. These methods are used for getting, setting, and modifying attributes programmatically.
Methods
Get Total Attribute Value
getAttribute(target: string, attribute: string, scale?: number): Promise<string | undefined>
Get Base Attribute Value
getAttributeBase(target: string, attribute: string, scale?: number): Promise<string | undefined>
Set Base Attribute Value
setAttributeBase(target: string, attribute: string, value: number): Promise<Promise<string> | undefined>
Add Attribute Modifier
addAttributeModifier(
target: string,
attribute: string,
uuid: string,
name: string,
value: number,
operation: string
): Promise<Promise<string> | undefined>
Remove Attribute Modifier
removeAttributeModifier(target: string, attribute: string, uuid: string): Promise<Promise<string> | undefined>
Get Attribute Modifier Value
getAttributeModifierValue(
target: string,
attribute: string,
uuid: string,
scale?: number
): Promise<Promise<string> | undefined>
Parameters for Attribute Methods
- Name
target
- Type
- string
- Description
Specifies the target entity.
- Name
attribute
- Type
- string
- Description
Specifies the attribute to interact with.
- Name
value
- Type
- number
- Description
The value to set for an attribute (optional for some methods).
- Name
uuid
- Type
- string
- Description
A unique identifier for the attribute modifier (required for some methods).
- Name
name
- Type
- string
- Description
The name of the modifier (optional for some methods).
- Name
operation
- Type
- string
- Description
The operation of the modifier (optional for some methods).
- Name
scale
- Type
- number
- Description
The scale to get the attribute (optional for some methods).