Skip to content

Commit 2eef24b

Browse files
committed
docs: migrate from LiteLoaderBDS
1 parent 034f4c9 commit 2eef24b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

99 files changed

+20458
-0
lines changed

.github/workflows/build_docs.yml

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
on:
2+
push:
3+
paths:
4+
- .github/workflows/build_docs.yml
5+
- docs/**
6+
- mkdocs.yml
7+
workflow_dispatch:
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
15+
- run: |
16+
pip install -r requirements.txt
17+
18+
- run: |
19+
mkdocs build
20+
21+
- uses: actions/upload-pages-artifact@v3
22+
with:
23+
path: |
24+
site/
25+
26+
deploy:
27+
# if: github.ref == 'refs/heads/main' && github.event_name == 'push'
28+
needs:
29+
- build
30+
permissions:
31+
id-token: write
32+
pages: write
33+
runs-on: ubuntu-latest
34+
steps:
35+
- uses: actions/deploy-pages@v4
36+

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ lip install github.com/LiteLDev/LegacyScriptEngine
1212

1313
Put LLSE plugins directly in `/path/to/bedrock_dedicated_server/plugins/` and run the server, then the plugins will be migrated to LeviLamina plugin manifest automatically. To load them, you need to restart the server.
1414

15+
For more information, please refer to [the documentation](https://lse.liteldev.com).
16+
1517
## Contributing
1618

1719
If you have any questions, please open an issue to discuss it.

docs/apis/DataAPI/ConfigFile.md

+275
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,275 @@
1+
# LLSE - Configuration and Data Processing Interface Documentation
2+
3+
> Here are a variety of options for working with **large amounts of data**
4+
5+
In the process of plugin work, it is inevitable to encounter scenarios that need to deal with configuration and a large amount of game-related data.
6+
LLSE provides a lot of `infrastructure`, including configuration files, databases, economic systems, and more.
7+
It is convenient for developers to focus on business code implementation, rather than entangled in the technical details of these aspects.
8+
9+
## 🔨 Profile API
10+
11+
The configuration file is generally used to separate some settings of the plug-in that can be modified by the user into a file, so as to facilitate the modification of some settings.
12+
Therefore, the content and format of the configuration file generally need to be readable.
13+
LLSE provides the ConfigFile configuration file interface to accomplish this task.
14+
Of course, you can also manually read and write files to assist in the operation of related configuration files.
15+
16+
<br>
17+
18+
### Description: Selection of Configuration File Type
19+
20+
The choice of configuration file format will affect the type of configuration data you can store.
21+
22+
- `JSON` format can store **most** types of data, including arrays, objects, etc., and the representation logic is relatively rich.
23+
- `ini` format is relatively `simple and intuitive`, and it is very easy for others to modify it, but the type of data stored is subject to certain restrictions.
24+
25+
Please make your choice as needed.
26+
27+
<br>
28+
29+
### 📰 JSON Format Configuration File
30+
31+
#### Create/Open a JSON Configuration File
32+
33+
[JavaScript] `new JsonConfigFile(path[,default])`
34+
[Lua] `JsonConfigFile(path[,default])`
35+
36+
- Parameters:
37+
- path : `String`
38+
The path where the configuration file is located, based on the BDS root directory.
39+
LLSE will automatically create a directory in the configuration file path if it does not already exist.
40+
- default : `String`
41+
(Optional parameter) Default content of the configuration file.
42+
If during initialization it **does not exist**, the engine will create a new configuration file and write the default content here.
43+
If this parameter is not passed in, the new configuration file will be empty.
44+
- Return value: Open/created profile object.
45+
- Return value type: `JsonConfigFile`
46+
- Throws exception if create/open fails.
47+
48+
We recommend that you create a directory named `BDS_Root_Directory/plugins/plugin_name/` with a config file named `config.json` to keep the configuration of each plugin uniform.
49+
50+
<br>
51+
52+
For a JSON profile object `conf`, you have these read and write interfaces available.
53+
54+
#### Initialize Configuration Items (Convenience Function
55+
56+
`conf.init(name,default)`
57+
58+
- Parameters:
59+
- name : `String`
60+
Configuration item name
61+
- default : `Any type`
62+
The value written when the configuration item is initialized.
63+
- Return value: The data of the specified configuration item.
64+
- Return value type: `Any type`, subject to the specific type of data stored.
65+
66+
Here is an easy way to initialize the configuration file, avoiding the trouble of handwriting the contents of the default configuration file:
67+
68+
If the accessed configuration item does not exist, then the engine will automatically create the item `init` in the configuration file and write the given default value.
69+
If the accessed configuration item `init` already exists, the engine will read and return the existing value in the configuration file.
70+
<br>
71+
72+
#### Write Configuration Item
73+
74+
`conf.set(name,data)`
75+
76+
- Parameters:
77+
- name : `String`
78+
Configuration item name
79+
- data : `Any type`
80+
Configuration data to write. The allowed data types are:
81+
`Integer` `Float` `String` `Boolean` `Array` `Object`
82+
The above elements can only be nested inside `Array` and `Object`.
83+
84+
- Return value: Whether the write is successful.
85+
86+
- Return value type: `Boolean`
87+
88+
<br>
89+
90+
#### Read Configuration Items
91+
92+
`conf.get(name[,default])`
93+
94+
- Parameters:
95+
- name : `String`
96+
Configuration item name
97+
- default : `Any type`
98+
(optional) The default value to return when the read fails.
99+
The default is `Null`
100+
- Return value: The data of the specified configuration item.
101+
- Return value type: `Any type`, subject to the specific type of data stored.
102+
103+
<br>
104+
105+
#### Delete Configuration Item
106+
107+
`conf.delete(name)`
108+
109+
- Parameter:
110+
- name : `String`
111+
Configuration item name
112+
- Return value: Whether the deletion is successful.
113+
- Return value type: `Boolean`
114+
115+
If you don't need this configuration item, in order to avoid confusion when others modify the configuration file, you can choose to delete it.
116+
117+
<br>
118+
119+
### 📄 Ini Format Configuration File
120+
121+
#### Create/Open an Ini Profile
122+
123+
[JavaScript] `new IniConfigFile(path[,default])`
124+
[Lua] `IniConfigFile(path[,default])`
125+
126+
- Parameters:
127+
- path : `String`
128+
The path where the configuration file is located, based on the BDS root directory.
129+
LLSE will automatically create a directory in the configuration file path if it does not already exist.
130+
- default : `String`
131+
(Optional parameter) Default content of the configuration file.
132+
If during initialization it **does not exist**, the engine will create a new configuration file and write the default content here.
133+
If this parameter is not passed in, the new configuration file will be empty.
134+
- Return value: Open/created profile object.
135+
- Return value type: `IniConfigFile`
136+
- Throws exception if create/open fails.
137+
138+
We recommend that you create a directory named `BDS_Root_Directory/plugins/plugin_name/` with a config file named `config.json` to keep the configuration of each plugin uniform.
139+
140+
<br>
141+
142+
For an ini profile object `conf`, you have these read and write interfaces available:
143+
144+
#### Initialize Configuration Items (Convenience Function)
145+
146+
`conf.init(section,name,default)`
147+
148+
- Parameters:
149+
- section : `String`
150+
Configuration item key name
151+
- name : `String`
152+
Configuration item name
153+
- default : `Any type`
154+
The value written when the configuration item is initialized. The allowed data types are:
155+
`Integer` `Float` `String` `Boolean`
156+
- Return value: The data of the specified configuration item.
157+
- Return value type: `Any type`, subject to the specific type of data stored.
158+
159+
Here is an easy way to initialize the configuration file, avoiding the trouble of handwriting the contents of the default configuration file.
160+
161+
If the accessed configuration item does not exist, then the engine will automatically create the item `init` in the configuration file and write the given default value.
162+
If the accessed configuration item `init` already exists, the engine will read and return the existing value in the configuration file.
163+
164+
<br>
165+
166+
#### Write Configuration Item
167+
168+
`conf.set(section,name,data)`
169+
170+
- Parameters:
171+
- section : `String`
172+
Configuration item key name
173+
- name : `String`
174+
Configuration item name
175+
- data : `Any type`
176+
Configuration data to write. The allowed data types are:
177+
`Integer` `Float` `String` `Boolean`
178+
179+
- Return value: Whether the write is successful.
180+
181+
- Return value type: `Boolean`
182+
183+
If the configuration item does not exist, the interface will be created automatically.
184+
185+
<br>
186+
187+
#### Read Configuration Items
188+
189+
Read string `conf.getStr(section,name[,default])`
190+
Read integer `conf.getInt(section,name[,default])`
191+
Read float `conf.getFloat(section,name[,default])`
192+
Read boolean `conf.getBool(section,name[,default])`
193+
194+
- Parameters:
195+
- section : `String`
196+
Configuration item key name
197+
- name : `String`
198+
Configuration item name
199+
- default : `String`/ `Integer`/ `Float`/ `Boolean`
200+
(optional) The default value to return when the read fails.
201+
The default is `0`
202+
- Return value: The data of the specified configuration item.
203+
- Return value type: `String`/ `Integer`/ `Float`/ `Boolean`
204+
205+
<br>
206+
207+
#### Delete Configuration Item
208+
209+
`conf.delete(section,name)`
210+
211+
- Parameters:
212+
- section : `String`
213+
Configuration item key name
214+
- name : `String`
215+
Configuration item name
216+
- Return value: Whether the deletion is successful.
217+
- Return value type: `Boolean`
218+
219+
If you don't need this configuration item, in order to avoid confusion when others modify the configuration file, you can choose to delete it.
220+
221+
<br>
222+
223+
### 💼 Other Common Interface Functions
224+
225+
For a profile object `conf`, you can use these generic interfaces for auxiliary purposes:
226+
227+
#### Reload the Configuration Items in the File
228+
229+
`conf.reload()`
230+
231+
- Return value: Whether the load was successful.
232+
233+
For performance reasons, the configuration file interface caches read operations, each read operation is read from direct memory, and writes are written directly to disk files. Considering that the configuration file may be modified by the user, after you confirm that the user has modified the configuration file, you need to use this function to refresh the memory cache data of the configuration file.
234+
235+
<br>
236+
237+
#### Close Config File
238+
239+
`conf.close()`
240+
241+
- Return value: Whether closing the file was successful.
242+
243+
After the profile is closed, do not continue to use it!
244+
245+
<br>
246+
247+
#### Get Configuration File Path
248+
249+
`conf.getPath()`
250+
251+
- Return value: The file path of the current configuration file.
252+
- Return value type: `String`
253+
254+
<br>
255+
256+
#### Read the Content of the Entire Configuration File
257+
258+
`conf.read()`
259+
260+
- Return value: All contents of the current configuration file.
261+
- Return value type: `String`
262+
263+
<br>
264+
265+
#### Write the Contents of the Entire Configuration File
266+
267+
`conf.write(content)`
268+
269+
- Parameter:
270+
- content : `String`
271+
The string that will be written to the configuration file.
272+
- Return value: Whether the write is successful.
273+
- Return value type: `Boolean`
274+
275+
<br>

0 commit comments

Comments
 (0)