UNPKG

chest-form

Version:

Sample plugin provides a basic configuration for plugin usage in the SerenityJS software.

73 lines (68 loc) 2.59 kB
import { Plugin, PluginPriority } from '@serenityjs/plugins'; import { Container, BlockType, BlockIdentifier, Player, ItemStack } from '@serenityjs/core'; import { BlockPosition } from '@serenityjs/protocol'; declare class ChestFormContainer extends Container { static readonly CHEST_TYPE: BlockType<BlockIdentifier.Chest>; /** * The title of the container. */ readonly title: string; /** * The positions where the chests are placed. */ protected placedPositions: Array<BlockPosition>; /** * The callback function to call when the container is shown. */ protected showCallback: ((index: number) => void) | null; /** * Create a new ChestFormContainer. * @param title The title of the container. * @param size The size of the container, default is 27 (1 chest). */ constructor(title: string, size?: number); show(player: Player, callback?: (index: number) => void): void; close(player: Player, serverInitiated?: boolean, index?: number): void; } declare class ChestForm { /** * The container that holds the items for the chest form. */ readonly container: ChestFormContainer; /** * Create a new ChestForm. * @param title The title of the chest form. * @param size The size of the chest form, either "single" for a single chest (27 slots) or "double" for a double chest (54 slots). */ constructor(title: string, size?: "single" | "double"); /** * Set the item stack at the specified slot in the container. * @param slot The slot index to set the item stack in. * @param itemStack The item stack to set in the specified slot. */ button(slot: number, itemStack: ItemStack): void; /** * Show the chest form to the player. * @param player The player to show the chest form to. * @param callback The callback function to call when an item is selected. */ show(player: Player, callback: (index: number) => void): void; } declare class ChestFormPlugin extends Plugin { readonly priority: PluginPriority; /** * The ChestFormContainer class that is used to create chest forms. */ readonly ChestFormContainer: typeof ChestFormContainer; /** * The ChestForm class that is used to create a chest form. */ readonly ChestForm: typeof ChestForm; /** * Constructor for the ChestFormPlugin. */ constructor(); onInitialize(): void; } declare const _default: ChestFormPlugin; export { ChestForm, ChestFormContainer, ChestFormPlugin, _default as default };