From cc17edfb7af7e212cf0e1659ce8eba25938a042a Mon Sep 17 00:00:00 2001 From: "takaro-ci-bot[bot]" <138661031+takaro-ci-bot[bot]@users.noreply.github.com> Date: Mon, 28 Oct 2024 10:18:43 +0000 Subject: [PATCH 01/10] chore: generate api client --- packages/lib-apiclient/src/generated/api.ts | 2 +- packages/lib-apiclient/src/generated/base.ts | 2 +- packages/lib-apiclient/src/generated/common.ts | 2 +- packages/lib-apiclient/src/generated/configuration.ts | 2 +- packages/lib-apiclient/src/generated/index.ts | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/lib-apiclient/src/generated/api.ts b/packages/lib-apiclient/src/generated/api.ts index a81b2ccee2..a21756eb73 100644 --- a/packages/lib-apiclient/src/generated/api.ts +++ b/packages/lib-apiclient/src/generated/api.ts @@ -4,7 +4,7 @@ * Takaro app-api * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) * - * The version of the OpenAPI document: development - f80f6d034a7760e0429de59c786ff04802006bc9 + * The version of the OpenAPI document: development - 876c98f679b75e178a498007fa2e40df3fb60f2a * Contact: support@takaro.io * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). diff --git a/packages/lib-apiclient/src/generated/base.ts b/packages/lib-apiclient/src/generated/base.ts index f29ef6fbe6..eb4ccab98f 100644 --- a/packages/lib-apiclient/src/generated/base.ts +++ b/packages/lib-apiclient/src/generated/base.ts @@ -4,7 +4,7 @@ * Takaro app-api * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) * - * The version of the OpenAPI document: development - f80f6d034a7760e0429de59c786ff04802006bc9 + * The version of the OpenAPI document: development - 876c98f679b75e178a498007fa2e40df3fb60f2a * Contact: support@takaro.io * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). diff --git a/packages/lib-apiclient/src/generated/common.ts b/packages/lib-apiclient/src/generated/common.ts index ec2d51ebf2..d8c8b33249 100644 --- a/packages/lib-apiclient/src/generated/common.ts +++ b/packages/lib-apiclient/src/generated/common.ts @@ -4,7 +4,7 @@ * Takaro app-api * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) * - * The version of the OpenAPI document: development - f80f6d034a7760e0429de59c786ff04802006bc9 + * The version of the OpenAPI document: development - 876c98f679b75e178a498007fa2e40df3fb60f2a * Contact: support@takaro.io * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). diff --git a/packages/lib-apiclient/src/generated/configuration.ts b/packages/lib-apiclient/src/generated/configuration.ts index 30ec99672a..6328aef390 100644 --- a/packages/lib-apiclient/src/generated/configuration.ts +++ b/packages/lib-apiclient/src/generated/configuration.ts @@ -4,7 +4,7 @@ * Takaro app-api * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) * - * The version of the OpenAPI document: development - f80f6d034a7760e0429de59c786ff04802006bc9 + * The version of the OpenAPI document: development - 876c98f679b75e178a498007fa2e40df3fb60f2a * Contact: support@takaro.io * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). diff --git a/packages/lib-apiclient/src/generated/index.ts b/packages/lib-apiclient/src/generated/index.ts index 431db2e536..42aed91465 100644 --- a/packages/lib-apiclient/src/generated/index.ts +++ b/packages/lib-apiclient/src/generated/index.ts @@ -4,7 +4,7 @@ * Takaro app-api * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) * - * The version of the OpenAPI document: development - f80f6d034a7760e0429de59c786ff04802006bc9 + * The version of the OpenAPI document: development - 876c98f679b75e178a498007fa2e40df3fb60f2a * Contact: support@takaro.io * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). From 6808a3513b925807449031a91c57d93a6970d9d8 Mon Sep 17 00:00:00 2001 From: Niek Candaele Date: Mon, 28 Oct 2024 13:47:13 +0100 Subject: [PATCH 02/10] refactor: built in module docs --- .../lib-modules/scripts/buildBuiltinJson.ts | 48 ++- packages/web-docs/docs/advanced/modules.md | 15 +- packages/web-docs/docs/built-in-modules.mdx | 117 ------ packages/web-docs/docs/economy.md | 11 +- .../docs/how-to-guides/Install-teleports.md | 160 --------- .../docs/how-to-guides/install-geoblock.md | 132 ------- packages/web-docs/docs/introduction.md | 28 +- .../web-docs/docs/modules/_category_.json | 7 + packages/web-docs/docs/modules/chatBridge.mdx | 54 +++ .../web-docs/docs/modules/economyUtils.mdx | 184 ++++++++++ packages/web-docs/docs/modules/geoBlock.mdx | 144 ++++++++ packages/web-docs/docs/modules/gimme.mdx | 41 +++ packages/web-docs/docs/modules/helpers.js | 69 ++++ .../web-docs/docs/modules/highPingKicker.mdx | 39 ++ packages/web-docs/docs/modules/lottery.mdx | 82 +++++ .../web-docs/docs/{ => modules}/modules.json | 0 packages/web-docs/docs/modules/overview.mdx | 42 +++ .../docs/modules/playerOnboarding.mdx | 47 +++ .../web-docs/docs/modules/serverMessages.mdx | 39 ++ packages/web-docs/docs/modules/teleports.mdx | 339 ++++++++++++++++++ .../web-docs/docs/modules/timedShutdown.mdx | 44 +++ packages/web-docs/docs/modules/utils.mdx | 56 +++ .../docs/supported-games/_category_.json | 2 +- 23 files changed, 1267 insertions(+), 433 deletions(-) delete mode 100644 packages/web-docs/docs/built-in-modules.mdx delete mode 100644 packages/web-docs/docs/how-to-guides/Install-teleports.md delete mode 100644 packages/web-docs/docs/how-to-guides/install-geoblock.md create mode 100644 packages/web-docs/docs/modules/_category_.json create mode 100644 packages/web-docs/docs/modules/chatBridge.mdx create mode 100644 packages/web-docs/docs/modules/economyUtils.mdx create mode 100644 packages/web-docs/docs/modules/geoBlock.mdx create mode 100644 packages/web-docs/docs/modules/gimme.mdx create mode 100644 packages/web-docs/docs/modules/helpers.js create mode 100644 packages/web-docs/docs/modules/highPingKicker.mdx create mode 100644 packages/web-docs/docs/modules/lottery.mdx rename packages/web-docs/docs/{ => modules}/modules.json (100%) create mode 100644 packages/web-docs/docs/modules/overview.mdx create mode 100644 packages/web-docs/docs/modules/playerOnboarding.mdx create mode 100644 packages/web-docs/docs/modules/serverMessages.mdx create mode 100644 packages/web-docs/docs/modules/teleports.mdx create mode 100644 packages/web-docs/docs/modules/timedShutdown.mdx create mode 100644 packages/web-docs/docs/modules/utils.mdx diff --git a/packages/lib-modules/scripts/buildBuiltinJson.ts b/packages/lib-modules/scripts/buildBuiltinJson.ts index 02d0cc0a78..50b6c75335 100644 --- a/packages/lib-modules/scripts/buildBuiltinJson.ts +++ b/packages/lib-modules/scripts/buildBuiltinJson.ts @@ -1,7 +1,7 @@ import 'reflect-metadata'; import { getModules } from '@takaro/modules'; import { writeFile } from 'fs/promises'; -import { readdir, readFile } from 'node:fs/promises'; +import { readdir, readFile, stat } from 'node:fs/promises'; import path from 'path'; const __dirname = path.dirname(new URL(import.meta.url).pathname); @@ -12,7 +12,7 @@ async function main() { const modules = getModules(); const modulesJson = JSON.stringify(modules, null, 2); await writeFile('dist/modules.json', modulesJson); - await writeFile('../web-docs/docs/modules.json', modulesJson); + await writeFile('../web-docs/docs/modules/modules.json', modulesJson); await writeFile('../e2e/src/web-main/fixtures/modules.json', modulesJson); // Community modules @@ -28,6 +28,50 @@ async function main() { await writeFile('dist/community-modules.json', communityModulesJson); await writeFile('../web-docs/docs/community-modules.json', communityModulesJson); await writeFile('../e2e/src/web-main/fixtures/community-modules.json', communityModulesJson); + + const startMarker = '{/* START AUTO-GENERATED CONTENT */}'; + const endMarker = '{/* END AUTO-GENERATED CONTENT */}'; + + // Generate docs pages for each builtin module + for (const mod of modules) { + const fileExists = await stat(`../web-docs/docs/modules/${mod.name}.mdx`).catch(() => null); + + const autoGeneratedContent = `${startMarker} +import { Commands, Config, CronJobs, Hooks } from './helpers'; + +# ${mod.name} + +export function Module() { + const mod = ${JSON.stringify(mod, null, 2)}; + + return ( +
+

{mod.description}

+ + + + +
+ ) +} + + + +--- +${endMarker}`; + + // If file doesnt exist yet, create it + if (!fileExists) { + await writeFile(`../web-docs/docs/modules/${mod.name}.mdx`, autoGeneratedContent); + } else { + const existingFile = await readFile(`../web-docs/docs/modules/${mod.name}.mdx`, 'utf-8'); + // Otherwise, fine the auto generated content markers and replace it + const end = existingFile.indexOf(endMarker) + endMarker.length; + + const newFile = autoGeneratedContent + existingFile.slice(end); + await writeFile(`../web-docs/docs/modules/${mod.name}.mdx`, newFile); + } + } } main().catch(console.error); diff --git a/packages/web-docs/docs/advanced/modules.md b/packages/web-docs/docs/advanced/modules.md index bf3afd6fcf..780b607eeb 100644 --- a/packages/web-docs/docs/advanced/modules.md +++ b/packages/web-docs/docs/advanced/modules.md @@ -6,7 +6,7 @@ sidebar_position: 1 The core of Takaro is built around Modules. Modules are a very powerful and flexible way of creating features.. -Takaro comes with a set of [built-in modules](../built-in-modules.mdx). When you enable these on a Gameserver, you will be able to change the configuration of the module to customize it but you cannot edit the code. This allows Takaro to automatically keep the built-in modules up-to-date. +Takaro comes with a set of [built-in modules](../modules/overview.mdx). When you enable these on a Gameserver, you will be able to change the configuration of the module to customize it but you cannot edit the code. This allows Takaro to automatically keep the built-in modules up-to-date. Each module consists of one or more of the following components: @@ -44,12 +44,11 @@ These fields offer the flexibility to adjust module functionalities according to For instance: -- The Geo block module includes a configuration field named `countryList`. This field allows you to specify which countries should be blocked form accessing. -By making the country list a configuration field you can dynamically adjust the list for each server you install the module on. +- The Geo block module includes a configuration field named `countryList`. This field allows you to specify which countries should be blocked form accessing. + By making the country list a configuration field you can dynamically adjust the list for each server you install the module on. - The gimme module features an `itemList` configuration field. This enables the creation of a customizable list of items that can be awarded to players. -This means the item module remains game agnostic as the module itself has no static list. - + This means the item module remains game agnostic as the module itself has no static list. ### Example @@ -65,17 +64,15 @@ As a contrived example, a config like the following exists: And a Hook on the event `playerConnected`, which fires whenever a Player connects to the Gameserver. The Function code: ```js - import { getTakaro } from '@takaro/helpers'; async function main() { - await takaro.gameserver.gameServerControllerSendMessage(data.gameServerId, { - message: `Welcome to the server, ${data.player.name}. ${data.module.userConfig.extraMessage}`, + await takaro.gameserver.gameServerControllerSendMessage(data.gameServerId, { + message: `Welcome to the server, ${data.player.name}. ${data.module.userConfig.extraMessage}`, }); } main(); - ``` Would result in a message in-game saying `Welcome to the server, John Doe! Don't forget to read the rules :)` diff --git a/packages/web-docs/docs/built-in-modules.mdx b/packages/web-docs/docs/built-in-modules.mdx deleted file mode 100644 index 170d99ddbd..0000000000 --- a/packages/web-docs/docs/built-in-modules.mdx +++ /dev/null @@ -1,117 +0,0 @@ ---- -sidebar_position: 2 -title: Built-in modules ---- - -import React from 'react'; -import modules from './modules.json'; -import comunityModules from './community-modules.json'; - -export function Commands({commands}) { - if(!commands.length) return null; - return ( - <> -

Commands

- - - ) -} - -export function Hooks({hooks}) { - if(!hooks.length) return null; - return ( - <> -

Hooks

- - - ); -} - -export function CronJobs({cronJobs}) { - if(!cronJobs.length) return null; - return ( - <> -

Cron Jobs

- - - ); -} - -export function Config({configSchema}) { - // configSchema is a jsonSchema object - // Parse it and display pretty: - const schema = JSON.parse(configSchema); - const properties = schema.properties; - - if(!properties) return null; - - return ( - <> -

Config variables

- - - ); - -} - -export function ModulesList({type}) { - const mods = type === 'builtin' ? modules : comunityModules; - - return ( -
- {mods.map((mod, index) => ( -
-

{mod.name}

- {type === 'community' && Download} -

{mod.description}

- - - - -
- ))} -
- -); -} - -# Built-in modules - -Takaro provides a set of built-in modules. These are created and maintained by the Takaro Team. You can configure and install these without having to write any code. - -You can install modules by browsing to a gameserver and clicking the "Modules" link. From there you can configure and install modules. - -## Core modules - - - -## Community modules - -This directory contains modules that are not part of the core suite of built in modules, but are contributed by the community. -They are not officially supported, but are provided as-is for the community to use and improve. - -We welcome contributions to this directory. If you have a module that you would like to contribute, please open a pull request. - - diff --git a/packages/web-docs/docs/economy.md b/packages/web-docs/docs/economy.md index ec183c7c41..7fdf67985f 100644 --- a/packages/web-docs/docs/economy.md +++ b/packages/web-docs/docs/economy.md @@ -6,21 +6,23 @@ sidebar_position: 5 Takaro allows users to enable an economy system on their server. This is a virtual currency system that allows users to earn and spend money on the server. This is a great way to encourage users to be active on the server and reward them for their activity. -Players can earn money in many ways using some of the [built-in modules](./built-in-modules.mdx) or you can create your own custom modules to allow players to earn money in other ways. +Players can earn money in many ways using some of the [built-in modules](./modules/overview.mdx) or you can create your own custom modules to allow players to earn money in other ways. Currency is kept per gameserver, so if you have multiple gameservers, each gameserver will have its own currency. This makes it easier to balance the economy on each gameserver; you might want different prices on your PvP server than on your PvE server for example. -Do note that we have in global settings, an option to enable Economy. You can override the global settings in each gameserver setting. +Do note that we have in global settings, an option to enable Economy. You can override the global settings in each gameserver setting. ## Shop + Takaro offers a built-in shop system to complement the server's economy. This feature allows community managers to create shop listings where they can sell individual items or bundles at specified prices. Each game server can have its own unique shop. To allow players to use the shop, they need to be linked to both Takaro and your game community. The player linking process is described in the [players](./players.md) section. ### Prerequisites + 1. **Enable the economy** for your game server. 2. Ensure **players are linked** to both Takaro and your game community (see [players](./players.md) for details). -3. Install the built-in module, [EconomyUtils](./built-in-modules.mdx), on your game server. +3. Install the built-in module, [EconomyUtils](./modules/overview.mdx), on your game server. ### Shop Functionalities @@ -28,11 +30,14 @@ To allow players to use the shop, they need to be linked to both Takaro and your - **Orders**: Provides an overview of the orders placed by players and their status. ### Claiming an Item + An item can be claimed in two ways: + - In Takaro, by going to "Orders" and clicking "Claim Item". You need to be in-game for this to work; otherwise, you'll receive an error message. - In-game, by typing the command `/link`. ### In-Game Store + The shop can be accessed in-game using the command `/shop`. The structure works as follows: - `/shop 1`: Shows the first page of items. diff --git a/packages/web-docs/docs/how-to-guides/Install-teleports.md b/packages/web-docs/docs/how-to-guides/Install-teleports.md deleted file mode 100644 index 21430b98f3..0000000000 --- a/packages/web-docs/docs/how-to-guides/Install-teleports.md +++ /dev/null @@ -1,160 +0,0 @@ ---- -title: Install Teleports -sidebar_position: 4 ---- - -# How to add teleports module to your game server - -This guide walks you through the process of integrating the Teleports module into your game servers. You'll learn how to set up teleport permissions for different player roles, create custom teleport roles for enhanced privileges, and manage teleport-related features effectively. - - -