Optional
savedDetails: {When this code should expire.
Set it to -1 to make it never expire.
Readonly
idThe super unique ID of this code.
The maximum number of uses allowed for this code.
Set it to -1n
to make the max uses infinite.
List of UUIDs of players who have redeemed this code.
How many times this code has been used.
Retrieves the saved item linked to this code.
This method places a structure at the given location, searches for an entity with a specific dynamic property, retrieves the item from the entity's inventory, and then removes the entity.
The location in the dimension where the structure containing the item storage entity is to be spawned.
The item stack retrieved from the entity's inventory.
Redeems a code for the given player. This method checks if the code has reached its maximum number of uses or if the player has already redeemed the code. If neither condition is met, it spawns the item for the player, adds the player to the list of redeemers, and saves the state.
The player who is redeeming the code.
Removes the current redeemable code from the list of codes, saves the updated list, and deletes the corresponding structure in the world structure manager.
Saves the current redeemable code instance.
This method performs the following actions:
saveCodes
to persist the updated list of codes.Sets the item linked to this code.
The item to be set in the storage entity.
The location where the item should be saved, including the dimension.
This method performs the following steps:
Converts the RedeemableCode instance to a JSONB object.
An object containing the code, id, redeemers, uses, max uses, and expiration time of the RedeemableCode instance.
Static
addStatic
getStatic
getStatic
loadStatic
redeemStatic
removeStatic
save
The code that users enter to redeem this code.