The LiquidBounce Marketplace allows users to subscribe to and install community-created content including scripts, themes, and configurations. The MarketplaceManager handles all marketplace operations.
Marketplace items are categorized by type in MarketplaceItemType:
enum class MarketplaceItemType( override val tag: String, val isListable: Boolean, // Can be browsed in marketplace val isSubscribable: Boolean // Can be subscribed/installed) : Tagged { CONFIG("Config", false, false), SCRIPT("Script", true, true), THEME("Theme", true, true), OTHER("Other", false, false)}
Only Script and Theme types are currently subscribable and can be installed through the marketplace.
The installation folder is determined dynamically:
fun getInstallationFolder(): File? { val revisionDir = itemDir.resolve(installedRevisionId.toString()) // Returns the folder containing files // Could be revision root or a subdirectory like /dist return findFolderWithFiles(revisionDir)}
suspend fun update(item: SubscribedItem) { // Check if update is available val updateRevisionId = item.checkUpdate() ?: return // Install the new revision item.install(updateRevisionId)}
suspend fun checkUpdate(): Int? { val newestRevisionId = getNewestRevisionId() if (installedRevisionId == newestRevisionId) { return null // Already up to date } return newestRevisionId}
The newest revision is fetched from the API:
suspend fun getNewestRevisionId(): Int? { val item = MarketplaceApi.getMarketplaceItem(id) // Only update if item is still active if (item.status != MarketplaceItemStatus.ACTIVE) { return null } // Get first (newest) revision val revisions = MarketplaceApi.getMarketplaceItemRevisions(id, 1, 1) return revisions.items.firstOrNull()?.id}