API reference / @jsprismarine/addon-tools / addon
addon
Interfaces
Addon
Defined in: addon.ts:95
An addon read from its folder and checked.
Extends
Properties
authors?
readonlyoptionalauthors?: readonlystring[]
Defined in: addon.ts:68
Who wrote the addon.
Inherited from
deprecated?
readonlyoptionaldeprecated?:string
Defined in: addon.ts:72
Why the addon should no longer be installed; servers warn with it.
Inherited from
description
readonlydescription:string
Defined in: addon.ts:58
A one-line description of what the addon does.
Inherited from
files
readonlyfiles:ReadonlyMap<string,Uint8Array<ArrayBufferLike>>
Defined in: addon.ts:107
Every file the pack holds, by its path in the folder with / separators, in path order: every file but those under ADDON_MEDIA_DIRECTORY, and for a TypeScript addon those that build its scripts.
license
readonlylicense:string
Defined in: addon.ts:62
The addon's license, as an SPDX expression such as MIT.
Inherited from
media
readonlymedia:ReadonlyMap<string,Uint8Array<ArrayBufferLike>>
Defined in: addon.ts:109
The files under ADDON_MEDIA_DIRECTORY, by path, in path order.
minServer
readonlyminServer:string
Defined in: addon.ts:60
The oldest JSPrismarine version the addon runs on, major.minor.patch.
Inherited from
name
readonlyname:string
Defined in: addon.ts:97
The folder's name.
replacedBy?
readonlyoptionalreplacedBy?:string
Defined in: addon.ts:74
The install id of the addon that replaces this one, such as warps-plus or owner/repo/name.
Inherited from
screenshots?
readonlyoptionalscreenshots?: readonlyAddonScreenshot[]
Defined in: addon.ts:70
Screenshots for the addon's page, in the order the page shows them.
Inherited from
tags?
readonlyoptionaltags?: readonly ("admin"|"chat"|"gameplay"|"performance"|"world")[]
Defined in: addon.ts:66
Tags from ADDON_TAGS, for the marketplace's filters.
Inherited from
title
readonlytitle:string
Defined in: addon.ts:101
The addon's name for people: addon.json's title, the README's first heading or the manifest header's name.
Overrides
version
readonlyversion:string
Defined in: addon.ts:99
The manifest header's version, major.minor.patch.
AddonListingFiles
Defined in: addon.ts:125
The files a release attaches beside an addon's pack for its listing.
Properties
icon?
readonlyoptionalicon?:AddonReleaseFile
Defined in: addon.ts:129
The pack's icon, <name>-<version>.png, when it has one.
readme
readonlyreadme:AddonReleaseFile
Defined in: addon.ts:127
The README, <name>-<version>.md.
screenshots
readonlyscreenshots: readonly (AddonReleaseFile&object)[]
Defined in: addon.ts:131
Each screenshot, <name>-<version>-<n> and its type, numbered from 1, with its path in the folder.
AddonMetadata
Defined in: addon.ts:56
What addon.json holds.
Extended by
Properties
authors?
readonlyoptionalauthors?: readonlystring[]
Defined in: addon.ts:68
Who wrote the addon.
deprecated?
readonlyoptionaldeprecated?:string
Defined in: addon.ts:72
Why the addon should no longer be installed; servers warn with it.
description
readonlydescription:string
Defined in: addon.ts:58
A one-line description of what the addon does.
license
readonlylicense:string
Defined in: addon.ts:62
The addon's license, as an SPDX expression such as MIT.
minServer
readonlyminServer:string
Defined in: addon.ts:60
The oldest JSPrismarine version the addon runs on, major.minor.patch.
replacedBy?
readonlyoptionalreplacedBy?:string
Defined in: addon.ts:74
The install id of the addon that replaces this one, such as warps-plus or owner/repo/name.
screenshots?
readonlyoptionalscreenshots?: readonlyAddonScreenshot[]
Defined in: addon.ts:70
Screenshots for the addon's page, in the order the page shows them.
tags?
readonlyoptionaltags?: readonly ("admin"|"chat"|"gameplay"|"performance"|"world")[]
Defined in: addon.ts:66
Tags from ADDON_TAGS, for the marketplace's filters.
title?
readonlyoptionaltitle?:string
Defined in: addon.ts:64
The addon's name for people. Defaults to the README's first heading, then the manifest header's name.
AddonReleaseFile
Defined in: addon.ts:113
A file an addon's release attaches.
Properties
bytes
readonlybytes:Uint8Array
Defined in: addon.ts:116
fileName
readonlyfileName:string
Defined in: addon.ts:115
The file's name on the release.
sha256
readonlysha256:string
Defined in: addon.ts:118
The file's SHA-256, in lowercase hexadecimal.
AddonScreenshot
Defined in: addon.ts:48
A screenshot addon.json lists.
Properties
alt
readonlyalt:string
Defined in: addon.ts:52
What the image shows, for a reader who cannot see it.
file
readonlyfile:string
Defined in: addon.ts:50
The image's path in the addon's folder, under ADDON_MEDIA_DIRECTORY.
Type Aliases
AddonPack
AddonPack =
AddonReleaseFile
Defined in: addon.ts:122
An addon's .mcpack, named <name>-<version>.mcpack.
AddonTag
AddonTag = typeof
ADDON_TAGS[number]
Defined in: addon.ts:36
One of ADDON_TAGS.
Variables
ADDON_FILES
constADDON_FILES: readonly ["manifest.json","addon.json","README.md"]
Defined in: addon.ts:24
The files every addon folder has.
ADDON_ICON_FILE
constADDON_ICON_FILE:"pack_icon.png"='pack_icon.png'
Defined in: addon.ts:42
The pack's icon, which Bedrock shows and the marketplace uses as the addon's icon.
ADDON_JSON_OPTIONAL_KEYS
constADDON_JSON_OPTIONAL_KEYS: readonly ["title","tags","authors","screenshots","deprecated","replacedBy"]
Defined in: addon.ts:85
The keys an addon.json may add for its listing and deprecation.
ADDON_JSON_REQUIRED_KEYS
constADDON_JSON_REQUIRED_KEYS: readonly ["description","minServer","license"]
Defined in: addon.ts:78
The keys every addon.json has.
ADDON_MEDIA_DIRECTORY
constADDON_MEDIA_DIRECTORY:"media"='media'
Defined in: addon.ts:39
The folder of an addon that holds its screenshots. The pack leaves it out.
ADDON_MODULE_TYPES
constADDON_MODULE_TYPES: readonlystring[]
Defined in: addon.ts:27
The manifest module types an addon may declare: a behavior pack's.
ADDON_SCREENSHOT_TYPES
constADDON_SCREENSHOT_TYPES: readonlystring[]
Defined in: addon.ts:45
The file types a screenshot may have.
ADDON_TAGS
constADDON_TAGS: readonly ["admin","chat","gameplay","performance","world"]
Defined in: addon.ts:33
The tags an addon may list in addon.json, which the marketplace filters by. The list is fixed so that each filter collects every addon it should.
Functions
addonIndexEntry()
addonIndexEntry(
addon,pack,baseUrl,listing?,commands?):AddonIndexEntry
Defined in: addon.ts:432
The index entry for an addon's pack, with the listing that names its listing files.
Parameters
addon
pack
baseUrl
string
Where the release's files download from; each file's name is added to it.
listing?
AddonListingFiles = ...
The addon's listing files, as addonListingFiles gives them.
commands?
readonly AddonCommand[]
The commands its scripts register, as readAddonCommands read them; left out when they could not be read.
Returns
addonListingFiles()
addonListingFiles(
addon):AddonListingFiles
Defined in: addon.ts:404
The files a release attaches beside an addon's pack for the marketplace: its README, its icon and its screenshots, each named for the addon and version so a published version's files stay fixed.
Parameters
addon
Returns
listingFileList()
listingFileList(
files):AddonReleaseFile[]
Defined in: addon.ts:419
Every file of a listing, README first.
Parameters
files
Returns
packAddon()
packAddon(
addon):AddonReleaseFile
Defined in: addon.ts:387
Zips an addon into its .mcpack. Entries are stored in path order and dated 1980-01-01, so the same files always give the same bytes and the same hash, on any machine.
Parameters
addon
Returns
parseAddonMetadata()
parseAddonMetadata(
addon,bytes):AddonMetadata
Defined in: addon.ts:175
Reads and checks an addon's addon.json: a description on one line, a minServer version and a license, each a non-empty string, the optional ADDON_JSON_OPTIONAL_KEYS in the shapes AddonMetadata gives, and no other keys.
Parameters
addon
string
The addon's name, for the error message.
bytes
Uint8Array
The file's contents.
Returns
Throws
InvalidAddonJson when the file breaks any of those rules.
readAddon()
readAddon(
directory):Promise<Addon>
Defined in: addon.ts:356
Reads an addon from its folder and checks it: the folder's name is an addon name, the three ADDON_FILES are there, manifest.json is a behavior pack manifest whose modules carry the header's version, each script module's entry exists, addon.json follows AddonMetadata with no other keys, each screenshot it lists exists, and a ADDON_ICON_FILE is a square PNG.
Parameters
directory
string
The addon's folder.
Returns
Promise<Addon>
Throws
When any check fails.