mirror of
https://github.com/quizhizhe/LiteLoaderBDS-1.16.40.git
synced 2025-06-01 11:43:41 +00:00
fist commit
This commit is contained in:
commit
388444d317
76
.clang-format
Normal file
76
.clang-format
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
# Documents: https://clang.llvm.org/docs/ClangFormatStyleOptions.html
|
||||||
|
Language: Cpp
|
||||||
|
# BasedOnStyle: LLVM
|
||||||
|
AccessModifierOffset: -4
|
||||||
|
AlignAfterOpenBracket: Align
|
||||||
|
AlignConsecutiveAssignments: false
|
||||||
|
AlignConsecutiveDeclarations: false
|
||||||
|
AlignEscapedNewlinesLeft: true
|
||||||
|
AlignOperands: Align
|
||||||
|
AlwaysBreakTemplateDeclarations : true
|
||||||
|
AlignTrailingComments: true
|
||||||
|
AllowAllArgumentsOnNextLine : true
|
||||||
|
AllowAllParametersOfDeclarationOnNextLine: true
|
||||||
|
AllowShortBlocksOnASingleLine : true
|
||||||
|
AllowShortCaseLabelsOnASingleLine: false
|
||||||
|
AllowShortFunctionsOnASingleLine: Inline
|
||||||
|
AllowShortIfStatementsOnASingleLine: false
|
||||||
|
AllowShortLoopsOnASingleLine: false
|
||||||
|
AllowShortFunctionsOnASingleLine: false
|
||||||
|
AllowShortLambdasOnASingleLine: true
|
||||||
|
AllowShortEnumsOnASingleLine: false
|
||||||
|
AlwaysBreakAfterDefinitionReturnType: None
|
||||||
|
BinPackArguments: true
|
||||||
|
BinPackParameters: true
|
||||||
|
ConstructorInitializerIndentWidth: 0
|
||||||
|
ConstructorInitializerAllOnOneLineOrOnePerLine: true
|
||||||
|
ColumnLimit: 0
|
||||||
|
CommentPragmas: '^ IWYU pragma:'
|
||||||
|
PointerAlignment: Left
|
||||||
|
IndentWidth: 4
|
||||||
|
SortIncludes: false
|
||||||
|
MaxEmptyLinesToKeep: 2
|
||||||
|
SpacesInSquareBrackets: false
|
||||||
|
SpacesInParentheses : false
|
||||||
|
SpaceBeforeAssignmentOperators: true
|
||||||
|
SpacesInContainerLiterals: true
|
||||||
|
IndentWrappedFunctionNames: true
|
||||||
|
KeepEmptyLinesAtTheStartOfBlocks: true
|
||||||
|
BreakConstructorInitializersBeforeComma: true
|
||||||
|
SpaceAfterCStyleCast: false
|
||||||
|
IndentCaseLabels: true
|
||||||
|
TabWidth: 4
|
||||||
|
UseTab: Never
|
||||||
|
|
||||||
|
BreakBeforeBraces: Custom
|
||||||
|
BraceWrapping:
|
||||||
|
# case 语句后面
|
||||||
|
AfterCaseLabel: false
|
||||||
|
# class定义后面
|
||||||
|
AfterClass: false
|
||||||
|
# 控制语句后面
|
||||||
|
AfterControlStatement: false
|
||||||
|
# enum定义后面
|
||||||
|
AfterEnum: false
|
||||||
|
# 函数定义后面
|
||||||
|
AfterFunction: false
|
||||||
|
# 命名空间定义后面
|
||||||
|
AfterNamespace: false
|
||||||
|
# struct定义后面
|
||||||
|
AfterStruct: false
|
||||||
|
# union定义后面
|
||||||
|
AfterUnion: false
|
||||||
|
# extern导出块后面
|
||||||
|
AfterExternBlock: false
|
||||||
|
# catch之前
|
||||||
|
BeforeCatch: false
|
||||||
|
# else之前
|
||||||
|
BeforeElse: false
|
||||||
|
# 缩进大括号(整个大括号框起来的部分都缩进)
|
||||||
|
IndentBraces: false
|
||||||
|
# 空函数的大括号是否可以在一行
|
||||||
|
SplitEmptyFunction: true
|
||||||
|
# 空记录体(struct/class/union)的大括号是否可以在一行
|
||||||
|
SplitEmptyRecord: true
|
||||||
|
# 空namespace的大括号是否可以在一行
|
||||||
|
SplitEmptyNamespace: true
|
12
.github/FUNDING.yml
vendored
Normal file
12
.github/FUNDING.yml
vendored
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
# These are supported funding model platforms
|
||||||
|
|
||||||
|
github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
|
||||||
|
patreon: # Replace with a single Patreon username
|
||||||
|
open_collective: # Replace with a single Open Collective username
|
||||||
|
ko_fi: # Replace with a single Ko-fi username
|
||||||
|
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
|
||||||
|
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
|
||||||
|
liberapay: # Replace with a single Liberapay username
|
||||||
|
issuehunt: # Replace with a single IssueHunt username
|
||||||
|
otechie: # Replace with a single Otechie username
|
||||||
|
custom: ['https://www.patreon.com/liteloaderbds','https://afdian.net/@liteldev']
|
97
.github/ISSUE_TEMPLATE/bug_report_en.yml
vendored
Normal file
97
.github/ISSUE_TEMPLATE/bug_report_en.yml
vendored
Normal file
@ -0,0 +1,97 @@
|
|||||||
|
name: "[ENG] Bug Report"
|
||||||
|
description: "Report a bug to us to make LiteLoader better."
|
||||||
|
labels: ["bug"]
|
||||||
|
body:
|
||||||
|
- type: markdown
|
||||||
|
attributes:
|
||||||
|
value: |
|
||||||
|
Thanks for taking the time to fill out this bug report!
|
||||||
|
> **NOTICE**
|
||||||
|
> 1. Feedback issues should belong to LiteLoader.
|
||||||
|
> 2. Please do not report destructive Minecraft Bugs, please send a private message to the project developer in IM, and give feedback to Mojang in time.
|
||||||
|
|
||||||
|
- type: dropdown
|
||||||
|
id: module
|
||||||
|
attributes:
|
||||||
|
label: Exceptions module
|
||||||
|
description: The module with problems
|
||||||
|
options:
|
||||||
|
- Core
|
||||||
|
- ScriptEngine
|
||||||
|
- AddonsHelper
|
||||||
|
- PeEditor
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: dropdown
|
||||||
|
id: os
|
||||||
|
attributes:
|
||||||
|
label: Operating System
|
||||||
|
multiple: false
|
||||||
|
options:
|
||||||
|
- Windows Server 2022
|
||||||
|
- Windows Server 2019
|
||||||
|
- Windows Server 2016
|
||||||
|
- Windows Server 2012
|
||||||
|
- Other Windows Server
|
||||||
|
- Windows 11
|
||||||
|
- Windows 10
|
||||||
|
- Other Windows
|
||||||
|
- GNU/Linux with docker
|
||||||
|
- GNU/Linux with wine
|
||||||
|
- Other
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: input
|
||||||
|
id: llversion
|
||||||
|
attributes:
|
||||||
|
label: "LiteLoader version"
|
||||||
|
placeholder: Type your LiteLoader version.
|
||||||
|
description: |
|
||||||
|
If you are using a beta LiteLoader downloaded from Actions, please type the corresponding Actions run ID (starting with #) or commit hash.
|
||||||
|
e.g. 2.1.0 Actions#1479 4f404a7
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: input
|
||||||
|
id: bdsversion
|
||||||
|
attributes:
|
||||||
|
label: "BDS version"
|
||||||
|
placeholder: Type your BDS version.
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: textarea
|
||||||
|
id: what-happened
|
||||||
|
attributes:
|
||||||
|
label: What happened?
|
||||||
|
description: |
|
||||||
|
What happened? Please describe your problem.
|
||||||
|
Also tell us, what did you expect to happen?
|
||||||
|
placeholder: Describe your problem clearly.
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: textarea
|
||||||
|
id: reproduce
|
||||||
|
attributes:
|
||||||
|
label: Steps to reproduce?
|
||||||
|
description: Describe in as clear and detailed a manner as possible how to reproduce.
|
||||||
|
placeholder: |
|
||||||
|
1. Do something
|
||||||
|
2. ...
|
||||||
|
3. ...
|
||||||
|
- type: textarea
|
||||||
|
id: logs
|
||||||
|
attributes:
|
||||||
|
label: Relevant log output
|
||||||
|
description: Please copy and paste any relevant log output.
|
||||||
|
render: shell
|
||||||
|
- type: textarea
|
||||||
|
id: plugins
|
||||||
|
attributes:
|
||||||
|
label: Plugin list
|
||||||
|
description: Please copy the command output of `ll list`.
|
||||||
|
render: shell
|
||||||
|
- type: markdown
|
||||||
|
attributes:
|
||||||
|
value: |
|
||||||
|
**If you have pictures or other content, please comment below. Screenshots,logs and dmp files are very important and helpful for solving your problem**
|
||||||
|
******
|
||||||
|
Thank you again for your contribution to LiteLoader!
|
96
.github/ISSUE_TEMPLATE/bug_report_zh.yml
vendored
Normal file
96
.github/ISSUE_TEMPLATE/bug_report_zh.yml
vendored
Normal file
@ -0,0 +1,96 @@
|
|||||||
|
name: "[简体中文] 报告漏洞/问题"
|
||||||
|
description: "向我们报告漏洞/问题以让LiteLoader变得更好"
|
||||||
|
labels: ["bug"]
|
||||||
|
body:
|
||||||
|
- type: markdown
|
||||||
|
attributes:
|
||||||
|
value: |
|
||||||
|
感谢您花时间填写这份Bug反馈!
|
||||||
|
> **注意事项**
|
||||||
|
> 1. 请勿反馈非加载器问题
|
||||||
|
> 2. 请勿在这里反馈具有严重影响的游戏漏洞, 相关问题请在聊天软件内私聊项目开发者并向及时向Mojang反馈
|
||||||
|
|
||||||
|
- type: dropdown
|
||||||
|
id: module
|
||||||
|
attributes:
|
||||||
|
label: 异常模块
|
||||||
|
description: 出现问题的模块
|
||||||
|
options:
|
||||||
|
- Core(核心)
|
||||||
|
- ScriptEngine(脚本引擎)
|
||||||
|
- AddonsHelper
|
||||||
|
- PeEditor
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: dropdown
|
||||||
|
id: os
|
||||||
|
attributes:
|
||||||
|
label: 操作系统
|
||||||
|
multiple: false
|
||||||
|
options:
|
||||||
|
- Windows Server 2022
|
||||||
|
- Windows Server 2019
|
||||||
|
- Windows Server 2016
|
||||||
|
- Windows Server 2012
|
||||||
|
- 其他版本的 Windows Server
|
||||||
|
- Windows 11
|
||||||
|
- Windows 10
|
||||||
|
- 其他版本的 Windows
|
||||||
|
- GNU/Linux with docker
|
||||||
|
- GNU/Linux with wine
|
||||||
|
- 其他操作系统
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: input
|
||||||
|
id: llversion
|
||||||
|
attributes:
|
||||||
|
label: "LiteLoader版本"
|
||||||
|
placeholder: 输入您的LiteLoader版本
|
||||||
|
description: |
|
||||||
|
如果您正在使用一个从Actions下载的beta版LiteLoader,请输入对应的Actions运行ID(#开头)或commit hash
|
||||||
|
e.g. 2.1.0 Actions#1479 4f404a7
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: input
|
||||||
|
id: bdsversion
|
||||||
|
attributes:
|
||||||
|
label: BDS版本
|
||||||
|
placeholder: 输入您的BDS版本
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: textarea
|
||||||
|
id: what-happened
|
||||||
|
attributes:
|
||||||
|
label: 发生了什么?
|
||||||
|
description: |
|
||||||
|
发生了什么?请描述你的问题. 并告诉我们, 您希望我们做什么
|
||||||
|
placeholder: 清晰地描述你的问题
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: textarea
|
||||||
|
id: reproduce
|
||||||
|
attributes:
|
||||||
|
label: 复现此问题的步骤
|
||||||
|
description: 尽可能清晰且详细的描述如何复现
|
||||||
|
placeholder: |
|
||||||
|
1. Do something
|
||||||
|
2. ...
|
||||||
|
3. ...
|
||||||
|
- type: textarea
|
||||||
|
id: logs
|
||||||
|
attributes:
|
||||||
|
label: 有关的日志/输出
|
||||||
|
description: 请粘贴有关此问题的日志到此处
|
||||||
|
render: shell
|
||||||
|
- type: textarea
|
||||||
|
id: plugins
|
||||||
|
attributes:
|
||||||
|
label: 插件列表
|
||||||
|
description: 请复制命令`ll list`的输出
|
||||||
|
render: shell
|
||||||
|
- type: markdown
|
||||||
|
attributes:
|
||||||
|
value: |
|
||||||
|
**如果你有图片或其他内容,请在下面评论(comment)。截图,日志和dmp文件对解决你的问题很重要、很有帮助**
|
||||||
|
******
|
||||||
|
再次感谢您对LiteLoader的贡献!
|
5
.github/ISSUE_TEMPLATE/config.yml
vendored
Normal file
5
.github/ISSUE_TEMPLATE/config.yml
vendored
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
blank_issues_enabled: true
|
||||||
|
contact_links:
|
||||||
|
- name: "Minecraft: Bedrock Edition Feedback"
|
||||||
|
url: https://bugs.mojang.com/projects/MCPE/issues
|
||||||
|
about: Please report MC game bugs here 反馈MC游戏问题
|
26
.github/ISSUE_TEMPLATE/feature_request_en.yml
vendored
Normal file
26
.github/ISSUE_TEMPLATE/feature_request_en.yml
vendored
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
name: "[ENG] Feature Request"
|
||||||
|
description: Suggest an idea/Request for a new feature
|
||||||
|
labels: ["enhancement"]
|
||||||
|
body:
|
||||||
|
- type: markdown
|
||||||
|
attributes:
|
||||||
|
value: |
|
||||||
|
Thanks for taking the time to fill out this feature request!
|
||||||
|
- type: textarea
|
||||||
|
id: problem
|
||||||
|
attributes:
|
||||||
|
label: Is your feature request related to a problem? Please describe.
|
||||||
|
description: A clear and concise description of what the problem is.
|
||||||
|
placeholder: |
|
||||||
|
e.g. I'm always frustrated when ...
|
||||||
|
- type: textarea
|
||||||
|
id: solution
|
||||||
|
attributes:
|
||||||
|
label: Describe the solution you'd like
|
||||||
|
description: A clear and concise description of what you want.
|
||||||
|
placeholder: |
|
||||||
|
e.g. I want a new event that ...
|
||||||
|
- type: markdown
|
||||||
|
attributes:
|
||||||
|
value: |
|
||||||
|
Thank you again for your contribution to LiteLoader!
|
26
.github/ISSUE_TEMPLATE/feature_request_zh.yml
vendored
Normal file
26
.github/ISSUE_TEMPLATE/feature_request_zh.yml
vendored
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
name: "[简体中文] 新功能请求/建议"
|
||||||
|
description: 提供建议/请求一个新的功能
|
||||||
|
labels: ["enhancement"]
|
||||||
|
body:
|
||||||
|
- type: markdown
|
||||||
|
attributes:
|
||||||
|
value: |
|
||||||
|
感谢您花时间填写这份新功能请求!
|
||||||
|
- type: textarea
|
||||||
|
id: problem
|
||||||
|
attributes:
|
||||||
|
label: 您的建议是否与现存的某个问题相关?请描述问题?
|
||||||
|
description: 简明扼要地描述问题是什么
|
||||||
|
placeholder: |
|
||||||
|
e.g. LiteLoader的...API总是让我...
|
||||||
|
- type: textarea
|
||||||
|
id: solution
|
||||||
|
attributes:
|
||||||
|
label: 您认为还缺少什么?如何解决您的问题?
|
||||||
|
description: 简明扼要地描述你想要什么
|
||||||
|
placeholder: |
|
||||||
|
e.g. 我想要一个新的监听事件...
|
||||||
|
- type: markdown
|
||||||
|
attributes:
|
||||||
|
value: |
|
||||||
|
再次感谢您对LiteLoader的贡献!
|
22
.github/PULL_REQUEST_TEMPLATE.md
vendored
Normal file
22
.github/PULL_REQUEST_TEMPLATE.md
vendored
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
## Description
|
||||||
|
|
||||||
|
Please carefully read the [Contributing note](https://docs.litebds.com/#/zh_CN/Maintenance/README) before making any pull requests.
|
||||||
|
And, **Do not make a pull request to merge into main branch unless it is a hotfix. Use the beta branch instead.**
|
||||||
|
## Issues fixed by this PR
|
||||||
|
|
||||||
|
<!--- Put the links of issues that may be fixed by this PR here (if any). -->
|
||||||
|
## Type of changes
|
||||||
|
|
||||||
|
<!--- Put an `x` in all the boxes that apply your changes. -->
|
||||||
|
|
||||||
|
- [ ] Bug fix
|
||||||
|
- [ ] New feature
|
||||||
|
- [ ] Enhancement
|
||||||
|
- [ ] Documentation
|
||||||
|
|
||||||
|
## Checklist:
|
||||||
|
|
||||||
|
- [ ] My code follows the style guidelines of this project
|
||||||
|
- [ ] My pull request is unique and no other pull requests have been opened for these changes
|
||||||
|
- [ ] I have read the [Contributing note](https://docs.litebds.com/#/zh_CN/Maintenance/README)
|
||||||
|
- [ ] I am responsible for any copyright issues with my code if it occurs in the future.
|
189
.github/workflows/cmake-self-hosted.yml
vendored
Normal file
189
.github/workflows/cmake-self-hosted.yml
vendored
Normal file
@ -0,0 +1,189 @@
|
|||||||
|
name: CMake(self-hosted)
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
paths:
|
||||||
|
- '**.cpp'
|
||||||
|
- '**.cc'
|
||||||
|
- '**.cxx'
|
||||||
|
- '**.c'
|
||||||
|
- '**.hpp'
|
||||||
|
- '**.hh'
|
||||||
|
- '**.hxx'
|
||||||
|
- '**.h'
|
||||||
|
- '.github/workflows/cmake-self-hosted.yml'
|
||||||
|
- '**/CMakeLists.txt'
|
||||||
|
|
||||||
|
env:
|
||||||
|
BUILD_TYPE: Release
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: self-hosted
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3.0.2
|
||||||
|
with:
|
||||||
|
fetch-depth: 1
|
||||||
|
submodules: 'true'
|
||||||
|
|
||||||
|
- name: Cache Bedrock Dedicated Server Library
|
||||||
|
id: cache-bds-lib
|
||||||
|
uses: actions/cache@v3
|
||||||
|
env:
|
||||||
|
cache-name: cache-bds-lib
|
||||||
|
with:
|
||||||
|
path: |
|
||||||
|
${{ env.GITHUB_WORKSPACE }}LiteLoader/Lib/bedrock_server_api.lib
|
||||||
|
${{ env.GITHUB_WORKSPACE }}LiteLoader/Lib/bedrock_server_var.lib
|
||||||
|
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('Scripts/LINK.txt') }}
|
||||||
|
|
||||||
|
- name: Download Server
|
||||||
|
if: steps.cache-bds-lib.outputs.cache-hit != 'true'
|
||||||
|
working-directory: ${{ env.GITHUB_WORKSPACE }}
|
||||||
|
run: |
|
||||||
|
mkdir Tools/Server
|
||||||
|
ServerLink=$(cat 'Scripts/LINK.txt')
|
||||||
|
curl -L -o Tools/Server/server.zip "$ServerLink"
|
||||||
|
unzip Tools/Server/server.zip -d Tools/Server/ > /dev/null
|
||||||
|
shell: bash
|
||||||
|
|
||||||
|
- name: Build Library
|
||||||
|
if: steps.cache-bds-lib.outputs.cache-hit != 'true'
|
||||||
|
working-directory: ${{ env.GITHUB_WORKSPACE }}
|
||||||
|
run: |
|
||||||
|
cd Tools
|
||||||
|
LibraryBuilder.exe Server
|
||||||
|
shell: cmd
|
||||||
|
|
||||||
|
- name: Change LITELOADER_VERSION_STATUS_BETA
|
||||||
|
working-directory: ${{ env.GITHUB_WORKSPACE }}
|
||||||
|
if: false == startsWith(github.ref, 'refs/tags/')
|
||||||
|
run: |
|
||||||
|
sed -r -i 's/#define\s+LITELOADER_VERSION_STATUS\s+LITELOADER_VERSION_\w+/#define LITELOADER_VERSION_STATUS LITELOADER_VERSION_BETA/' LiteLoader/Main/Version.h
|
||||||
|
sed -r -i 's/#define\s+LITELOADER_VERSION_ACTIONS\s+.*/#define LITELOADER_VERSION_ACTIONS ${{ github.run_number }}\r/' LiteLoader/Main/Version.h
|
||||||
|
cat LiteLoader/Main/Version.h
|
||||||
|
shell: bash
|
||||||
|
|
||||||
|
- name: Change LITELOADER_VERSION_STATUS_RELEASE
|
||||||
|
working-directory: ${{ env.GITHUB_WORKSPACE }}
|
||||||
|
if: startsWith(github.ref, 'refs/tags/')
|
||||||
|
run: |
|
||||||
|
sed -r -i 's/#define\s+LITELOADER_VERSION_STATUS\s+LITELOADER_VERSION_\w+/#define LITELOADER_VERSION_STATUS LITELOADER_VERSION_RELEASE/' LiteLoader/Main/Version.h
|
||||||
|
sed -r -i 's/#define\s+LITELOADER_VERSION_ACTIONS\s+.*/#define LITELOADER_VERSION_ACTIONS ${{ github.run_number }}\r/' LiteLoader/Main/Version.h
|
||||||
|
shell: bash
|
||||||
|
|
||||||
|
- name: Get MSVC Path
|
||||||
|
working-directory: E:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\
|
||||||
|
run: echo "MSVC_VER=$(ls | tail -n 1)" >> $GITHUB_ENV
|
||||||
|
shell: bash
|
||||||
|
|
||||||
|
#- name: Configure CMake(MSVC)
|
||||||
|
# run: |
|
||||||
|
# set CC="E:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/${{env.MSVC_VER}}/bin/Hostx64/x64/cl.exe"
|
||||||
|
# "E:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvarsall.bat" x64 & cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -G Ninja -DCMAKE_TRY_COMPILE_TARGET_TYPE="STATIC_LIBRARY" -DCMAKE_MAKE_PROGRAM="E:\PROGRAM FILES\MICROSOFT VISUAL STUDIO\2022\Community\COMMON7\IDE\COMMONEXTENSIONS\Microsoft\CMake\Ninja\ninja.exe"
|
||||||
|
# shell: cmd
|
||||||
|
|
||||||
|
#- name: Build
|
||||||
|
# run: |
|
||||||
|
# "E:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvarsall.bat" x64 & cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
|
||||||
|
# shell: cmd
|
||||||
|
|
||||||
|
- name: Configure CMake(MSVC)
|
||||||
|
run: |
|
||||||
|
cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
|
||||||
|
shell: cmd
|
||||||
|
|
||||||
|
- name: Build
|
||||||
|
run: |
|
||||||
|
cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
|
||||||
|
shell: cmd
|
||||||
|
|
||||||
|
- name: Configure CMake(ClangCL)
|
||||||
|
run: |
|
||||||
|
cmake -B ${{github.workspace}}/build_clang -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -T clangcl
|
||||||
|
shell: cmd
|
||||||
|
|
||||||
|
- name: Build SymDBHelper
|
||||||
|
run: cmake --build ${{github.workspace}}/build_clang --config ${{env.BUILD_TYPE}} --target SymDBHelper
|
||||||
|
|
||||||
|
- name: Compress Resource Packs
|
||||||
|
run: |
|
||||||
|
cd RELEASE/plugins/LiteLoader/ResourcePacks
|
||||||
|
7z a LiteLoaderBDS-CUI.tar LiteLoaderBDS-CUI
|
||||||
|
rm -r LiteLoaderBDS-CUI
|
||||||
|
shell: bash
|
||||||
|
|
||||||
|
- name: Pack Release
|
||||||
|
working-directory: ${{ env.GITHUB_WORKSPACE }}
|
||||||
|
run: |
|
||||||
|
cd Scripts
|
||||||
|
./PackRelease.cmd action
|
||||||
|
shell: cmd
|
||||||
|
|
||||||
|
- name: Move PDB to path
|
||||||
|
working-directory: ${{ env.GITHUB_WORKSPACE }}
|
||||||
|
run: |
|
||||||
|
mkdir PDB
|
||||||
|
cp x64/Release/*.pdb PDB
|
||||||
|
shell: bash
|
||||||
|
|
||||||
|
- name: Pack PDB
|
||||||
|
working-directory: ${{ env.GITHUB_WORKSPACE }}
|
||||||
|
if: startsWith(github.ref, 'refs/tags/')
|
||||||
|
run: 7z a -tzip PDB.zip PDB
|
||||||
|
shell: bash
|
||||||
|
|
||||||
|
- name: Update LiteLoaderSDK
|
||||||
|
working-directory: ${{ env.GITHUB_WORKSPACE }}
|
||||||
|
run: |
|
||||||
|
git config --global user.name "github-actions[bot]"
|
||||||
|
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
||||||
|
cd Scripts
|
||||||
|
./UploadSDK.cmd action
|
||||||
|
env:
|
||||||
|
REPO_KEY: ${{secrets.PUSH_TOKEN}}
|
||||||
|
USERNAME: github-actions[bot]
|
||||||
|
shell: cmd
|
||||||
|
|
||||||
|
- name: Upload LiteLoader
|
||||||
|
uses: actions/upload-artifact@v3.1.0
|
||||||
|
with:
|
||||||
|
name: LiteLoader
|
||||||
|
path: ${{ github.workspace }}\RELEASE\
|
||||||
|
|
||||||
|
- name: Upload PDB
|
||||||
|
uses: actions/upload-artifact@v3.1.0
|
||||||
|
with:
|
||||||
|
name: PDB
|
||||||
|
path: ${{ github.workspace }}\PDB
|
||||||
|
|
||||||
|
- name: Prepare for creating Release
|
||||||
|
working-directory: ${{ env.GITHUB_WORKSPACE }}
|
||||||
|
id: rel
|
||||||
|
if: startsWith(github.ref, 'refs/tags/')
|
||||||
|
run: |
|
||||||
|
echo ::set-output name=tag::${GITHUB_REF#refs/*/}
|
||||||
|
mv LiteLoader.zip LiteLoader-${GITHUB_REF#refs/*/}.zip
|
||||||
|
shell: bash
|
||||||
|
|
||||||
|
- name: Create New Release
|
||||||
|
uses: softprops/action-gh-release@v0.1.14
|
||||||
|
if: startsWith(github.ref, 'refs/tags/')
|
||||||
|
with:
|
||||||
|
body_path: ${{ github.workspace }}\CHANGELOG.md
|
||||||
|
files: |
|
||||||
|
${{ github.workspace }}\LiteLoader-${{ steps.rel.outputs.tag }}.zip
|
||||||
|
${{ github.workspace }}\PDB.zip
|
||||||
|
env:
|
||||||
|
GITHUB_REPOSITORY: LiteLDev/LiteLoaderBDS
|
||||||
|
|
||||||
|
#- name: Publish to MineBBS
|
||||||
|
# working-directory: ${{ env.GITHUB_WORKSPACE }}
|
||||||
|
# if: startsWith(github.ref, 'refs/tags/')
|
||||||
|
# run: |
|
||||||
|
# curl -X POST https://api.github.com/repos/LiteLDev/AutoUpdate-MineBBS/dispatches \
|
||||||
|
# -H "Accept: application/vnd.github.everest-preview+json" \
|
||||||
|
# -H "Authorization: Bearer ${{ secrets.MB_TOKEN }}" \
|
||||||
|
# --data '{"event_type": "webhook"}'
|
||||||
|
# shell: bash
|
124
.github/workflows/cmake.yml
vendored
Normal file
124
.github/workflows/cmake.yml
vendored
Normal file
@ -0,0 +1,124 @@
|
|||||||
|
name: CMake
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
pull_request:
|
||||||
|
paths:
|
||||||
|
- '**.cpp'
|
||||||
|
- '**.cc'
|
||||||
|
- '**.cxx'
|
||||||
|
- '**.c'
|
||||||
|
- '**.hpp'
|
||||||
|
- '**.hh'
|
||||||
|
- '**.hxx'
|
||||||
|
- '**.h'
|
||||||
|
- '.github/workflows/cmake.yml'
|
||||||
|
- '**/CMakeLists.txt'
|
||||||
|
|
||||||
|
env:
|
||||||
|
BUILD_TYPE: Release
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: windows-2022
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3.0.2
|
||||||
|
with:
|
||||||
|
fetch-depth: 1
|
||||||
|
#submodules: 'true'
|
||||||
|
|
||||||
|
- name: Cache Bedrock Dedicated Server Library
|
||||||
|
id: cache-bds-lib
|
||||||
|
uses: actions/cache@v3
|
||||||
|
env:
|
||||||
|
cache-name: cache-bds-lib
|
||||||
|
with:
|
||||||
|
path: |
|
||||||
|
${{ env.GITHUB_WORKSPACE }}LiteLoader/Lib/bedrock_server_api.lib
|
||||||
|
${{ env.GITHUB_WORKSPACE }}LiteLoader/Lib/bedrock_server_var.lib
|
||||||
|
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('Scripts/LINK.txt') }}
|
||||||
|
|
||||||
|
- name: Download Server
|
||||||
|
if: steps.cache-bds-lib.outputs.cache-hit != 'true'
|
||||||
|
working-directory: ${{ env.GITHUB_WORKSPACE }}
|
||||||
|
run: |
|
||||||
|
mkdir Tools/Server
|
||||||
|
ServerLink=$(cat 'Scripts/LINK.txt')
|
||||||
|
curl -L -o Tools/Server/server.zip "$ServerLink"
|
||||||
|
unzip Tools/Server/server.zip -d Tools/Server/ > /dev/null
|
||||||
|
shell: bash
|
||||||
|
|
||||||
|
- name: Build Library
|
||||||
|
if: steps.cache-bds-lib.outputs.cache-hit != 'true'
|
||||||
|
working-directory: ${{ env.GITHUB_WORKSPACE }}
|
||||||
|
run: |
|
||||||
|
cd Tools
|
||||||
|
LibraryBuilder.exe Server
|
||||||
|
shell: cmd
|
||||||
|
|
||||||
|
- name: Change LITELOADER_VERSION_STATUS_BETA
|
||||||
|
working-directory: ${{ env.GITHUB_WORKSPACE }}
|
||||||
|
if: false == startsWith(github.ref, 'refs/tags/')
|
||||||
|
run: |
|
||||||
|
sed -r -i 's/#define\s+LITELOADER_VERSION_STATUS\s+LITELOADER_VERSION_\w+/#define LITELOADER_VERSION_STATUS LITELOADER_VERSION_BETA/' LiteLoader/Main/Version.h
|
||||||
|
sed -r -i 's/#define\s+LITELOADER_VERSION_ACTIONS\s+.*/#define LITELOADER_VERSION_ACTIONS ${{ github.run_number }}\r/' LiteLoader/Main/Version.h
|
||||||
|
cat LiteLoader/Main/Version.h
|
||||||
|
shell: bash
|
||||||
|
|
||||||
|
- name: Change LITELOADER_VERSION_STATUS_RELEASE
|
||||||
|
working-directory: ${{ env.GITHUB_WORKSPACE }}
|
||||||
|
if: startsWith(github.ref, 'refs/tags/')
|
||||||
|
run: |
|
||||||
|
sed -r -i 's/#define\s+LITELOADER_VERSION_STATUS\s+LITELOADER_VERSION_\w+/#define LITELOADER_VERSION_STATUS LITELOADER_VERSION_RELEASE/' LiteLoader/Main/Version.h
|
||||||
|
sed -r -i 's/#define\s+LITELOADER_VERSION_ACTIONS\s+.*/#define LITELOADER_VERSION_ACTIONS ${{ github.run_number }}\r/' LiteLoader/Main/Version.h
|
||||||
|
shell: bash
|
||||||
|
|
||||||
|
- name: Get MSVC Path
|
||||||
|
working-directory: C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\
|
||||||
|
run: echo "MSVC_VER=$(ls | tail -n 1)" >> $GITHUB_ENV
|
||||||
|
shell: bash
|
||||||
|
|
||||||
|
- name: Configure CMake(MSVC)
|
||||||
|
run: |
|
||||||
|
cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
|
||||||
|
shell: cmd
|
||||||
|
|
||||||
|
- name: Build
|
||||||
|
run: |
|
||||||
|
cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
|
||||||
|
shell: cmd
|
||||||
|
|
||||||
|
- name: Configure CMake(ClangCL)
|
||||||
|
run: |
|
||||||
|
cmake -B ${{github.workspace}}/build_clang -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -T clangcl
|
||||||
|
shell: cmd
|
||||||
|
|
||||||
|
- name: Build SymDBHelper
|
||||||
|
run: cmake --build ${{github.workspace}}/build_clang --config ${{env.BUILD_TYPE}} --target SymDBHelper
|
||||||
|
|
||||||
|
- name: Pack Release
|
||||||
|
working-directory: ${{ env.GITHUB_WORKSPACE }}
|
||||||
|
run: |
|
||||||
|
cd Scripts
|
||||||
|
./PackRelease.cmd action
|
||||||
|
shell: cmd
|
||||||
|
|
||||||
|
- name: Move PDB to path
|
||||||
|
working-directory: ${{ env.GITHUB_WORKSPACE }}
|
||||||
|
run: |
|
||||||
|
mkdir PDB
|
||||||
|
cp x64/Release/*.pdb PDB
|
||||||
|
shell: bash
|
||||||
|
|
||||||
|
- name: Upload LiteLoader
|
||||||
|
uses: actions/upload-artifact@v3.1.0
|
||||||
|
with:
|
||||||
|
name: LiteLoader
|
||||||
|
path: ${{ github.workspace }}\RELEASE\
|
||||||
|
|
||||||
|
- name: Upload PDB
|
||||||
|
uses: actions/upload-artifact@v3.1.0
|
||||||
|
with:
|
||||||
|
name: PDB
|
||||||
|
path: ${{ github.workspace }}\PDB
|
19
.github/workflows/issue-close-require.yml
vendored
Normal file
19
.github/workflows/issue-close-require.yml
vendored
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
name: Issue Close Require
|
||||||
|
|
||||||
|
on:
|
||||||
|
schedule:
|
||||||
|
- cron: "0 0 * * *"
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
issue-close-require:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: need reproduce
|
||||||
|
uses: actions-cool/issues-helper@v2
|
||||||
|
with:
|
||||||
|
actions: 'close-issues'
|
||||||
|
labels: 'status: more information needed'
|
||||||
|
inactive-day: 30
|
||||||
|
body: |
|
||||||
|
您超过 30 天未反馈信息,我们将关闭该 issue,如有需求您可以重新打开或者提交新的 issue。
|
||||||
|
If you haven't provided feedback for more than 30 days, we will close the issue. You can reopen or submit a new issue if necessary.
|
16
.github/workflows/issue-close.yml
vendored
Normal file
16
.github/workflows/issue-close.yml
vendored
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
name: Issue Close Check
|
||||||
|
|
||||||
|
on:
|
||||||
|
issues:
|
||||||
|
types: [closed]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
issue-close-remove-labels:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Remove labels
|
||||||
|
uses: actions-cool/issues-helper@v2
|
||||||
|
if: ${{ !github.event.issue.pull_request }}
|
||||||
|
with:
|
||||||
|
actions: 'remove-labels'
|
||||||
|
labels: 'status: need review,status: more information needed'
|
38
.github/workflows/issue-comment.yml
vendored
Normal file
38
.github/workflows/issue-comment.yml
vendored
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
on:
|
||||||
|
issue_comment:
|
||||||
|
types: [created]
|
||||||
|
|
||||||
|
name: Add issues workflow labels
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
add-label-if-is-author:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
if: (github.event.issue.user.id == github.event.comment.user.id) && !github.event.issue.pull_request && (github.event.issue.state == 'open')
|
||||||
|
steps:
|
||||||
|
- name: Add require handle label
|
||||||
|
uses: actions-cool/issues-helper@v2
|
||||||
|
with:
|
||||||
|
actions: 'add-labels'
|
||||||
|
labels: 'status: need review'
|
||||||
|
|
||||||
|
- name: Remove require reply label
|
||||||
|
uses: actions-cool/issues-helper@v2
|
||||||
|
with:
|
||||||
|
actions: 'remove-labels'
|
||||||
|
labels: 'status: more information needed'
|
||||||
|
|
||||||
|
add-label-if-not-author:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
if: (github.event.issue.user.id != github.event.comment.user.id) && !github.event.issue.pull_request && (github.event.issue.state == 'open')
|
||||||
|
steps:
|
||||||
|
- name: Add require replay label
|
||||||
|
uses: actions-cool/issues-helper@v2
|
||||||
|
with:
|
||||||
|
actions: 'add-labels'
|
||||||
|
labels: 'status: more information needed'
|
||||||
|
|
||||||
|
- name: Remove require handle label
|
||||||
|
uses: actions-cool/issues-helper@v2
|
||||||
|
with:
|
||||||
|
actions: 'remove-labels'
|
||||||
|
labels: 'status: need review'
|
16
.github/workflows/issue-open.yml
vendored
Normal file
16
.github/workflows/issue-open.yml
vendored
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
name: Issue Open Check
|
||||||
|
|
||||||
|
on:
|
||||||
|
issues:
|
||||||
|
types: [opened]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
issue-open-add-labels:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Add labels
|
||||||
|
uses: actions-cool/issues-helper@v2
|
||||||
|
if: ${{ !github.event.issue.pull_request }}
|
||||||
|
with:
|
||||||
|
actions: 'add-labels'
|
||||||
|
labels: 'status: need review'
|
36
.gitignore
vendored
Normal file
36
.gitignore
vendored
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
x64/
|
||||||
|
**/.vs/
|
||||||
|
**/x64/
|
||||||
|
**/*.user
|
||||||
|
**/.vscode/
|
||||||
|
|
||||||
|
**/bedrock_server_api.lib
|
||||||
|
**/bedrock_server_var.lib
|
||||||
|
**/SymDB_DelayLoadHelper.lib
|
||||||
|
LiteLoader/Lib/SymDBHelper.lib
|
||||||
|
**/*.lastcodeanalysissucceeded
|
||||||
|
*.zip
|
||||||
|
|
||||||
|
/LiteLoader/out/
|
||||||
|
LiteLoaderSDK/
|
||||||
|
|
||||||
|
RELEASE/*.dll
|
||||||
|
RELEASE/LLPeEditor.exe
|
||||||
|
!RELEASE/ChakraCore.dll
|
||||||
|
RELEASE/plugins/LiteLoader/LiteLoader.*.dll
|
||||||
|
RELEASE/plugins/LiteLoader/LiteLoader.*.pdb
|
||||||
|
RELEASE/plugins/LiteLoader/pdb
|
||||||
|
!RELEASE/plugins/LiteLoader/CrashLogger.dll
|
||||||
|
|
||||||
|
.idea/**
|
||||||
|
!.idea/cmake.xml
|
||||||
|
|
||||||
|
cmake-build-release/
|
||||||
|
/out
|
||||||
|
LiteLoader/Lib/Demangler.pdb
|
||||||
|
LiteLoader/Lib/Demangler.lib
|
||||||
|
|
||||||
|
/build
|
||||||
|
**/Directory.build.props
|
||||||
|
RELEASE/plugins/lib/BaseLib.js
|
||||||
|
RELEASE/plugins/lib/BaseLib.lua
|
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
[submodule "RELEASE/plugins/LiteLoader/ResourcePacks/LiteLoaderBDS-CUI"]
|
||||||
|
path = RELEASE/plugins/LiteLoader/ResourcePacks/LiteLoaderBDS-CUI
|
||||||
|
url = https://github.com/OEOTYAN/LiteLoaderBDS-CUI.git
|
8
.idea/cmake.xml
Normal file
8
.idea/cmake.xml
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="CMakeSharedSettings">
|
||||||
|
<configurations>
|
||||||
|
<configuration PROFILE_NAME="Release" ENABLED="true" CONFIG_NAME="Release" GENERATION_OPTIONS="-G "Visual Studio 17 2022"" />
|
||||||
|
</configurations>
|
||||||
|
</component>
|
||||||
|
</project>
|
5
CHANGELOG.md
Normal file
5
CHANGELOG.md
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
## [LiteLoader Release Note]
|
||||||
|
LiteLoaderBDS-2.6.2 update has been released, adapted to BDS-1.19.21,BDS-1.19.22, ProtocolVersion 545
|
||||||
|
|
||||||
|
## [Bug Fixes]
|
||||||
|
- Fix LLSE `NetworkAPI`
|
14
CMakeLists.txt
Normal file
14
CMakeLists.txt
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.21)
|
||||||
|
project(LL-Parent)
|
||||||
|
|
||||||
|
# Add sub directories
|
||||||
|
add_subdirectory(PreLoader)
|
||||||
|
add_subdirectory(LiteLoader)
|
||||||
|
add_subdirectory(ScriptEngine/CMake/ScriptEngine-Lua)
|
||||||
|
add_subdirectory(ScriptEngine/CMake/ScriptEngine-QuickJs)
|
||||||
|
add_subdirectory(ScriptEngine/CMake/ScriptEngine-NodeJs)
|
||||||
|
add_subdirectory(Tools/Demangler)
|
||||||
|
add_subdirectory(ScriptEngine/third-party/ScriptX/CMake/ScriptX-Lua)
|
||||||
|
add_subdirectory(ScriptEngine/third-party/ScriptX/CMake/ScriptX-QuickJs)
|
||||||
|
add_subdirectory(ScriptEngine/third-party/ScriptX/CMake/ScriptX-NodeJs)
|
||||||
|
add_subdirectory(Tools/SymDBHelper)
|
188
LICENSE
Normal file
188
LICENSE
Normal file
@ -0,0 +1,188 @@
|
|||||||
|
[CHINESE VERSION]
|
||||||
|
|
||||||
|
版权所有 © 2020-2022 [LiteLoaderBDS Developers](https://github.com/LiteLDev) 保留所有权利
|
||||||
|
|
||||||
|
本项目使用 GNU Lesser General Public License version 3(LGPLv3许可证),例外情况如下:
|
||||||
|
|
||||||
|
LiteLoaderSDK不受此许可证约束, LiteLoaderSDK使用MIT许可证开源。
|
||||||
|
|
||||||
|
注: LiteLoaderSDK指本仓库的LiteLoader/Header目录下的文件
|
||||||
|
许可证详见https://github.com/LiteLDev/LiteLoaderSDK/tree/main/LICENSE
|
||||||
|
|
||||||
|
[ENGLISH VERSION]
|
||||||
|
|
||||||
|
Copyright © 2020-2022 [LiteLoaderBDS Developers](https://github.com/LiteLDev) All rights reserved.
|
||||||
|
|
||||||
|
This project is under the GNU Lesser General Public License version 3, with exceptions as follows:
|
||||||
|
|
||||||
|
LiteLoaderSDK is not under the terms of this license, and is open source under the MIT license.
|
||||||
|
|
||||||
|
Note: LiteLoaderSDK refers to the repository's LiteLoader/Header directory.
|
||||||
|
See https://github.com/LiteLDev/LiteLoaderSDK/tree/main/LICENSE for the license.
|
||||||
|
|
||||||
|
========================================================================
|
||||||
|
GNU LESSER GENERAL PUBLIC LICENSE
|
||||||
|
Version 3, 29 June 2007
|
||||||
|
|
||||||
|
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||||
|
Everyone is permitted to copy and distribute verbatim copies
|
||||||
|
of this license document, but changing it is not allowed.
|
||||||
|
|
||||||
|
|
||||||
|
This version of the GNU Lesser General Public License incorporates
|
||||||
|
the terms and conditions of version 3 of the GNU General Public
|
||||||
|
License, supplemented by the additional permissions listed below.
|
||||||
|
|
||||||
|
0. Additional Definitions.
|
||||||
|
|
||||||
|
As used herein, "this License" refers to version 3 of the GNU Lesser
|
||||||
|
General Public License, and the "GNU GPL" refers to version 3 of the GNU
|
||||||
|
General Public License.
|
||||||
|
|
||||||
|
"The Library" refers to a covered work governed by this License,
|
||||||
|
other than an Application or a Combined Work as defined below.
|
||||||
|
|
||||||
|
An "Application" is any work that makes use of an interface provided
|
||||||
|
by the Library, but which is not otherwise based on the Library.
|
||||||
|
Defining a subclass of a class defined by the Library is deemed a mode
|
||||||
|
of using an interface provided by the Library.
|
||||||
|
|
||||||
|
A "Combined Work" is a work produced by combining or linking an
|
||||||
|
Application with the Library. The particular version of the Library
|
||||||
|
with which the Combined Work was made is also called the "Linked
|
||||||
|
Version".
|
||||||
|
|
||||||
|
The "Minimal Corresponding Source" for a Combined Work means the
|
||||||
|
Corresponding Source for the Combined Work, excluding any source code
|
||||||
|
for portions of the Combined Work that, considered in isolation, are
|
||||||
|
based on the Application, and not on the Linked Version.
|
||||||
|
|
||||||
|
The "Corresponding Application Code" for a Combined Work means the
|
||||||
|
object code and/or source code for the Application, including any data
|
||||||
|
and utility programs needed for reproducing the Combined Work from the
|
||||||
|
Application, but excluding the System Libraries of the Combined Work.
|
||||||
|
|
||||||
|
1. Exception to Section 3 of the GNU GPL.
|
||||||
|
|
||||||
|
You may convey a covered work under sections 3 and 4 of this License
|
||||||
|
without being bound by section 3 of the GNU GPL.
|
||||||
|
|
||||||
|
2. Conveying Modified Versions.
|
||||||
|
|
||||||
|
If you modify a copy of the Library, and, in your modifications, a
|
||||||
|
facility refers to a function or data to be supplied by an Application
|
||||||
|
that uses the facility (other than as an argument passed when the
|
||||||
|
facility is invoked), then you may convey a copy of the modified
|
||||||
|
version:
|
||||||
|
|
||||||
|
a) under this License, provided that you make a good faith effort to
|
||||||
|
ensure that, in the event an Application does not supply the
|
||||||
|
function or data, the facility still operates, and performs
|
||||||
|
whatever part of its purpose remains meaningful, or
|
||||||
|
|
||||||
|
b) under the GNU GPL, with none of the additional permissions of
|
||||||
|
this License applicable to that copy.
|
||||||
|
|
||||||
|
3. Object Code Incorporating Material from Library Header Files.
|
||||||
|
|
||||||
|
The object code form of an Application may incorporate material from
|
||||||
|
a header file that is part of the Library. You may convey such object
|
||||||
|
code under terms of your choice, provided that, if the incorporated
|
||||||
|
material is not limited to numerical parameters, data structure
|
||||||
|
layouts and accessors, or small macros, inline functions and templates
|
||||||
|
(ten or fewer lines in length), you do both of the following:
|
||||||
|
|
||||||
|
a) Give prominent notice with each copy of the object code that the
|
||||||
|
Library is used in it and that the Library and its use are
|
||||||
|
covered by this License.
|
||||||
|
|
||||||
|
b) Accompany the object code with a copy of the GNU GPL and this license
|
||||||
|
document.
|
||||||
|
|
||||||
|
4. Combined Works.
|
||||||
|
|
||||||
|
You may convey a Combined Work under terms of your choice that,
|
||||||
|
taken together, effectively do not restrict modification of the
|
||||||
|
portions of the Library contained in the Combined Work and reverse
|
||||||
|
engineering for debugging such modifications, if you also do each of
|
||||||
|
the following:
|
||||||
|
|
||||||
|
a) Give prominent notice with each copy of the Combined Work that
|
||||||
|
the Library is used in it and that the Library and its use are
|
||||||
|
covered by this License.
|
||||||
|
|
||||||
|
b) Accompany the Combined Work with a copy of the GNU GPL and this license
|
||||||
|
document.
|
||||||
|
|
||||||
|
c) For a Combined Work that displays copyright notices during
|
||||||
|
execution, include the copyright notice for the Library among
|
||||||
|
these notices, as well as a reference directing the user to the
|
||||||
|
copies of the GNU GPL and this license document.
|
||||||
|
|
||||||
|
d) Do one of the following:
|
||||||
|
|
||||||
|
0) Convey the Minimal Corresponding Source under the terms of this
|
||||||
|
License, and the Corresponding Application Code in a form
|
||||||
|
suitable for, and under terms that permit, the user to
|
||||||
|
recombine or relink the Application with a modified version of
|
||||||
|
the Linked Version to produce a modified Combined Work, in the
|
||||||
|
manner specified by section 6 of the GNU GPL for conveying
|
||||||
|
Corresponding Source.
|
||||||
|
|
||||||
|
1) Use a suitable shared library mechanism for linking with the
|
||||||
|
Library. A suitable mechanism is one that (a) uses at run time
|
||||||
|
a copy of the Library already present on the user's computer
|
||||||
|
system, and (b) will operate properly with a modified version
|
||||||
|
of the Library that is interface-compatible with the Linked
|
||||||
|
Version.
|
||||||
|
|
||||||
|
e) Provide Installation Information, but only if you would otherwise
|
||||||
|
be required to provide such information under section 6 of the
|
||||||
|
GNU GPL, and only to the extent that such information is
|
||||||
|
necessary to install and execute a modified version of the
|
||||||
|
Combined Work produced by recombining or relinking the
|
||||||
|
Application with a modified version of the Linked Version. (If
|
||||||
|
you use option 4d0, the Installation Information must accompany
|
||||||
|
the Minimal Corresponding Source and Corresponding Application
|
||||||
|
Code. If you use option 4d1, you must provide the Installation
|
||||||
|
Information in the manner specified by section 6 of the GNU GPL
|
||||||
|
for conveying Corresponding Source.)
|
||||||
|
|
||||||
|
5. Combined Libraries.
|
||||||
|
|
||||||
|
You may place library facilities that are a work based on the
|
||||||
|
Library side by side in a single library together with other library
|
||||||
|
facilities that are not Applications and are not covered by this
|
||||||
|
License, and convey such a combined library under terms of your
|
||||||
|
choice, if you do both of the following:
|
||||||
|
|
||||||
|
a) Accompany the combined library with a copy of the same work based
|
||||||
|
on the Library, uncombined with any other library facilities,
|
||||||
|
conveyed under the terms of this License.
|
||||||
|
|
||||||
|
b) Give prominent notice with the combined library that part of it
|
||||||
|
is a work based on the Library, and explaining where to find the
|
||||||
|
accompanying uncombined form of the same work.
|
||||||
|
|
||||||
|
6. Revised Versions of the GNU Lesser General Public License.
|
||||||
|
|
||||||
|
The Free Software Foundation may publish revised and/or new versions
|
||||||
|
of the GNU Lesser General Public License from time to time. Such new
|
||||||
|
versions will be similar in spirit to the present version, but may
|
||||||
|
differ in detail to address new problems or concerns.
|
||||||
|
|
||||||
|
Each version is given a distinguishing version number. If the
|
||||||
|
Library as you received it specifies that a certain numbered version
|
||||||
|
of the GNU Lesser General Public License "or any later version"
|
||||||
|
applies to it, you have the option of following the terms and
|
||||||
|
conditions either of that published version or of any later version
|
||||||
|
published by the Free Software Foundation. If the Library as you
|
||||||
|
received it does not specify a version number of the GNU Lesser
|
||||||
|
General Public License, you may choose any version of the GNU Lesser
|
||||||
|
General Public License ever published by the Free Software Foundation.
|
||||||
|
|
||||||
|
If the Library as you received it specifies that a proxy can decide
|
||||||
|
whether future versions of the GNU Lesser General Public License shall
|
||||||
|
apply, that proxy's public statement of acceptance of any version is
|
||||||
|
permanent authorization for you to choose that version for the
|
||||||
|
Library.
|
5
LiteLoader/.gitignore
vendored
Normal file
5
LiteLoader/.gitignore
vendored
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
*.user
|
||||||
|
/cmake-build-release/
|
||||||
|
/cmake-build-debug/
|
||||||
|
/.idea/
|
||||||
|
Lib/LiteLoader.lib
|
70
LiteLoader/CMakeLists.txt
Normal file
70
LiteLoader/CMakeLists.txt
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.21)
|
||||||
|
project(LiteLoader)
|
||||||
|
|
||||||
|
set(CMAKE_CXX_STANDARD 20)
|
||||||
|
set(CMAKE_BUILD_TYPE Release) # Always uses Release mode to build BDS plugin for ABI Compatibility
|
||||||
|
|
||||||
|
set(LIBRARY_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/x64/)
|
||||||
|
|
||||||
|
set(TARGET_DIR ${CMAKE_SOURCE_DIR}/x64/Release/)
|
||||||
|
|
||||||
|
file(GLOB_RECURSE SRC_FILES
|
||||||
|
${PROJECT_SOURCE_DIR}/Lib/third-party/nbt-cpp/*.cpp
|
||||||
|
${PROJECT_SOURCE_DIR}/Header/*.cpp
|
||||||
|
${PROJECT_SOURCE_DIR}/Header/*.hpp
|
||||||
|
${PROJECT_SOURCE_DIR}/Header/*.h
|
||||||
|
${PROJECT_SOURCE_DIR}/Kernel/*.cpp
|
||||||
|
${PROJECT_SOURCE_DIR}/Kernel/*.hpp
|
||||||
|
${PROJECT_SOURCE_DIR}/Kernel/*.h
|
||||||
|
${PROJECT_SOURCE_DIR}/Main/*.cpp
|
||||||
|
${PROJECT_SOURCE_DIR}/Main/*.hpp
|
||||||
|
${PROJECT_SOURCE_DIR}/Main/*.h
|
||||||
|
${PROJECT_SOURCE_DIR}/Resource/*.rc
|
||||||
|
${PROJECT_SOURCE_DIR}/Resource/*.h
|
||||||
|
)
|
||||||
|
|
||||||
|
add_definitions(
|
||||||
|
-DUNICODE -DNDEBUG -DLITELOADER_EXPORTS -DWIN32_LEAN_AND_MEAN
|
||||||
|
-DCPPHTTPLIB_OPENSSL_SUPPORT -D_CRT_SECURE_NO_WARNINGS -D_WINDOWS
|
||||||
|
-D_USRDLL -D_AMD64_ -DNOMINMAX
|
||||||
|
)
|
||||||
|
|
||||||
|
add_compile_options(
|
||||||
|
/permissive /MP /analyze:external- /GS /GL /W3 /Gy /Zc:wchar_t /Zi /Gm- /O2 /sdl /Zc:inline /fp:precise
|
||||||
|
/external:W1 /errorReport:prompt /WX- /Zc:forScope /Gd /Oi /MD /FC /EHa /nologo /Ot /diagnostics:column
|
||||||
|
/utf-8
|
||||||
|
)
|
||||||
|
|
||||||
|
add_link_options(
|
||||||
|
/MANIFEST /LTCG:incremental /NXCOMPAT /DEBUG:FULL /DLL /MACHINE:X64 /OPT:REF /INCREMENTAL:NO /SUBSYSTEM:CONSOLE
|
||||||
|
/MANIFESTUAC:NO /OPT:ICF /ERRORREPORT:PROMPT /NOLOGO /TLBID:1
|
||||||
|
/DELAYLOAD:bedrock_server.dll # use delayload to import BDS APIs manually(bedrock_server.dll does not need to exist)
|
||||||
|
)
|
||||||
|
|
||||||
|
include_directories(${PROJECT_SOURCE_DIR})
|
||||||
|
include_directories(${PROJECT_SOURCE_DIR}/Header)
|
||||||
|
include_directories(${PROJECT_SOURCE_DIR}/Header/third-party)
|
||||||
|
include_directories(${CMAKE_SOURCE_DIR})
|
||||||
|
|
||||||
|
link_directories(${PROJECT_SOURCE_DIR})
|
||||||
|
link_directories(${CMAKE_SOURCE_DIR}/x64/Release)
|
||||||
|
|
||||||
|
add_library(LiteLoader SHARED ${SRC_FILES})
|
||||||
|
|
||||||
|
target_link_libraries(LiteLoader LLPreLoader
|
||||||
|
"${PROJECT_SOURCE_DIR}/Lib/third-party/leveldb/leveldb.lib"
|
||||||
|
"${PROJECT_SOURCE_DIR}/Lib/third-party/openssl/libcrypto.lib"
|
||||||
|
"${PROJECT_SOURCE_DIR}/Lib/third-party/openssl/libssl.lib"
|
||||||
|
"${PROJECT_SOURCE_DIR}/Lib/third-party/SQLiteCpp/SQLiteCpp.lib"
|
||||||
|
"${PROJECT_SOURCE_DIR}/Lib/third-party/SQLiteCpp/sqlite3.lib"
|
||||||
|
"${PROJECT_SOURCE_DIR}/Lib/third-party/mysql/mysqlclient.lib"
|
||||||
|
"${PROJECT_SOURCE_DIR}/Lib/third-party/compact_enc_det/ced.lib"
|
||||||
|
"${PROJECT_SOURCE_DIR}/Lib/third-party/dyncall/dyncall_s.lib"
|
||||||
|
"${PROJECT_SOURCE_DIR}/Lib/third-party/dyncall/dyncallback_s.lib"
|
||||||
|
"${PROJECT_SOURCE_DIR}/Lib/third-party/dyncall/dynload_s.lib"
|
||||||
|
"${PROJECT_SOURCE_DIR}/Lib/third-party/compact_enc_det/ced.lib"
|
||||||
|
"${PROJECT_SOURCE_DIR}/Lib/third-party/dbghelp/dbghelp.lib"
|
||||||
|
# Please make sure that the BDS APIs ImportLibrary is at the bottom of the list to ensure proper linking.
|
||||||
|
"${PROJECT_SOURCE_DIR}/Lib/bedrock_server_api.lib"
|
||||||
|
"${PROJECT_SOURCE_DIR}/Lib/bedrock_server_var.lib"
|
||||||
|
)
|
51
LiteLoader/Header/AllowListAPI.h
Normal file
51
LiteLoader/Header/AllowListAPI.h
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "Global.h"
|
||||||
|
#include "third-party/Nlohmann/json.hpp"
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////
|
||||||
|
// For managing AllowList
|
||||||
|
//
|
||||||
|
// [Usage]
|
||||||
|
//
|
||||||
|
// AllowListManager().has("steve"[, "114514"]);
|
||||||
|
// AllowListManager().add("alex"[, "11451419", true]).reload();
|
||||||
|
// AllowListManager().remove("mojang"[, "233333"]).reload();
|
||||||
|
// AllowListManager().add(...).remove(...).reload();
|
||||||
|
//
|
||||||
|
// [Note]
|
||||||
|
//
|
||||||
|
// If you don't call reload after add/remove, the changes will only write to file
|
||||||
|
// but it will not take effect in the game.
|
||||||
|
// This means the player you added won't be able to join the game until reloading
|
||||||
|
//
|
||||||
|
// 如果你在使用add/remove成员之后不调用reload函数, 这些更改将只会写入文件而不会在游戏中生效
|
||||||
|
// 这意味着你添加到白名单的玩家将不能加入游戏, 直到重载白名单
|
||||||
|
//
|
||||||
|
//////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
// class AllowListManager {
|
||||||
|
|
||||||
|
// void save();
|
||||||
|
|
||||||
|
// public:
|
||||||
|
// nlohmann::json allowList;
|
||||||
|
|
||||||
|
// LIAPI AllowListManager();
|
||||||
|
|
||||||
|
// LIAPI size_t size();
|
||||||
|
|
||||||
|
// // @summary Return whether the player in the allowlist
|
||||||
|
// LIAPI bool has(const std::string& name, const xuid_t& xuid = "");
|
||||||
|
// // @summary Return whether the player in the allowlist
|
||||||
|
// // @param index If exists, index will be set to the array index
|
||||||
|
// LIAPI bool has(const std::string& name, const xuid_t& xuid, size_t& index);
|
||||||
|
|
||||||
|
// // @summary Add a player to allowlist
|
||||||
|
// LIAPI AllowListManager& add(const std::string& name, const xuid_t& xuid = "", bool ignore = false);
|
||||||
|
|
||||||
|
// // @summary Remove a player from allowlist
|
||||||
|
// LIAPI AllowListManager& remove(const std::string& name, const xuid_t& xuid = "");
|
||||||
|
|
||||||
|
// // @summary Reload the allowlist(Making changes effective)
|
||||||
|
// LIAPI void reload();
|
||||||
|
// };
|
728
LiteLoader/Header/DB/Any.h
Normal file
728
LiteLoader/Header/DB/Any.h
Normal file
@ -0,0 +1,728 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "../Global.h"
|
||||||
|
#include "Types.h"
|
||||||
|
|
||||||
|
#pragma region AnyConversion
|
||||||
|
|
||||||
|
namespace DB
|
||||||
|
{
|
||||||
|
// Declare Any class
|
||||||
|
class Any;
|
||||||
|
} // namespace DB
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Function to convert Any to T.
|
||||||
|
*
|
||||||
|
* @tparam T The type to convert to
|
||||||
|
* @param v The Any object
|
||||||
|
* @return T The converted value
|
||||||
|
*/
|
||||||
|
template <typename T>
|
||||||
|
inline T any_to(const DB::Any& v)
|
||||||
|
{
|
||||||
|
throw std::bad_cast();
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
inline std::vector<DB::Any> to_any_container(const std::vector<T>& v)
|
||||||
|
{
|
||||||
|
std::vector<DB::Any> result;
|
||||||
|
for (auto& i : v)
|
||||||
|
{
|
||||||
|
result.push_back(DB::Any(i));
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
template <typename T>
|
||||||
|
inline std::set<DB::Any> to_any_container(const std::set<T>& v)
|
||||||
|
{
|
||||||
|
std::set<DB::Any> result;
|
||||||
|
for (auto& i : v)
|
||||||
|
{
|
||||||
|
result.insert(DB::Any(i));
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
template <typename T>
|
||||||
|
inline std::list<DB::Any> to_any_container(const std::list<T>& v)
|
||||||
|
{
|
||||||
|
std::list<DB::Any> result;
|
||||||
|
for (auto& i : v)
|
||||||
|
{
|
||||||
|
result.push_back(DB::Any(i));
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
template <typename T>
|
||||||
|
inline std::unordered_set<DB::Any> to_any_container(const std::unordered_set<T>& v)
|
||||||
|
{
|
||||||
|
std::unordered_set<DB::Any> result;
|
||||||
|
for (auto& i : v)
|
||||||
|
{
|
||||||
|
result.insert(DB::Any(i));
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
template <typename K, typename V>
|
||||||
|
inline std::map<K, DB::Any> to_any_container(const std::map<K, V>& v)
|
||||||
|
{
|
||||||
|
std::map<K, DB::Any> result;
|
||||||
|
for (auto& i : v)
|
||||||
|
{
|
||||||
|
result.insert(std::make_pair(i.first, DB::Any(i.second)));
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
template <typename K, typename V>
|
||||||
|
inline std::unordered_map<K, DB::Any> to_any_unordered_map(const std::unordered_map<K, V>& v)
|
||||||
|
{
|
||||||
|
std::unordered_map<K, DB::Any> result;
|
||||||
|
for (auto& i : v)
|
||||||
|
{
|
||||||
|
result.insert(std::make_pair(i.first, DB::Any(i.second)));
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma endregion
|
||||||
|
|
||||||
|
namespace DB
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Any class to store some SQL basic types
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
class Any
|
||||||
|
{
|
||||||
|
|
||||||
|
public:
|
||||||
|
union Value
|
||||||
|
{
|
||||||
|
bool boolean;
|
||||||
|
int64_t integer;
|
||||||
|
uint64_t uinteger;
|
||||||
|
double floating;
|
||||||
|
std::string* string;
|
||||||
|
Date* date;
|
||||||
|
Time* time;
|
||||||
|
DateTime* datetime;
|
||||||
|
ByteArray* blob;
|
||||||
|
} value; ///< Value
|
||||||
|
|
||||||
|
enum class Type : char
|
||||||
|
{
|
||||||
|
Null = 0,
|
||||||
|
Boolean = 1,
|
||||||
|
Integer = 2,
|
||||||
|
UInteger = 3,
|
||||||
|
Floating = 4,
|
||||||
|
String = 5,
|
||||||
|
Date = 6,
|
||||||
|
Time = 7,
|
||||||
|
DateTime = 8,
|
||||||
|
Blob = 9
|
||||||
|
} type = Type::Null; ///< Type of the value
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Construct a new Any object with null value.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
LIAPI Any();
|
||||||
|
/**
|
||||||
|
* @brief Construct a new Any object with boolean value.
|
||||||
|
*
|
||||||
|
* @param v The boolean value
|
||||||
|
*/
|
||||||
|
LIAPI Any(bool v);
|
||||||
|
/**
|
||||||
|
* @brief Construct a new Any object with int64 value.
|
||||||
|
*
|
||||||
|
* @param v The integer value
|
||||||
|
*/
|
||||||
|
LIAPI Any(int64_t v);
|
||||||
|
/**
|
||||||
|
* @brief Construct a new Any object with uint64 value.
|
||||||
|
*
|
||||||
|
* @param v The unsigned integer value
|
||||||
|
*/
|
||||||
|
LIAPI Any(uint64_t v);
|
||||||
|
/**
|
||||||
|
* @brief Construct a new Any object with double value.
|
||||||
|
*
|
||||||
|
* @param v The floating value
|
||||||
|
*/
|
||||||
|
LIAPI Any(double v);
|
||||||
|
/**
|
||||||
|
* @brief Construct a new Any object with string value.
|
||||||
|
*
|
||||||
|
* @param v The string value
|
||||||
|
*/
|
||||||
|
LIAPI Any(const std::string& v);
|
||||||
|
/**
|
||||||
|
* @brief Construct a new Any object with const char* value.
|
||||||
|
*
|
||||||
|
* @param v The const char* value
|
||||||
|
*/
|
||||||
|
LIAPI Any(const char* v);
|
||||||
|
/**
|
||||||
|
* @brief Construct a new Any object with char* value.
|
||||||
|
*
|
||||||
|
* @param v The char* value
|
||||||
|
* @param len The length of the char* value
|
||||||
|
*/
|
||||||
|
LIAPI Any(char* v, size_t len);
|
||||||
|
/**
|
||||||
|
* @brief Construct a new Any object with date value.
|
||||||
|
*
|
||||||
|
* @param v The Date object
|
||||||
|
*/
|
||||||
|
LIAPI Any(const Date& v);
|
||||||
|
/**
|
||||||
|
* @brief Construct a new Any object with time value.
|
||||||
|
*
|
||||||
|
* @param v The Time object
|
||||||
|
*/
|
||||||
|
LIAPI Any(const Time& v);
|
||||||
|
/**
|
||||||
|
* @brief Construct a new Any object with date time value.
|
||||||
|
*
|
||||||
|
* @param v The DateTime object
|
||||||
|
*/
|
||||||
|
LIAPI Any(const DateTime& v);
|
||||||
|
/**
|
||||||
|
* @brief Construct a new Any object with int8(char) value.
|
||||||
|
*
|
||||||
|
* @param v The char value
|
||||||
|
*/
|
||||||
|
LIAPI Any(char v);
|
||||||
|
/**
|
||||||
|
* @brief Construct a new Any object with uint8(unsigned char) value.
|
||||||
|
*
|
||||||
|
* @param v The unsigned char value
|
||||||
|
*/
|
||||||
|
LIAPI Any(unsigned char v);
|
||||||
|
/**
|
||||||
|
* @brief Construct a new Any object with int16(short) value.
|
||||||
|
*
|
||||||
|
* @param v The short value
|
||||||
|
*/
|
||||||
|
LIAPI Any(short v);
|
||||||
|
/**
|
||||||
|
* @brief Construct a new Any object with uint16(unsigned short) value.
|
||||||
|
*
|
||||||
|
* @param v The unsigned short value
|
||||||
|
*/
|
||||||
|
LIAPI Any(unsigned short v);
|
||||||
|
/**
|
||||||
|
* @brief Construct a new Any object with int32(int) value.
|
||||||
|
*
|
||||||
|
* @param v The int value
|
||||||
|
*/
|
||||||
|
LIAPI Any(int v);
|
||||||
|
/**
|
||||||
|
* @brief Construct a new Any object with uint32(unsigned int) value.
|
||||||
|
*
|
||||||
|
* @param v The unsigned int value
|
||||||
|
*/
|
||||||
|
LIAPI Any(unsigned int v);
|
||||||
|
/**
|
||||||
|
* @brief Construct a new Any object with long value.
|
||||||
|
*
|
||||||
|
* @param v The long value
|
||||||
|
*/
|
||||||
|
LIAPI Any(long v);
|
||||||
|
/**
|
||||||
|
* @brief Construct a new Any object with unsigned long value.
|
||||||
|
*
|
||||||
|
* @param v The unsigned long value
|
||||||
|
*/
|
||||||
|
LIAPI Any(unsigned long v);
|
||||||
|
/**
|
||||||
|
* @brief Construct a new Any object with float value.
|
||||||
|
*
|
||||||
|
* @param v The float value
|
||||||
|
*/
|
||||||
|
LIAPI Any(float v);
|
||||||
|
/**
|
||||||
|
* @brief Construct a new Any object with byte array value.
|
||||||
|
*
|
||||||
|
* @param v The byte array value
|
||||||
|
*/
|
||||||
|
LIAPI Any(const ByteArray& v);
|
||||||
|
/// Copy constructor
|
||||||
|
LIAPI Any(const Any& v);
|
||||||
|
/// Copy assignment operator
|
||||||
|
LIAPI Any& operator=(const Any& v);
|
||||||
|
|
||||||
|
/// Destructor
|
||||||
|
LIAPI ~Any();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get if the value is null.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
LIAPI bool is_null() const;
|
||||||
|
/**
|
||||||
|
* @brief Get if the value is boolean.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
LIAPI bool is_boolean() const;
|
||||||
|
/**
|
||||||
|
* @brief Get if the value is (unsigned) integer.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
LIAPI bool is_integer() const;
|
||||||
|
/**
|
||||||
|
* @brief Get if the value is unsigned integer.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
LIAPI bool is_uinteger() const;
|
||||||
|
/**
|
||||||
|
* @brief Get if the value is floating.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
LIAPI bool is_floating() const;
|
||||||
|
/**
|
||||||
|
* @brief Get if the value is string.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
LIAPI bool is_string() const;
|
||||||
|
/**
|
||||||
|
* @brief Get if the value is date.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
LIAPI bool is_date() const;
|
||||||
|
/**
|
||||||
|
* @brief Get if the value is time.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
LIAPI bool is_time() const;
|
||||||
|
/**
|
||||||
|
* @brief Get if the value is date time.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
LIAPI bool is_datetime() const;
|
||||||
|
/**
|
||||||
|
* @brief Get if the value is blob.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
LIAPI bool is_blob() const;
|
||||||
|
/**
|
||||||
|
* @brief Get if the value is floating or (unsigned) integer.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
LIAPI bool is_number() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the number value as T
|
||||||
|
*
|
||||||
|
* @tparam T The C++ basic number type to convert to, such as int, long, double, etc.
|
||||||
|
* @return T The value
|
||||||
|
* @throws std::bad_cast If the value cannot be converted to T or the value is not a number
|
||||||
|
* @note You can use Any::is_number() to check if the value is a number before calling this function.
|
||||||
|
* @see is_number()
|
||||||
|
*/
|
||||||
|
template <typename T>
|
||||||
|
inline T get_number() const
|
||||||
|
{
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
#if !defined(DBANY_NO_NULL_CONVERSION)
|
||||||
|
case Type::Null:
|
||||||
|
return 0;
|
||||||
|
#endif
|
||||||
|
case Type::Boolean:
|
||||||
|
return static_cast<T>(value.boolean);
|
||||||
|
case Type::Integer:
|
||||||
|
case Type::UInteger:
|
||||||
|
return static_cast<T>(value.integer);
|
||||||
|
case Type::Floating:
|
||||||
|
return static_cast<T>(value.floating);
|
||||||
|
case Type::String:
|
||||||
|
case Type::Date:
|
||||||
|
case Type::Time:
|
||||||
|
case Type::DateTime:
|
||||||
|
case Type::Blob:
|
||||||
|
default:
|
||||||
|
throw std::bad_cast();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the value as T.
|
||||||
|
*
|
||||||
|
* @tparam T The type of the value
|
||||||
|
* @return T The value
|
||||||
|
* @throws std::bad_cast If the value cannot be converted to T
|
||||||
|
* @par Custom Type Conversion
|
||||||
|
* Define a custom type conversion function for the type T
|
||||||
|
* @code
|
||||||
|
* template <>
|
||||||
|
* MyClass any_to(const Any& v) {
|
||||||
|
* MyClass result;
|
||||||
|
* switch (v.type) {
|
||||||
|
* case Any::Type::String:
|
||||||
|
* result.a = *v.value.string;
|
||||||
|
* default:
|
||||||
|
* throw std::bad_cast();
|
||||||
|
* }
|
||||||
|
* return result;
|
||||||
|
* }
|
||||||
|
* @endcode
|
||||||
|
* @note You can use `#define DBANY_NO_NULL_CONVERSION` to disable null conversion.
|
||||||
|
* (throw an exception when trying converting from a null type value)
|
||||||
|
* @see any_to
|
||||||
|
*/
|
||||||
|
template <typename T>
|
||||||
|
inline T get() const
|
||||||
|
{
|
||||||
|
return any_to<T>(*this);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @brief Get the value as string
|
||||||
|
*
|
||||||
|
* @tparam T = bool
|
||||||
|
* @return bool The value
|
||||||
|
* @throws std::bad_cast If the value cannot be converted to string
|
||||||
|
*/
|
||||||
|
template <>
|
||||||
|
inline bool get() const
|
||||||
|
{
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
#if !defined(DBANY_NO_NULL_CONVERSION)
|
||||||
|
case Type::Null:
|
||||||
|
return false;
|
||||||
|
#endif
|
||||||
|
case Type::Boolean:
|
||||||
|
return value.boolean;
|
||||||
|
case Type::Integer:
|
||||||
|
case Type::UInteger:
|
||||||
|
case Type::Floating:
|
||||||
|
return (bool)value.integer;
|
||||||
|
case Type::String:
|
||||||
|
case Type::Date:
|
||||||
|
case Type::Time:
|
||||||
|
case Type::DateTime:
|
||||||
|
case Type::Blob:
|
||||||
|
default:
|
||||||
|
throw std::bad_cast();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @brief Get the value as char
|
||||||
|
*
|
||||||
|
* @tparam T = char
|
||||||
|
* @return char The value
|
||||||
|
* @throws std::bad_cast If the value cannot be converted to char
|
||||||
|
*/
|
||||||
|
template <>
|
||||||
|
inline char get() const
|
||||||
|
{
|
||||||
|
return get_number<char>();
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @brief Get the value as unsigned char
|
||||||
|
*
|
||||||
|
* @tparam T = unsigned char
|
||||||
|
* @return unsigned char The value
|
||||||
|
* @throws std::bad_cast If the value cannot be converted to unsigned char
|
||||||
|
*/
|
||||||
|
template <>
|
||||||
|
inline unsigned char get() const
|
||||||
|
{
|
||||||
|
return get_number<unsigned char>();
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @brief Get the value as short
|
||||||
|
*
|
||||||
|
* @tparam T = short
|
||||||
|
* @return short The value
|
||||||
|
* @throws std::bad_cast If the value cannot be converted to short
|
||||||
|
*/
|
||||||
|
template <>
|
||||||
|
inline short get() const
|
||||||
|
{
|
||||||
|
return get_number<short>();
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @brief Get the value as unsigned short
|
||||||
|
*
|
||||||
|
* @tparam T = unsigned short
|
||||||
|
* @return unsigned short The value
|
||||||
|
* @throws std::bad_cast If the value cannot be converted to unsigned short
|
||||||
|
*/
|
||||||
|
template <>
|
||||||
|
inline unsigned short get() const
|
||||||
|
{
|
||||||
|
return get_number<unsigned short>();
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @brief Get the value as int
|
||||||
|
*
|
||||||
|
* @tparam T = int
|
||||||
|
* @return int The value
|
||||||
|
* @throws std::bad_cast If the value cannot be converted to int
|
||||||
|
*/
|
||||||
|
template <>
|
||||||
|
inline int get() const
|
||||||
|
{
|
||||||
|
return get_number<int>();
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @brief Get the value as unsigned int
|
||||||
|
*
|
||||||
|
* @tparam T = unsigned int
|
||||||
|
* @return unsigned int The value
|
||||||
|
* @throws std::bad_cast If the value cannot be converted to unsigned int
|
||||||
|
*/
|
||||||
|
template <>
|
||||||
|
inline unsigned int get() const
|
||||||
|
{
|
||||||
|
return get_number<unsigned int>();
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @brief Get the value as long
|
||||||
|
*
|
||||||
|
* @tparam T = long
|
||||||
|
* @return long The value
|
||||||
|
* @throws std::bad_cast If the value cannot be converted to long
|
||||||
|
*/
|
||||||
|
template <>
|
||||||
|
inline long get() const
|
||||||
|
{
|
||||||
|
return get_number<long>();
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @brief Get the value as unsigned long
|
||||||
|
*
|
||||||
|
* @tparam T = unsigned long
|
||||||
|
* @return unsigned long The value
|
||||||
|
* @throws std::bad_cast If the value cannot be converted to unsigned long
|
||||||
|
*/
|
||||||
|
template <>
|
||||||
|
inline unsigned long get() const
|
||||||
|
{
|
||||||
|
return get_number<unsigned long>();
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @brief Get the value as long long
|
||||||
|
*
|
||||||
|
* @tparam T = long long
|
||||||
|
* @return long long The value
|
||||||
|
* @throws std::bad_cast If the value cannot be converted to long long
|
||||||
|
*/
|
||||||
|
template <>
|
||||||
|
inline long long get() const
|
||||||
|
{
|
||||||
|
return get_number<long long>();
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @brief Get the value as unsigned long long
|
||||||
|
*
|
||||||
|
* @tparam T = unsigned long long
|
||||||
|
* @return unsigned long long The value
|
||||||
|
* @throws std::bad_cast If the value cannot be converted to unsigned long long
|
||||||
|
*/
|
||||||
|
template <>
|
||||||
|
inline unsigned long long get() const
|
||||||
|
{
|
||||||
|
return get_number<unsigned long long>();
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @brief Get the value as double.
|
||||||
|
*
|
||||||
|
* @tparam T = double
|
||||||
|
* @return double The value
|
||||||
|
* @throws std::bad_cast If the value cannot be converted to double
|
||||||
|
*/
|
||||||
|
template <>
|
||||||
|
inline double get() const
|
||||||
|
{
|
||||||
|
return get_number<double>();
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @brief Get the value as float.
|
||||||
|
*
|
||||||
|
* @tparam T = float
|
||||||
|
* @return float The value
|
||||||
|
* @throws std::bad_cast If the value cannot be converted to float
|
||||||
|
*/
|
||||||
|
template <>
|
||||||
|
inline float get() const
|
||||||
|
{
|
||||||
|
return get_number<float>();
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @brief Get the value as string.
|
||||||
|
*
|
||||||
|
* @tparam T = std::string
|
||||||
|
* @return std::string The value
|
||||||
|
* @throws std::bad_cast If the value cannot be converted to string
|
||||||
|
*/
|
||||||
|
template <>
|
||||||
|
std::string get() const
|
||||||
|
{
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
#if !defined(DBANY_NO_NULL_CONVERSION)
|
||||||
|
case Type::Null:
|
||||||
|
return "";
|
||||||
|
#endif
|
||||||
|
case Type::Boolean:
|
||||||
|
return value.boolean ? "true" : "false";
|
||||||
|
case Type::Integer:
|
||||||
|
return std::to_string(value.integer);
|
||||||
|
case Type::UInteger:
|
||||||
|
return std::to_string(value.uinteger);
|
||||||
|
case Type::Floating:
|
||||||
|
return std::to_string(value.floating);
|
||||||
|
case Type::String:
|
||||||
|
return *value.string;
|
||||||
|
case Type::Date:
|
||||||
|
return std::to_string(value.date->year) + "-" +
|
||||||
|
std::to_string(value.date->month) + "-" +
|
||||||
|
std::to_string(value.date->day);
|
||||||
|
break;
|
||||||
|
case Type::Time:
|
||||||
|
return std::to_string(value.time->hour) + ":" +
|
||||||
|
std::to_string(value.time->minute) + ":" +
|
||||||
|
std::to_string(value.time->second);
|
||||||
|
case Type::DateTime:
|
||||||
|
return std::to_string(value.datetime->date.year) + "-" +
|
||||||
|
std::to_string(value.datetime->date.month) + "-" +
|
||||||
|
std::to_string(value.datetime->date.day) + " " +
|
||||||
|
std::to_string(value.datetime->time.hour) + ":" +
|
||||||
|
std::to_string(value.datetime->time.minute) + ":" +
|
||||||
|
std::to_string(value.datetime->time.second);
|
||||||
|
case Type::Blob:
|
||||||
|
return std::string(value.blob->begin(), value.blob->end());
|
||||||
|
default:
|
||||||
|
throw std::bad_cast();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @brief Get the value as Date
|
||||||
|
*
|
||||||
|
* @tparam T = DB::Date
|
||||||
|
* @return DB::Date The value
|
||||||
|
* @throws std::bad_cast If the value cannot be converted to DB::Date
|
||||||
|
*/
|
||||||
|
template <>
|
||||||
|
Date get() const
|
||||||
|
{
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case Type::Date:
|
||||||
|
return *value.date;
|
||||||
|
case Type::DateTime:
|
||||||
|
return value.datetime->date;
|
||||||
|
case Type::String:
|
||||||
|
case Type::Integer:
|
||||||
|
case Type::UInteger:
|
||||||
|
case Type::Floating:
|
||||||
|
case Type::Time:
|
||||||
|
case Type::Blob:
|
||||||
|
default:
|
||||||
|
throw std::bad_cast();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @brief Get the value as Time
|
||||||
|
*
|
||||||
|
* @tparam T = DB::Time
|
||||||
|
* @return DB::Time The value
|
||||||
|
* @throws std::bad_cast If the value cannot be converted to DB::Time
|
||||||
|
*/
|
||||||
|
template <>
|
||||||
|
Time get() const
|
||||||
|
{
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case Type::Time:
|
||||||
|
return *value.time;
|
||||||
|
case Type::DateTime:
|
||||||
|
return value.datetime->time;
|
||||||
|
case Type::String:
|
||||||
|
case Type::Integer:
|
||||||
|
case Type::UInteger:
|
||||||
|
case Type::Floating:
|
||||||
|
case Type::Date:
|
||||||
|
case Type::Blob:
|
||||||
|
default:
|
||||||
|
throw std::bad_cast();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @brief Get the value as DateTime
|
||||||
|
*
|
||||||
|
* @tparam T = DB::DateTime
|
||||||
|
* @return DB::DateTime The value
|
||||||
|
* @throws std::bad_cast If the value cannot be converted to DB::DateTime
|
||||||
|
*/
|
||||||
|
template <>
|
||||||
|
DateTime get() const
|
||||||
|
{
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case Type::DateTime:
|
||||||
|
return *value.datetime;
|
||||||
|
case Type::String:
|
||||||
|
case Type::Integer:
|
||||||
|
case Type::UInteger:
|
||||||
|
case Type::Floating:
|
||||||
|
case Type::Date:
|
||||||
|
case Type::Time:
|
||||||
|
case Type::Blob:
|
||||||
|
default:
|
||||||
|
throw std::bad_cast();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @brief Get the value as ByteArray
|
||||||
|
*
|
||||||
|
* @tparam T = DB::ByteArray
|
||||||
|
* @return DB::ByteArray The value
|
||||||
|
* @throws std::bad_cast If the value cannot be converted to DB::ByteArray
|
||||||
|
*/
|
||||||
|
template <>
|
||||||
|
ByteArray get() const
|
||||||
|
{
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case Type::Blob:
|
||||||
|
return *value.blob;
|
||||||
|
case Type::String:
|
||||||
|
return ByteArray((unsigned char*)value.string->data(),
|
||||||
|
(unsigned char*)value.string->data() + value.string->size());
|
||||||
|
case Type::Integer:
|
||||||
|
case Type::UInteger:
|
||||||
|
case Type::Floating:
|
||||||
|
case Type::Date:
|
||||||
|
case Type::Time:
|
||||||
|
case Type::DateTime:
|
||||||
|
default:
|
||||||
|
throw std::bad_cast();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Convert Any::Type to string.
|
||||||
|
*
|
||||||
|
* @param type The Any::Type value
|
||||||
|
* @return std::string The string value
|
||||||
|
*/
|
||||||
|
LIAPI static std::string type2str(Any::Type type);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Convert string to Any.
|
||||||
|
*
|
||||||
|
* @param str The string
|
||||||
|
* @return Any The converted value
|
||||||
|
*/
|
||||||
|
LIAPI static Any str2any(const std::string& str);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace DB
|
140
LiteLoader/Header/DB/ConnParams.h
Normal file
140
LiteLoader/Header/DB/ConnParams.h
Normal file
@ -0,0 +1,140 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "Any.h"
|
||||||
|
#include <unordered_map>
|
||||||
|
|
||||||
|
namespace DB
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Connection parameters
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
class ConnParams : public std::unordered_map<std::string, Any>
|
||||||
|
{
|
||||||
|
|
||||||
|
std::string raw;
|
||||||
|
|
||||||
|
public:
|
||||||
|
ConnParams() = default;
|
||||||
|
/**
|
||||||
|
* @brief Construct a new ConnParams object
|
||||||
|
*
|
||||||
|
* @param list An initializer list like `{"host", "localhost", "port", 3306}`
|
||||||
|
* @throw std::invalid_argument If the type of key is not supported
|
||||||
|
*/
|
||||||
|
LIAPI ConnParams(const std::initializer_list<Any>& list);
|
||||||
|
/**
|
||||||
|
* @brief Construct a new ConnParams object
|
||||||
|
*
|
||||||
|
* @param list An initializer list like `{{"key1", "value1"}, {"key2", "value2"}}`
|
||||||
|
*/
|
||||||
|
LIAPI ConnParams(const std::initializer_list<std::pair<std::string, Any>>& list);
|
||||||
|
/**
|
||||||
|
* @brief Construct a new ConnParams object
|
||||||
|
*
|
||||||
|
* @param str Connection string like `mysql://localhost:3306?key1=value1&key2=value2`
|
||||||
|
*/
|
||||||
|
LIAPI ConnParams(const std::string& str);
|
||||||
|
/**
|
||||||
|
* @brief Construct a new ConnParams object
|
||||||
|
*
|
||||||
|
* @param str Connection string like `mysql://localhost:3306?key1=value1&key2=value2`
|
||||||
|
*/
|
||||||
|
LIAPI ConnParams(const char* str);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the scheme.
|
||||||
|
*
|
||||||
|
* @return std::string The scheme
|
||||||
|
*/
|
||||||
|
LIAPI std::string getScheme();
|
||||||
|
/**
|
||||||
|
* @brief Get the host.
|
||||||
|
*
|
||||||
|
* @return std::string The host name
|
||||||
|
*/
|
||||||
|
LIAPI std::string getHost();
|
||||||
|
/**
|
||||||
|
* @brief Get the port.
|
||||||
|
*
|
||||||
|
* @return uint16_t The port number
|
||||||
|
*/
|
||||||
|
LIAPI uint16_t getPort();
|
||||||
|
/**
|
||||||
|
* @brief Get the username.
|
||||||
|
*
|
||||||
|
* @return std::string The username
|
||||||
|
*/
|
||||||
|
LIAPI std::string getUsername();
|
||||||
|
/**
|
||||||
|
* @brief Get the password.
|
||||||
|
*
|
||||||
|
* @return std::string The password
|
||||||
|
*/
|
||||||
|
LIAPI std::string getPassword();
|
||||||
|
/**
|
||||||
|
* @brief Get the database.
|
||||||
|
*
|
||||||
|
* @return std::string The database name
|
||||||
|
*/
|
||||||
|
LIAPI std::string getDatabase();
|
||||||
|
/**
|
||||||
|
* @brief Get the path.
|
||||||
|
*
|
||||||
|
* @return std::string The path
|
||||||
|
*/
|
||||||
|
LIAPI std::string getPath();
|
||||||
|
/**
|
||||||
|
* @brief Get the raw connection string.
|
||||||
|
*
|
||||||
|
* @return std::string The connection string
|
||||||
|
* @note If this object is constructed by `ConnParams(const std::string& str)`
|
||||||
|
* or `ConnParams(const char* str)`,
|
||||||
|
* the return value is the same as the parameter `str`.
|
||||||
|
* Otherwise, the return value will be empty.
|
||||||
|
*/
|
||||||
|
LIAPI std::string getRaw();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the value of one of the keys.
|
||||||
|
*
|
||||||
|
* @tparam T The type of the value
|
||||||
|
* @param keys The keys (If ignoreCase is true, keys must be lowercase)
|
||||||
|
* @param ignoreCase Whether to ignore the case of the key
|
||||||
|
* @param defaultValue The default value
|
||||||
|
* @return T The value
|
||||||
|
* @note If there are multiple keys matched,
|
||||||
|
* the first one(keys[0]) will be returned.
|
||||||
|
*/
|
||||||
|
template <typename T>
|
||||||
|
inline T get(const std::vector<std::string>& keys, bool ignoreCase = true, T defaultValue = T())
|
||||||
|
{
|
||||||
|
Any value;
|
||||||
|
int w = INT_MAX;
|
||||||
|
for (auto& [k, v] : *this)
|
||||||
|
{
|
||||||
|
std::string lowerKey = k;
|
||||||
|
if (ignoreCase)
|
||||||
|
{
|
||||||
|
std::transform(lowerKey.begin(), lowerKey.end(), lowerKey.begin(), ::tolower);
|
||||||
|
}
|
||||||
|
int i = 0;
|
||||||
|
for (auto& key : keys)
|
||||||
|
{
|
||||||
|
if (lowerKey == key && i < w)
|
||||||
|
{
|
||||||
|
value = v;
|
||||||
|
w = i;
|
||||||
|
if (w == 0) break;
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
if (w == 0) break;
|
||||||
|
}
|
||||||
|
if (value.is_null())
|
||||||
|
return defaultValue;
|
||||||
|
return value.get<T>();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace DB
|
40
LiteLoader/Header/DB/Impl/MySQL/Session.h
Normal file
40
LiteLoader/Header/DB/Impl/MySQL/Session.h
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "../../Session.h"
|
||||||
|
|
||||||
|
struct MYSQL;
|
||||||
|
|
||||||
|
namespace DB
|
||||||
|
{
|
||||||
|
|
||||||
|
class MySQLStmt;
|
||||||
|
|
||||||
|
class MySQLSession : public Session
|
||||||
|
{
|
||||||
|
|
||||||
|
MYSQL* conn = nullptr;
|
||||||
|
|
||||||
|
void setSSL(const ConnParams& params);
|
||||||
|
|
||||||
|
public:
|
||||||
|
MySQLSession();
|
||||||
|
MySQLSession(const ConnParams& params);
|
||||||
|
~MySQLSession();
|
||||||
|
void open(const ConnParams& params);
|
||||||
|
bool execute(const std::string& query);
|
||||||
|
bool relogin(const std::string& user, const std::string& password, const std::string& db = "");
|
||||||
|
Session& query(const std::string& query, std::function<bool(const Row&)> callback);
|
||||||
|
SharedPointer<Stmt> prepare(const std::string& query, bool autoExecute = false);
|
||||||
|
std::string getLastError() const;
|
||||||
|
uint64_t getAffectedRows() const;
|
||||||
|
uint64_t getLastInsertId() const;
|
||||||
|
void close();
|
||||||
|
bool isOpen();
|
||||||
|
DBType getType();
|
||||||
|
|
||||||
|
SharedPointer<Stmt> operator<<(const std::string& query);
|
||||||
|
|
||||||
|
friend class MySQLStmt;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace DB
|
71
LiteLoader/Header/DB/Impl/MySQL/Stmt.h
Normal file
71
LiteLoader/Header/DB/Impl/MySQL/Stmt.h
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "../../Stmt.h"
|
||||||
|
|
||||||
|
struct MYSQL_STMT;
|
||||||
|
|
||||||
|
namespace DB
|
||||||
|
{
|
||||||
|
|
||||||
|
class MySQLSession;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Fetched data receiver(buffer)
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
struct Receiver
|
||||||
|
{
|
||||||
|
MYSQL_FIELD field;
|
||||||
|
std::shared_ptr<char[]> buffer;
|
||||||
|
unsigned long length = 0;
|
||||||
|
bool isNull = false;
|
||||||
|
bool isUnsigned = false;
|
||||||
|
bool error = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
class MySQLStmt : public Stmt
|
||||||
|
{
|
||||||
|
|
||||||
|
MYSQL_STMT* stmt = nullptr;
|
||||||
|
MYSQL_RES* metadata = nullptr;
|
||||||
|
std::shared_ptr<MYSQL_BIND[]> params = nullptr; ///< Parameters to bind
|
||||||
|
std::shared_ptr<MYSQL_BIND[]> result = nullptr; ///< Result of query
|
||||||
|
std::shared_ptr<RowHeader> resultHeader = nullptr;
|
||||||
|
std::vector<int> boundIndexes;
|
||||||
|
std::vector<Receiver> paramValues;
|
||||||
|
std::vector<Receiver> resultValues;
|
||||||
|
std::unordered_map<std::string, int> paramIndexes;
|
||||||
|
std::string query;
|
||||||
|
int boundParamsCount = 0;
|
||||||
|
int totalParamsCount = 0;
|
||||||
|
int steps = 0;
|
||||||
|
bool fetched = false;
|
||||||
|
|
||||||
|
MySQLStmt(MYSQL_STMT* stmt, const std::weak_ptr<Session>& parent, bool autoExecute = false);
|
||||||
|
int getNextParamIndex();
|
||||||
|
void bindResult();
|
||||||
|
|
||||||
|
public:
|
||||||
|
~MySQLStmt();
|
||||||
|
Stmt& bind(const Any& value, int index);
|
||||||
|
Stmt& bind(const Any& value, const std::string& name);
|
||||||
|
Stmt& bind(const Any& value);
|
||||||
|
Stmt& execute();
|
||||||
|
bool step();
|
||||||
|
bool next();
|
||||||
|
bool done();
|
||||||
|
Row _Fetch();
|
||||||
|
Stmt& reset();
|
||||||
|
Stmt& reexec();
|
||||||
|
Stmt& clear();
|
||||||
|
void close();
|
||||||
|
uint64_t getAffectedRows() const;
|
||||||
|
uint64_t getInsertId() const;
|
||||||
|
int getUnboundParams() const;
|
||||||
|
int getBoundParams() const;
|
||||||
|
int getParamsCount() const;
|
||||||
|
DBType getType() const;
|
||||||
|
|
||||||
|
LIAPI static SharedPointer<Stmt> create(const std::weak_ptr<Session>& sess, const std::string& sql, bool autoExecute = false);
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace DB
|
34
LiteLoader/Header/DB/Impl/SQLite/Session.h
Normal file
34
LiteLoader/Header/DB/Impl/SQLite/Session.h
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "../../Session.h"
|
||||||
|
|
||||||
|
struct sqlite3;
|
||||||
|
namespace DB
|
||||||
|
{
|
||||||
|
|
||||||
|
class SQLiteSession : public Session
|
||||||
|
{
|
||||||
|
|
||||||
|
sqlite3* conn = nullptr;
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
SQLiteSession();
|
||||||
|
SQLiteSession(const ConnParams& params);
|
||||||
|
~SQLiteSession();
|
||||||
|
void open(const ConnParams& params);
|
||||||
|
bool execute(const std::string& query);
|
||||||
|
Session& query(const std::string& query, std::function<bool(const Row&)> callback);
|
||||||
|
SharedPointer<Stmt> prepare(const std::string& query, bool autoExecute = false);
|
||||||
|
std::string getLastError() const;
|
||||||
|
uint64_t getAffectedRows() const;
|
||||||
|
uint64_t getLastInsertId() const;
|
||||||
|
void close();
|
||||||
|
bool isOpen();
|
||||||
|
DBType getType();
|
||||||
|
|
||||||
|
SharedPointer<Stmt> operator<<(const std::string& query);
|
||||||
|
|
||||||
|
friend class SQLiteStmt;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace DB
|
57
LiteLoader/Header/DB/Impl/SQLite/Stmt.h
Normal file
57
LiteLoader/Header/DB/Impl/SQLite/Stmt.h
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "../../Stmt.h"
|
||||||
|
|
||||||
|
struct sqlite3_stmt;
|
||||||
|
|
||||||
|
namespace DB
|
||||||
|
{
|
||||||
|
|
||||||
|
class SQLiteSession;
|
||||||
|
|
||||||
|
class SQLiteStmt : public Stmt
|
||||||
|
{
|
||||||
|
|
||||||
|
std::shared_ptr<RowHeader> resultHeader;
|
||||||
|
sqlite3_stmt* stmt = nullptr;
|
||||||
|
int boundParamsCount = 0;
|
||||||
|
int totalParamsCount = 0;
|
||||||
|
int steps = 0;
|
||||||
|
uint64_t affectedRowCount = -1;
|
||||||
|
uint64_t insertRowId = -1;
|
||||||
|
bool stepped = false;
|
||||||
|
bool executed = false;
|
||||||
|
std::vector<int> boundIndexes;
|
||||||
|
|
||||||
|
SQLiteStmt(sqlite3_stmt* stmt, const std::weak_ptr<Session> parent, bool autoExecute);
|
||||||
|
int getNextParamIndex();
|
||||||
|
void fetchResultHeader();
|
||||||
|
|
||||||
|
public:
|
||||||
|
~SQLiteStmt();
|
||||||
|
Stmt& bind(const Any& value, int index);
|
||||||
|
Stmt& bind(const Any& value, const std::string& name);
|
||||||
|
Stmt& bind(const Any& value);
|
||||||
|
Stmt& execute();
|
||||||
|
bool step();
|
||||||
|
bool next();
|
||||||
|
bool done();
|
||||||
|
Row _Fetch();
|
||||||
|
Stmt& reset();
|
||||||
|
/**
|
||||||
|
* @see Stmt::reexec for details
|
||||||
|
* @see https://www.sqlite.org/c3ref/reexec.html
|
||||||
|
*/
|
||||||
|
Stmt& reexec();
|
||||||
|
Stmt& clear();
|
||||||
|
void close();
|
||||||
|
uint64_t getAffectedRows() const;
|
||||||
|
uint64_t getInsertId() const;
|
||||||
|
int getUnboundParams() const;
|
||||||
|
int getBoundParams() const;
|
||||||
|
int getParamsCount() const;
|
||||||
|
DBType getType() const;
|
||||||
|
|
||||||
|
LIAPI static SharedPointer<Stmt> create(const std::weak_ptr<Session>& sess, const std::string& sql, bool autoExecute = false);
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace DB
|
68
LiteLoader/Header/DB/Pointer.h
Normal file
68
LiteLoader/Header/DB/Pointer.h
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
namespace DB
|
||||||
|
{
|
||||||
|
|
||||||
|
class Stmt;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief A smart pointer class extended from std::shared_ptr
|
||||||
|
*
|
||||||
|
* @tparam T Type of the pointer
|
||||||
|
* @warning This class is only for internal use(Session, Stmt and so on).
|
||||||
|
* So do not use this class directly, use std::shared_ptr instead.
|
||||||
|
*/
|
||||||
|
template <typename T>
|
||||||
|
class SharedPointer : public std::shared_ptr<T>
|
||||||
|
{
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
SharedPointer(T* ptr = nullptr) : std::shared_ptr<T>(ptr) {}
|
||||||
|
SharedPointer(const std::shared_ptr<T>& ptr) : std::shared_ptr<T>(ptr) {}
|
||||||
|
SharedPointer(std::shared_ptr<T>&& ptr) : std::shared_ptr<T>(ptr) {}
|
||||||
|
SharedPointer(const SharedPointer<T>& other) : std::shared_ptr<T>(other) {}
|
||||||
|
SharedPointer(SharedPointer<T>&& other) : std::shared_ptr<T>(other) {}
|
||||||
|
~SharedPointer()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
inline SharedPointer<T>& operator=(const SharedPointer<T>& other)
|
||||||
|
{
|
||||||
|
std::shared_ptr<T>::operator=(other);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
inline SharedPointer<T>& operator=(SharedPointer<T>&& other) noexcept
|
||||||
|
{
|
||||||
|
std::shared_ptr<T>::operator=(other);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename U>
|
||||||
|
inline SharedPointer<Stmt> operator<<(const U& v)
|
||||||
|
{
|
||||||
|
auto ptr = std::shared_ptr<T>::get();
|
||||||
|
if (!ptr) throw std::runtime_error("The pointer is nullptr");
|
||||||
|
//Logger("DBG").debug("operator<< {}", (void*)ptr);
|
||||||
|
return (*ptr) << v;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename U>
|
||||||
|
inline SharedPointer<Stmt> operator>>(U& v)
|
||||||
|
{
|
||||||
|
auto ptr = std::shared_ptr<T>::get();
|
||||||
|
if (!ptr) throw std::runtime_error("The pointer is nullptr");
|
||||||
|
return (*ptr) >> v;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename U>
|
||||||
|
inline SharedPointer<Stmt> operator,(U v)
|
||||||
|
{
|
||||||
|
auto ptr = std::shared_ptr<T>::get();
|
||||||
|
if (!ptr) throw std::runtime_error("The pointer is nullptr");
|
||||||
|
return ptr->operator,(v);
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace DB
|
269
LiteLoader/Header/DB/Row.h
Normal file
269
LiteLoader/Header/DB/Row.h
Normal file
@ -0,0 +1,269 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "Any.h"
|
||||||
|
#include <unordered_map>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
namespace DB
|
||||||
|
{
|
||||||
|
|
||||||
|
class Row;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief The header of a row
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
class RowHeader : private std::vector<std::string>
|
||||||
|
{
|
||||||
|
|
||||||
|
using Base = std::vector<std::string>;
|
||||||
|
std::vector<uint64_t> hashes;
|
||||||
|
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* @brief Construct a new Row Header object.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
RowHeader() = default;
|
||||||
|
/**
|
||||||
|
* @brief Construct a new Row Header object.
|
||||||
|
*
|
||||||
|
* @param list An initializer list like `{"col1", "col2", "col3"}`
|
||||||
|
*/
|
||||||
|
LIAPI RowHeader(const std::initializer_list<std::string>& list);
|
||||||
|
/// Move constructor
|
||||||
|
RowHeader(RowHeader&& other) noexcept = default;
|
||||||
|
/// Copy constructor
|
||||||
|
RowHeader(const RowHeader& other) = default;
|
||||||
|
/// Destructor
|
||||||
|
~RowHeader();
|
||||||
|
/**
|
||||||
|
* @brief Add a column to the header.
|
||||||
|
*
|
||||||
|
* @param name The name of the column
|
||||||
|
* @return int The index of the column
|
||||||
|
*/
|
||||||
|
LIAPI size_t add(const std::string& name);
|
||||||
|
/**
|
||||||
|
* @brief Get whether the header contains a column.
|
||||||
|
*
|
||||||
|
* @param name The name of the column
|
||||||
|
* @return bool True if the column exists
|
||||||
|
*/
|
||||||
|
LIAPI bool contains(const std::string& name);
|
||||||
|
/**
|
||||||
|
* @brief Remove a column from the header.
|
||||||
|
*
|
||||||
|
* @param name The name of the column
|
||||||
|
* @throws std::out_of_range If the column does not exist
|
||||||
|
*/
|
||||||
|
LIAPI void remove(const std::string& name);
|
||||||
|
/**
|
||||||
|
* @brief Get the size of the header.
|
||||||
|
*
|
||||||
|
* @return int The size of the header
|
||||||
|
*/
|
||||||
|
LIAPI size_t size() const;
|
||||||
|
/**
|
||||||
|
* @brief Get weather the header is empty.
|
||||||
|
*
|
||||||
|
* @return bool True if the header is empty
|
||||||
|
*/
|
||||||
|
LIAPI bool empty() const;
|
||||||
|
/**
|
||||||
|
* @brief Get the index of a column.
|
||||||
|
*
|
||||||
|
* @param name The name of the column
|
||||||
|
* @return int The index of the column
|
||||||
|
* @throws std::out_of_range If the column does not exist
|
||||||
|
*/
|
||||||
|
LIAPI size_t at(const std::string& name);
|
||||||
|
/**
|
||||||
|
* @brief Get the index of a column.
|
||||||
|
*
|
||||||
|
* @param index The index of the column
|
||||||
|
* @return std::string& The name of the column
|
||||||
|
* @throws std::out_of_range If the column does not exist
|
||||||
|
*/
|
||||||
|
LIAPI std::string& at(size_t index);
|
||||||
|
/**
|
||||||
|
* @brief Get the iterator to the first element
|
||||||
|
*
|
||||||
|
* @return std::unordered_map<std::string, int>::iterator The iterator
|
||||||
|
*/
|
||||||
|
LIAPI std::vector<std::string>::iterator begin();
|
||||||
|
/**
|
||||||
|
* @brief Get the iterator to the last element.
|
||||||
|
*
|
||||||
|
* @return std::unordered_map<std::string, int>::iterator The iterator
|
||||||
|
*/
|
||||||
|
LIAPI std::vector<std::string>::iterator end();
|
||||||
|
/**
|
||||||
|
* @brief Check whether the row can be adapted to the header.
|
||||||
|
*
|
||||||
|
* @param row The row to adapt
|
||||||
|
* @return bool True if the row can be adapted
|
||||||
|
*/
|
||||||
|
LIAPI bool check(const Row& row) const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the index of a column.
|
||||||
|
*
|
||||||
|
* @param name The name of the column
|
||||||
|
* @return int The index of the column
|
||||||
|
* @note It will create the column(=add) if it does not exist
|
||||||
|
*/
|
||||||
|
LIAPI size_t operator[](const std::string& name);
|
||||||
|
/**
|
||||||
|
* @brief Get the name of a column.
|
||||||
|
*
|
||||||
|
* @param index The index of the column
|
||||||
|
* @return std::string& The name of the column
|
||||||
|
*/
|
||||||
|
LIAPI std::string& operator[](size_t index);
|
||||||
|
|
||||||
|
/// Move assignment operator
|
||||||
|
RowHeader& operator=(RowHeader&& other) noexcept = default;
|
||||||
|
/// Copy assignment operator
|
||||||
|
RowHeader& operator=(const RowHeader& other) = default;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief A row of data
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
class Row : public std::vector<Any>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
std::shared_ptr<RowHeader> header; //!< The header of the row
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Construct a new Row object.
|
||||||
|
*
|
||||||
|
* @param header The header(column names) of the row(shared_ptr)
|
||||||
|
*/
|
||||||
|
LIAPI Row(const std::shared_ptr<RowHeader>& header = nullptr);
|
||||||
|
/**
|
||||||
|
* @brief Construct a new Row object.
|
||||||
|
*
|
||||||
|
* @param header The header(column names) of the row
|
||||||
|
* @note This will create a shared_ptr of the header
|
||||||
|
*/
|
||||||
|
LIAPI Row(const RowHeader& header);
|
||||||
|
/**
|
||||||
|
* @brief Construct a new Row object.
|
||||||
|
*
|
||||||
|
* @param list List of values
|
||||||
|
* @param header The header(column names) of the row
|
||||||
|
* @throw std::invalid_argument If the size of the list is not equal to the size of the header
|
||||||
|
* @par Example
|
||||||
|
* @code
|
||||||
|
* RowHeader header{"id", "age", "name"};
|
||||||
|
* Row row1({114, 24, "alex"}, header);
|
||||||
|
* Row row2({514, 24, "steve"}, {"id", "age", "name"});
|
||||||
|
* @endcode
|
||||||
|
*/
|
||||||
|
LIAPI Row(const std::initializer_list<Any>& list, const RowHeader& header);
|
||||||
|
/**
|
||||||
|
* @brief Construct a new Row object.
|
||||||
|
*
|
||||||
|
* @param list List of values
|
||||||
|
* @param header The header(column names) of the row(shared_ptr)
|
||||||
|
* @throw std::invalid_argument If the size of the list is not equal to the size of the header
|
||||||
|
*/
|
||||||
|
LIAPI Row(const std::initializer_list<Any>& list,
|
||||||
|
const std::shared_ptr<RowHeader>& header = nullptr);
|
||||||
|
/**
|
||||||
|
* @brief Construct a new Row object(move).
|
||||||
|
*
|
||||||
|
* @param list Vector of values
|
||||||
|
* @param header The header(column names) of the row
|
||||||
|
* @throw std::invalid_argument If the size of the vector is not equal to the size of the header
|
||||||
|
*/
|
||||||
|
LIAPI Row(std::vector<Any>&& list, const RowHeader& header);
|
||||||
|
/**
|
||||||
|
* @brief Construct a new Row object.
|
||||||
|
*
|
||||||
|
* @param list Vector of values
|
||||||
|
* @param header The header(column names) of the row
|
||||||
|
* @throw std::invalid_argument If the size of the vector is not equal to the size of the header
|
||||||
|
*/
|
||||||
|
LIAPI Row(const std::vector<Any>& list, const RowHeader& header);
|
||||||
|
/**
|
||||||
|
* @brief Construct a new Row object(move).
|
||||||
|
*
|
||||||
|
* @param list Vector of column names(header) and values
|
||||||
|
* @par Example
|
||||||
|
* @code
|
||||||
|
* Row row({{"id", 114}, {"age", 2000}, {"name", "alex"}});
|
||||||
|
* @endcode
|
||||||
|
*/
|
||||||
|
LIAPI Row(const std::initializer_list<std::pair<std::string, Any>>& list);
|
||||||
|
/// Move constructor
|
||||||
|
LIAPI Row(Row&& other) noexcept;
|
||||||
|
/// Copy constructor
|
||||||
|
LIAPI Row(const Row& other);
|
||||||
|
/// Move assignment operator
|
||||||
|
LIAPI Row& operator=(Row&& other) noexcept;
|
||||||
|
/// Copy assignment operator
|
||||||
|
LIAPI Row& operator=(const Row& other);
|
||||||
|
/**
|
||||||
|
* @brief Get the value of a column
|
||||||
|
*
|
||||||
|
* @param column The name of the column
|
||||||
|
* @return Any& The value of the column
|
||||||
|
* @note It will create a new Any object if the column doesn't exist
|
||||||
|
*/
|
||||||
|
LIAPI Any& operator[](const std::string& name);
|
||||||
|
/**
|
||||||
|
* @brief Get the value of a column
|
||||||
|
*
|
||||||
|
* @param column The name of the column
|
||||||
|
* @return Any& The value of the column
|
||||||
|
* @see Row::at
|
||||||
|
*/
|
||||||
|
LIAPI const Any& operator[](const std::string& name) const;
|
||||||
|
/**
|
||||||
|
* @brief Get the value of a column
|
||||||
|
*
|
||||||
|
* @param column The name of the column
|
||||||
|
* @return Any& The value of the column
|
||||||
|
* @throw std::out_of_range If the column does not exist
|
||||||
|
*/
|
||||||
|
LIAPI Any& at(const std::string& column);
|
||||||
|
LIAPI const Any& at(const std::string& column) const;
|
||||||
|
/**
|
||||||
|
* @brief Traverse the row(references)
|
||||||
|
*
|
||||||
|
* @param cb The function to call for each element
|
||||||
|
* @note Return false in callback function to stop the iteration
|
||||||
|
*/
|
||||||
|
LIAPI void forEach_ref(std::function<bool(const std::string&, Any&)> cb);
|
||||||
|
/**
|
||||||
|
* @brief Traverse the row
|
||||||
|
*
|
||||||
|
* @param cb The function to call for each element
|
||||||
|
* @note Return false in callback function to stop the iteration
|
||||||
|
*/
|
||||||
|
LIAPI void forEach(std::function<bool(const std::string&, const Any&)> cb) const;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace DB
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Function to convert a row to T.
|
||||||
|
*
|
||||||
|
* @tparam T The type to convert to
|
||||||
|
* @param row A row
|
||||||
|
* @return T The converted value
|
||||||
|
*/
|
||||||
|
template <typename T>
|
||||||
|
inline T row_to(const DB::Row& row)
|
||||||
|
{
|
||||||
|
throw std::bad_cast();
|
||||||
|
}
|
||||||
|
|
||||||
|
template <>
|
||||||
|
inline DB::Row row_to(const DB::Row& row)
|
||||||
|
{
|
||||||
|
return row;
|
||||||
|
}
|
78
LiteLoader/Header/DB/RowSet.h
Normal file
78
LiteLoader/Header/DB/RowSet.h
Normal file
@ -0,0 +1,78 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "Row.h"
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
#undef max
|
||||||
|
|
||||||
|
namespace DB
|
||||||
|
{
|
||||||
|
|
||||||
|
class RowSet : public std::vector<Row>
|
||||||
|
{
|
||||||
|
|
||||||
|
using Base = std::vector<Row>;
|
||||||
|
|
||||||
|
public:
|
||||||
|
std::shared_ptr<RowHeader> header; //!< The header of the rows
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Construct a new Row Set object
|
||||||
|
*
|
||||||
|
* @param header The header(column names) of rows(shared_ptr)
|
||||||
|
*/
|
||||||
|
LIAPI RowSet(const std::shared_ptr<RowHeader>& header = nullptr);
|
||||||
|
/**
|
||||||
|
* @brief Construct a new Row Set object
|
||||||
|
*
|
||||||
|
* @param header The header(column names) of rows
|
||||||
|
*/
|
||||||
|
LIAPI RowSet(const RowHeader& header);
|
||||||
|
/// Move constructor
|
||||||
|
LIAPI RowSet(RowSet&& set) noexcept;
|
||||||
|
/// Copy constructor
|
||||||
|
LIAPI RowSet(const RowSet& set);
|
||||||
|
/// Move assignment operator
|
||||||
|
LIAPI RowSet& operator=(RowSet&& set) noexcept;
|
||||||
|
/// Copy assignment operator
|
||||||
|
LIAPI RowSet& operator=(const RowSet& set);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Add a row to the set.
|
||||||
|
*
|
||||||
|
* @param row The row to add
|
||||||
|
*/
|
||||||
|
LIAPI void add(const Row& row);
|
||||||
|
/**
|
||||||
|
* @brief Get if the set is valid
|
||||||
|
*
|
||||||
|
* @return bool True if valid
|
||||||
|
*/
|
||||||
|
LIAPI bool valid();
|
||||||
|
/**
|
||||||
|
* @brief Add a row to the set.
|
||||||
|
*
|
||||||
|
* @param row The row to add
|
||||||
|
* @see add(const Row&)
|
||||||
|
*/
|
||||||
|
LIAPI void push_back(const Row& row);
|
||||||
|
/**
|
||||||
|
* @brief Convert to the table string.
|
||||||
|
*
|
||||||
|
* @param nullPattern When the value is null, what to replace with(default '<NULL>')
|
||||||
|
* @return std::string The result string
|
||||||
|
* @par sample
|
||||||
|
* @code
|
||||||
|
* | a | b |
|
||||||
|
* |=====|========|
|
||||||
|
* | awa | 114514 |
|
||||||
|
* | qwq | 233 |
|
||||||
|
* | ll | <NULL> |
|
||||||
|
* |=====|========|
|
||||||
|
* @endcode
|
||||||
|
*/
|
||||||
|
LIAPI std::string toTableString(const std::string& nullPattern = "<NULL>") const;
|
||||||
|
};
|
||||||
|
|
||||||
|
using ResultSet = RowSet;
|
||||||
|
|
||||||
|
} // namespace DB
|
231
LiteLoader/Header/DB/Session.h
Normal file
231
LiteLoader/Header/DB/Session.h
Normal file
@ -0,0 +1,231 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "RowSet.h"
|
||||||
|
#include "Stmt.h"
|
||||||
|
#include "ConnParams.h"
|
||||||
|
#include "Pointer.h"
|
||||||
|
|
||||||
|
class Logger;
|
||||||
|
|
||||||
|
namespace DB
|
||||||
|
{
|
||||||
|
|
||||||
|
extern Logger dbLogger;
|
||||||
|
|
||||||
|
class Session
|
||||||
|
{
|
||||||
|
|
||||||
|
protected:
|
||||||
|
#if defined(LLDB_DEBUG_MODE)
|
||||||
|
bool debugOutput = true;
|
||||||
|
#else
|
||||||
|
bool debugOutput = false;
|
||||||
|
#endif
|
||||||
|
std::weak_ptr<Session> self;
|
||||||
|
std::vector<std::weak_ptr<Stmt>> stmtPool; ///< List of statements opened by prepare method.
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
/// Destructor
|
||||||
|
virtual ~Session() = default;
|
||||||
|
/**
|
||||||
|
* @brief Open the database connection.
|
||||||
|
*
|
||||||
|
* @par Implementation
|
||||||
|
* @see SQLiteSession::open
|
||||||
|
*/
|
||||||
|
virtual void open(const ConnParams& params) = 0;
|
||||||
|
/**
|
||||||
|
* @brief Turn on/off debug output.
|
||||||
|
*
|
||||||
|
* @param enable Enable or not
|
||||||
|
*/
|
||||||
|
LIAPI void setDebugOutput(bool enable);
|
||||||
|
/**
|
||||||
|
* @brief Change current user and database.
|
||||||
|
*
|
||||||
|
* @param user Username
|
||||||
|
* @param pass Password
|
||||||
|
* @param db Database name
|
||||||
|
* @return bool Success or not
|
||||||
|
* @throws std::runtime_error If not implemented
|
||||||
|
* @par Implementation
|
||||||
|
* None
|
||||||
|
*/
|
||||||
|
virtual bool relogin(const std::string& user, const std::string& password, const std::string& db = "");
|
||||||
|
/**
|
||||||
|
* @brief Execute a query.
|
||||||
|
*
|
||||||
|
* @param query Query to execute
|
||||||
|
* @param callback Callback to process results
|
||||||
|
* @return *this
|
||||||
|
*
|
||||||
|
* @par Implementation
|
||||||
|
* @see SQLiteSession::query
|
||||||
|
*/
|
||||||
|
virtual Session& query(const std::string& query, std::function<bool(const Row&)> callback) = 0;
|
||||||
|
/**
|
||||||
|
* @brief Execute a query.
|
||||||
|
*
|
||||||
|
* @param query The query to execute
|
||||||
|
* @return ResultSet Result set
|
||||||
|
*/
|
||||||
|
virtual ResultSet query(const std::string& query);
|
||||||
|
/**
|
||||||
|
* @brief Execute a query without results.
|
||||||
|
*
|
||||||
|
* @param query The query to execute
|
||||||
|
* @return bool Success or not
|
||||||
|
*/
|
||||||
|
virtual bool execute(const std::string& query) = 0;
|
||||||
|
/**
|
||||||
|
* @brief Prepare a query.
|
||||||
|
*
|
||||||
|
* @param query The query to execute
|
||||||
|
* @param autoExecute Whether to execute the statement automatically after binding all parameters
|
||||||
|
* @return SharedPointer<Stmt> The statement
|
||||||
|
* @par Example
|
||||||
|
* @code
|
||||||
|
* auto& stmt = session.prepare("SELECT * FROM table WHERE id = ?");
|
||||||
|
* stmt.bind(1);
|
||||||
|
* auto res = stmt.getResults();
|
||||||
|
* stmt.close();
|
||||||
|
* @endcode
|
||||||
|
*/
|
||||||
|
virtual SharedPointer<Stmt> prepare(const std::string& query, bool autoExecute = false) = 0;
|
||||||
|
/**
|
||||||
|
* @brief Get the last error message
|
||||||
|
*
|
||||||
|
* @return std::string Error message
|
||||||
|
*/
|
||||||
|
virtual std::string getLastError() const;
|
||||||
|
/**
|
||||||
|
* @brief Get the number of affected rows by the last query.
|
||||||
|
*
|
||||||
|
* @return uint64_t The number of affected rows
|
||||||
|
*/
|
||||||
|
virtual uint64_t getAffectedRows() const = 0;
|
||||||
|
/**
|
||||||
|
* @brief Get the last insert id
|
||||||
|
*
|
||||||
|
* @return uint64_t The row id of the last inserted row
|
||||||
|
*/
|
||||||
|
virtual uint64_t getLastInsertId() const = 0;
|
||||||
|
/**
|
||||||
|
* @brief Close the session.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
virtual void close() = 0;
|
||||||
|
/**
|
||||||
|
* @brief Get whether the session is open.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
virtual bool isOpen() = 0;
|
||||||
|
/**
|
||||||
|
* @brief Get the type of session
|
||||||
|
*
|
||||||
|
* @return DBType The database type
|
||||||
|
*/
|
||||||
|
virtual DBType getType() = 0;
|
||||||
|
/**
|
||||||
|
* @brief Get or set the self pointer
|
||||||
|
*
|
||||||
|
* @return std::weak_ptr<Session> self
|
||||||
|
*/
|
||||||
|
virtual std::weak_ptr<Session> getOrSetSelf();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Operator<< to execute a query.
|
||||||
|
*
|
||||||
|
* @param query The query to execute
|
||||||
|
* @return SharedPointer<Stmt> The prepared statement
|
||||||
|
* @par Example
|
||||||
|
* @code
|
||||||
|
* ResultSet res;
|
||||||
|
* session << "SELECT * FROM table WHERE id = ?", bind(114514), into(res);
|
||||||
|
* @endcode
|
||||||
|
* @note It is not recommended to store the DB::Stmt reference returned by this method,
|
||||||
|
* it will be closed on the next execution.
|
||||||
|
*/
|
||||||
|
virtual SharedPointer<Stmt> operator<<(const std::string& query);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Create a new session.
|
||||||
|
*
|
||||||
|
* @param type Database type
|
||||||
|
* @return SharedPointer<Session> The session
|
||||||
|
*/
|
||||||
|
LIAPI static SharedPointer<Session> create(DBType type);
|
||||||
|
/**
|
||||||
|
* @brief Create and open a new session.
|
||||||
|
*
|
||||||
|
* @param params Connection parameters
|
||||||
|
* @return SharedPointer<Session> The session
|
||||||
|
*/
|
||||||
|
LIAPI static SharedPointer<Session> create(const ConnParams& params);
|
||||||
|
/**
|
||||||
|
* @brief Create and open a new session.
|
||||||
|
*
|
||||||
|
* @param type Database type
|
||||||
|
* @param params Connection parameters
|
||||||
|
* @return SharedPointer<Session> The session
|
||||||
|
*/
|
||||||
|
LIAPI static SharedPointer<Session> create(DBType type, const ConnParams& params);
|
||||||
|
/**
|
||||||
|
* @brief Create and open a new session.
|
||||||
|
*
|
||||||
|
* @param type Database type
|
||||||
|
* @param host Hostname
|
||||||
|
* @param port Port
|
||||||
|
* @param user Username
|
||||||
|
* @param password Password
|
||||||
|
* @param database Database name
|
||||||
|
* @return SharedPointer<Session> The session
|
||||||
|
*/
|
||||||
|
LIAPI static SharedPointer<Session> create(DBType type, const std::string& host, uint16_t port, const std::string& user, const std::string& password, const std::string& database);
|
||||||
|
/**
|
||||||
|
* @brief Create and open a new session.
|
||||||
|
*
|
||||||
|
* @param type Database type
|
||||||
|
* @param path Path to the database file
|
||||||
|
* @return SharedPointer<Session> The session
|
||||||
|
*/
|
||||||
|
LIAPI static SharedPointer<Session> create(DBType type, const std::string& path);
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Create a new session(internal).
|
||||||
|
*
|
||||||
|
* @param type Database type
|
||||||
|
* @param params Connection parameters
|
||||||
|
* @return SharedPointer<Session> The session
|
||||||
|
*/
|
||||||
|
static SharedPointer<Session> _Create(DBType type, const ConnParams& params = {});
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
static std::vector<std::weak_ptr<Session>> sessionPool; ///< List of sessions(weak pointers)
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the Session ptr by the (this) pointer.
|
||||||
|
*
|
||||||
|
* @param session The (this) pointer
|
||||||
|
* @return std::shared_ptr<Session> The Session ptr
|
||||||
|
*/
|
||||||
|
static std::shared_ptr<Session> getSession(Session* session)
|
||||||
|
{
|
||||||
|
for (auto& s : sessionPool)
|
||||||
|
{
|
||||||
|
if (s.expired()) continue;
|
||||||
|
auto ptr = s.lock();
|
||||||
|
if (ptr.get() == session)
|
||||||
|
return ptr;
|
||||||
|
}
|
||||||
|
throw std::runtime_error("Session::getSession: Session is not found or expired");
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace DB
|
673
LiteLoader/Header/DB/Stmt.h
Normal file
673
LiteLoader/Header/DB/Stmt.h
Normal file
@ -0,0 +1,673 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "RowSet.h"
|
||||||
|
#include "Pointer.h"
|
||||||
|
|
||||||
|
#define IF_ENDBG if (debugOutput)
|
||||||
|
|
||||||
|
class Logger;
|
||||||
|
|
||||||
|
namespace DB
|
||||||
|
{
|
||||||
|
|
||||||
|
extern Logger dbLogger;
|
||||||
|
|
||||||
|
class Session;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Structure to store a single value to bind to a prepared statement.
|
||||||
|
*
|
||||||
|
* @tparam T Type of sequence container, must have begin() and end() methods
|
||||||
|
* @tparam The value type of the container must be DB::Any.
|
||||||
|
*/
|
||||||
|
struct BindType
|
||||||
|
{
|
||||||
|
Any value;
|
||||||
|
std::string name;
|
||||||
|
int idx = -1;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Structure to store a sequential container
|
||||||
|
* to bind multiple parameters at once.
|
||||||
|
*
|
||||||
|
* @tparam T Type of sequence container, must have begin() and end() methods
|
||||||
|
* @tparam The value type of the container must be DB::Any.
|
||||||
|
*/
|
||||||
|
template <typename T>
|
||||||
|
struct BindSequenceType
|
||||||
|
{
|
||||||
|
T values;
|
||||||
|
static_assert(std::is_same<typename T::value_type, Any>::value, "Container value type must be DB::Any");
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* @brief Structure to store a map(relevance) container
|
||||||
|
* to bind multiple parameters at once.
|
||||||
|
*
|
||||||
|
* @tparam T Type of map container, must have begin() and end() methods
|
||||||
|
* @note The key type of the map must be std::string,
|
||||||
|
* and the value type of the map must be DB::Any.
|
||||||
|
*/
|
||||||
|
template <typename T>
|
||||||
|
struct BindMapType
|
||||||
|
{
|
||||||
|
T values;
|
||||||
|
static_assert(std::is_same<typename T::key_type, std::string>::value, "Map key type must be std::string");
|
||||||
|
static_assert(std::is_same<typename T::mapped_type, Any>::value, "Map value type must be DB::Any");
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
struct IntoType
|
||||||
|
{
|
||||||
|
T& value;
|
||||||
|
};
|
||||||
|
|
||||||
|
class Stmt
|
||||||
|
{
|
||||||
|
|
||||||
|
protected:
|
||||||
|
#if defined(LLDB_DEBUG_MODE)
|
||||||
|
bool debugOutput = true;
|
||||||
|
#else
|
||||||
|
bool debugOutput = false;
|
||||||
|
#endif
|
||||||
|
bool autoExecute = false; ///< Whether to automatically execute the statement on bind
|
||||||
|
std::weak_ptr<Session> parent; ///< Parent session
|
||||||
|
std::weak_ptr<Stmt> self;
|
||||||
|
|
||||||
|
public:
|
||||||
|
Stmt(const std::weak_ptr<Session>& parent, bool autoExecute = false);
|
||||||
|
|
||||||
|
virtual ~Stmt();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Turn on/off debug output.
|
||||||
|
*
|
||||||
|
* @param enable Enable or not
|
||||||
|
*/
|
||||||
|
LIAPI void setDebugOutput(bool enable);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Bind a value to a statement parameter.
|
||||||
|
*
|
||||||
|
* @param value Value to bind
|
||||||
|
* @param index Parameter index
|
||||||
|
* @throws std::runtime_error If error occurs
|
||||||
|
*
|
||||||
|
* @par Implementation
|
||||||
|
* @see SQLiteStmt::bind
|
||||||
|
*/
|
||||||
|
virtual Stmt& bind(const Any& value, int index) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Bind a value to a statement parameter.
|
||||||
|
*
|
||||||
|
* @param value Value to bind
|
||||||
|
* @param name Parameter name
|
||||||
|
* @throws std::runtime_error If error occurs
|
||||||
|
*
|
||||||
|
* @par Impletementation
|
||||||
|
* @see SQLiteStmt::bind
|
||||||
|
*/
|
||||||
|
virtual Stmt& bind(const Any& value, const std::string& name) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Bind a value to the next statement parameter.
|
||||||
|
*
|
||||||
|
* @param value Value to bind
|
||||||
|
* @throws std::runtime_error If error occurs
|
||||||
|
*
|
||||||
|
* @par Impletementation
|
||||||
|
* @see SQLiteStmt::bind
|
||||||
|
*/
|
||||||
|
virtual Stmt& bind(const Any& value) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Execute the statement(after binding all the parameters)
|
||||||
|
*
|
||||||
|
* @return Stmt& *this
|
||||||
|
* @note If `this->autoExecute` is true, there is no need to call this method
|
||||||
|
*/
|
||||||
|
virtual Stmt& execute() = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Step to the next row(not fetch).
|
||||||
|
*
|
||||||
|
* @return bool True if there is a next row
|
||||||
|
*
|
||||||
|
* @par Impletementation
|
||||||
|
* @see SQLiteStmt::step
|
||||||
|
*/
|
||||||
|
virtual bool step() = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Step to the next row(=step).
|
||||||
|
*
|
||||||
|
* @return bool True if there is a next row
|
||||||
|
*
|
||||||
|
* @par Impletementation
|
||||||
|
* @see SQLiteStmt::next
|
||||||
|
*/
|
||||||
|
virtual bool next() = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get weather all the rows have been fetched.
|
||||||
|
*
|
||||||
|
* @return bool True if all the rows have been fetched
|
||||||
|
*
|
||||||
|
* @par Impletementation
|
||||||
|
* @see SQLiteStmt::done
|
||||||
|
*/
|
||||||
|
virtual bool done() = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Fetch the current row.
|
||||||
|
*
|
||||||
|
* @tparam T The type of the value to return
|
||||||
|
* @return T The current row(converted)
|
||||||
|
* @throws std::runtime_error If there is no row to fetch
|
||||||
|
*
|
||||||
|
* @par Example
|
||||||
|
* @code
|
||||||
|
* auto stmt = sess->prepare("SELECT * FROM table");
|
||||||
|
* while (stmt->step()) {
|
||||||
|
* auto row = stmt->fetch();
|
||||||
|
* // Do something with the row
|
||||||
|
* }
|
||||||
|
* stmt->close();
|
||||||
|
* @endcode
|
||||||
|
*/
|
||||||
|
template <typename T = Row>
|
||||||
|
inline T fetch()
|
||||||
|
{
|
||||||
|
return row_to<T>(_Fetch());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Fetch the current row.
|
||||||
|
*
|
||||||
|
* @param[out] row The current row
|
||||||
|
* @return Stmt& *this
|
||||||
|
*/
|
||||||
|
template <typename T = Row>
|
||||||
|
inline Stmt& fetch(T& row)
|
||||||
|
{
|
||||||
|
row = row_to<T>(_Fetch());
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Fetch each of the result rows.
|
||||||
|
*
|
||||||
|
* @param cb Callback function to handle the result rows
|
||||||
|
* @return Stmt& *this
|
||||||
|
* @note Return false in callback to stop fetching
|
||||||
|
*
|
||||||
|
* @par Example
|
||||||
|
* @code
|
||||||
|
* sess->prepare("SELECT * FROM table")
|
||||||
|
* ->fetchEach([](const Row& row) {
|
||||||
|
* // Do something with the row
|
||||||
|
* return true;
|
||||||
|
* })
|
||||||
|
* ->close();
|
||||||
|
* @endcode
|
||||||
|
*/
|
||||||
|
inline Stmt& fetchEach(std::function<bool(const Row&)> cb)
|
||||||
|
{
|
||||||
|
do {
|
||||||
|
auto res = _Fetch();
|
||||||
|
if (res.size() == 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (!cb(res)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} while (step());
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Fetch each of the result rows(For compatibility).
|
||||||
|
*
|
||||||
|
* @param cb Callback function to handle the result rows
|
||||||
|
* @return Stmt& *this
|
||||||
|
* @note Return false in callback to stop fetching
|
||||||
|
* @see Stmt::fetchEach
|
||||||
|
*/
|
||||||
|
inline Stmt& fetchAll(std::function<bool(const Row&)> cb)
|
||||||
|
{
|
||||||
|
return fetchEach(cb);
|
||||||
|
}
|
||||||
|
//virtual Stmt& fetchAll(std::function<bool(const Row&)> cb);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Fetch all the result rows.
|
||||||
|
*
|
||||||
|
* @tparam T The value type of vector
|
||||||
|
* @param[out] rows The result set
|
||||||
|
* @return Stmt& *this
|
||||||
|
*/
|
||||||
|
template <typename T>
|
||||||
|
inline Stmt& fetchAll(std::vector<T>& rows) {
|
||||||
|
return fetchEach([&](const Row& row) {
|
||||||
|
rows.push_back(row_to<T>(row));
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Fetch all the result rows.
|
||||||
|
*
|
||||||
|
* @tparam T The value type of vector
|
||||||
|
* @return std::vector<T> The result rows
|
||||||
|
*/
|
||||||
|
template <typename T>
|
||||||
|
inline std::vector<T> fetchAll() {
|
||||||
|
std::vector<T> result;
|
||||||
|
fetchAll(result);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
//virtual ResultSet fetchAll() = 0;
|
||||||
|
//virtual Stmt& fetchAll(ResultSet& rows);
|
||||||
|
|
||||||
|
inline ResultSet fetchAll()
|
||||||
|
{
|
||||||
|
ResultSet set;
|
||||||
|
fetchAll(set);
|
||||||
|
return set;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline Stmt& fetchAll(ResultSet& rows)
|
||||||
|
{
|
||||||
|
return fetchEach([&rows](const Row& row) {
|
||||||
|
rows.push_back(row);
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Reset the statement from executing state to perpared state
|
||||||
|
*
|
||||||
|
* @return Stmt& *this
|
||||||
|
*
|
||||||
|
* @par Note
|
||||||
|
* Different between `reset()`, `reexec` and `clear()`:
|
||||||
|
* - `reset()` : Reset the statement to the prepared state
|
||||||
|
* - `reexec()`: Reset the statement to the prepared state and execute it
|
||||||
|
* - `clear()` : Reset the statement to the prepared state and clear the parameters, but not execute it
|
||||||
|
*/
|
||||||
|
virtual Stmt& reset() = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Re-execute the statement(keep the currently bound value to re-excute).
|
||||||
|
*
|
||||||
|
* @return Stmt& *this
|
||||||
|
* @note If you want to clear the bound value, use clear() instead.
|
||||||
|
* @see Stmt::reset
|
||||||
|
*
|
||||||
|
* @par Impletementation
|
||||||
|
* @see SQLiteStmt::reexec
|
||||||
|
*/
|
||||||
|
virtual Stmt& reexec() = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Clear all the bound values.
|
||||||
|
*
|
||||||
|
* @return Stmt& *this
|
||||||
|
* @see Stmt::reset
|
||||||
|
*
|
||||||
|
* @par Impletementation
|
||||||
|
* @see SQLiteStmt::clear
|
||||||
|
*/
|
||||||
|
virtual Stmt& clear() = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Close the statement.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @par Impletementation
|
||||||
|
* @see SQLiteStmt::close
|
||||||
|
*/
|
||||||
|
virtual void close() = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the number of rows affected by the statement.
|
||||||
|
*
|
||||||
|
* @return int The number of rows affected
|
||||||
|
* @note It will return -1(ULLONG_MAX - 1) if the row count is not available
|
||||||
|
*
|
||||||
|
* @par Impletementation
|
||||||
|
* @see SQLiteStmt::getAffectedRows
|
||||||
|
*/
|
||||||
|
virtual uint64_t getAffectedRows() const = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the insert id of the statement
|
||||||
|
*
|
||||||
|
* @return uint64_t The insert id
|
||||||
|
* @throws std::runtime_error If error occurs
|
||||||
|
* @note It will return -1(ULLONG_MAX - 1) if the insert id is not available
|
||||||
|
*
|
||||||
|
* @par Implementation
|
||||||
|
* @see SQLiteStmt::getInsertId
|
||||||
|
*/
|
||||||
|
virtual uint64_t getInsertId() const = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the number of the unbound parameters.
|
||||||
|
*
|
||||||
|
* @return int The number of the unbound parameters
|
||||||
|
*
|
||||||
|
* @par Impletementation
|
||||||
|
* @see SQLiteStmt::getUnboundParams
|
||||||
|
*/
|
||||||
|
virtual int getUnboundParams() const = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the number of the bound parameters.
|
||||||
|
*
|
||||||
|
* @return int The number of the bound parameters
|
||||||
|
*
|
||||||
|
* @par Impletementation
|
||||||
|
* @see SQLiteStmt::getBoundParams
|
||||||
|
*/
|
||||||
|
virtual int getBoundParams() const = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the number of parameters.
|
||||||
|
*
|
||||||
|
* @return int The number of parameters
|
||||||
|
*
|
||||||
|
* @par Impletementation
|
||||||
|
* @see SQLiteStmt::getParamsCount
|
||||||
|
*/
|
||||||
|
virtual int getParamsCount() const = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the session.
|
||||||
|
*
|
||||||
|
* @return std::weak_ptr<Session> The session ptr
|
||||||
|
*/
|
||||||
|
virtual std::weak_ptr<Session> getParent() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the shared pointer point to this
|
||||||
|
*
|
||||||
|
* @return SharedPointer<Stmt> The ptr
|
||||||
|
*/
|
||||||
|
virtual SharedPointer<Stmt> getSharedPointer() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the session type
|
||||||
|
*
|
||||||
|
* @return DB::DBType The database type
|
||||||
|
*
|
||||||
|
* @par Impletementation
|
||||||
|
* @see SQLiteStmt::getType
|
||||||
|
*/
|
||||||
|
virtual DBType getType() const = 0;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Fetch the current row(internal).
|
||||||
|
*
|
||||||
|
* @return Row The current row
|
||||||
|
*/
|
||||||
|
virtual Row _Fetch() = 0;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Operator<< to bind values.
|
||||||
|
*
|
||||||
|
* @param v The value
|
||||||
|
* @return SharedPointer<Stmt> this
|
||||||
|
*/
|
||||||
|
inline SharedPointer<Stmt> operator<<(const Any& v)
|
||||||
|
{
|
||||||
|
bind(v);
|
||||||
|
return getSharedPointer();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Operator>> to store the result.
|
||||||
|
*
|
||||||
|
* @tparam T The value type
|
||||||
|
* @param v Where to store
|
||||||
|
* @return SharedPointer<Stmt> this
|
||||||
|
*/
|
||||||
|
template <typename T>
|
||||||
|
inline SharedPointer<Stmt> operator>>(T& v)
|
||||||
|
{
|
||||||
|
fetch(v);
|
||||||
|
return getSharedPointer();
|
||||||
|
}
|
||||||
|
template <>
|
||||||
|
inline SharedPointer<Stmt> operator>>(ResultSet& v)
|
||||||
|
{
|
||||||
|
fetchAll(v);
|
||||||
|
return getSharedPointer();
|
||||||
|
}
|
||||||
|
template <typename T>
|
||||||
|
inline SharedPointer<Stmt> operator>>(std::vector<T>& v)
|
||||||
|
{
|
||||||
|
fetchAll(v);
|
||||||
|
return getSharedPointer();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Operator, to bind single values.
|
||||||
|
*
|
||||||
|
* @param b The return value of DB::use
|
||||||
|
* @return SharedPointer<Stmt> this
|
||||||
|
*/
|
||||||
|
virtual SharedPointer<Stmt> operator,(const BindType& b);
|
||||||
|
/**
|
||||||
|
* @brief Operator, to bind a sequence container.
|
||||||
|
*
|
||||||
|
* @param b The return value of DB::use
|
||||||
|
* @return SharedPointer<Stmt> this
|
||||||
|
*/
|
||||||
|
template <typename T>
|
||||||
|
inline SharedPointer<Stmt> operator,(const BindSequenceType<T>& b)
|
||||||
|
{
|
||||||
|
for (auto& v : b.values)
|
||||||
|
{
|
||||||
|
bind(v);
|
||||||
|
}
|
||||||
|
return getSharedPointer();
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @brief Operator, to bind a row.
|
||||||
|
*
|
||||||
|
* @param b The return value of DB::use
|
||||||
|
* @return SharedPointer<Stmt> this
|
||||||
|
*/
|
||||||
|
template <>
|
||||||
|
inline SharedPointer<Stmt> operator,(const BindSequenceType<Row>& b)
|
||||||
|
{
|
||||||
|
if (b.values.header && b.values.header->size())
|
||||||
|
{
|
||||||
|
b.values.forEach([&](const std::string& name, const Any& value) {
|
||||||
|
bind(value, name);
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (auto& v : b.values)
|
||||||
|
{
|
||||||
|
bind(v);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return getSharedPointer();
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @brief Operator, to bind a map container.
|
||||||
|
*
|
||||||
|
* @param b The return value of DB::bind
|
||||||
|
* @return SharedPointer<Stmt> this
|
||||||
|
*/
|
||||||
|
template <typename T>
|
||||||
|
inline SharedPointer<Stmt> operator,(const BindMapType<T>& b)
|
||||||
|
{
|
||||||
|
for (auto& v : b.values)
|
||||||
|
{
|
||||||
|
bind(v.second, v.first);
|
||||||
|
}
|
||||||
|
return getSharedPointer();
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @brief Operator, to store a row of results.
|
||||||
|
*
|
||||||
|
* @param i The return value of DB::into
|
||||||
|
* @return SharedPointer<Stmt> this
|
||||||
|
*/
|
||||||
|
template <typename T>
|
||||||
|
inline SharedPointer<Stmt> operator,(IntoType<T>& i)
|
||||||
|
{
|
||||||
|
if (!done()) fetch<T>(i.value);
|
||||||
|
return getSharedPointer();
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @brief Operator, to store a set of results.
|
||||||
|
*
|
||||||
|
* @param i The return value of DB::into
|
||||||
|
* @return SharedPointer<Stmt> this
|
||||||
|
*/
|
||||||
|
template <typename T>
|
||||||
|
inline SharedPointer<Stmt> operator,(IntoType<std::vector<T>>& i)
|
||||||
|
{
|
||||||
|
fetchAll<std::vector<T>>(i.value);
|
||||||
|
return getSharedPointer();
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @brief Operator, to store a set of results.
|
||||||
|
*
|
||||||
|
* @param i The return value of DB::into
|
||||||
|
* @return SharedPointer<Stmt> this
|
||||||
|
*/
|
||||||
|
template <>
|
||||||
|
inline SharedPointer<Stmt> operator,(IntoType<ResultSet>& i)
|
||||||
|
{
|
||||||
|
fetchAll(i.value);
|
||||||
|
return getSharedPointer();
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @brief Operator, to store a row of results.
|
||||||
|
*
|
||||||
|
* @param i The return value of DB::into
|
||||||
|
* @return SharedPointer<Stmt> this
|
||||||
|
*/
|
||||||
|
template <>
|
||||||
|
inline SharedPointer<Stmt> operator,(IntoType<Row>& i)
|
||||||
|
{
|
||||||
|
fetch(i.value);
|
||||||
|
return getSharedPointer();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Operator-> to implement better API.
|
||||||
|
*
|
||||||
|
* @return Stmt* this
|
||||||
|
*/
|
||||||
|
inline Stmt* operator->()
|
||||||
|
{
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
inline BindType use(const Any& value, int idx = -1)
|
||||||
|
{
|
||||||
|
return BindType{value, std::string(), idx};
|
||||||
|
}
|
||||||
|
inline BindType use(const Any& value, const std::string& name)
|
||||||
|
{
|
||||||
|
return BindType{value, name};
|
||||||
|
}
|
||||||
|
inline BindSequenceType<Row> use(const Row& values)
|
||||||
|
{
|
||||||
|
return BindSequenceType<Row>{values};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
inline BindSequenceType<std::vector<T>> use(const std::vector<T>& values)
|
||||||
|
{
|
||||||
|
return BindSequenceType<std::vector<Any>>{to_any_container(values)};
|
||||||
|
}
|
||||||
|
template <typename T>
|
||||||
|
inline BindSequenceType<std::set<T>> use(const std::set<T>& values)
|
||||||
|
{
|
||||||
|
return BindSequenceType<std::set<T>>{to_any_container(values)};
|
||||||
|
}
|
||||||
|
template <typename T>
|
||||||
|
inline BindSequenceType<std::list<T>> use(const std::list<T>& values)
|
||||||
|
{
|
||||||
|
return BindSequenceType<std::list<T>>{to_any_container(values)};
|
||||||
|
}
|
||||||
|
template <typename T>
|
||||||
|
inline BindSequenceType<std::vector<T>> use(const std::initializer_list<T>& values)
|
||||||
|
{
|
||||||
|
return BindSequenceType<std::vector<T>>{to_any_container(std::vector<T>(values))};
|
||||||
|
}
|
||||||
|
template <>
|
||||||
|
inline BindSequenceType<std::vector<Any>> use(const std::vector<Any>& values)
|
||||||
|
{
|
||||||
|
return BindSequenceType<std::vector<Any>>{values};
|
||||||
|
}
|
||||||
|
template <>
|
||||||
|
inline BindSequenceType<std::set<Any>> use(const std::set<Any>& values)
|
||||||
|
{
|
||||||
|
return BindSequenceType<std::set<Any>>{values};
|
||||||
|
}
|
||||||
|
template <>
|
||||||
|
inline BindSequenceType<std::list<Any>> use(const std::list<Any>& values)
|
||||||
|
{
|
||||||
|
return BindSequenceType<std::list<Any>>{values};
|
||||||
|
}
|
||||||
|
template <>
|
||||||
|
inline BindSequenceType<std::vector<Any>> use(const std::initializer_list<Any>& values)
|
||||||
|
{
|
||||||
|
return BindSequenceType<std::vector<Any>>{std::vector<Any>(values)};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Map
|
||||||
|
template <typename T>
|
||||||
|
inline BindMapType<std::map<std::string, T>> use(const std::map<std::string, T>& values)
|
||||||
|
{
|
||||||
|
return BindMapType<std::map<std::string, T>>{values};
|
||||||
|
}
|
||||||
|
template <typename T>
|
||||||
|
inline BindMapType<std::unordered_map<std::string, T>> use(const std::unordered_map<std::string, T>& values)
|
||||||
|
{
|
||||||
|
return BindMapType<std::unordered_map<std::string, T>>{values};
|
||||||
|
}
|
||||||
|
template <>
|
||||||
|
inline BindMapType<std::map<std::string, Any>> use(const std::map<std::string, Any>& values)
|
||||||
|
{
|
||||||
|
return BindMapType<std::map<std::string, Any>>{values};
|
||||||
|
}
|
||||||
|
template <>
|
||||||
|
inline BindMapType<std::unordered_map<std::string, Any>> use(const std::unordered_map<std::string, Any>& values)
|
||||||
|
{
|
||||||
|
return BindMapType<std::unordered_map<std::string, Any>>{values};
|
||||||
|
}
|
||||||
|
inline BindMapType<std::map<std::string, Any>> use(const std::initializer_list<std::pair<std::string, Any>>& values)
|
||||||
|
{
|
||||||
|
std::map<std::string, Any> result;
|
||||||
|
for (auto& pair : values)
|
||||||
|
{
|
||||||
|
result.insert(std::make_pair(pair.first, pair.second));
|
||||||
|
}
|
||||||
|
return BindMapType<std::map<std::string, Any>>{result};
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
inline IntoType<T> into(T& out)
|
||||||
|
{
|
||||||
|
return IntoType<T>{out};
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace DB
|
44
LiteLoader/Header/DB/Types.h
Normal file
44
LiteLoader/Header/DB/Types.h
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <vector>
|
||||||
|
//#define LLDB_DEBUG_MODE
|
||||||
|
|
||||||
|
namespace DB
|
||||||
|
{
|
||||||
|
|
||||||
|
enum class DBType : char
|
||||||
|
{
|
||||||
|
None,
|
||||||
|
SQLite,
|
||||||
|
MySQL,
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Date
|
||||||
|
{
|
||||||
|
int year;
|
||||||
|
int month;
|
||||||
|
int day;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Time
|
||||||
|
{
|
||||||
|
int hour;
|
||||||
|
int minute;
|
||||||
|
int second;
|
||||||
|
int timezone = -1;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct DateTime
|
||||||
|
{
|
||||||
|
Date date;
|
||||||
|
Time time;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Decimal
|
||||||
|
{
|
||||||
|
int64_t value;
|
||||||
|
int scale;
|
||||||
|
};
|
||||||
|
|
||||||
|
using ByteArray = std::vector<unsigned char>;
|
||||||
|
|
||||||
|
} // namespace DB
|
558
LiteLoader/Header/DynamicCommandAPI.h
Normal file
558
LiteLoader/Header/DynamicCommandAPI.h
Normal file
@ -0,0 +1,558 @@
|
|||||||
|
// #pragma once
|
||||||
|
// #include "Global.h"
|
||||||
|
// class Actor;
|
||||||
|
// #define USE_PARSE_ENUM_STRING
|
||||||
|
// //#define ENABLE_PARAMETER_TYPE_POSTFIX
|
||||||
|
// #include "MC/Command.hpp"
|
||||||
|
// #include "MC/CommandOrigin.hpp"
|
||||||
|
// #include "MC/CommandOutput.hpp"
|
||||||
|
// #include "MC/CommandParameterData.hpp"
|
||||||
|
// #include "MC/CommandRegistry.hpp"
|
||||||
|
// #include "MC/CommandSelector.hpp"
|
||||||
|
// #include "MC/CommandPosition.hpp"
|
||||||
|
// #include "Utils/WinHelper.h"
|
||||||
|
// #include <third-party/magic_enum/magic_enum.hpp>
|
||||||
|
|
||||||
|
// ///////////////////////////////////////////////////////
|
||||||
|
// // Dynamic Command Registry
|
||||||
|
// //
|
||||||
|
// // [Example]
|
||||||
|
// // ## One Example:
|
||||||
|
// // // Direct setup of dynamic command with necessary information
|
||||||
|
// // using ParamType = DynamicCommand::ParameterType;
|
||||||
|
// // using Param = DynamicCommand::ParameterData;
|
||||||
|
// // DynamicCommand::setup(
|
||||||
|
// // "testenum", // command name
|
||||||
|
// // "dynamic command", // command description
|
||||||
|
// // {
|
||||||
|
// // // enums{enumName, {values...}}
|
||||||
|
// // {"TestEnum1", {"add", "remove"}},
|
||||||
|
// // {"TestEnum2", {"list"}},
|
||||||
|
// // },
|
||||||
|
// // {
|
||||||
|
// // // parameters(type, name, [optional], [enumOptions(also enumName)], [identifier])
|
||||||
|
// // // identifier: used to identify unique parameter data, if idnetifier is not set,
|
||||||
|
// // // it is set to be the same as enumOptions or name (identifier = enumOptions.empty() ? name:enumOptions)
|
||||||
|
// // Param("testEnum", ParamType::Enum, "TestEnum1"),
|
||||||
|
// // Param("testEnum", ParamType::Enum, "TestEnum2"),
|
||||||
|
// // Param("testInt", ParamType::Int, true),
|
||||||
|
// // },
|
||||||
|
// // {
|
||||||
|
// // // overloads{ (type == Enum ? enumOptions : name) ...}
|
||||||
|
// // {"TestEnum1", "testInt"}, // testenum <add|remove> [testInt]
|
||||||
|
// // {"TestEnum2"}, // testenum <list>
|
||||||
|
// // },
|
||||||
|
// // // dynamic command callback
|
||||||
|
// // [](DynamicCommand const& command, CommandOrigin const& origin, CommandOutput& output,
|
||||||
|
// // std::unordered_map<std::string, DynamicCommand::Result>& results) {
|
||||||
|
// // auto& action = results["testEnum"].get<std::string>();
|
||||||
|
// // switch (do_hash(action.c_str()))
|
||||||
|
// // {
|
||||||
|
// // case do_hash("add"):
|
||||||
|
// // if (results["testInt"].isSet)
|
||||||
|
// // output.success(fmt::format("add {}", results["testInt"].getRaw<int>()));
|
||||||
|
// // else
|
||||||
|
// // output.success("add nothing");
|
||||||
|
// // break;
|
||||||
|
// // case do_hash("remove"):
|
||||||
|
// // if (results["testInt"].isSet)
|
||||||
|
// // output.success(fmt::format("remove {}", results["testInt"].getRaw<int>()));
|
||||||
|
// // else
|
||||||
|
// // output.success("remove nothing");
|
||||||
|
// // break;
|
||||||
|
// // case do_hash("list"):
|
||||||
|
// // output.success("list");
|
||||||
|
// // break;
|
||||||
|
// // default:
|
||||||
|
// // break;
|
||||||
|
// // }
|
||||||
|
// // },
|
||||||
|
// // CommandPermissionLevel::GameMasters);
|
||||||
|
// //
|
||||||
|
// // ## Another Example
|
||||||
|
// // using ParamType = DynamicCommand::ParameterType;
|
||||||
|
// // // create a dynamic command
|
||||||
|
// // auto command = DynamicCommand::createCommand("testcmd", "dynamic command", CommandPermissionLevel::GameMasters);
|
||||||
|
// //
|
||||||
|
// // auto& optionsAdd = command->setEnum("TestOperation1", {"add", "remove"});
|
||||||
|
// // auto& optionsList = command->setEnum("TestOperation2", {"list"});
|
||||||
|
// //
|
||||||
|
// // command->mandatory("testEnum", ParamType::Enum, optionsAdd, CommandParameterOption::EnumAutocompleteExpansion);
|
||||||
|
// // command->mandatory("testEnum", ParamType::Enum, optionsList, CommandParameterOption::EnumAutocompleteExpansion);
|
||||||
|
// // command->mandatory("testString", ParamType::String);
|
||||||
|
// //
|
||||||
|
// // command->addOverload({optionsAdd, "testString"}); // dyncmd <add|remove> <testString:string>
|
||||||
|
// // command->addOverload({"TestOperation2"}); // dyncmd <list>
|
||||||
|
// //
|
||||||
|
// // command->setCallback([](DynamicCommand const& command, CommandOrigin const& origin, CommandOutput& output, std::unordered_map<std::string, Result>& results) {
|
||||||
|
// // switch (do_hash(results["testEnum"].getRaw<std::string>().c_str()))
|
||||||
|
// // {
|
||||||
|
// // case do_hash("add"):
|
||||||
|
// // output.success(fmt::format("Add - {}", results["testString"].getRaw<std::string>()));
|
||||||
|
// // break;
|
||||||
|
// // case do_hash("remove"):
|
||||||
|
// // output.success(fmt::format("Remove - {}", results["testString"].getRaw<std::string>()));
|
||||||
|
// // break;
|
||||||
|
// // case do_hash("list"):
|
||||||
|
// // output.success("List");
|
||||||
|
// // break;
|
||||||
|
// // default:
|
||||||
|
// // break;
|
||||||
|
// // }
|
||||||
|
// // });
|
||||||
|
// // // do not forget to setup the command instance
|
||||||
|
// // DynamicCommand::setup(std::move(command));
|
||||||
|
// //
|
||||||
|
// /////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
// struct DCCallback;
|
||||||
|
// struct DCArgs;
|
||||||
|
// typedef union DCValue_ DCValue;
|
||||||
|
// class DynamicCommandInstance;
|
||||||
|
// class CommandMessage;
|
||||||
|
// class CommandOutput;
|
||||||
|
// class CommandRegistry;
|
||||||
|
// class Player;
|
||||||
|
|
||||||
|
|
||||||
|
// #define AllResultType bool const*, int const*, float const*, std::string const*, CommandSelector<Actor> const*, CommandSelector<Player> const*, CommandPosition const*, CommandPositionFloat const*, CommandRawText const*, CommandMessage const*, Json::Value const*, CommandItem const*, Block const* const*, MobEffect const* const*, ActorDefinitionIdentifier const* const*, std::unique_ptr<Command> const*
|
||||||
|
|
||||||
|
// class DynamicCommand : public Command {
|
||||||
|
// template <typename _Ty, class... _Types>
|
||||||
|
// static constexpr bool is_one_of_v = std::_Meta_find_unique_index<std::variant<_Types...>, std::add_pointer_t<std::add_const_t<_Ty>>>::value < sizeof...(_Types);
|
||||||
|
// template <typename _Ty>
|
||||||
|
// static constexpr bool is_supported_result_type_v = is_one_of_v<_Ty, AllResultType>;
|
||||||
|
// template <typename _Ty, typename Type>
|
||||||
|
// using enable_if_supported_t = std::enable_if_t<is_supported_result_type_v<_Ty>, Type>;
|
||||||
|
|
||||||
|
// public:
|
||||||
|
// enum class ParameterType {
|
||||||
|
// Bool, // bool
|
||||||
|
// Int, // int
|
||||||
|
// Float, // float
|
||||||
|
// String, // std::string
|
||||||
|
// Actor, // CommandSelector<Actor>
|
||||||
|
// Player, // CommandSelector<Player>
|
||||||
|
// BlockPos, // CommandPosition
|
||||||
|
// Vec3, // CommandPositionFloat
|
||||||
|
// RawText, // CommandRawText
|
||||||
|
// Message, // CommandMessage
|
||||||
|
// JsonValue, // Json::Value
|
||||||
|
// Item, // CommandItem
|
||||||
|
// Block, // Block const*
|
||||||
|
// Effect, // MobEffect const*
|
||||||
|
// Enum, // ENUM
|
||||||
|
// SoftEnum, // SOFT_ENUM
|
||||||
|
// ActorType, // ActorDefinitionIdentifier const*
|
||||||
|
// Command, // std::unique_ptr<Command>
|
||||||
|
// WildcardSelector, // WildcardCommandSelector<Actor>
|
||||||
|
// #ifdef ENABLE_PARAMETER_TYPE_POSTFIX
|
||||||
|
// Postfix, // int?
|
||||||
|
// #endif // ENABLE_PARAMETER_TYPE_POSTFIX
|
||||||
|
// };
|
||||||
|
// struct ParameterPtr;
|
||||||
|
|
||||||
|
// struct Result {
|
||||||
|
// ParameterType const type;
|
||||||
|
// size_t const offset;
|
||||||
|
// bool const isSet;
|
||||||
|
|
||||||
|
// DynamicCommand const* command;
|
||||||
|
// DynamicCommandInstance const* instance;
|
||||||
|
// CommandOrigin const* origin;
|
||||||
|
|
||||||
|
// LIAPI Result(ParameterPtr const* ptr, DynamicCommand const* command, CommandOrigin const* origin, DynamicCommandInstance const* instance = nullptr);
|
||||||
|
// LIAPI Result();
|
||||||
|
// LIAPI std::string const& getEnumValue() const;
|
||||||
|
// LIAPI ParameterType getType() const;
|
||||||
|
// LIAPI std::string getName() const;
|
||||||
|
// LIAPI std::string toDebugString() const;
|
||||||
|
// LIAPI DynamicCommandInstance const* getInstance() const;
|
||||||
|
|
||||||
|
// template <typename T>
|
||||||
|
// inline enable_if_supported_t<T, T const&> getRaw() const {
|
||||||
|
// #ifdef USE_PARSE_ENUM_STRING
|
||||||
|
// if (type == ParameterType::Enum) {
|
||||||
|
// auto& val = dAccess<std::pair<std::string, int>>(command, offset);
|
||||||
|
// if constexpr (std::is_same_v<std::remove_cv_t<T>, int> || std::is_enum_v<T>) {
|
||||||
|
// return static_cast<T const&>(val.second);
|
||||||
|
// } else if constexpr (std::is_same_v<std::remove_cv_t<T>, std::string>) {
|
||||||
|
// return static_cast<T const&>(val.first);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// #else
|
||||||
|
// if constexpr (std::is_same_v<std::remove_cv_t<T>, std::string>) {
|
||||||
|
// if (type == ParameterType::Enum)
|
||||||
|
// return getEnumValue();
|
||||||
|
// }
|
||||||
|
// #endif // USE_PARSE_ENUM_STRING
|
||||||
|
// if (checkTempateType<T>(type))
|
||||||
|
// return dAccess<T>(command, offset);
|
||||||
|
// throw std::runtime_error(fmt::format("Raw type not match, parameter Type: {}, data type: {}", magic_enum::enum_name(type), typeid(T).name()));
|
||||||
|
// }
|
||||||
|
|
||||||
|
// template <typename T>
|
||||||
|
// inline enable_if_supported_t<T, T const&> value_or(T const& defaultValue) {
|
||||||
|
// if (isSet)
|
||||||
|
// return getRaw<T>();
|
||||||
|
// return defaultValue;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// template <typename T>
|
||||||
|
// inline std::conditional_t<std::is_lvalue_reference_v<T>, std::add_lvalue_reference_t<std::add_const_t<std::remove_reference_t<T>>>, T>
|
||||||
|
// get() const {
|
||||||
|
// static_assert(is_supported_result_type_v<T> || (std::is_lvalue_reference_v<T> && is_supported_result_type_v<std::remove_reference_t<T>>),
|
||||||
|
// "Unsupported Result Type in " __FUNCTION__);
|
||||||
|
// if constexpr (std::is_lvalue_reference_v<T>)
|
||||||
|
// return getRaw<std::remove_reference_t<T>>();
|
||||||
|
// else
|
||||||
|
// return getRaw<T>();
|
||||||
|
// }
|
||||||
|
|
||||||
|
// template <>
|
||||||
|
// inline std::vector<Actor*> get<std::vector<Actor*>>() const {
|
||||||
|
// if (type == ParameterType::Player) {
|
||||||
|
// auto players = get<std::vector<Player*>>();
|
||||||
|
// std::vector<Actor*> actors(players.size());
|
||||||
|
// std::transform(players.begin(), players.end(), actors.begin(),
|
||||||
|
// [](Player* player) { return static_cast<Actor*>(player); });
|
||||||
|
// return actors;
|
||||||
|
// }
|
||||||
|
// std::vector<Actor*> rtn;
|
||||||
|
// for (auto& result : getRaw<CommandSelector<Actor>>().results(*origin)) {
|
||||||
|
// rtn.push_back(result);
|
||||||
|
// }
|
||||||
|
// return rtn;
|
||||||
|
// }
|
||||||
|
// template <>
|
||||||
|
// inline std::vector<Player*> get<std::vector<Player*>>() const {
|
||||||
|
// std::vector<Player*> rtn;
|
||||||
|
// for (auto& result : getRaw<CommandSelector<Player>>().results(*origin)) {
|
||||||
|
// rtn.push_back(result);
|
||||||
|
// }
|
||||||
|
// return rtn;
|
||||||
|
// }
|
||||||
|
// template <>
|
||||||
|
// inline BlockPos get<BlockPos>() const {
|
||||||
|
// auto& pos = getRaw<CommandPosition>();
|
||||||
|
// return pos.getBlockPos(*origin, Vec3::ZERO);
|
||||||
|
// }
|
||||||
|
// template <>
|
||||||
|
// inline Vec3 get<Vec3>() const {
|
||||||
|
// auto& pos = getRaw<CommandPositionFloat>();
|
||||||
|
// return pos.getPosition(*origin, Vec3::ZERO);
|
||||||
|
// }
|
||||||
|
// };
|
||||||
|
|
||||||
|
// struct ParameterPtr {
|
||||||
|
// ParameterType type;
|
||||||
|
|
||||||
|
// private:
|
||||||
|
// size_t offset = -1;
|
||||||
|
|
||||||
|
// friend struct Result;
|
||||||
|
|
||||||
|
// public:
|
||||||
|
// LIAPI ParameterPtr(ParameterType type, size_t offset);
|
||||||
|
// LIAPI bool isValueSet(DynamicCommand const* command) const;
|
||||||
|
// LIAPI Result getResult(DynamicCommand const* command, CommandOrigin const* origin) const;
|
||||||
|
|
||||||
|
// inline size_t getOffset() const {
|
||||||
|
// return offset;
|
||||||
|
// }
|
||||||
|
// };
|
||||||
|
|
||||||
|
// struct ParameterData {
|
||||||
|
// protected:
|
||||||
|
// DynamicCommand::ParameterType type;
|
||||||
|
// size_t offset = -1;
|
||||||
|
// std::string name;
|
||||||
|
// std::string description;
|
||||||
|
// std::string identifier;
|
||||||
|
// bool optional = false;
|
||||||
|
// CommandParameterOption option;
|
||||||
|
|
||||||
|
// public:
|
||||||
|
// ParameterData() = delete;
|
||||||
|
// LIAPI ParameterData(ParameterData const&);
|
||||||
|
// LIAPI ParameterData(std::string const& name, DynamicCommand::ParameterType type, bool optional = false, std::string const& enumOptions = "", std::string const& identifier = "", CommandParameterOption parameterOption = (CommandParameterOption)0);
|
||||||
|
// LIAPI ParameterData(std::string const& name, DynamicCommand::ParameterType type, std::string const& enumOptions = "", std::string const& identifier = "", CommandParameterOption parameterOption = (CommandParameterOption)0);
|
||||||
|
// LIAPI CommandParameterData makeParameterData() const;
|
||||||
|
|
||||||
|
// friend class DynamicCommandInstance;
|
||||||
|
// friend class DynamicCommand;
|
||||||
|
|
||||||
|
// template <ParameterType type>
|
||||||
|
// inline static constexpr CommandParameterDataType getCommandParameterDataType() {
|
||||||
|
// if constexpr (type == ParameterType::Enum)
|
||||||
|
// return CommandParameterDataType::ENUM;
|
||||||
|
// else if constexpr (type == ParameterType::SoftEnum)
|
||||||
|
// return CommandParameterDataType::SOFT_ENUM;
|
||||||
|
// // else if constexpr (type == ParameterType::Postfix)
|
||||||
|
// // return CommandParameterDataType::POSIFIX;
|
||||||
|
// else
|
||||||
|
// return CommandParameterDataType::NORMAL;
|
||||||
|
// }
|
||||||
|
// template <ParameterType type, typename T>
|
||||||
|
// CommandParameterData makeParameterData() const {
|
||||||
|
// CommandParameterData param{
|
||||||
|
// type == ParameterType::Enum ? typeid_t<CommandRegistry>::count++ : type_id<CommandRegistry, T>(),
|
||||||
|
// type == ParameterType::Enum ? &CommandRegistry::fakeParse<T> : CommandRegistry::getParseFn<T>(),
|
||||||
|
// name,
|
||||||
|
// getCommandParameterDataType<type>(),
|
||||||
|
// description == "" ? nullptr : description.data(),
|
||||||
|
// (int)offset,
|
||||||
|
// optional,
|
||||||
|
// (int)offset + std::max(8, (int)sizeof(T))};
|
||||||
|
// param.addOptions(option);
|
||||||
|
// // logger.warn(Global<CommandRegistry>->describe(param));
|
||||||
|
// return std::move(param);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// inline void setOptional(bool optional) {
|
||||||
|
// this->optional = optional;
|
||||||
|
// }
|
||||||
|
// inline bool setEnumOptions(std::string const& enumOptions) {
|
||||||
|
// if (type != DynamicCommand::ParameterType::Enum && type != DynamicCommand::ParameterType::SoftEnum)
|
||||||
|
// return false;
|
||||||
|
// this->description = enumOptions;
|
||||||
|
// return true;
|
||||||
|
// }
|
||||||
|
// inline bool setParameterOption(CommandParameterOption parameterOption) {
|
||||||
|
// this->option = parameterOption;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// inline ParameterData(std::string const& name, ParameterType type, const char* enumOptions = "", std::string const& identifer = "", CommandParameterOption parameterOption = (CommandParameterOption)0)
|
||||||
|
// : ParameterData(name, type, (std::string const&)enumOptions, identifer, parameterOption){};
|
||||||
|
// };
|
||||||
|
|
||||||
|
// using CallBackFn = std::function<void(DynamicCommand const& cmd, CommandOrigin const& origin, CommandOutput& output, std::unordered_map<std::string, Result>& results)>;
|
||||||
|
// using BuilderFn = std::unique_ptr<Command> (*)();
|
||||||
|
|
||||||
|
// private:
|
||||||
|
// template <typename _Ty>
|
||||||
|
// inline static enable_if_supported_t<_Ty, bool> checkTempateType(ParameterType type) {
|
||||||
|
// switch (type) {
|
||||||
|
// case ParameterType::Bool:
|
||||||
|
// return std::is_same_v<bool, std::remove_cv_t<_Ty>>;
|
||||||
|
// case ParameterType::Int:
|
||||||
|
// return std::is_same_v<int, std::remove_cv_t<_Ty>>;
|
||||||
|
// case ParameterType::Float:
|
||||||
|
// return std::is_same_v<float, std::remove_cv_t<_Ty>>;
|
||||||
|
// case ParameterType::String:
|
||||||
|
// return std::is_same_v<std::string, std::remove_cv_t<_Ty>>;
|
||||||
|
// case ParameterType::Actor:
|
||||||
|
// return std::is_same_v<CommandSelector<Actor>, std::remove_cv_t<_Ty>>;
|
||||||
|
// case ParameterType::Player:
|
||||||
|
// return std::is_same_v<CommandSelector<Player>, std::remove_cv_t<_Ty>>;
|
||||||
|
// case ParameterType::BlockPos:
|
||||||
|
// case ParameterType::Vec3:
|
||||||
|
// return std::is_same_v<CommandPosition, std::remove_cv_t<_Ty>> || std::is_same_v<CommandPositionFloat, std::remove_cv_t<_Ty>>;
|
||||||
|
// case ParameterType::RawText:
|
||||||
|
// return std::is_same_v<CommandRawText, std::remove_cv_t<_Ty>> || std::is_same_v<std::string, std::remove_cv_t<_Ty>>;
|
||||||
|
// case ParameterType::Message:
|
||||||
|
// return std::is_same_v<CommandMessage, std::remove_cv_t<_Ty>>;
|
||||||
|
// case ParameterType::JsonValue:
|
||||||
|
// return std::is_same_v<Json::Value, std::remove_cv_t<_Ty>>;
|
||||||
|
// case ParameterType::Item:
|
||||||
|
// return std::is_same_v<CommandItem, std::remove_cv_t<_Ty>>;
|
||||||
|
// case ParameterType::Block:
|
||||||
|
// return std::is_same_v<Block const*, std::remove_cv_t<_Ty>>;
|
||||||
|
// case ParameterType::Effect:
|
||||||
|
// return std::is_same_v<MobEffect const*, std::remove_cv_t<_Ty>>;
|
||||||
|
// // case ParameterType::Position:
|
||||||
|
// // return std::is_same_v<ParameterDataType::Position, std::remove_cv_t<_Ty>> || std::is_same_v<BlockPos, std::remove_cv_t<_Ty>> || std::is_same_v<Vec3, std::remove_cv_t<_Ty>>;
|
||||||
|
// case ParameterType::Enum:
|
||||||
|
// return std::is_same_v<int, std::remove_cv_t<_Ty>> || std::is_same_v<std::string, std::remove_cv_t<_Ty>> || std::is_enum_v<_Ty>;
|
||||||
|
// case ParameterType::SoftEnum:
|
||||||
|
// return std::is_same_v<std::string, std::remove_cv_t<_Ty>>;
|
||||||
|
// case ParameterType::ActorType:
|
||||||
|
// return std::is_same_v<ActorDefinitionIdentifier const*, std::remove_cv_t<_Ty>>;
|
||||||
|
// case ParameterType::Command:
|
||||||
|
// return std::is_same_v<std::unique_ptr<Command>, std::remove_cv_t<_Ty>>;
|
||||||
|
// default:
|
||||||
|
// return false;
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
// return false;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// LIAPI static char builderCallbackHanler(DCCallback* cb, DCArgs* args, DCValue* result, void* userdata);
|
||||||
|
// LIAPI static std::unique_ptr<Command>* commandBuilder(std::unique_ptr<Command>* rtn, std::string name);
|
||||||
|
// LIAPI static DynamicCommandInstance* _setup(std::unique_ptr<class DynamicCommandInstance> commandInstance);
|
||||||
|
|
||||||
|
// public:
|
||||||
|
// static bool onServerCommandsRegister(CommandRegistry& registry);
|
||||||
|
|
||||||
|
// friend class DynamicCommandInstance;
|
||||||
|
|
||||||
|
// public:
|
||||||
|
// /*0*/ virtual ~DynamicCommand();
|
||||||
|
// /*1*/ virtual void execute(class CommandOrigin const& origin, class CommandOutput& output) const;
|
||||||
|
|
||||||
|
// LIAPI static std::unique_ptr<class DynamicCommandInstance> createCommand(std::string const& name, std::string const& description, CommandPermissionLevel permission = CommandPermissionLevel::GameMasters, CommandFlag flag1 = {(CommandFlagValue)0x80}, CommandFlag flag2 = {(CommandFlagValue)0}, HMODULE handle = GetCurrentModule());
|
||||||
|
// LIAPI static std::unique_ptr<class DynamicCommandInstance> createCommand(
|
||||||
|
// std::string const& name,
|
||||||
|
// std::string const& description,
|
||||||
|
// std::unordered_map<std::string, std::vector<std::string>>&& enums,
|
||||||
|
// std::vector<ParameterData>&& params,
|
||||||
|
// std::vector<std::vector<std::string>>&& overloads,
|
||||||
|
// CallBackFn callback,
|
||||||
|
// CommandPermissionLevel permission = CommandPermissionLevel::GameMasters,
|
||||||
|
// CommandFlag flag1 = {(CommandFlagValue)0x80},
|
||||||
|
// CommandFlag flag2 = {(CommandFlagValue)0},
|
||||||
|
// HMODULE handle = GetCurrentModule());
|
||||||
|
|
||||||
|
// LIAPI static DynamicCommandInstance const* setup(std::unique_ptr<class DynamicCommandInstance> commandInstance);
|
||||||
|
// inline static DynamicCommandInstance const* setup(
|
||||||
|
// std::string const& name,
|
||||||
|
// std::string const& description,
|
||||||
|
// std::unordered_map<std::string, std::vector<std::string>>&& enums,
|
||||||
|
// std::vector<ParameterData>&& params,
|
||||||
|
// std::vector<std::vector<std::string>>&& overloads,
|
||||||
|
// CallBackFn callback,
|
||||||
|
// CommandPermissionLevel permission = CommandPermissionLevel::GameMasters,
|
||||||
|
// CommandFlag flag1 = {(CommandFlagValue)0x80},
|
||||||
|
// CommandFlag flag2 = {(CommandFlagValue)0},
|
||||||
|
// HMODULE handle = GetCurrentModule()) {
|
||||||
|
// return setup(createCommand(name, description, std::move(enums), std::move(params), std::move(overloads), std::move(callback), permission, flag1, flag2, handle));
|
||||||
|
// };
|
||||||
|
|
||||||
|
// // Experiment
|
||||||
|
// LIAPI static bool unregisterCommand(std::string const& name);
|
||||||
|
|
||||||
|
// LIAPI static bool updateAvailableCommands();
|
||||||
|
|
||||||
|
// LIAPI DynamicCommandInstance const* getInstance() const;
|
||||||
|
|
||||||
|
// LIAPI static DynamicCommandInstance const* getInstance(std::string const& commandName);
|
||||||
|
// };
|
||||||
|
|
||||||
|
// class DynamicCommandInstance {
|
||||||
|
// public:
|
||||||
|
// struct ParameterIndex {
|
||||||
|
// DynamicCommandInstance* instance;
|
||||||
|
// size_t index;
|
||||||
|
// ParameterIndex(DynamicCommandInstance* instance, size_t index)
|
||||||
|
// : instance(instance)
|
||||||
|
// , index(index){};
|
||||||
|
// inline operator size_t() const {
|
||||||
|
// return index;
|
||||||
|
// }
|
||||||
|
// inline DynamicCommand::ParameterData& operator->() {
|
||||||
|
// return instance->parameterDatas.at(index);
|
||||||
|
// }
|
||||||
|
// inline bool isValid() const {
|
||||||
|
// size_t size = instance->parameterDatas.size();
|
||||||
|
// return index >= 0 && index < size;
|
||||||
|
// }
|
||||||
|
// };
|
||||||
|
|
||||||
|
// private:
|
||||||
|
// std::string name;
|
||||||
|
// std::string alias;
|
||||||
|
// std::unique_ptr<std::string> description;
|
||||||
|
// CommandPermissionLevel permission;
|
||||||
|
// CommandFlag flag;
|
||||||
|
// DynamicCommand::BuilderFn builder = nullptr;
|
||||||
|
|
||||||
|
// public:
|
||||||
|
// // Parameter Pointers to DynamicCommand Extra Part
|
||||||
|
// size_t commandSize = sizeof(DynamicCommand);
|
||||||
|
// std::unordered_map<std::string, DynamicCommand::ParameterPtr> parameterPtrs = {};
|
||||||
|
|
||||||
|
// // Use unique_ptr to keep the address of enumName.c_str() immutable
|
||||||
|
// std::vector<std::unique_ptr<std::string>> enumNames = {};
|
||||||
|
// std::vector<std::string> enumValues = {};
|
||||||
|
// // unordered_map{ enumName, pair{ enumIndex, enumSize } }
|
||||||
|
// std::unordered_map<std::string_view, std::pair<size_t, size_t>> enumRanges = {};
|
||||||
|
|
||||||
|
// //// unordered_map{ enumName, pair{ enumIndex, enumConstraint } }
|
||||||
|
// // std::unordered_map<std::string_view, std::pair<size_t, SemanticConstraint>> enumConstraints = {};
|
||||||
|
|
||||||
|
// // SoftEnum
|
||||||
|
// mutable std::unordered_map<std::string, std::vector<std::string>> softEnums;
|
||||||
|
|
||||||
|
// std::vector<DynamicCommand::ParameterData> parameterDatas = {};
|
||||||
|
|
||||||
|
// private:
|
||||||
|
// std::vector<std::vector<ParameterIndex>> overloads = {}; // indices of parameter instance
|
||||||
|
|
||||||
|
// mutable DynamicCommand::CallBackFn callback = nullptr;
|
||||||
|
// HMODULE handle = nullptr;
|
||||||
|
|
||||||
|
// friend class DynamicCommand;
|
||||||
|
|
||||||
|
// LIAPI DynamicCommandInstance(std::string const& name, std::string const& description, CommandPermissionLevel permission = CommandPermissionLevel::GameMasters, CommandFlag flag = {(CommandFlagValue)0x80}, HMODULE handle = GetCurrentModule());
|
||||||
|
|
||||||
|
// LIAPI bool setBuilder(DynamicCommand::BuilderFn builder);
|
||||||
|
// LIAPI DynamicCommand::BuilderFn initCommandBuilder();
|
||||||
|
// LIAPI std::vector<CommandParameterData> buildOverload(std::vector<ParameterIndex> const& overload);
|
||||||
|
|
||||||
|
// public:
|
||||||
|
// virtual ~DynamicCommandInstance();
|
||||||
|
|
||||||
|
// LIAPI static std::unique_ptr<DynamicCommandInstance> create(std::string const& name, std::string const& description, CommandPermissionLevel permission, CommandFlag flag, HMODULE handle = GetCurrentModule());
|
||||||
|
// LIAPI std::string const& setEnum(std::string const& description, std::vector<std::string> const& values);
|
||||||
|
// LIAPI std::string const& getEnumValue(int index) const;
|
||||||
|
// LIAPI ParameterIndex newParameter(DynamicCommand::ParameterData&& data);
|
||||||
|
// LIAPI ParameterIndex newParameter(std::string const& name, DynamicCommand::ParameterType type, bool optional = false, std::string const& description = "", std::string const& identifier = "", CommandParameterOption parameterOption = (CommandParameterOption)0);
|
||||||
|
// LIAPI ParameterIndex findParameterIndex(std::string const& param);
|
||||||
|
// LIAPI ParameterIndex mandatory(std::string const& name, DynamicCommand::ParameterType type, std::string const& description, std::string const& identifier, CommandParameterOption parameterOption = (CommandParameterOption)0);
|
||||||
|
// LIAPI ParameterIndex mandatory(std::string const& name, DynamicCommand::ParameterType type, std::string const& description, CommandParameterOption parameterOption = (CommandParameterOption)0);
|
||||||
|
// LIAPI ParameterIndex mandatory(std::string const& name, DynamicCommand::ParameterType type, CommandParameterOption parameterOption = CommandParameterOption::None);
|
||||||
|
// LIAPI ParameterIndex optional(std::string const& name, DynamicCommand::ParameterType type, std::string const& description, std::string const& identifier, CommandParameterOption parameterOption = (CommandParameterOption)0);
|
||||||
|
// LIAPI ParameterIndex optional(std::string const& name, DynamicCommand::ParameterType type, std::string const& description, CommandParameterOption parameterOption = (CommandParameterOption)0);
|
||||||
|
// LIAPI ParameterIndex optional(std::string const& name, DynamicCommand::ParameterType type, CommandParameterOption parameterOption = CommandParameterOption::None);
|
||||||
|
|
||||||
|
// // LIAPI bool addOverload();
|
||||||
|
// LIAPI bool addOverload(std::vector<ParameterIndex>&& params);
|
||||||
|
// LIAPI bool addOverload(std::vector<std::string>&& params);
|
||||||
|
// LIAPI bool addOverload(std::vector<char const*>&& params);
|
||||||
|
// LIAPI bool addOverload(std::vector<DynamicCommand::ParameterData>&& params);
|
||||||
|
// LIAPI bool setAlias(std::string const& alias);
|
||||||
|
// LIAPI void setCallback(DynamicCommand::CallBackFn&& callback) const;
|
||||||
|
// LIAPI void removeCallback() const;
|
||||||
|
// // LIAPI static bool updateSoftEnum(std::string const& name = "") const;
|
||||||
|
// LIAPI std::string setSoftEnum(std::string const& name, std::vector<std::string> const& values) const;
|
||||||
|
// LIAPI bool addSoftEnumValues(std::string const& name, std::vector<std::string> const& values) const;
|
||||||
|
// LIAPI bool removeSoftEnumValues(std::string const& name, std::vector<std::string> const& values) const;
|
||||||
|
// LIAPI static std::vector<std::string> getSoftEnumValues(std::string const& name);
|
||||||
|
// LIAPI static std::vector<std::string> getSoftEnumNames();
|
||||||
|
|
||||||
|
// template <typename T>
|
||||||
|
// inline std::enable_if_t<fmt::v8::detail::is_string<T>::value, ParameterIndex>
|
||||||
|
// toIndex(T const& arg) {
|
||||||
|
// return findParameterIndex(arg);
|
||||||
|
// }
|
||||||
|
// template <typename T>
|
||||||
|
// inline std::enable_if_t<!fmt::v8::detail::is_string<T>::value, ParameterIndex>
|
||||||
|
// toIndex(T const& arg) = delete;
|
||||||
|
// template <>
|
||||||
|
// inline ParameterIndex toIndex(ParameterIndex const& arg) {
|
||||||
|
// return arg;
|
||||||
|
// }
|
||||||
|
// template <>
|
||||||
|
// inline ParameterIndex toIndex(DynamicCommand::ParameterData const& arg) {
|
||||||
|
// return newParameter(DynamicCommand::ParameterData(arg));
|
||||||
|
// }
|
||||||
|
// template <typename... Args>
|
||||||
|
// inline bool addOverload(Args const&... args) {
|
||||||
|
// return addOverload(std::vector<ParameterIndex>{toIndex(args)...});
|
||||||
|
// }
|
||||||
|
|
||||||
|
// template <typename T>
|
||||||
|
// inline bool addOverload(std::initializer_list<T>&& params) {
|
||||||
|
// return addOverload((std::vector<T>)params);
|
||||||
|
// }
|
||||||
|
// LIAPI std::string const& getCommandName() const;
|
||||||
|
// inline ParameterIndex newParameter(std::string const& name, DynamicCommand::ParameterType type, const char* description, std::string const& identifier, CommandParameterOption parameterOption = (CommandParameterOption)0) {
|
||||||
|
// return newParameter(name, type, false, (std::string const&)description, identifier, parameterOption);
|
||||||
|
// };
|
||||||
|
// inline bool hasRegistered() const {
|
||||||
|
// return DynamicCommand::getInstance(getCommandName()) != nullptr;
|
||||||
|
// };
|
||||||
|
// inline void onExecute(DynamicCommand const& command, CommandOrigin const& origin, CommandOutput& output) const {
|
||||||
|
|
||||||
|
// };
|
||||||
|
// };
|
635
LiteLoader/Header/EventAPI.h
Normal file
635
LiteLoader/Header/EventAPI.h
Normal file
@ -0,0 +1,635 @@
|
|||||||
|
#pragma once
|
||||||
|
////////////////////////////////////////////////////////////////////////
|
||||||
|
// Event System - Make it easier to subscribe game events
|
||||||
|
//
|
||||||
|
// [Examples]
|
||||||
|
//
|
||||||
|
// Event::PlayerJoinEvent::subscribe([](const Event::PlayerJoinEvent& ev) { //Common situation - Const parameter "ev"
|
||||||
|
// ev.mPlayer->sendText("hello world~");
|
||||||
|
// return true;
|
||||||
|
// });
|
||||||
|
//
|
||||||
|
// Event::PlayerChatEvent::subscribe_ref([](Event::PlayerChatEvent& ev) { //Need to modify event's parameters - Reference parameter "ev"
|
||||||
|
// ev.mMessage = "[Plugin Modified] " + ev.mMessage;
|
||||||
|
// return true;
|
||||||
|
// });
|
||||||
|
//
|
||||||
|
// auto listener = Event::PlayerPickupItemEvent::subscribe([](const Event::PlayerPickupItemEvent& ev) {
|
||||||
|
// if(ev.mPlayer->getName() == "Jack")
|
||||||
|
// return false; //Prevent events to be done - return false
|
||||||
|
// else
|
||||||
|
// return true;
|
||||||
|
// });
|
||||||
|
// ......
|
||||||
|
// ......
|
||||||
|
// listener.remove(); //Remove this event listener
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
#include "Global.h"
|
||||||
|
#include "LoggerAPI.h"
|
||||||
|
#include "MC/BlockInstance.hpp"
|
||||||
|
#include "MC/MCRESULT.hpp"
|
||||||
|
#include <functional>
|
||||||
|
#include <iterator>
|
||||||
|
#include <list>
|
||||||
|
#include <string>
|
||||||
|
#include <unordered_map>
|
||||||
|
#include <LLAPI.h>
|
||||||
|
#include <Utils/WinHelper.h>
|
||||||
|
|
||||||
|
class Actor;
|
||||||
|
class ServerPlayer;
|
||||||
|
class Player;
|
||||||
|
class Block;
|
||||||
|
class Mob;
|
||||||
|
struct ActorDefinitionIdentifier;
|
||||||
|
class ItemStack;
|
||||||
|
class ActorDamageSource;
|
||||||
|
class Certificate;
|
||||||
|
class CommandRegistry;
|
||||||
|
class MobEffectInstance;
|
||||||
|
class Container;
|
||||||
|
class WitherBoss;
|
||||||
|
class ArmorStand;
|
||||||
|
class Objective;
|
||||||
|
struct ScoreboardId;
|
||||||
|
|
||||||
|
namespace Event {
|
||||||
|
///////////////////////////// Impl /////////////////////////////
|
||||||
|
|
||||||
|
constexpr bool Ok = true;
|
||||||
|
constexpr bool Cancel = false;
|
||||||
|
|
||||||
|
template <typename EVENT>
|
||||||
|
class EventManager {
|
||||||
|
public:
|
||||||
|
LIAPI static int addEventListener(std::string name, std::function<bool(EVENT)> callback);
|
||||||
|
LIAPI static int addEventListenerRef(std::string name, std::function<bool(EVENT&)> callback);
|
||||||
|
LIAPI static bool removeEventListener(int id);
|
||||||
|
LIAPI static bool hasListener();
|
||||||
|
LIAPI static bool call(EVENT& ev);
|
||||||
|
LIAPI static bool callToPlugin(std::string pluginName, EVENT& ev);
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename EVENT>
|
||||||
|
class EventListener {
|
||||||
|
private:
|
||||||
|
int listenerId;
|
||||||
|
bool deleted = false;
|
||||||
|
|
||||||
|
public:
|
||||||
|
EventListener(int id)
|
||||||
|
: listenerId(id) {
|
||||||
|
}
|
||||||
|
|
||||||
|
void remove() {
|
||||||
|
if (!deleted) {
|
||||||
|
deleted = true;
|
||||||
|
EventManager<EVENT>::removeEventListener(listenerId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename EVENT>
|
||||||
|
class EventTemplate {
|
||||||
|
public:
|
||||||
|
static EventListener<EVENT> subscribe(std::function<bool(EVENT)> callback) {
|
||||||
|
auto plugin = LL::getPlugin(GetCurrentModule());
|
||||||
|
return EventListener<EVENT>(EventManager<EVENT>::addEventListener(plugin ? plugin->name : "", callback));
|
||||||
|
}
|
||||||
|
|
||||||
|
static EventListener<EVENT> subscribe_ref(std::function<bool(EVENT&)> callback) {
|
||||||
|
auto plugin = LL::getPlugin(GetCurrentModule());
|
||||||
|
return EventListener<EVENT>(EventManager<EVENT>::addEventListenerRef(plugin ? plugin->name : "", callback));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void unsubscribe(const EventListener<EVENT>& listener) {
|
||||||
|
listener.remove();
|
||||||
|
}
|
||||||
|
static bool hasListener() {
|
||||||
|
return EventManager<EVENT>::hasListener();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool call() {
|
||||||
|
return EventManager<EVENT>::call(*(EVENT*)this);
|
||||||
|
}
|
||||||
|
bool callToPlugin(std::string pluginName) {
|
||||||
|
return EventManager<EVENT>::callToPlugin(pluginName, *(EVENT*)this);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
////////////////////// For compatibility DO NOT UPDATE //////////////////////
|
||||||
|
protected:
|
||||||
|
friend class EventManager<EVENT>;
|
||||||
|
LIAPI static std::list<std::pair<string, std::function<bool(const EVENT&)>>> listeners;
|
||||||
|
LIAPI static std::list<std::pair<string, std::function<bool(EVENT&)>>> listenersNoConst;
|
||||||
|
////////////////////// For compatibility DO NOT UPDATE //////////////////////
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
///////////////////////////// Player Events /////////////////////////////
|
||||||
|
|
||||||
|
class PlayerPreJoinEvent : public EventTemplate<PlayerPreJoinEvent> {
|
||||||
|
public:
|
||||||
|
Player* mPlayer;
|
||||||
|
string mIP;
|
||||||
|
string mXUID;
|
||||||
|
};
|
||||||
|
|
||||||
|
class PlayerJoinEvent : public EventTemplate<PlayerJoinEvent> {
|
||||||
|
public:
|
||||||
|
Player* mPlayer;
|
||||||
|
};
|
||||||
|
|
||||||
|
class PlayerLeftEvent : public EventTemplate<PlayerLeftEvent> {
|
||||||
|
public:
|
||||||
|
Player* mPlayer;
|
||||||
|
string mXUID;
|
||||||
|
};
|
||||||
|
|
||||||
|
class PlayerRespawnEvent : public EventTemplate<PlayerRespawnEvent> {
|
||||||
|
public:
|
||||||
|
Player* mPlayer;
|
||||||
|
};
|
||||||
|
|
||||||
|
class PlayerUseItemEvent : public EventTemplate<PlayerUseItemEvent> {
|
||||||
|
public:
|
||||||
|
Player* mPlayer;
|
||||||
|
ItemStack* mItemStack;
|
||||||
|
};
|
||||||
|
|
||||||
|
class PlayerUseItemOnEvent : public EventTemplate<PlayerUseItemOnEvent> {
|
||||||
|
public:
|
||||||
|
Player* mPlayer;
|
||||||
|
ItemStack* mItemStack;
|
||||||
|
BlockInstance mBlockInstance;
|
||||||
|
unsigned char mFace;
|
||||||
|
Vec3 mClickPos;
|
||||||
|
};
|
||||||
|
|
||||||
|
class PlayerChatEvent : public EventTemplate<PlayerChatEvent> {
|
||||||
|
public:
|
||||||
|
Player* mPlayer;
|
||||||
|
string mMessage;
|
||||||
|
};
|
||||||
|
|
||||||
|
class PlayerChangeDimEvent : public EventTemplate<PlayerChangeDimEvent> {
|
||||||
|
public:
|
||||||
|
Player* mPlayer;
|
||||||
|
int mToDimensionId;
|
||||||
|
};
|
||||||
|
|
||||||
|
class PlayerJumpEvent : public EventTemplate<PlayerJumpEvent> {
|
||||||
|
public:
|
||||||
|
Player* mPlayer;
|
||||||
|
};
|
||||||
|
|
||||||
|
class PlayerSneakEvent : public EventTemplate<PlayerSneakEvent> {
|
||||||
|
public:
|
||||||
|
Player* mPlayer;
|
||||||
|
bool mIsSneaking;
|
||||||
|
};
|
||||||
|
|
||||||
|
class PlayerAttackEvent : public EventTemplate<PlayerAttackEvent> {
|
||||||
|
public:
|
||||||
|
Player* mPlayer;
|
||||||
|
Actor* mTarget;
|
||||||
|
int mAttackDamage;
|
||||||
|
};
|
||||||
|
|
||||||
|
class PlayerAttackBlockEvent : public EventTemplate<PlayerAttackBlockEvent> {
|
||||||
|
public:
|
||||||
|
Player* mPlayer;
|
||||||
|
ItemStack* mItemStack;
|
||||||
|
BlockInstance mBlockInstance;
|
||||||
|
};
|
||||||
|
|
||||||
|
class PlayerDieEvent : public EventTemplate<PlayerDieEvent> {
|
||||||
|
public:
|
||||||
|
Player* mPlayer;
|
||||||
|
ActorDamageSource* mDamageSource;
|
||||||
|
};
|
||||||
|
|
||||||
|
class PlayerPickupItemEvent : public EventTemplate<PlayerPickupItemEvent> {
|
||||||
|
public:
|
||||||
|
Player* mPlayer;
|
||||||
|
Actor* mItemEntity;
|
||||||
|
ItemStack* mItemStack;
|
||||||
|
};
|
||||||
|
|
||||||
|
class PlayerDropItemEvent : public EventTemplate<PlayerDropItemEvent> {
|
||||||
|
public:
|
||||||
|
Player* mPlayer;
|
||||||
|
ItemStack* mItemStack;
|
||||||
|
};
|
||||||
|
|
||||||
|
class PlayerEatEvent : public EventTemplate<PlayerEatEvent> {
|
||||||
|
public:
|
||||||
|
Player* mPlayer;
|
||||||
|
ItemStack* mFoodItem;
|
||||||
|
};
|
||||||
|
|
||||||
|
class PlayerConsumeTotemEvent : public EventTemplate<PlayerConsumeTotemEvent> {
|
||||||
|
public:
|
||||||
|
Player* mPlayer;
|
||||||
|
};
|
||||||
|
|
||||||
|
class PlayerCmdEvent : public EventTemplate<PlayerCmdEvent> {
|
||||||
|
public:
|
||||||
|
Player* mPlayer;
|
||||||
|
string mCommand;
|
||||||
|
MCRESULT* mResult;
|
||||||
|
};
|
||||||
|
|
||||||
|
class PlayerEffectChangedEvent : public EventTemplate<PlayerEffectChangedEvent> {
|
||||||
|
public:
|
||||||
|
enum class EventType {
|
||||||
|
Add,
|
||||||
|
Remove,
|
||||||
|
Update
|
||||||
|
};
|
||||||
|
Player* mPlayer;
|
||||||
|
EventType mEventType;
|
||||||
|
MobEffectInstance* mEffect;
|
||||||
|
};
|
||||||
|
|
||||||
|
class PlayerStartDestroyBlockEvent : public EventTemplate<PlayerStartDestroyBlockEvent> {
|
||||||
|
public:
|
||||||
|
Player* mPlayer;
|
||||||
|
BlockInstance mBlockInstance;
|
||||||
|
};
|
||||||
|
|
||||||
|
class PlayerDestroyBlockEvent : public EventTemplate<PlayerDestroyBlockEvent> {
|
||||||
|
public:
|
||||||
|
Player* mPlayer;
|
||||||
|
BlockInstance mBlockInstance;
|
||||||
|
};
|
||||||
|
|
||||||
|
class PlayerPlaceBlockEvent : public EventTemplate<PlayerPlaceBlockEvent> {
|
||||||
|
public:
|
||||||
|
Player* mPlayer;
|
||||||
|
BlockInstance mBlockInstance;
|
||||||
|
};
|
||||||
|
|
||||||
|
class BlockPlacedByPlayerEvent : public EventTemplate<BlockPlacedByPlayerEvent> {
|
||||||
|
public:
|
||||||
|
Player* mPlayer;
|
||||||
|
BlockInstance mBlockInstance;
|
||||||
|
};
|
||||||
|
|
||||||
|
class PlayerOpenContainerEvent : public EventTemplate<PlayerOpenContainerEvent> {
|
||||||
|
public:
|
||||||
|
Player* mPlayer;
|
||||||
|
BlockInstance mBlockInstance;
|
||||||
|
Container* mContainer;
|
||||||
|
};
|
||||||
|
|
||||||
|
class PlayerCloseContainerEvent : public EventTemplate<PlayerCloseContainerEvent> {
|
||||||
|
public:
|
||||||
|
Player* mPlayer;
|
||||||
|
BlockInstance mBlockInstance;
|
||||||
|
Container* mContainer;
|
||||||
|
};
|
||||||
|
|
||||||
|
class PlayerInventoryChangeEvent : public EventTemplate<PlayerInventoryChangeEvent> {
|
||||||
|
public:
|
||||||
|
Player* mPlayer;
|
||||||
|
int mSlot;
|
||||||
|
ItemStack* mPreviousItemStack;
|
||||||
|
ItemStack* mNewItemStack;
|
||||||
|
};
|
||||||
|
|
||||||
|
class PlayerMoveEvent : public EventTemplate<PlayerMoveEvent> {
|
||||||
|
public:
|
||||||
|
Player* mPlayer;
|
||||||
|
Vec3 mPos;
|
||||||
|
};
|
||||||
|
|
||||||
|
class PlayerSprintEvent : public EventTemplate<PlayerSprintEvent> {
|
||||||
|
public:
|
||||||
|
Player* mPlayer;
|
||||||
|
bool mIsSprinting;
|
||||||
|
};
|
||||||
|
|
||||||
|
class PlayerSetArmorEvent : public EventTemplate<PlayerSetArmorEvent> {
|
||||||
|
public:
|
||||||
|
Player* mPlayer;
|
||||||
|
int mSlot;
|
||||||
|
ItemStack* mArmorItem;
|
||||||
|
};
|
||||||
|
|
||||||
|
class PlayerUseRespawnAnchorEvent : public EventTemplate<PlayerUseRespawnAnchorEvent> {
|
||||||
|
public:
|
||||||
|
Player* mPlayer;
|
||||||
|
BlockInstance mBlockInstance;
|
||||||
|
};
|
||||||
|
|
||||||
|
class PlayerOpenContainerScreenEvent : public EventTemplate<PlayerOpenContainerScreenEvent> {
|
||||||
|
public:
|
||||||
|
Player* mPlayer;
|
||||||
|
};
|
||||||
|
|
||||||
|
class PlayerUseFrameBlockEvent : public EventTemplate<PlayerUseFrameBlockEvent> {
|
||||||
|
public:
|
||||||
|
enum class Type {
|
||||||
|
Use,
|
||||||
|
Attack
|
||||||
|
};
|
||||||
|
Type mType;
|
||||||
|
Player* mPlayer;
|
||||||
|
BlockInstance mBlockInstance;
|
||||||
|
};
|
||||||
|
|
||||||
|
class PlayerScoreChangedEvent : public EventTemplate<PlayerScoreChangedEvent> {
|
||||||
|
public:
|
||||||
|
Player* mPlayer;
|
||||||
|
int mScore;
|
||||||
|
Objective* mObjective;
|
||||||
|
ScoreboardId* mScoreboardId;
|
||||||
|
};
|
||||||
|
|
||||||
|
class PlayerExperienceAddEvent : public EventTemplate<PlayerExperienceAddEvent> {
|
||||||
|
public:
|
||||||
|
Player* mPlayer;
|
||||||
|
int mExp;
|
||||||
|
};
|
||||||
|
|
||||||
|
class PlayerInteractEntityEvent : public EventTemplate<PlayerInteractEntityEvent> {
|
||||||
|
public:
|
||||||
|
enum class InteractiveMode {
|
||||||
|
RightClick,
|
||||||
|
LeftClick
|
||||||
|
};
|
||||||
|
|
||||||
|
ServerPlayer* mPlayer;
|
||||||
|
ActorRuntimeID mTargetId;
|
||||||
|
InteractiveMode mInteractiveMode;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
///////////////////////////// Block Events /////////////////////////////
|
||||||
|
|
||||||
|
class BlockInteractedEvent : public EventTemplate<BlockInteractedEvent> {
|
||||||
|
public:
|
||||||
|
BlockInstance mBlockInstance;
|
||||||
|
Player* mPlayer;
|
||||||
|
};
|
||||||
|
|
||||||
|
class BlockChangedEvent : public EventTemplate<BlockChangedEvent> {
|
||||||
|
public:
|
||||||
|
BlockInstance mPreviousBlockInstance;
|
||||||
|
BlockInstance mNewBlockInstance;
|
||||||
|
};
|
||||||
|
|
||||||
|
class BlockExplodedEvent : public EventTemplate<BlockExplodedEvent> {
|
||||||
|
public:
|
||||||
|
BlockInstance mBlockInstance;
|
||||||
|
Actor* mExplodeSource;
|
||||||
|
};
|
||||||
|
|
||||||
|
class FireSpreadEvent : public EventTemplate<FireSpreadEvent> {
|
||||||
|
public:
|
||||||
|
BlockPos mTarget;
|
||||||
|
int mDimensionId;
|
||||||
|
};
|
||||||
|
|
||||||
|
class ContainerChangeEvent : public EventTemplate<ContainerChangeEvent> {
|
||||||
|
public:
|
||||||
|
Player* mPlayer;
|
||||||
|
Actor* mActor;
|
||||||
|
BlockInstance mBlockInstance;
|
||||||
|
Container* mContainer;
|
||||||
|
int mSlot;
|
||||||
|
ItemStack* mPreviousItemStack;
|
||||||
|
ItemStack* mNewItemStack;
|
||||||
|
};
|
||||||
|
|
||||||
|
class ProjectileHitBlockEvent : public EventTemplate<ProjectileHitBlockEvent> {
|
||||||
|
public:
|
||||||
|
BlockInstance mBlockInstance;
|
||||||
|
Actor* mSource;
|
||||||
|
};
|
||||||
|
|
||||||
|
class RedStoneUpdateEvent : public EventTemplate<RedStoneUpdateEvent> {
|
||||||
|
public:
|
||||||
|
BlockInstance mBlockInstance;
|
||||||
|
int mRedStonePower;
|
||||||
|
bool mIsActivated;
|
||||||
|
};
|
||||||
|
|
||||||
|
class HopperSearchItemEvent : public EventTemplate<HopperSearchItemEvent> {
|
||||||
|
public:
|
||||||
|
bool isMinecart;
|
||||||
|
BlockInstance mHopperBlock;
|
||||||
|
Vec3 mMinecartPos;
|
||||||
|
int mDimensionId;
|
||||||
|
};
|
||||||
|
|
||||||
|
class HopperPushOutEvent : public EventTemplate<HopperPushOutEvent> {
|
||||||
|
public:
|
||||||
|
Vec3 mPos;
|
||||||
|
int mDimensionId;
|
||||||
|
};
|
||||||
|
|
||||||
|
class PistonTryPushEvent : public EventTemplate<PistonTryPushEvent> {
|
||||||
|
public:
|
||||||
|
BlockInstance mPistonBlockInstance;
|
||||||
|
BlockInstance mTargetBlockInstance;
|
||||||
|
};
|
||||||
|
|
||||||
|
class PistonPushEvent : public EventTemplate<PistonPushEvent> {
|
||||||
|
public:
|
||||||
|
BlockInstance mPistonBlockInstance;
|
||||||
|
BlockInstance mTargetBlockInstance;
|
||||||
|
};
|
||||||
|
|
||||||
|
class FarmLandDecayEvent : public EventTemplate<FarmLandDecayEvent> {
|
||||||
|
public:
|
||||||
|
BlockInstance mBlockInstance;
|
||||||
|
Actor* mActor;
|
||||||
|
};
|
||||||
|
|
||||||
|
class LiquidSpreadEvent : public EventTemplate<LiquidSpreadEvent> {
|
||||||
|
public:
|
||||||
|
BlockInstance mBlockInstance;
|
||||||
|
BlockPos mTarget;
|
||||||
|
int mDimensionId;
|
||||||
|
};
|
||||||
|
|
||||||
|
class CmdBlockExecuteEvent : public EventTemplate<CmdBlockExecuteEvent> {
|
||||||
|
public:
|
||||||
|
string mCommand;
|
||||||
|
bool mIsMinecart;
|
||||||
|
BlockInstance mBlockInstance;
|
||||||
|
Actor* mMinecart;
|
||||||
|
};
|
||||||
|
|
||||||
|
class BlockExplodeEvent : public EventTemplate<BlockExplodeEvent> {
|
||||||
|
public:
|
||||||
|
BlockInstance mBlockInstance;
|
||||||
|
float mRadius;
|
||||||
|
float mMaxResistance;
|
||||||
|
bool mBreaking;
|
||||||
|
bool mFire;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
///////////////////////////// Entity Events /////////////////////////////
|
||||||
|
|
||||||
|
class EntityExplodeEvent : public EventTemplate<EntityExplodeEvent> {
|
||||||
|
public:
|
||||||
|
Actor* mActor;
|
||||||
|
Vec3 mPos;
|
||||||
|
BlockSource* mDimension;
|
||||||
|
float mRadius;
|
||||||
|
float mMaxResistance;
|
||||||
|
bool mBreaking;
|
||||||
|
bool mFire;
|
||||||
|
};
|
||||||
|
|
||||||
|
class MobHurtEvent : public EventTemplate<MobHurtEvent> {
|
||||||
|
public:
|
||||||
|
Mob* mMob;
|
||||||
|
ActorDamageSource* mDamageSource;
|
||||||
|
float mDamage;
|
||||||
|
};
|
||||||
|
|
||||||
|
class MobDieEvent : public EventTemplate<MobDieEvent> {
|
||||||
|
public:
|
||||||
|
Mob* mMob;
|
||||||
|
ActorDamageSource* mDamageSource;
|
||||||
|
};
|
||||||
|
|
||||||
|
class ProjectileHitEntityEvent : public EventTemplate<ProjectileHitEntityEvent> {
|
||||||
|
public:
|
||||||
|
Actor* mTarget;
|
||||||
|
Actor* mSource;
|
||||||
|
};
|
||||||
|
|
||||||
|
class WitherBossDestroyEvent : public EventTemplate<WitherBossDestroyEvent> {
|
||||||
|
public:
|
||||||
|
WitherBoss* mWitherBoss;
|
||||||
|
AABB mDestroyRange = {{}, {}};
|
||||||
|
};
|
||||||
|
|
||||||
|
class EntityRideEvent : public EventTemplate<EntityRideEvent> {
|
||||||
|
public:
|
||||||
|
Actor* mRider;
|
||||||
|
Actor* mVehicle;
|
||||||
|
};
|
||||||
|
|
||||||
|
class EntityStepOnPressurePlateEvent : public EventTemplate<EntityStepOnPressurePlateEvent> {
|
||||||
|
public:
|
||||||
|
Actor* mActor;
|
||||||
|
BlockInstance mBlockInstance;
|
||||||
|
};
|
||||||
|
|
||||||
|
class NpcCmdEvent : public EventTemplate<NpcCmdEvent> {
|
||||||
|
public:
|
||||||
|
Actor* mNpc;
|
||||||
|
std::string mCommand;
|
||||||
|
Player* mPlayer;
|
||||||
|
};
|
||||||
|
|
||||||
|
class ProjectileSpawnEvent : public EventTemplate<ProjectileSpawnEvent> {
|
||||||
|
public:
|
||||||
|
Actor* mShooter;
|
||||||
|
ActorDefinitionIdentifier* mIdentifier;
|
||||||
|
std::string mType;
|
||||||
|
};
|
||||||
|
|
||||||
|
class ProjectileCreatedEvent : public EventTemplate<ProjectileCreatedEvent> {
|
||||||
|
public:
|
||||||
|
Actor* mShooter;
|
||||||
|
Actor* mProjectile;
|
||||||
|
};
|
||||||
|
|
||||||
|
class ArmorStandChangeEvent : public EventTemplate<ArmorStandChangeEvent> {
|
||||||
|
public:
|
||||||
|
ArmorStand* mArmorStand;
|
||||||
|
Player* mPlayer;
|
||||||
|
int mSlot;
|
||||||
|
};
|
||||||
|
|
||||||
|
class EntityTransformEvent : public EventTemplate<EntityTransformEvent> {
|
||||||
|
public:
|
||||||
|
ActorUniqueID* mBeforeEntityUniqueId;
|
||||||
|
Actor* mAfterEntity;
|
||||||
|
};
|
||||||
|
|
||||||
|
///////////////////////////// Other Events /////////////////////////////
|
||||||
|
|
||||||
|
class PostInitEvent : public EventTemplate<PostInitEvent> {
|
||||||
|
};
|
||||||
|
|
||||||
|
class ServerStartedEvent : public EventTemplate<ServerStartedEvent> {
|
||||||
|
};
|
||||||
|
|
||||||
|
class ServerStoppedEvent : public EventTemplate<ServerStoppedEvent> {
|
||||||
|
};
|
||||||
|
|
||||||
|
class ConsoleCmdEvent : public EventTemplate<ConsoleCmdEvent> {
|
||||||
|
public:
|
||||||
|
std::string mCommand;
|
||||||
|
};
|
||||||
|
|
||||||
|
class RegCmdEvent : public EventTemplate<RegCmdEvent> {
|
||||||
|
public:
|
||||||
|
CommandRegistry* mCommandRegistry;
|
||||||
|
};
|
||||||
|
|
||||||
|
class ConsoleOutputEvent : public EventTemplate<ConsoleOutputEvent> {
|
||||||
|
public:
|
||||||
|
std::string mOutput;
|
||||||
|
};
|
||||||
|
|
||||||
|
class PlayerBedEnterEvent : public EventTemplate<PlayerBedEnterEvent> {
|
||||||
|
public:
|
||||||
|
Player* mPlayer;
|
||||||
|
BlockInstance* mBlockInstance;
|
||||||
|
};
|
||||||
|
|
||||||
|
class ScriptPluginManagerEvent : public EventTemplate<ScriptPluginManagerEvent> {
|
||||||
|
public:
|
||||||
|
enum class Operation {
|
||||||
|
Load,
|
||||||
|
Unload,
|
||||||
|
Reload
|
||||||
|
};
|
||||||
|
enum class PluginType {
|
||||||
|
SingleFile, // like .js / .lua
|
||||||
|
PluginPackage, // like .llplugin
|
||||||
|
UncompressedPackage // like plugins/nodejs/ABC
|
||||||
|
};
|
||||||
|
|
||||||
|
Operation operation;
|
||||||
|
std::string target;
|
||||||
|
std::string otherInfo;
|
||||||
|
std::string pluginExtention;
|
||||||
|
|
||||||
|
bool success = false;
|
||||||
|
PluginType pluginType;
|
||||||
|
};
|
||||||
|
|
||||||
|
class MobSpawnEvent : public EventTemplate<MobSpawnEvent> {
|
||||||
|
public:
|
||||||
|
string mTypeName;
|
||||||
|
Vec3 mPos;
|
||||||
|
int mDimensionId;
|
||||||
|
};
|
||||||
|
|
||||||
|
class FormResponsePacketEvent : public EventTemplate<FormResponsePacketEvent> {
|
||||||
|
public:
|
||||||
|
ServerPlayer* mServerPlayer;
|
||||||
|
unsigned mFormId;
|
||||||
|
string mJsonData;
|
||||||
|
};
|
||||||
|
|
||||||
|
class ResourcePackInitEvent : public EventTemplate<ResourcePackInitEvent> {
|
||||||
|
public:
|
||||||
|
ResourcePackRepository* mRepo;
|
||||||
|
};
|
||||||
|
|
||||||
|
}; // namespace Event
|
446
LiteLoader/Header/FormUI.h
Normal file
446
LiteLoader/Header/FormUI.h
Normal file
@ -0,0 +1,446 @@
|
|||||||
|
#pragma once
|
||||||
|
////////////////////////////////////////////////////////////////////////
|
||||||
|
// Form UI Utility - Help you to build forms and options more easily
|
||||||
|
//
|
||||||
|
// [Example - Simple Form]
|
||||||
|
// - Form that contains several buttons (with optional image)
|
||||||
|
// - Let the player choose an option from multiple options
|
||||||
|
//
|
||||||
|
// SimpleForm form("Welcome to shop", "Choose what you want to do..."); // Initialize the form with title and content
|
||||||
|
// form.addButton("Buy", "textures/items/apple", // Add a button "Buy" with texture image
|
||||||
|
// [](Player* pl) { pl->sendText("To buy something..."); }) // Buy's callback function
|
||||||
|
//
|
||||||
|
// .addButton("Sell", "https://xxx.com/xxx.png", // Add a button "Sell" with online image
|
||||||
|
// [](Player* pl) { pl->sendText("To sell something..."); }) // Sell's callback function
|
||||||
|
//
|
||||||
|
// .addButton("Settings", "", // Add a button "Settings" with no image
|
||||||
|
// [](Player* pl) { pl->sendText("Get into settings..."); }) // Settings's callback function
|
||||||
|
//
|
||||||
|
// .addButton("Exit") // Add a single button "Exit"
|
||||||
|
// .sendTo(Level::getPlayer("John")); // Send the form to a player called "John"
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// [Example - Modal Form]
|
||||||
|
// - Form with Confirm and Cancel buttons
|
||||||
|
// - Let the player confirm or cancel an action
|
||||||
|
//
|
||||||
|
// ModalForm form("Confirm the action", "Do you want that?", "Yes", "Nope"); // Initialize the form with title, content and two buttons ("Yes", "Nope")
|
||||||
|
// form.sendTo(Level::getPlayer("S3v3N1ce"), // Send the form to a player called "S3v3N1ce"
|
||||||
|
// [](Player* player, bool isConfirm) // Callback function to process the result
|
||||||
|
// {
|
||||||
|
// if (isConfirm) // Player pressed button "Yes"
|
||||||
|
// player->sendText("Okay, let's go");
|
||||||
|
// else // Player pressed button "Nope"
|
||||||
|
// player->sendText("Hm, suit yourself");
|
||||||
|
// });
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// [Example - Custom Form]
|
||||||
|
// - Form that contains some kinds of elements (like input line, toggle, dropdown, ....)
|
||||||
|
// - Let the player provide some detailed information
|
||||||
|
//
|
||||||
|
// CustomForm form2("Information Collection Form"); // Initialize the form with title
|
||||||
|
// form2.addLabel("label1", "Personal Information") // Add a label shows "Personal Information"
|
||||||
|
// .addInput("username", "Your Name") // Add an input line to gather player's name
|
||||||
|
// .addDropdown("sex", "Your Sex", { "Male","Female","Secret" }) // Add a dropdown to gather player's sex
|
||||||
|
// .addSlider("age", "Your Age", 3, 100) // Add a slider to gather player's age
|
||||||
|
//
|
||||||
|
// .addLabel("label2", "MC Information") // Add a label shows "MC Information"
|
||||||
|
// .addToggle("licensed", "Purchased a licensed Minecraft?", true) // Add a toggle about whether he buys a licensed mc or not
|
||||||
|
// .addStepSlider("skill", "Skill Lvl", { "Beginner", "Amateur", "Pro" }) // Add a step slider shows his game skill level
|
||||||
|
//
|
||||||
|
// .sendTo(Level::getPlayer("yqs112358"), // Send the form to a player called "yqs112358"
|
||||||
|
// [](Player* player, auto result) // Callback function to process the result
|
||||||
|
// {
|
||||||
|
// if (result.empty()) // Player cancelled the form
|
||||||
|
// return;
|
||||||
|
// player->sendText("You have commited the form.");
|
||||||
|
// player->sendFormattedText("Your name: {}", result["username"]->getString());
|
||||||
|
// player->sendFormattedText("Your sex: {}", result["sex"]->getString());
|
||||||
|
// player->sendFormattedText("Your age: {}", result["age"]->getNumber());
|
||||||
|
// player->sendFormattedText("Your license: {}", result["licensed"]->getBool() ? "yes" : "no");
|
||||||
|
// player->sendFormattedText("Your skill level: {}:", result["skill"]->getString());
|
||||||
|
// });
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// Tips: The <key> of std::map "result" equals the first argument "name" you pass to these elements
|
||||||
|
// So, "name" must be *unique* or error will occur
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
#include <utility>
|
||||||
|
#include "Global.h"
|
||||||
|
|
||||||
|
class ServerPlayer;
|
||||||
|
class Player;
|
||||||
|
|
||||||
|
|
||||||
|
namespace Form {
|
||||||
|
//////////////////////////////// Simple Form Elements ////////////////////////////////
|
||||||
|
class SimpleFormElement {
|
||||||
|
protected:
|
||||||
|
virtual string serialize() = 0;
|
||||||
|
friend class SimpleForm;
|
||||||
|
};
|
||||||
|
|
||||||
|
class Button : public SimpleFormElement {
|
||||||
|
protected:
|
||||||
|
LIAPI string serialize() override;
|
||||||
|
|
||||||
|
public:
|
||||||
|
using ButtonCallback = std::function<void(Player*)>;
|
||||||
|
string text, image;
|
||||||
|
ButtonCallback callback;
|
||||||
|
|
||||||
|
public:
|
||||||
|
inline explicit Button(string text, string image = "", ButtonCallback callback = ButtonCallback())
|
||||||
|
: text(std::move(text))
|
||||||
|
, image(std::move(image))
|
||||||
|
, callback(std::move(callback)) {
|
||||||
|
}
|
||||||
|
inline void setText(const string& _text) {
|
||||||
|
this->text = _text;
|
||||||
|
}
|
||||||
|
inline void setImage(const string& _image) {
|
||||||
|
this->image = _image;
|
||||||
|
}
|
||||||
|
inline void setCallback(ButtonCallback _callback) {
|
||||||
|
this->callback = std::move(_callback);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
//////////////////////////////// Custom Form Elements ////////////////////////////////
|
||||||
|
class CustomFormElement {
|
||||||
|
protected:
|
||||||
|
LIAPI virtual string serialize() = 0;
|
||||||
|
friend class CustomForm;
|
||||||
|
|
||||||
|
public:
|
||||||
|
enum class Type {
|
||||||
|
Label,
|
||||||
|
Input,
|
||||||
|
Toggle,
|
||||||
|
Dropdown,
|
||||||
|
Slider,
|
||||||
|
StepSlider
|
||||||
|
};
|
||||||
|
string name;
|
||||||
|
string value;
|
||||||
|
Type type{};
|
||||||
|
inline void setName(const string& _name) {
|
||||||
|
this->name = _name;
|
||||||
|
}
|
||||||
|
inline virtual Type getType() = 0;
|
||||||
|
LIAPI std::string getString();
|
||||||
|
[[deprecated("Please use getInt")]]
|
||||||
|
LIAPI int getNumber();
|
||||||
|
LIAPI int getInt();
|
||||||
|
LIAPI float getFloat();
|
||||||
|
LIAPI double getDouble();
|
||||||
|
LIAPI bool getBool();
|
||||||
|
};
|
||||||
|
|
||||||
|
class Label : public CustomFormElement {
|
||||||
|
protected:
|
||||||
|
LIAPI string serialize() override;
|
||||||
|
|
||||||
|
public:
|
||||||
|
string text;
|
||||||
|
|
||||||
|
public:
|
||||||
|
inline Label(const string& name, string text)
|
||||||
|
: text(std::move(text)) {
|
||||||
|
setName(name);
|
||||||
|
}
|
||||||
|
inline Type getType() override {
|
||||||
|
return Type::Label;
|
||||||
|
}
|
||||||
|
inline void setText(const string& _text) {
|
||||||
|
this->text = _text;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
class Input : public CustomFormElement {
|
||||||
|
protected:
|
||||||
|
LIAPI string serialize() override;
|
||||||
|
|
||||||
|
public:
|
||||||
|
string title, placeholder, def;
|
||||||
|
inline Input(const string& name, string title, string placeholder = "", string def = "")
|
||||||
|
: title(std::move(title))
|
||||||
|
, placeholder(std::move(placeholder))
|
||||||
|
, def(std::move(def)) {
|
||||||
|
setName(name);
|
||||||
|
}
|
||||||
|
inline Type getType() override {
|
||||||
|
return Type::Input;
|
||||||
|
}
|
||||||
|
inline void setTitle(const string& _title) {
|
||||||
|
this->title = _title;
|
||||||
|
}
|
||||||
|
inline void setPlaceHolder(const string& _placeholder) {
|
||||||
|
this->placeholder = _placeholder;
|
||||||
|
}
|
||||||
|
inline void setDefault(const string& _def) {
|
||||||
|
this->def = _def;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
class Toggle : public CustomFormElement {
|
||||||
|
protected:
|
||||||
|
LIAPI string serialize() override;
|
||||||
|
|
||||||
|
public:
|
||||||
|
public:
|
||||||
|
string title;
|
||||||
|
bool def;
|
||||||
|
|
||||||
|
public:
|
||||||
|
inline Toggle(const string& name, string title, bool def = false)
|
||||||
|
: title(std::move(title))
|
||||||
|
, def(def) {
|
||||||
|
setName(name);
|
||||||
|
}
|
||||||
|
inline virtual Type getType() override {
|
||||||
|
return Type::Toggle;
|
||||||
|
}
|
||||||
|
inline void setTitle(const string& _title) {
|
||||||
|
this->title = _title;
|
||||||
|
}
|
||||||
|
inline void setDefault(bool _def) {
|
||||||
|
this->def = _def;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
class Dropdown : public CustomFormElement {
|
||||||
|
protected:
|
||||||
|
LIAPI string serialize() override;
|
||||||
|
|
||||||
|
public:
|
||||||
|
string title;
|
||||||
|
vector<string> options;
|
||||||
|
int def;
|
||||||
|
|
||||||
|
public:
|
||||||
|
inline Dropdown(const string& name, string title, const vector<string>& options, int defId = 0)
|
||||||
|
: title(std::move(title))
|
||||||
|
, options(options)
|
||||||
|
, def(defId) {
|
||||||
|
setName(name);
|
||||||
|
}
|
||||||
|
inline Type getType() override {
|
||||||
|
return Type::Dropdown;
|
||||||
|
}
|
||||||
|
inline void setTitle(const string& _title) {
|
||||||
|
this->title = _title;
|
||||||
|
}
|
||||||
|
inline void setOptions(const vector<string>& _options) {
|
||||||
|
this->options = _options;
|
||||||
|
}
|
||||||
|
inline void addOption(const string& option) {
|
||||||
|
options.push_back(option);
|
||||||
|
}
|
||||||
|
inline void setDefault(int defId) {
|
||||||
|
this->def = defId;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
class Slider : public CustomFormElement {
|
||||||
|
protected:
|
||||||
|
LIAPI string serialize() override;
|
||||||
|
|
||||||
|
public:
|
||||||
|
string title;
|
||||||
|
double minValue, maxValue, step, def;
|
||||||
|
|
||||||
|
public:
|
||||||
|
inline Slider(const string& name, string title, double minValue, double maxValue, double step = 1, double def = 0)
|
||||||
|
: title(std::move(title))
|
||||||
|
, minValue(minValue)
|
||||||
|
, maxValue(maxValue)
|
||||||
|
, step(step)
|
||||||
|
, def(def) {
|
||||||
|
setName(name);
|
||||||
|
}
|
||||||
|
inline Type getType() override {
|
||||||
|
return Type::Slider;
|
||||||
|
}
|
||||||
|
inline void setTitle(const string& _title) {
|
||||||
|
this->title = _title;
|
||||||
|
}
|
||||||
|
inline void setMin(double _minValue) {
|
||||||
|
this->minValue = _minValue;
|
||||||
|
}
|
||||||
|
inline void setMax(double _maxValue) {
|
||||||
|
this->maxValue = _maxValue;
|
||||||
|
}
|
||||||
|
inline void setStep(double _step) {
|
||||||
|
this->step = _step;
|
||||||
|
}
|
||||||
|
inline void setDefault(double _def) {
|
||||||
|
this->def = _def;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
class StepSlider : public CustomFormElement {
|
||||||
|
protected:
|
||||||
|
LIAPI string serialize() override;
|
||||||
|
|
||||||
|
public:
|
||||||
|
string title;
|
||||||
|
vector<string> options;
|
||||||
|
int def;
|
||||||
|
|
||||||
|
public:
|
||||||
|
inline StepSlider(const string& name, string title, const vector<string>& options, int defId = 0)
|
||||||
|
: title(std::move(title))
|
||||||
|
, options(options)
|
||||||
|
, def(defId) {
|
||||||
|
setName(name);
|
||||||
|
}
|
||||||
|
inline Type getType() override {
|
||||||
|
return Type::StepSlider;
|
||||||
|
}
|
||||||
|
inline void setTitle(const string& _title) {
|
||||||
|
this->title = _title;
|
||||||
|
}
|
||||||
|
inline void setOptions(const vector<string>& _options) {
|
||||||
|
this->options = _options;
|
||||||
|
}
|
||||||
|
inline void addOption(const string& option) {
|
||||||
|
options.push_back(option);
|
||||||
|
}
|
||||||
|
inline void setDefault(int defId) {
|
||||||
|
this->def = defId;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
//////////////////////////////// Forms ////////////////////////////////
|
||||||
|
class FormImpl {
|
||||||
|
protected:
|
||||||
|
// fifo_json json;
|
||||||
|
virtual string serialize() = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
class SimpleForm : public FormImpl {
|
||||||
|
protected:
|
||||||
|
LIAPI string serialize() override;
|
||||||
|
|
||||||
|
public:
|
||||||
|
using Callback = std::function<void(Player*, int)>;
|
||||||
|
string title, content;
|
||||||
|
vector<std::shared_ptr<SimpleFormElement>> elements;
|
||||||
|
Callback callback;
|
||||||
|
|
||||||
|
public:
|
||||||
|
SimpleForm(string title, string content)
|
||||||
|
: title(std::move(title))
|
||||||
|
, content(std::move(content)) {
|
||||||
|
}
|
||||||
|
template <typename T, typename... Args>
|
||||||
|
SimpleForm(const string& title, const string& content, T element, Args... args) {
|
||||||
|
append(element);
|
||||||
|
SimpleForm(title, content, args...);
|
||||||
|
}
|
||||||
|
LIAPI SimpleForm& setTitle(const string& title);
|
||||||
|
LIAPI SimpleForm& setContent(const string& content);
|
||||||
|
LIAPI SimpleForm& addButton(string text, string image = "", Button::ButtonCallback callback = Button::ButtonCallback());
|
||||||
|
LIAPI SimpleForm& append(const Button& element);
|
||||||
|
LIAPI bool sendTo(Player* player, Callback callback = Callback());
|
||||||
|
};
|
||||||
|
|
||||||
|
class ModalForm : public FormImpl {
|
||||||
|
protected:
|
||||||
|
LIAPI string serialize() override;
|
||||||
|
|
||||||
|
public:
|
||||||
|
using Callback = std::function<void(Player*, bool)>;
|
||||||
|
string title, content, confirmButton, cancelButton;
|
||||||
|
Callback callback;
|
||||||
|
|
||||||
|
public:
|
||||||
|
ModalForm(string title, string content, string button1, string button2)
|
||||||
|
: title(std::move(title))
|
||||||
|
, content(std::move(content))
|
||||||
|
, confirmButton(std::move(button1))
|
||||||
|
, cancelButton(std::move(button2)) {
|
||||||
|
}
|
||||||
|
template <typename T, typename... Args>
|
||||||
|
ModalForm(const string& title, const string& content, const string& confirmButton, const string& cancelButton, Args... args) {
|
||||||
|
ModalForm(title, content, confirmButton, cancelButton, args...);
|
||||||
|
}
|
||||||
|
LIAPI ModalForm& setTitle(const string& title);
|
||||||
|
LIAPI ModalForm& setContent(const string& content);
|
||||||
|
LIAPI ModalForm& setConfirmButton(const string& text);
|
||||||
|
LIAPI ModalForm& setCancelButton(const string& text);
|
||||||
|
LIAPI bool sendTo(Player* player, Callback callback = Callback());
|
||||||
|
};
|
||||||
|
|
||||||
|
class CustomForm : public FormImpl {
|
||||||
|
protected:
|
||||||
|
LIAPI string serialize() override;
|
||||||
|
|
||||||
|
public:
|
||||||
|
using Callback = std::function<void(Player*, std::map<string, std::shared_ptr<CustomFormElement>>)>;
|
||||||
|
using Callback2 = std::function<void(Player*, std::string)>;
|
||||||
|
string title;
|
||||||
|
std::vector<std::pair<string, std::shared_ptr<CustomFormElement>>> elements;
|
||||||
|
Callback callback;
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit CustomForm(string title)
|
||||||
|
: title(std::move(title)) {
|
||||||
|
}
|
||||||
|
template <typename T, typename... Args>
|
||||||
|
CustomForm(const string& title, T element, Args... args) {
|
||||||
|
append(element);
|
||||||
|
CustomForm(title, args...);
|
||||||
|
}
|
||||||
|
LIAPI CustomForm& setTitle(const string& title);
|
||||||
|
|
||||||
|
LIAPI CustomForm& addLabel(const string& name, string text);
|
||||||
|
LIAPI CustomForm& addInput(const string& name, string title, string placeholder = "", string def = "");
|
||||||
|
LIAPI CustomForm& addToggle(const string& name, string title, bool def = false);
|
||||||
|
LIAPI CustomForm& addDropdown(const string& name, string title, const vector<string>& options, int defId = 0);
|
||||||
|
LIAPI CustomForm& addSlider(const string& name, string title, double min, double max, double step = 1, double def = 0);
|
||||||
|
LIAPI CustomForm& addStepSlider(const string& name, string title, const vector<string>& options, int defId = 0);
|
||||||
|
|
||||||
|
LIAPI CustomForm& append(const Label& element);
|
||||||
|
LIAPI CustomForm& append(const Input& element);
|
||||||
|
LIAPI CustomForm& append(const Toggle& element);
|
||||||
|
LIAPI CustomForm& append(const Dropdown& element);
|
||||||
|
LIAPI CustomForm& append(const Slider& element);
|
||||||
|
LIAPI CustomForm& append(const StepSlider& element);
|
||||||
|
|
||||||
|
LIAPI bool sendTo(Player* player, Callback callback);
|
||||||
|
LIAPI bool sendToForRawJson(Player* player, Callback2 callback);
|
||||||
|
LIAPI CustomFormElement* getElement(const string& name);
|
||||||
|
LIAPI CustomFormElement* getElement(int index);
|
||||||
|
LIAPI CustomFormElement::Type getType(int index);
|
||||||
|
|
||||||
|
LIAPI string getString(const string& name);
|
||||||
|
[[deprecated("Please use getInt")]]
|
||||||
|
LIAPI int getNumber(const string& name);
|
||||||
|
LIAPI int getInt(const string& name);
|
||||||
|
LIAPI float getFloat(const string& name);
|
||||||
|
LIAPI double getDouble(const string& name);
|
||||||
|
LIAPI bool getBool(const string& name);
|
||||||
|
LIAPI string getString(int index);
|
||||||
|
[[deprecated("Please use getInt")]]
|
||||||
|
LIAPI int getNumber(int index);
|
||||||
|
LIAPI int getInt(int index);
|
||||||
|
LIAPI float getFloat(int index);
|
||||||
|
LIAPI double getDouble(int index);
|
||||||
|
LIAPI bool getBool(int index);
|
||||||
|
|
||||||
|
// Tool Functions
|
||||||
|
template <typename T>
|
||||||
|
inline void setValue(int index, T value) {
|
||||||
|
elements[index].second->value = std::to_string(value);
|
||||||
|
}
|
||||||
|
inline void setValue(int index, string value) {
|
||||||
|
elements[index].second->value = value;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
} // namespace Form
|
90
LiteLoader/Header/Global.h
Normal file
90
LiteLoader/Header/Global.h
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
#pragma once
|
||||||
|
#pragma warning(disable : 4250)
|
||||||
|
|
||||||
|
#ifdef LITELOADER_EXPORTS
|
||||||
|
#define LIAPI __declspec(dllexport)
|
||||||
|
#else
|
||||||
|
#define LIAPI __declspec(dllimport)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define MCAPI __declspec(dllimport)
|
||||||
|
#define MCVAPI __declspec(dllimport)
|
||||||
|
#define MCINLINE inline
|
||||||
|
#define MCCLS
|
||||||
|
|
||||||
|
#ifndef FMT_HEADER_ONLY
|
||||||
|
#define FMT_HEADER_ONLY
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef LL_CONSTEXPR
|
||||||
|
#if __cplusplus <= 201703L
|
||||||
|
#define LL_CONSTEXPR inline
|
||||||
|
#else
|
||||||
|
#define LL_CONSTEXPR constexpr
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/// std containers
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
#include <stack>
|
||||||
|
#include <queue>
|
||||||
|
#include <bitset>
|
||||||
|
|
||||||
|
#include <set>
|
||||||
|
#include <map>
|
||||||
|
#include <unordered_map>
|
||||||
|
#include <unordered_set>
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
#include <optional>
|
||||||
|
#include <functional>
|
||||||
|
#include <mutex>
|
||||||
|
#include <shared_mutex>
|
||||||
|
|
||||||
|
// std utils
|
||||||
|
#include <cuchar>
|
||||||
|
#include <utility>
|
||||||
|
#include <variant>
|
||||||
|
#include <numeric>
|
||||||
|
#include <cmath>
|
||||||
|
#include <random>
|
||||||
|
#include <algorithm>
|
||||||
|
#include <iomanip>
|
||||||
|
#include <xhash>
|
||||||
|
|
||||||
|
// windows types
|
||||||
|
#include <minwindef.h>
|
||||||
|
|
||||||
|
#include "third-party/entt/entt.hpp"
|
||||||
|
#include "third-party/gsl/gsl"
|
||||||
|
#include "third-party/seh_exception/seh_exception.hpp"
|
||||||
|
#include "third-party/FMT/chrono.h"
|
||||||
|
#include "third-party/FMT/color.h"
|
||||||
|
#include "third-party/FMT/core.h"
|
||||||
|
#include "third-party/FMT/os.h"
|
||||||
|
#include "third-party/FMT/printf.h"
|
||||||
|
|
||||||
|
#include "GlobalServiceAPI.h"
|
||||||
|
#include "Utils/Optional.h"
|
||||||
|
|
||||||
|
// basic mc types
|
||||||
|
#include "MC/Types.hpp"
|
||||||
|
// clang-format off
|
||||||
|
#define M_E 2.71828182845904523536 // e
|
||||||
|
#define M_LOG2E 1.44269504088896340736 // log2(e)
|
||||||
|
#define M_LOG10E 0.434294481903251827651 // log10(e)
|
||||||
|
#define M_LN2 0.693147180559945309417 // ln(2)
|
||||||
|
#define M_LN10 2.30258509299404568402 // ln(10)
|
||||||
|
#define M_PI 3.14159265358979323846 // pi
|
||||||
|
#define M_PI_2 1.57079632679489661923 // pi/2
|
||||||
|
#define M_PI_4 0.785398163397448309616 // pi/4
|
||||||
|
#define M_1_PI 0.318309886183790671538 // 1/pi
|
||||||
|
#define M_2_PI 0.636619772367581343076 // 2/pi
|
||||||
|
#define M_2_SQRTPI 1.12837916709551257390 // 2/sqrt(pi)
|
||||||
|
#define M_SQRT2 1.41421356237309504880 // sqrt(2)
|
||||||
|
#define M_SQRT1_2 0.707106781186547524401 // 1/sqrt(2)
|
||||||
|
// clang-format on
|
||||||
|
using std::map;
|
||||||
|
using std::string;
|
||||||
|
using std::vector;
|
23
LiteLoader/Header/GlobalServiceAPI.h
Normal file
23
LiteLoader/Header/GlobalServiceAPI.h
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
// Types
|
||||||
|
namespace RakNet {
|
||||||
|
class RakPeer;
|
||||||
|
};
|
||||||
|
class Level;
|
||||||
|
class CommandRegistry;
|
||||||
|
class Minecraft;
|
||||||
|
class MinecraftCommands;
|
||||||
|
class RakNetServerLocator;
|
||||||
|
class ServerLevel;
|
||||||
|
class ServerNetworkHandler;
|
||||||
|
class DBStorage;
|
||||||
|
class Scoreboard;
|
||||||
|
class AllowListFile;
|
||||||
|
class PropertiesSettings;
|
||||||
|
class ResourcePackRepository;
|
||||||
|
class LevelStorage;
|
||||||
|
class NetworkHandler;
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
LIAPI inline T* Global = nullptr;
|
253
LiteLoader/Header/HookAPI.h
Normal file
253
LiteLoader/Header/HookAPI.h
Normal file
@ -0,0 +1,253 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "Global.h"
|
||||||
|
#include "Utils/Hash.h"
|
||||||
|
#include <vector>
|
||||||
|
#include <string>
|
||||||
|
#include <thread>
|
||||||
|
#include "third-party/ModUtils/ModUtils.h"
|
||||||
|
|
||||||
|
// The core api of the hook function
|
||||||
|
//__declspec(dllimport) int HookFunction(void* oldfunc, void** poutold, void* newfunc);
|
||||||
|
// Used to get a server-defined specific function by name
|
||||||
|
extern "C" {
|
||||||
|
LIAPI int HookFunction(void* oldfunc, void** poutold, void* newfunc);
|
||||||
|
LIAPI void* dlsym_real(char const* name);
|
||||||
|
}
|
||||||
|
|
||||||
|
extern std::vector<std::string> dlsym_reverse(int addr);
|
||||||
|
|
||||||
|
template <typename RTN = void, typename... Args>
|
||||||
|
RTN inline VirtualCall(void const* _this, uintptr_t off, Args... args) {
|
||||||
|
return (*(RTN(**)(void const*, Args...))(*(uintptr_t*)_this + off))(_this, args...);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T, int off>
|
||||||
|
inline T& dAccess(void* ptr) {
|
||||||
|
return *(T*)(((uintptr_t)ptr) + off);
|
||||||
|
}
|
||||||
|
template <typename T, int off>
|
||||||
|
inline T const& dAccess(void const* ptr) {
|
||||||
|
return *(T*)(((uintptr_t)ptr) + off);
|
||||||
|
}
|
||||||
|
template <typename T>
|
||||||
|
inline T& dAccess(void* ptr, uintptr_t off) {
|
||||||
|
return *(T*)(((uintptr_t)ptr) + off);
|
||||||
|
}
|
||||||
|
template <typename T>
|
||||||
|
inline const T& dAccess(void const* ptr, uintptr_t off) {
|
||||||
|
return *(T*)(((uintptr_t)ptr) + off);
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace mem {
|
||||||
|
inline std::string ptrToStr(uintptr_t ptr) {
|
||||||
|
std::ostringstream ss;
|
||||||
|
ss << std::hex << ((UINT64)ptr) << std::endl;
|
||||||
|
return ss.str();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void* uintptrToPtr(uintptr_t ptr) {
|
||||||
|
return (void*)ptr;
|
||||||
|
}
|
||||||
|
} // namespace mem
|
||||||
|
|
||||||
|
#if _HAS_CXX20
|
||||||
|
template <size_t N>
|
||||||
|
struct FixedString {
|
||||||
|
char buf[N + 1]{};
|
||||||
|
constexpr FixedString(char const* s) {
|
||||||
|
for (unsigned i = 0; i != N; ++i)
|
||||||
|
buf[i] = s[i];
|
||||||
|
}
|
||||||
|
constexpr operator char const*() const {
|
||||||
|
return buf;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
template <size_t N>
|
||||||
|
FixedString(char const (&)[N]) -> FixedString<N - 1>;
|
||||||
|
|
||||||
|
template <FixedString Fn>
|
||||||
|
__declspec(selectany) void* __dlsym_ptr_cache = dlsym_real(Fn);
|
||||||
|
|
||||||
|
#define VA_EXPAND(...) __VA_ARGS__
|
||||||
|
template <FixedString Fn, typename ret, typename... p>
|
||||||
|
static inline auto __imp_Call() {
|
||||||
|
return ((ret(*)(p...))(__dlsym_ptr_cache<Fn>));
|
||||||
|
}
|
||||||
|
|
||||||
|
template <FixedString Fn, typename ret, typename... p>
|
||||||
|
static inline auto __imp_Call_Sig() {
|
||||||
|
return ((ret(*)(p...))((void*)ModUtils::FindSig(Fn)));
|
||||||
|
}
|
||||||
|
|
||||||
|
template <FixedString Fn, typename ret, typename... p>
|
||||||
|
static inline auto __imp_Call_Addr() {
|
||||||
|
return ((ret(*)(p...))((void*)Fn));
|
||||||
|
}
|
||||||
|
|
||||||
|
#define AddrCall(fn, ret, ...) (__imp_Call_Addr<fn, ret, __VA_ARGS__>())
|
||||||
|
#define SigCall(fn, ret, ...) (__imp_Call_Sig<fn, ret, __VA_ARGS__>())
|
||||||
|
#define AddrCall2(name, fn, ret, ...) (__imp_Call_Addr<fn, ret, __VA_ARGS__>())
|
||||||
|
#define SigCall2(name, fn, ret, ...) (__imp_Call_Sig<fn, ret, __VA_ARGS__>())
|
||||||
|
#define SymCall(fn, ret, ...) (__imp_Call<fn, ret, __VA_ARGS__>())
|
||||||
|
#define SYM(fn) (__dlsym_ptr_cache<fn>)
|
||||||
|
#define dlsym(xx) SYM(xx)
|
||||||
|
|
||||||
|
#else
|
||||||
|
template <CHash, CHash>
|
||||||
|
__declspec(selectany) void* __ptr_cache;
|
||||||
|
template <CHash hash, CHash hash2>
|
||||||
|
inline static void* dlsym_cache(const char* fn) {
|
||||||
|
if (!__ptr_cache<hash, hash2>) {
|
||||||
|
__ptr_cache<hash, hash2> = dlsym_real(fn);
|
||||||
|
}
|
||||||
|
return __ptr_cache<hash, hash2>;
|
||||||
|
}
|
||||||
|
|
||||||
|
#define VA_EXPAND(...) __VA_ARGS__
|
||||||
|
template <CHash hash, CHash hash2, typename ret, typename... p>
|
||||||
|
static inline auto __imp_Call(const char* fn) {
|
||||||
|
return ((ret(*)(p...))(dlsym_cache<hash, hash2>(fn)));
|
||||||
|
}
|
||||||
|
|
||||||
|
#define SymCall(fn, ret, ...) (__imp_Call<do_hash(fn), do_hash2(fn), ret, __VA_ARGS__>(fn))
|
||||||
|
#define SYM(fn) (dlsym_cache<do_hash(fn), do_hash2(fn)>(fn))
|
||||||
|
#define dlsym(xx) SYM(xx)
|
||||||
|
#endif
|
||||||
|
class THookRegister {
|
||||||
|
public:
|
||||||
|
THookRegister(void* address, void* hook, void** org) {
|
||||||
|
auto ret = HookFunction(address, org, hook);
|
||||||
|
if (ret != 0) {
|
||||||
|
printf("FailedToHook: %p\n", address);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
THookRegister(char const* sym, void* hook, void** org) {
|
||||||
|
auto found = dlsym_real(sym);
|
||||||
|
if (found == nullptr) {
|
||||||
|
printf("FailedToHook: %p\n", sym);
|
||||||
|
} else {
|
||||||
|
auto ret = HookFunction(found, org, hook);
|
||||||
|
if (ret != 0) {
|
||||||
|
printf("FailedToHook: %s\n", sym);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
template <typename T>
|
||||||
|
THookRegister(const char* sym, T hook, void** org) {
|
||||||
|
union {
|
||||||
|
T a;
|
||||||
|
void* b;
|
||||||
|
} hookUnion;
|
||||||
|
hookUnion.a = hook;
|
||||||
|
THookRegister(sym, hookUnion.b, org);
|
||||||
|
}
|
||||||
|
template <typename T>
|
||||||
|
THookRegister(void* address, T hook, void** org) {
|
||||||
|
union {
|
||||||
|
T a;
|
||||||
|
void* b;
|
||||||
|
} hookUnion;
|
||||||
|
hookUnion.a = hook;
|
||||||
|
THookRegister(address, hookUnion.b, org);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
#define VA_EXPAND(...) __VA_ARGS__
|
||||||
|
template <CHash, CHash>
|
||||||
|
struct THookTemplate;
|
||||||
|
template <CHash, CHash>
|
||||||
|
extern THookRegister THookRegisterTemplate;
|
||||||
|
|
||||||
|
#define _TInstanceHook(class_inh, pclass, iname, sym, ret, ...) \
|
||||||
|
template <> \
|
||||||
|
struct THookTemplate<do_hash(iname), do_hash2(iname)> class_inh { \
|
||||||
|
typedef ret (THookTemplate::*original_type)(__VA_ARGS__); \
|
||||||
|
static original_type& _original() { \
|
||||||
|
static original_type storage; \
|
||||||
|
return storage; \
|
||||||
|
} \
|
||||||
|
template <typename... Params> \
|
||||||
|
static ret original(pclass* _this, Params&&... params) { \
|
||||||
|
return (((THookTemplate*)_this)->*_original())(std::forward<Params>(params)...); \
|
||||||
|
} \
|
||||||
|
ret _hook(__VA_ARGS__); \
|
||||||
|
}; \
|
||||||
|
template <> \
|
||||||
|
static THookRegister THookRegisterTemplate<do_hash(iname), do_hash2(iname)>{ \
|
||||||
|
sym, &THookTemplate<do_hash(iname), do_hash2(iname)>::_hook, \
|
||||||
|
(void**)&THookTemplate<do_hash(iname), do_hash2(iname)>::_original()}; \
|
||||||
|
ret THookTemplate<do_hash(iname), do_hash2(iname)>::_hook(__VA_ARGS__)
|
||||||
|
|
||||||
|
#define _TInstanceDefHook(iname, sym, ret, type, ...) \
|
||||||
|
_TInstanceHook( \
|
||||||
|
: public type, type, iname, sym, ret, VA_EXPAND(__VA_ARGS__))
|
||||||
|
#define _TInstanceNoDefHook(iname, sym, ret, ...) \
|
||||||
|
_TInstanceHook(, void, iname, sym, ret, VA_EXPAND(__VA_ARGS__))
|
||||||
|
|
||||||
|
#define _TStaticHook(pclass, iname, sym, ret, ...) \
|
||||||
|
template <> \
|
||||||
|
struct THookTemplate<do_hash(iname), do_hash2(iname)> pclass { \
|
||||||
|
typedef ret (*original_type)(__VA_ARGS__); \
|
||||||
|
static original_type& _original() { \
|
||||||
|
static original_type storage; \
|
||||||
|
return storage; \
|
||||||
|
} \
|
||||||
|
template <typename... Params> \
|
||||||
|
static ret original(Params&&... params) { \
|
||||||
|
return _original()(std::forward<Params>(params)...); \
|
||||||
|
} \
|
||||||
|
static ret _hook(__VA_ARGS__); \
|
||||||
|
}; \
|
||||||
|
template <> \
|
||||||
|
static THookRegister THookRegisterTemplate<do_hash(iname), do_hash2(iname)>{ \
|
||||||
|
sym, &THookTemplate<do_hash(iname), do_hash2(iname)>::_hook, \
|
||||||
|
(void**)&THookTemplate<do_hash(iname), do_hash2(iname)>::_original()}; \
|
||||||
|
ret THookTemplate<do_hash(iname), do_hash2(iname)>::_hook(__VA_ARGS__)
|
||||||
|
|
||||||
|
#define _TStaticDefHook(iname, sym, ret, type, ...) \
|
||||||
|
_TStaticHook( \
|
||||||
|
: public type, iname, sym, ret, VA_EXPAND(__VA_ARGS__))
|
||||||
|
#define _TStaticNoDefHook(iname, sym, ret, ...) \
|
||||||
|
_TStaticHook(, iname, sym, ret, VA_EXPAND(__VA_ARGS__))
|
||||||
|
|
||||||
|
#define SHook2(iname, ret, sig, ...) _TStaticNoDefHook(iname, (void*)ModUtils::FindSig(sig), ret, VA_EXPAND(__VA_ARGS__))
|
||||||
|
#define SHook(ret, sig, ...) SHook2(sig, ret, sig, VA_EXPAND(__VA_ARGS__))
|
||||||
|
#define SStaticHook2(iname, ret, sig, type, ...) \
|
||||||
|
_TStaticDefHook(iname, (void*)ModUtils::FindSig(sig), ret, type, VA_EXPAND(__VA_ARGS__))
|
||||||
|
#define SStaticHook(ret, sig, type, ...) SStaticHook2(sig, ret, sig, type, VA_EXPAND(__VA_ARGS__))
|
||||||
|
#define SClasslessInstanceHook2(iname, ret, sig, ...) \
|
||||||
|
_TInstanceNoDefHook(iname, (void*)ModUtils::FindSig(sig), ret, VA_EXPAND(__VA_ARGS__))
|
||||||
|
#define SClasslessInstanceHook(ret, sig, ...) \
|
||||||
|
SClasslessInstanceHook2(sig, ret, sig, VA_EXPAND(__VA_ARGS__))
|
||||||
|
#define SInstanceHook2(iname, ret, sig, type, ...) \
|
||||||
|
_TInstanceDefHook(iname, (void*)ModUtils::FindSig(sig), ret, type, VA_EXPAND(__VA_ARGS__))
|
||||||
|
#define SInstanceHook(ret, sig, type, ...) \
|
||||||
|
SInstanceHook2(sig, ret, sig, type, VA_EXPAND(__VA_ARGS__))
|
||||||
|
|
||||||
|
#define AHook2(iname, ret, addr, ...) _TStaticNoDefHook(iname, mem::uintptrToPtr(addr), ret, VA_EXPAND(__VA_ARGS__))
|
||||||
|
#define AHook(ret, addr, ...) AHook2(std::to_string(addr), ret, addr, VA_EXPAND(__VA_ARGS__))
|
||||||
|
#define AStaticHook2(iname, ret, addr, type, ...) \
|
||||||
|
_TStaticDefHook(iname, mem::uintptrToPtr(addr), ret, type, VA_EXPAND(__VA_ARGS__))
|
||||||
|
#define AStaticHook(ret, addr, type, ...) AStaticHook2(std::to_string(addr), ret, addr, type, VA_EXPAND(__VA_ARGS__))
|
||||||
|
#define AClasslessInstanceHook2(iname, ret, addr, ...) \
|
||||||
|
_TInstanceNoDefHook(iname, mem::uintptrToPtr(addr), ret, VA_EXPAND(__VA_ARGS__))
|
||||||
|
#define AClasslessInstanceHook(ret, addr, ...) \
|
||||||
|
AClasslessInstanceHook2(std::to_string(addr), ret, addr, VA_EXPAND(__VA_ARGS__))
|
||||||
|
#define AInstanceHook2(iname, ret, addr, type, ...) \
|
||||||
|
_TInstanceDefHook(iname, mem::uintptrToPtr(addr), ret, type, VA_EXPAND(__VA_ARGS__))
|
||||||
|
#define AInstanceHook(ret, addr, type, ...) \
|
||||||
|
AInstanceHook2(std::to_string(addr), ret, addr, type, VA_EXPAND(__VA_ARGS__))
|
||||||
|
|
||||||
|
#define THook2(iname, ret, sym, ...) _TStaticNoDefHook(iname, sym, ret, VA_EXPAND(__VA_ARGS__))
|
||||||
|
#define THook(ret, sym, ...) THook2(sym, ret, sym, VA_EXPAND(__VA_ARGS__))
|
||||||
|
#define TStaticHook2(iname, ret, sym, type, ...) \
|
||||||
|
_TStaticDefHook(iname, sym, ret, type, VA_EXPAND(__VA_ARGS__))
|
||||||
|
#define TStaticHook(ret, sym, type, ...) TStaticHook2(sym, ret, sym, type, VA_EXPAND(__VA_ARGS__))
|
||||||
|
#define TClasslessInstanceHook2(iname, ret, sym, ...) \
|
||||||
|
_TInstanceNoDefHook(iname, sym, ret, VA_EXPAND(__VA_ARGS__))
|
||||||
|
#define TClasslessInstanceHook(ret, sym, ...) \
|
||||||
|
TClasslessInstanceHook2(sym, ret, sym, VA_EXPAND(__VA_ARGS__))
|
||||||
|
#define TInstanceHook2(iname, ret, sym, type, ...) \
|
||||||
|
_TInstanceDefHook(iname, sym, ret, type, VA_EXPAND(__VA_ARGS__))
|
||||||
|
#define TInstanceHook(ret, sym, type, ...) \
|
||||||
|
TInstanceHook2(sym, ret, sym, type, VA_EXPAND(__VA_ARGS__))
|
506
LiteLoader/Header/I18nAPI.h
Normal file
506
LiteLoader/Header/I18nAPI.h
Normal file
@ -0,0 +1,506 @@
|
|||||||
|
#pragma once
|
||||||
|
//////////////////////////////////////////////////////
|
||||||
|
// For Internationalization
|
||||||
|
//
|
||||||
|
// [Usage - Translation]
|
||||||
|
//
|
||||||
|
// Translation::load("plugins/xxx/lang.json");
|
||||||
|
// ...
|
||||||
|
// tr("There are {0} days before {1} to come back", 3, "alex"); // return translated string [std::string]
|
||||||
|
// trc("There are {0} days before {1} to come back", 3, "alex"); // return translated string [const char*]
|
||||||
|
//
|
||||||
|
// ** In Translation File: plugins/xxx/lang.json
|
||||||
|
// {
|
||||||
|
// "zh_CN": {
|
||||||
|
// "There are {0} days before {1} to come back": "在{1}回来前还剩{0}天",
|
||||||
|
// "...": "...",
|
||||||
|
// "...": "..."
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// [Usage - Text Encoding]
|
||||||
|
//
|
||||||
|
// Encoding local = TextEncoding::getLocalEncoding(); // Get local encoding
|
||||||
|
// Encoding code = TextEncoding::detectEncoding("你好吗?"); // Detect the encoding of text
|
||||||
|
//
|
||||||
|
// string hello = TextEncoding::fromUnicode(L"Hello"); // Convert Unicode wstring -> MBCS string
|
||||||
|
// wstring world = TextEncoding::toUnicode("World"); // Convert MBCS string -> Unicode wstring
|
||||||
|
//
|
||||||
|
// string tomorrow = TextEncoding::toUTF8("明天"); // Convert MBCS string of any encoding to UTF8 string
|
||||||
|
// string tonight = TextEncoding::convert("今天晚上", Encoding::CHINESE_GB, Encoding::UTF8);
|
||||||
|
// // Convert from one MBCS encoding to another
|
||||||
|
//
|
||||||
|
//////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#include "Global.h"
|
||||||
|
#include "LLAPI.h"
|
||||||
|
#include "Utils/FileHelper.h"
|
||||||
|
#include "Utils/PluginOwnData.h"
|
||||||
|
#include "third-party/Nlohmann/json.hpp"
|
||||||
|
#include "third-party/FMT/core.h"
|
||||||
|
#include "third-party/FMT/os.h"
|
||||||
|
#include <string>
|
||||||
|
#include "Utils/StringHelper.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief I18nBase API class.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
class I18nBase {
|
||||||
|
|
||||||
|
public:
|
||||||
|
using SubLangData = std::unordered_map<std::string, std::string>;
|
||||||
|
using LangData = std::map<std::string, SubLangData>;
|
||||||
|
|
||||||
|
enum class Type : char
|
||||||
|
{
|
||||||
|
None,
|
||||||
|
SingleFile,
|
||||||
|
MultiFile,
|
||||||
|
Custom,
|
||||||
|
};
|
||||||
|
|
||||||
|
Type type = Type::None;
|
||||||
|
LangData langData;
|
||||||
|
LangData defaultLangData;
|
||||||
|
std::string defaultLocaleName = "en_US";
|
||||||
|
|
||||||
|
virtual ~I18nBase() = default;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the translation of the specified key.
|
||||||
|
*
|
||||||
|
* @param key The language key
|
||||||
|
* @param localeName The language code like en_US,zh_CN("" => this->defaultLocaleName)
|
||||||
|
* @return std::string The translation
|
||||||
|
* @see I18nBase::defaultLocaleName
|
||||||
|
*/
|
||||||
|
LIAPI virtual std::string get(const std::string& key, const std::string& localeName = "");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @breif Get the type of the i18n object.
|
||||||
|
*
|
||||||
|
* @return The type of the i18n object
|
||||||
|
*/
|
||||||
|
LIAPI virtual Type getType() = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the default language code of the i18n object.
|
||||||
|
*
|
||||||
|
* @return The default language code of the i18n object
|
||||||
|
*/
|
||||||
|
LIAPI virtual std::string getDefaultLocaleName();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Clone a new i18n object.
|
||||||
|
*
|
||||||
|
* @return The new i18n object.
|
||||||
|
*/
|
||||||
|
LIAPI virtual I18nBase* clone();
|
||||||
|
|
||||||
|
static const constexpr char* POD_KEY = "ll_plugin_i18n"; ///< PluginOwnData key
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Lightweight and simple I18nBase support.
|
||||||
|
*
|
||||||
|
* @note Use this, all the language data will be saved in a single JSON file.
|
||||||
|
* So it is not recommended to use it in large plugins(that have a lot of strings to translate)
|
||||||
|
*/
|
||||||
|
class SingleFileI18N : public I18nBase {
|
||||||
|
|
||||||
|
public:
|
||||||
|
std::string filePath;
|
||||||
|
|
||||||
|
LIAPI void load(const std::string& fileName);
|
||||||
|
LIAPI void save();
|
||||||
|
|
||||||
|
SingleFileI18N() {
|
||||||
|
this->type = Type::SingleFile;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @brief Construct a SingleFileI18N object.
|
||||||
|
*
|
||||||
|
* @param filePath The path to the i18n file(json)
|
||||||
|
* @param pattern The i18n file pattern(SingleFile I18nBase supports `Mode::Normal` and `Mode::Normal`
|
||||||
|
* @param defaultLocaleName The default language code(if empty, default the system default language)
|
||||||
|
* @param defaultLangData The default translation data
|
||||||
|
*/
|
||||||
|
SingleFileI18N(const std::string& filePath, const std::string& defaultLocaleName = "",
|
||||||
|
const LangData& defaultLangData = {})
|
||||||
|
: filePath(filePath) {
|
||||||
|
this->type = Type::SingleFile;
|
||||||
|
this->defaultLangData = defaultLangData;
|
||||||
|
if (defaultLocaleName.empty()) {
|
||||||
|
this->defaultLocaleName = GetSystemLocaleName();
|
||||||
|
} else {
|
||||||
|
this->defaultLocaleName = defaultLocaleName;
|
||||||
|
}
|
||||||
|
load(filePath);
|
||||||
|
}
|
||||||
|
/// Copy constructor
|
||||||
|
SingleFileI18N(const SingleFileI18N& other) {
|
||||||
|
*this = other;
|
||||||
|
}
|
||||||
|
~SingleFileI18N() = default;
|
||||||
|
|
||||||
|
LIAPI Type getType();
|
||||||
|
};
|
||||||
|
|
||||||
|
class MultiFileI18N : public I18nBase {
|
||||||
|
|
||||||
|
public:
|
||||||
|
std::string dirPath;
|
||||||
|
|
||||||
|
LIAPI void load(const std::string& dirName);
|
||||||
|
LIAPI void save(bool nested = false);
|
||||||
|
|
||||||
|
MultiFileI18N() {
|
||||||
|
this->type = Type::MultiFile;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @brief Construct a heavy I18nBase object.
|
||||||
|
*
|
||||||
|
* @param dirPath The path to the i18n dir
|
||||||
|
* @param pattern The i18n file pattern
|
||||||
|
* @param defaultLocaleName The default language code
|
||||||
|
* @param defaultLangData The default translation data
|
||||||
|
*/
|
||||||
|
MultiFileI18N(const std::string& dirPath, const std::string& defaultLocaleName = "",
|
||||||
|
const LangData& defaultLangData = {})
|
||||||
|
: dirPath(dirPath) {
|
||||||
|
this->type = Type::MultiFile;
|
||||||
|
this->defaultLangData = defaultLangData;
|
||||||
|
if (defaultLocaleName.empty()) {
|
||||||
|
this->defaultLocaleName = GetSystemLocaleName();
|
||||||
|
} else {
|
||||||
|
this->defaultLocaleName = defaultLocaleName;
|
||||||
|
}
|
||||||
|
load(dirPath);
|
||||||
|
}
|
||||||
|
/// Copy constructor
|
||||||
|
MultiFileI18N(const MultiFileI18N& other) {
|
||||||
|
*this = other;
|
||||||
|
}
|
||||||
|
~MultiFileI18N() = default;
|
||||||
|
|
||||||
|
LIAPI Type getType();
|
||||||
|
};
|
||||||
|
|
||||||
|
#ifdef UNICODE
|
||||||
|
#include "third-party/compact_enc_det/compact_enc_det.h"
|
||||||
|
#define UNICODE
|
||||||
|
#else
|
||||||
|
#include "third-party/compact_enc_det/compact_enc_det.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
namespace Translation {
|
||||||
|
template <bool B, class T = void>
|
||||||
|
using enable_if_t = typename std::enable_if<B, T>::type;
|
||||||
|
|
||||||
|
///////////////// tr Impl /////////////////
|
||||||
|
template <typename S, typename... Args, Translation::enable_if_t<(fmt::v8::detail::is_string<S>::value), int> = 0>
|
||||||
|
inline std::string trlImpl(HMODULE hPlugin, const std::string& localeName, const S& formatStr, Args&&... args) {
|
||||||
|
std::string realFormatStr = formatStr;
|
||||||
|
if (PluginOwnData::hasImpl(hPlugin, I18nBase::POD_KEY)) {
|
||||||
|
auto& i18n = PluginOwnData::getImpl<I18nBase>(hPlugin, I18nBase::POD_KEY);
|
||||||
|
realFormatStr = i18n.get(formatStr, localeName);
|
||||||
|
if (realFormatStr == formatStr) {
|
||||||
|
// If failed and the str dosn't match the args count, avoid fmt to avoid errors
|
||||||
|
auto argSz = sizeof...(args);
|
||||||
|
bool lastIsBracket = false;
|
||||||
|
size_t cnt = 0;
|
||||||
|
for (auto& c : formatStr) {
|
||||||
|
if (c == '{') {
|
||||||
|
if (lastIsBracket) {
|
||||||
|
cnt--;
|
||||||
|
lastIsBracket = false;
|
||||||
|
} else {
|
||||||
|
cnt++;
|
||||||
|
lastIsBracket = true;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (lastIsBracket) {
|
||||||
|
lastIsBracket = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (cnt != argSz) {
|
||||||
|
return formatStr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// realFormatStr = FixCurlyBracket(realFormatStr);
|
||||||
|
if constexpr (0 == sizeof...(args)) {
|
||||||
|
// Avoid fmt if only one argument
|
||||||
|
return realFormatStr;
|
||||||
|
} else {
|
||||||
|
return fmt::format(realFormatStr, std::forward<Args>(args)...);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
template <typename S, typename... Args, Translation::enable_if_t<(fmt::v8::detail::is_string<S>::value), int> = 0>
|
||||||
|
inline std::string trImpl(HMODULE hPlugin, const S& formatStr, Args&&... args) {
|
||||||
|
return trlImpl(hPlugin, "", formatStr, std::forward<Args>(args)...);
|
||||||
|
}
|
||||||
|
|
||||||
|
///////////////// trc Impl /////////////////
|
||||||
|
template <typename S, typename... Args, Translation::enable_if_t<(fmt::v8::detail::is_string<S>::value), int> = 0>
|
||||||
|
[[deprecated("Use trImpl(...).c_str() instead")]] inline const char* trcImpl(HMODULE hPlugin, const S& formatStr,
|
||||||
|
const Args&... args) {
|
||||||
|
std::string res = trImpl(hPlugin, formatStr, args...);
|
||||||
|
std::string name =
|
||||||
|
std::string(I18nBase::POD_KEY) + "_translation_" + fmt::v8::detail::to_string_view<S>(formatStr).data();
|
||||||
|
auto& str = PluginOwnData::setImpl<std::string>(hPlugin, name, res);
|
||||||
|
return str.c_str();
|
||||||
|
}
|
||||||
|
|
||||||
|
LIAPI I18nBase* loadI18nImpl(HMODULE hPlugin, const std::string& path, const std::string& defaultLocaleName,
|
||||||
|
const I18nBase::LangData& defaultLangData);
|
||||||
|
|
||||||
|
LIAPI I18nBase* loadFromImpl(HMODULE hPlugin, HMODULE hTarget);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Load translation from a file or dir.
|
||||||
|
*
|
||||||
|
* @param path The path to the i18n file(json) or dir
|
||||||
|
* @param defaultLocaleName The default language code(if no lang code is specified, it will use this)
|
||||||
|
* @param defaultLangData The default translation data
|
||||||
|
* @return I18nBase* The pointer to the I18nBase object in PluginOwnData, null if failed
|
||||||
|
* @par Example
|
||||||
|
* 1. SingleFileI18N (1)
|
||||||
|
* @code
|
||||||
|
* // In the file plugins/xxx/language.json:
|
||||||
|
* // {"zh_CN": {"text": "文本"}, "en_US": {"text", "text"}}
|
||||||
|
* Translation::load("plugins/xxx/language.json");
|
||||||
|
* tr("text");
|
||||||
|
* @endcode
|
||||||
|
* 2. SingleFileI18N (2)
|
||||||
|
* @code
|
||||||
|
* // In the file plugins/xxx/language.json:
|
||||||
|
* // {"zh_CN": {"a.b.c.id.text": "文本"}, "en_US": {"a.b.c.id.text", "text"}}
|
||||||
|
* Translation::load("plugins/xxx/language.json");
|
||||||
|
* tr("a.b.c.d.id.text");
|
||||||
|
* @endcode
|
||||||
|
* 3. MultiFileI18N (1)
|
||||||
|
* @code
|
||||||
|
* // In the file plugins/xxx/LangPack/en.json:
|
||||||
|
* // {"text": "text"}
|
||||||
|
* // In the file plugins/xxx/LangPack/zh_CN.json:
|
||||||
|
* // {"text": "文本"}
|
||||||
|
* Translation::load("plugins/xxx/LangPack/");
|
||||||
|
* tr("text");
|
||||||
|
* @endcode
|
||||||
|
* 4. MultiFileI18N (2)
|
||||||
|
* @code
|
||||||
|
* // In the file plugins/xxx/LangPack/en.json:
|
||||||
|
* // {"a.b.c.d.text1": "text"}
|
||||||
|
* // In the file plugins/xxx/LangPack/zh_CN.json:
|
||||||
|
* // {"a.b.c.d.text1": "文本"}
|
||||||
|
* Translation::load("plugins/xxx/LangPack/");
|
||||||
|
* tr("a.b.c.d.text1");
|
||||||
|
* @endcode
|
||||||
|
* 5. MultiFileI18N Nested (3)
|
||||||
|
* @code
|
||||||
|
* // In the file plugins/xxx/LangPack/en.json:
|
||||||
|
* // {"a": {"b": {"c": {"d": {"text1": "text"}}}}}
|
||||||
|
* // In the file plugins/xxx/LangPack/zh_CN.json:
|
||||||
|
* // {"a": {"b": {"c": {"d": {"text1": "文本"}}}}}
|
||||||
|
* Translation::load("plugins/xxx/LangPack/");
|
||||||
|
* tr("a.b.c.d.text1");
|
||||||
|
* @endcode
|
||||||
|
*/
|
||||||
|
inline I18nBase* load(const std::string& path,
|
||||||
|
const std::string& defaultLocaleName = "",
|
||||||
|
const I18nBase::LangData& defaultLangData = {}) {
|
||||||
|
return loadI18nImpl(GetCurrentModule(), path, defaultLocaleName, defaultLangData);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load i18n with custom i18n type.
|
||||||
|
*
|
||||||
|
* @param args... The args to pass to the i18n type constructor
|
||||||
|
* @return I18nBase* The pointer to the I18nBase object in PluginOwnData, null if failed
|
||||||
|
*/
|
||||||
|
template <typename T, typename... Args>
|
||||||
|
inline I18nBase* load(Args&&... args) {
|
||||||
|
try {
|
||||||
|
I18nBase* res = new T(std::forward<Args>(args)...);
|
||||||
|
return &PluginOwnData::setWithoutNewImpl<I18nBase>(GetCurrentModule(), I18nBase::POD_KEY, res);
|
||||||
|
} catch (...) {}
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Load translation from another plugin.
|
||||||
|
*
|
||||||
|
* @param plugin The plugin name.
|
||||||
|
* @return I18nBase* The pointer to the I18nBase object in PluginOwnData, null if failed
|
||||||
|
*/
|
||||||
|
inline I18nBase* loadFrom(const std::string& plugin) {
|
||||||
|
if (LL::hasPlugin(plugin)) {
|
||||||
|
auto p = LL::getPlugin(plugin);
|
||||||
|
if (p) {
|
||||||
|
return loadFromImpl(GetCurrentModule(), p->handle);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the I18nBase object of a certain plugin.
|
||||||
|
*
|
||||||
|
* @param hPlugin The plugin handle(nullptr -> GetCurrentModule())
|
||||||
|
* @return I18nBase* The I18nBase pointer
|
||||||
|
*/
|
||||||
|
inline I18nBase* getI18N(HMODULE hPlugin = nullptr) {
|
||||||
|
auto handle = (hPlugin == nullptr ? GetCurrentModule() : hPlugin);
|
||||||
|
if (handle && PluginOwnData::hasImpl(handle, I18nBase::POD_KEY)) {
|
||||||
|
return &PluginOwnData::getImpl<I18nBase>(handle, I18nBase::POD_KEY);
|
||||||
|
}
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
}; // namespace Translation
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Translate a str.
|
||||||
|
*
|
||||||
|
* @tparam S The string type
|
||||||
|
* @tparam Args ...
|
||||||
|
* @param formatStr The str to translate and format
|
||||||
|
* @param args The format arguments
|
||||||
|
* @return std::string The translated str
|
||||||
|
* @see fmt::format
|
||||||
|
* @see https://fmt.dev/latest/index.html
|
||||||
|
* @par Example
|
||||||
|
* @code
|
||||||
|
* tr(std::string("There are {0} days before {1} to come back"), 3, "alex");
|
||||||
|
* @endcode
|
||||||
|
*/
|
||||||
|
template <typename S, typename... Args, Translation::enable_if_t<(fmt::v8::detail::is_string<S>::value), int> = 0>
|
||||||
|
inline std::string tr(const S& formatStr, Args&&... args) {
|
||||||
|
return Translation::trImpl(GetCurrentModule(), formatStr, std::forward<Args>(args)...);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Translate a str.
|
||||||
|
*
|
||||||
|
* @tparam Args ...
|
||||||
|
* @param formatStr The str to translate and format
|
||||||
|
* @param args The format arguments
|
||||||
|
* @return std::string The translated str
|
||||||
|
* @see fmt::format
|
||||||
|
* @see https://fmt.dev/latest/index.html
|
||||||
|
* @par Example
|
||||||
|
* @code
|
||||||
|
* tr("There are {0} days before {1} to come back", 3, "alex");
|
||||||
|
* @endcode
|
||||||
|
*/
|
||||||
|
template <typename... Args>
|
||||||
|
inline std::string tr(const char* formatStr, Args&&... args) {
|
||||||
|
return tr(std::string(formatStr), std::forward<Args>(args)...);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Translate a str(c-style str).
|
||||||
|
*
|
||||||
|
* @tparam S The string type
|
||||||
|
* @tparam Args ...
|
||||||
|
* @param formatStr The str to translate and format
|
||||||
|
* @param args The format arguments
|
||||||
|
* @return const char* The translated str(c-style str)
|
||||||
|
* @see fmt::format
|
||||||
|
* @see https://fmt.dev/latest/index.html
|
||||||
|
* @par Example
|
||||||
|
* @code
|
||||||
|
* trc(std::string("There are {0} days before {1} to come back"), 3, "alex");
|
||||||
|
* @endcode
|
||||||
|
*/
|
||||||
|
template <typename S, typename... Args, Translation::enable_if_t<(fmt::v8::detail::is_string<S>::value), int> = 0>
|
||||||
|
inline const char* trc(const S& formatStr, Args&&... args) {
|
||||||
|
return Translation::trcImpl(GetCurrentModule(), formatStr, std::forward<Args>(args)...);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Translate a str(c-style str).
|
||||||
|
*
|
||||||
|
* @tparam Args ...
|
||||||
|
* @param formatStr The str to translate and format
|
||||||
|
* @param args The format arguments
|
||||||
|
* @return const char* The translated str(c-style str)
|
||||||
|
* @see fmt::format
|
||||||
|
* @see https://fmt.dev/latest/index.html
|
||||||
|
* @par Example
|
||||||
|
* @code
|
||||||
|
* trc("There are {0} days before {1} to come back", 3, "alex");
|
||||||
|
* @endcode
|
||||||
|
*/
|
||||||
|
template <typename... Args>
|
||||||
|
inline const char* trc(const char* formatStr, Args&&... args) {
|
||||||
|
return trc(std::string(formatStr), std::forward<Args>(args)...);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Translate a str to the specified language.
|
||||||
|
*
|
||||||
|
* @tparam S The string type
|
||||||
|
* @tparam Args ...
|
||||||
|
* @param localeName The language code like en_US
|
||||||
|
* @param formatStr The str to translate and format
|
||||||
|
* @param args The format arguments
|
||||||
|
* @return std::string The translated str
|
||||||
|
* @see fmt::format
|
||||||
|
* @see https://fmt.dev/latest/index.html
|
||||||
|
* @par Example
|
||||||
|
* @code
|
||||||
|
* trl("zh_CN", "There are {0} days before {1} to come back", 3, "alex");
|
||||||
|
* @endcode
|
||||||
|
*/
|
||||||
|
template <typename S, typename... Args>
|
||||||
|
inline std::string trl(const std::string& localeName, const S& formatStr, Args&&... args) {
|
||||||
|
return Translation::trlImpl(GetCurrentModule(), localeName, formatStr, std::forward<Args>(args)...);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Translate a str to the specified language.
|
||||||
|
*
|
||||||
|
* @tparam Args ...
|
||||||
|
* @param localeName The language code like en_US
|
||||||
|
* @param formatStr The str to translate and format(c-style)
|
||||||
|
* @param args The format arguments
|
||||||
|
* @return std::string The translated str
|
||||||
|
* @see fmt::format
|
||||||
|
* @see https://fmt.dev/latest/index.html
|
||||||
|
* @par Example
|
||||||
|
* @code
|
||||||
|
* trl("zh_CN", "There are {0} days before {1} to come back", 3, "alex");
|
||||||
|
* @endcode
|
||||||
|
*/
|
||||||
|
template <typename... Args>
|
||||||
|
inline std::string trl(const std::string& localeName, const char* formatStr, Args&&... args) {
|
||||||
|
return trl(localeName, std::string(formatStr), std::forward<Args>(args)...);
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace Translation {
|
||||||
|
namespace literals {
|
||||||
|
|
||||||
|
inline std::string operator""_tr(const char* str, size_t) {
|
||||||
|
return tr(str);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace literals
|
||||||
|
} // namespace Translation
|
||||||
|
|
||||||
|
// For text encoding
|
||||||
|
namespace TextEncoding {
|
||||||
|
LIAPI Encoding getLocalEncoding();
|
||||||
|
LIAPI Encoding detectEncoding(const std::string& text, bool* isReliable = nullptr);
|
||||||
|
|
||||||
|
LIAPI std::string fromUnicode(const std::wstring& text, Encoding to = Encoding::UTF8);
|
||||||
|
LIAPI std::wstring toUnicode(const std::string& text, Encoding from = Encoding::UTF8);
|
||||||
|
LIAPI std::string toUTF8(const std::string& text);
|
||||||
|
LIAPI std::string toUTF8(const std::string& text, Encoding from);
|
||||||
|
|
||||||
|
LIAPI std::string convert(const std::string& text, Encoding from, Encoding to);
|
||||||
|
} // namespace TextEncoding
|
22
LiteLoader/Header/Impl/FormPacketHelper.h
Normal file
22
LiteLoader/Header/Impl/FormPacketHelper.h
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <cstdlib>
|
||||||
|
#include "../Global.h"
|
||||||
|
#include "../FormUI.h"
|
||||||
|
#include <MC/Player.hpp>
|
||||||
|
|
||||||
|
LIAPI unsigned NewFormId();
|
||||||
|
|
||||||
|
LIAPI void SetSimpleFormPacketCallback(unsigned formId, std::function<void(Player*, int)> callback);
|
||||||
|
|
||||||
|
LIAPI void SetModalFormPacketCallback(unsigned formId, std::function<void(Player*, bool)> callback);
|
||||||
|
|
||||||
|
LIAPI void SetCustomFormPacketCallback(unsigned formId, std::function<void(Player*, string)> callback);
|
||||||
|
|
||||||
|
LIAPI void SetSimpleFormBuilderData(unsigned formId, std::shared_ptr<Form::SimpleForm> data);
|
||||||
|
|
||||||
|
LIAPI void SetModalFormBuilderData(unsigned formId, std::shared_ptr<Form::ModalForm> data);
|
||||||
|
|
||||||
|
LIAPI void SetCustomFormBuilderData(unsigned formId, std::shared_ptr<Form::CustomForm> data);
|
||||||
|
|
||||||
|
LIAPI void HandleFormPacket(Player* player, unsigned formId, const string& data);
|
5
LiteLoader/Header/Impl/ObjectivePacketHelper.h
Normal file
5
LiteLoader/Header/Impl/ObjectivePacketHelper.h
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "../Global.h"
|
||||||
|
|
||||||
|
LIAPI uint64_t NewScoreId();
|
46
LiteLoader/Header/KVDBAPI.h
Normal file
46
LiteLoader/Header/KVDBAPI.h
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "third-party/leveldb/c.h"
|
||||||
|
#include "third-party/leveldb/cache.h"
|
||||||
|
#include "third-party/leveldb/db.h"
|
||||||
|
#include "third-party/leveldb/filter_policy.h"
|
||||||
|
#include "third-party/leveldb/iterator.h"
|
||||||
|
#include <Global.h>
|
||||||
|
#include <functional>
|
||||||
|
#include <string_view>
|
||||||
|
#include <unordered_map>
|
||||||
|
|
||||||
|
class KVDB {
|
||||||
|
leveldb::DB* db;
|
||||||
|
leveldb::ReadOptions rdopt;
|
||||||
|
leveldb::WriteOptions wropt;
|
||||||
|
leveldb::Options options;
|
||||||
|
leveldb::Status status;
|
||||||
|
std::string dbpath;
|
||||||
|
|
||||||
|
void _init(const char* path, bool create, bool read_cache, int cache_sz, int Bfilter_bit);
|
||||||
|
|
||||||
|
public:
|
||||||
|
LIAPI static std::unique_ptr<KVDB> create(const std::string& path, bool read_cache = true, int cache_sz = 0, int Bfilter_bit = 0);
|
||||||
|
LIAPI static std::unique_ptr<KVDB> open(const std::string& path, bool create = true, bool read_cache = true, int cache_sz = 0, int Bfilter_bit = 0);
|
||||||
|
LIAPI ~KVDB();
|
||||||
|
|
||||||
|
KVDB() = default;
|
||||||
|
KVDB(KVDB const&) = delete;
|
||||||
|
KVDB& operator=(KVDB const&) = delete;
|
||||||
|
|
||||||
|
LIAPI bool get(std::string_view key, std::string& val);
|
||||||
|
LIAPI std::optional<std::string> get(std::string_view key);
|
||||||
|
LIAPI bool set(std::string_view key, std::string_view val);
|
||||||
|
LIAPI bool del(std::string_view key);
|
||||||
|
LIAPI void iter(std::function<bool(std::string_view key, std::string_view val)> const& fn);
|
||||||
|
LIAPI void iter(std::function<bool(std::string_view key)> const&);
|
||||||
|
LIAPI std::string error(leveldb::Status status);
|
||||||
|
LIAPI std::vector<std::string> getAllKeys();
|
||||||
|
LIAPI bool isValid();
|
||||||
|
LIAPI operator bool();
|
||||||
|
|
||||||
|
// For Compatibility
|
||||||
|
inline bool put(std::string_view key, std::string_view val) {
|
||||||
|
return set(key, val);
|
||||||
|
}
|
||||||
|
};
|
212
LiteLoader/Header/LLAPI.h
Normal file
212
LiteLoader/Header/LLAPI.h
Normal file
@ -0,0 +1,212 @@
|
|||||||
|
#pragma once
|
||||||
|
#pragma warning(disable : 26812)
|
||||||
|
#include <string>
|
||||||
|
#include <unordered_map>
|
||||||
|
|
||||||
|
#ifndef WIN32_LEAN_AND_MEAN
|
||||||
|
#define WIN32_LEAN_AND_MEAN
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef NOMINMAX
|
||||||
|
#define NOMINMAX
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <windows.h>
|
||||||
|
|
||||||
|
#include "Global.h"
|
||||||
|
#include "Utils/WinHelper.h"
|
||||||
|
#include "Utils/PluginOwnData.h"
|
||||||
|
|
||||||
|
// LL types
|
||||||
|
namespace LL {
|
||||||
|
|
||||||
|
struct Version {
|
||||||
|
enum Status {
|
||||||
|
Dev,
|
||||||
|
Beta,
|
||||||
|
Release
|
||||||
|
};
|
||||||
|
|
||||||
|
int major;
|
||||||
|
int minor;
|
||||||
|
int revision;
|
||||||
|
Status status;
|
||||||
|
|
||||||
|
LIAPI explicit Version(int major = 0, int minor = 0, int revision = 0, Status status = Status::Release);
|
||||||
|
|
||||||
|
LIAPI bool operator<(Version b);
|
||||||
|
LIAPI bool operator==(Version b);
|
||||||
|
|
||||||
|
LIAPI std::string toString(bool needStatus = false);
|
||||||
|
LIAPI static Version parse(const std::string& str);
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Plugin {
|
||||||
|
std::string name;
|
||||||
|
std::string desc; // `introduction` before
|
||||||
|
Version version;
|
||||||
|
std::map<std::string, std::string> others; // `otherInformation` before
|
||||||
|
|
||||||
|
std::string filePath;
|
||||||
|
HMODULE handle;
|
||||||
|
|
||||||
|
enum class PluginType {
|
||||||
|
DllPlugin,
|
||||||
|
ScriptPlugin
|
||||||
|
};
|
||||||
|
|
||||||
|
PluginType type;
|
||||||
|
|
||||||
|
// Call a Function by Symbol String
|
||||||
|
template <typename ReturnType = void, typename... Args>
|
||||||
|
inline ReturnType callFunction(const char* functionName, Args... args) {
|
||||||
|
void* address = GetProcAddress(handle, functionName);
|
||||||
|
if (!address)
|
||||||
|
return ReturnType();
|
||||||
|
return reinterpret_cast<ReturnType (*)(Args...)>(address)(std::forward<Args>(args)...);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace LL
|
||||||
|
inline bool operator<=(LL::Version a, LL::Version b) {
|
||||||
|
return a < b || a == b;
|
||||||
|
}
|
||||||
|
inline bool operator>(LL::Version a, LL::Version b) {
|
||||||
|
return b < a;
|
||||||
|
}
|
||||||
|
inline bool operator>=(LL::Version a, LL::Version b) {
|
||||||
|
return b < a || b == a;
|
||||||
|
}
|
||||||
|
|
||||||
|
// helper
|
||||||
|
LIAPI bool RegisterPlugin(HMODULE hPlugin, std::string name, std::string desc, LL::Version version,
|
||||||
|
std::map<std::string, std::string> others);
|
||||||
|
|
||||||
|
// Loader APIs
|
||||||
|
namespace LL {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the loader version as a string
|
||||||
|
*
|
||||||
|
* @return std::string The loader version
|
||||||
|
*/
|
||||||
|
LIAPI std::string getLoaderVersionString();
|
||||||
|
/**
|
||||||
|
* @brief Get the loader version as a Version object
|
||||||
|
*
|
||||||
|
* @return LL::Version The loader version
|
||||||
|
*/
|
||||||
|
LIAPI Version getLoaderVersion();
|
||||||
|
/**
|
||||||
|
* @brief Get whether LiteLoader is in debug mode
|
||||||
|
*
|
||||||
|
* @return bool True if it is in debug mode
|
||||||
|
*/
|
||||||
|
LIAPI bool isDebugMode();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the data path of the plugin
|
||||||
|
*
|
||||||
|
* @param pluginName The name of the plugin
|
||||||
|
* @return std::string The data path of the plugin
|
||||||
|
*/
|
||||||
|
LIAPI std::string getDataPath(const std::string& pluginName);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Register a plugin
|
||||||
|
*
|
||||||
|
* @param name The name of the plugin
|
||||||
|
* @param desc The description(introduction) of the plugin
|
||||||
|
* @param version The version of the plugin(LL::Version)
|
||||||
|
* @param git The git information of the plugin
|
||||||
|
* @param license The license of the plugin
|
||||||
|
* @param website The website
|
||||||
|
* @return bool True if the plugin is registered successfully
|
||||||
|
* @note The implementation of this function must be in header file(because of `GetCurrentModule`)
|
||||||
|
*/
|
||||||
|
inline bool registerPlugin(std::string name, std::string desc, LL::Version version,
|
||||||
|
std::string git = "", std::string license = "", std::string website = "") {
|
||||||
|
std::map<std::string, std::string> others;
|
||||||
|
if (!git.empty())
|
||||||
|
others.emplace("Git", git);
|
||||||
|
if (!license.empty())
|
||||||
|
others.emplace("License", license);
|
||||||
|
if (!website.empty())
|
||||||
|
others.emplace("Website", website);
|
||||||
|
return ::RegisterPlugin(GetCurrentModule(), name, desc, version, others);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Register a plugin
|
||||||
|
*
|
||||||
|
* @param name The name of the plugin
|
||||||
|
* @param desc The descirption(introduction) of the plugin
|
||||||
|
* @param version The version of the plugin(LL::Version)
|
||||||
|
* @param others The other information of the plugin(key-value)
|
||||||
|
* @return bool True if the plugin is registered successfully
|
||||||
|
* @note The implementation of this function must be in header file(because of `GetCurrentModule`)
|
||||||
|
*
|
||||||
|
* @par Example
|
||||||
|
* @code
|
||||||
|
* LL::registerPlugin("Test", "A test plugin", Version(0, 0, 1, Version::Dev), {{"Note","This is Note"}});
|
||||||
|
* @endcode
|
||||||
|
*/
|
||||||
|
inline bool registerPlugin(std::string name, std::string desc, LL::Version version,
|
||||||
|
std::map<std::string, std::string> others) {
|
||||||
|
return ::RegisterPlugin(GetCurrentModule(), name, desc, version, others);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get a loaded plugin by name
|
||||||
|
*
|
||||||
|
* @param name The name of the plugin
|
||||||
|
* @return LL::Plugin* The plugin(nullptr if not found)
|
||||||
|
*/
|
||||||
|
LIAPI LL::Plugin* getPlugin(std::string name);
|
||||||
|
/**
|
||||||
|
* @brief Get a loaded plugin by HMODULE handle
|
||||||
|
*
|
||||||
|
* @param name The name of the plugin
|
||||||
|
* @return LL::Plugin* The plugin(nullptr if not found)
|
||||||
|
*/
|
||||||
|
LIAPI LL::Plugin* getPlugin(HMODULE handle);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get whether the plugin is loaded
|
||||||
|
*
|
||||||
|
* @param name The name of the plugin
|
||||||
|
* @return bool True if the plugin is loaded
|
||||||
|
*/
|
||||||
|
LIAPI bool hasPlugin(std::string name);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the All the loaded plugins
|
||||||
|
*
|
||||||
|
* @return std::unordered_map<std::string, LL::Plugin*> The loaded plugins(name-plugin)
|
||||||
|
*/
|
||||||
|
LIAPI std::unordered_map<std::string, LL::Plugin*> getAllPlugins();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @breif Get the handle of LiteLoader.dll.
|
||||||
|
*
|
||||||
|
* @return HMODULE The handle
|
||||||
|
*/
|
||||||
|
LIAPI HMODULE getLoaderHandle();
|
||||||
|
|
||||||
|
/// Server Status
|
||||||
|
enum class ServerStatus {
|
||||||
|
Starting,
|
||||||
|
Running,
|
||||||
|
Stopping
|
||||||
|
};
|
||||||
|
LIAPI ServerStatus getServerStatus();
|
||||||
|
LIAPI bool isServerStarting();
|
||||||
|
LIAPI bool isServerStopping();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @breif Get LiteLoaderBDS's current language
|
||||||
|
*
|
||||||
|
* @return std::string Language(such as: en, zh_CN, ja, ru)
|
||||||
|
*/
|
||||||
|
std::string getLanguage();
|
||||||
|
}; // namespace LL
|
189
LiteLoader/Header/LoggerAPI.h
Normal file
189
LiteLoader/Header/LoggerAPI.h
Normal file
@ -0,0 +1,189 @@
|
|||||||
|
////////////////////////////////////////////////////////////////////////
|
||||||
|
// Logger System - Log text to console, file and player easily
|
||||||
|
// - Created by RimuruChan on 2021/12/11.
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// [Create Logger]
|
||||||
|
//
|
||||||
|
// Logger logger("MyPlugin"); // Create a logger (default: only log to console)
|
||||||
|
// logger.setFile("logs/MyPlugin.log"); // Optional, also record log to File
|
||||||
|
//
|
||||||
|
// auto pl = mc.getPlayer("Jim");
|
||||||
|
// if(pl)
|
||||||
|
// logger.setPlayer(pl); // Optional, also record log to a Player
|
||||||
|
// ......
|
||||||
|
// logger.setFile(nullptr); // Stop record log to File (Passing nullptr to setPlayer works like this)
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// [Use Logger]
|
||||||
|
//
|
||||||
|
// logger.info("Infomation"); // Common
|
||||||
|
// logger.error("Error! Code:{}",GetLastError()); // FMT Format
|
||||||
|
// logger.warn << "Warning! Fail to do sth." << logger.endl; // STL Format
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifndef FMT_HEADER_ONLY
|
||||||
|
#define FMT_HEADER_ONLY
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <filesystem>
|
||||||
|
#include "third-party/FMT/chrono.h"
|
||||||
|
#include "third-party/FMT/color.h"
|
||||||
|
#include "third-party/FMT/core.h"
|
||||||
|
#include "third-party/FMT/os.h"
|
||||||
|
#include "third-party/FMT/printf.h"
|
||||||
|
#include "Utils/CsLock.h"
|
||||||
|
#include "Utils/WinHelper.h"
|
||||||
|
#include "Utils/FileHelper.h"
|
||||||
|
#include "Utils/PluginOwnData.h"
|
||||||
|
#include "Utils/StringHelper.h"
|
||||||
|
#include "I18nAPI.h"
|
||||||
|
#include <string>
|
||||||
|
#include <sstream>
|
||||||
|
#include <iostream>
|
||||||
|
#include <fstream>
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
|
class Player;
|
||||||
|
|
||||||
|
#define LOGGER_CURRENT_FILE "ll_plugin_logger_file"
|
||||||
|
|
||||||
|
template <bool B, class T = void>
|
||||||
|
using enable_if_type = typename std::enable_if<B, T>::type;
|
||||||
|
|
||||||
|
HMODULE GetCurrentModule();
|
||||||
|
|
||||||
|
class Logger {
|
||||||
|
public:
|
||||||
|
class OutputStream {
|
||||||
|
friend class Logger;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
LIAPI explicit OutputStream();
|
||||||
|
|
||||||
|
public:
|
||||||
|
Logger* logger{};
|
||||||
|
int level{};
|
||||||
|
std::string consoleFormat;
|
||||||
|
std::string fileFormat;
|
||||||
|
std::string playerFormat;
|
||||||
|
fmt::text_style style;
|
||||||
|
std::string levelPrefix;
|
||||||
|
std::ostringstream os;
|
||||||
|
bool locked = false; // Deprecated
|
||||||
|
|
||||||
|
LIAPI explicit OutputStream(Logger* logger, int level, std::string&& consoleFormat, std::string&& fileFormat, std::string&& playerFormat, fmt::text_style&& style, std::string&& mode);
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
OutputStream& operator<<(T t) {
|
||||||
|
logger->lock();
|
||||||
|
os << t;
|
||||||
|
logger->unlock();
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <>
|
||||||
|
OutputStream& operator<<(std::wstring wstr) {
|
||||||
|
logger->lock();
|
||||||
|
os << wstr2str(wstr);
|
||||||
|
logger->unlock();
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
template <>
|
||||||
|
OutputStream& operator<<(const wchar_t* wstr) {
|
||||||
|
logger->lock();
|
||||||
|
os << wstr2str(wstr);
|
||||||
|
logger->unlock();
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <>
|
||||||
|
OutputStream& operator<<(void (*t)(OutputStream&)) {
|
||||||
|
t(*this);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename S, typename... Args, enable_if_type<(fmt::v8::detail::is_string<S>::value), int> = 0>
|
||||||
|
void operator()(const S& formatStr, const Args&... args) {
|
||||||
|
if constexpr (0 == sizeof...(args)) {
|
||||||
|
// Avoid fmt if only one argument
|
||||||
|
*this << formatStr << endl;
|
||||||
|
} else {
|
||||||
|
std::string str = fmt::format(formatStr, args...);
|
||||||
|
*this << str << endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename... Args>
|
||||||
|
void operator()(const char* formatStr, const Args&... args) {
|
||||||
|
if constexpr (0 == sizeof...(args)) {
|
||||||
|
// Avoid fmt if only one argument
|
||||||
|
*this << formatStr << endl;
|
||||||
|
} else {
|
||||||
|
std::string str = fmt::format(std::string(formatStr), args...);
|
||||||
|
*this << str << endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
private:
|
||||||
|
LIAPI static bool setDefaultFileImpl(HMODULE hPlugin, const std::string& logFile, bool appendMode);
|
||||||
|
LIAPI static bool setDefaultFileImpl(HMODULE hPlugin, nullptr_t);
|
||||||
|
|
||||||
|
LIAPI static void endlImpl(HMODULE hPlugin, OutputStream& o);
|
||||||
|
|
||||||
|
public:
|
||||||
|
std::string title;
|
||||||
|
std::ofstream ofs;
|
||||||
|
Player* player = nullptr;
|
||||||
|
int consoleLevel = -1;
|
||||||
|
int fileLevel = -1;
|
||||||
|
int playerLevel = -1;
|
||||||
|
|
||||||
|
~Logger() {
|
||||||
|
setFile(nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline static bool setDefaultFile(const std::string& logFile, bool appendMode) {
|
||||||
|
return setDefaultFileImpl(GetCurrentModule(), logFile, appendMode);
|
||||||
|
};
|
||||||
|
|
||||||
|
inline static bool setDefaultFile(nullptr_t a0) {
|
||||||
|
return setDefaultFileImpl(GetCurrentModule(), a0);
|
||||||
|
};
|
||||||
|
|
||||||
|
inline static void endl(OutputStream& o) {
|
||||||
|
return endlImpl(GetCurrentModule(), o);
|
||||||
|
};
|
||||||
|
|
||||||
|
LIAPI bool setFile(const std::string& logFile, bool appendMode = true);
|
||||||
|
LIAPI bool setFile(nullptr_t);
|
||||||
|
|
||||||
|
LIAPI bool tryLock();
|
||||||
|
LIAPI bool lock();
|
||||||
|
LIAPI bool unlock();
|
||||||
|
|
||||||
|
OutputStream debug;
|
||||||
|
OutputStream info;
|
||||||
|
OutputStream warn;
|
||||||
|
OutputStream error;
|
||||||
|
OutputStream fatal;
|
||||||
|
|
||||||
|
inline Logger()
|
||||||
|
: Logger("") {
|
||||||
|
}
|
||||||
|
LIAPI explicit Logger(const std::string& title);
|
||||||
|
|
||||||
|
private:
|
||||||
|
LIAPI CsLock& getLocker();
|
||||||
|
|
||||||
|
|
||||||
|
// For compatibility
|
||||||
|
private:
|
||||||
|
LIAPI static void initLockImpl(HMODULE hPlugin);
|
||||||
|
LIAPI static void lockImpl(HMODULE hPlugin);
|
||||||
|
LIAPI static void unlockImpl(HMODULE hPlugin);
|
||||||
|
};
|
44
LiteLoader/Header/MC/AABB.hpp
Normal file
44
LiteLoader/Header/MC/AABB.hpp
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
// This Header is auto generated by BDSLiteLoader Toolchain
|
||||||
|
#pragma once
|
||||||
|
#define AUTO_GENERATED
|
||||||
|
#include "../Global.h"
|
||||||
|
|
||||||
|
#define BEFORE_EXTRA
|
||||||
|
|
||||||
|
#undef BEFORE_EXTRA
|
||||||
|
|
||||||
|
class AABB {
|
||||||
|
|
||||||
|
#define AFTER_EXTRA
|
||||||
|
|
||||||
|
#undef AFTER_EXTRA
|
||||||
|
#ifndef DISABLE_CONSTRUCTOR_PREVENTION_AABB
|
||||||
|
public:
|
||||||
|
class AABB& operator=(class AABB const &) = delete;
|
||||||
|
AABB(class AABB const &) = delete;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
public:
|
||||||
|
#ifdef ENABLE_VIRTUAL_FAKESYMBOL_AABB
|
||||||
|
#endif
|
||||||
|
MCAPI AABB();
|
||||||
|
MCAPI AABB(float, float, float, float, float, float);
|
||||||
|
MCAPI AABB(class Vec3 const &, class Vec3 const &);
|
||||||
|
MCAPI class HitResult clip(class Vec3 const &, class Vec3 const &) const;
|
||||||
|
MCAPI class Vec3 clipCollide(class AABB const &, class Vec3 const &, bool, float *) const;
|
||||||
|
MCAPI bool contains(class Vec3 const &) const;
|
||||||
|
MCAPI float distanceTo(class Vec3 const &) const;
|
||||||
|
MCAPI float distanceToSqr(class AABB const &) const;
|
||||||
|
MCAPI class AABB expanded(class Vec3 const &) const;
|
||||||
|
MCAPI class AABB flooredCeiledCopy() const;
|
||||||
|
MCAPI class AABB flooredCopy(float, float) const;
|
||||||
|
MCAPI class AABB grow(class Vec3 const &) const;
|
||||||
|
MCAPI bool intersects(class AABB const &) const;
|
||||||
|
MCAPI bool intersects(class Vec3 const &, class Vec3 const &) const;
|
||||||
|
MCAPI class AABB merge(class AABB const &) const;
|
||||||
|
MCAPI class AABB & set(class Vec3 const &, class Vec3 const &);
|
||||||
|
MCAPI void set(float, float, float, float, float, float);
|
||||||
|
MCAPI class AABB shrink(class Vec3 const &) const;
|
||||||
|
MCAPI static class AABB const EMPTY;
|
||||||
|
|
||||||
|
};
|
26
LiteLoader/Header/MC/AABBBucket.hpp
Normal file
26
LiteLoader/Header/MC/AABBBucket.hpp
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
// This Header is auto generated by BDSLiteLoader Toolchain
|
||||||
|
#pragma once
|
||||||
|
#define AUTO_GENERATED
|
||||||
|
#include "../Global.h"
|
||||||
|
|
||||||
|
#define BEFORE_EXTRA
|
||||||
|
|
||||||
|
#undef BEFORE_EXTRA
|
||||||
|
|
||||||
|
struct AABBBucket {
|
||||||
|
|
||||||
|
#define AFTER_EXTRA
|
||||||
|
|
||||||
|
#undef AFTER_EXTRA
|
||||||
|
#ifndef DISABLE_CONSTRUCTOR_PREVENTION_AABBBUCKET
|
||||||
|
public:
|
||||||
|
struct AABBBucket& operator=(struct AABBBucket const &) = delete;
|
||||||
|
AABBBucket(struct AABBBucket const &) = delete;
|
||||||
|
AABBBucket() = delete;
|
||||||
|
#endif
|
||||||
|
public:
|
||||||
|
#ifdef ENABLE_VIRTUAL_FAKESYMBOL_AABBBUCKET
|
||||||
|
#endif
|
||||||
|
MCAPI void mergeAABBs();
|
||||||
|
|
||||||
|
};
|
27
LiteLoader/Header/MC/AABBPred.hpp
Normal file
27
LiteLoader/Header/MC/AABBPred.hpp
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
// This Header is auto generated by BDSLiteLoader Toolchain
|
||||||
|
#pragma once
|
||||||
|
#define AUTO_GENERATED
|
||||||
|
#include "../Global.h"
|
||||||
|
|
||||||
|
#define BEFORE_EXTRA
|
||||||
|
|
||||||
|
#undef BEFORE_EXTRA
|
||||||
|
|
||||||
|
class AABBPred {
|
||||||
|
|
||||||
|
#define AFTER_EXTRA
|
||||||
|
|
||||||
|
#undef AFTER_EXTRA
|
||||||
|
#ifndef DISABLE_CONSTRUCTOR_PREVENTION_AABBPRED
|
||||||
|
public:
|
||||||
|
class AABBPred& operator=(class AABBPred const &) = delete;
|
||||||
|
AABBPred(class AABBPred const &) = delete;
|
||||||
|
AABBPred() = delete;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
public:
|
||||||
|
#ifdef ENABLE_VIRTUAL_FAKESYMBOL_AABBPRED
|
||||||
|
#endif
|
||||||
|
MCAPI bool operator()(class AABB const &, class AABB const &) const;
|
||||||
|
|
||||||
|
};
|
33
LiteLoader/Header/MC/Abilities.hpp
Normal file
33
LiteLoader/Header/MC/Abilities.hpp
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
// This Header is auto generated by BDSLiteLoader Toolchain
|
||||||
|
#pragma once
|
||||||
|
#define AUTO_GENERATED
|
||||||
|
#include "../Global.h"
|
||||||
|
|
||||||
|
#define BEFORE_EXTRA
|
||||||
|
|
||||||
|
#undef BEFORE_EXTRA
|
||||||
|
|
||||||
|
class Abilities {
|
||||||
|
|
||||||
|
#define AFTER_EXTRA
|
||||||
|
|
||||||
|
#undef AFTER_EXTRA
|
||||||
|
public:
|
||||||
|
#ifdef ENABLE_VIRTUAL_FAKESYMBOL_ABILITIES
|
||||||
|
#endif
|
||||||
|
MCAPI Abilities();
|
||||||
|
MCAPI Abilities(class Abilities const &);
|
||||||
|
MCAPI void addSaveData(class CompoundTag &) const;
|
||||||
|
MCAPI bool loadSaveData(class CompoundTag const &);
|
||||||
|
MCAPI class Abilities & operator=(class Abilities const &);
|
||||||
|
MCAPI void setPlayerPermissions(enum PlayerPermissionLevel);
|
||||||
|
MCAPI ~Abilities();
|
||||||
|
|
||||||
|
//private:
|
||||||
|
MCAPI void _registerAbilities();
|
||||||
|
|
||||||
|
private:
|
||||||
|
MCAPI static class std::array<char const *, 18> ABILITY_NAMES;
|
||||||
|
MCAPI static std::string const TAG;
|
||||||
|
|
||||||
|
};
|
26
LiteLoader/Header/MC/Ability.hpp
Normal file
26
LiteLoader/Header/MC/Ability.hpp
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
// This Header is auto generated by BDSLiteLoader Toolchain
|
||||||
|
#pragma once
|
||||||
|
#define AUTO_GENERATED
|
||||||
|
#include "../Global.h"
|
||||||
|
|
||||||
|
#define BEFORE_EXTRA
|
||||||
|
|
||||||
|
#undef BEFORE_EXTRA
|
||||||
|
|
||||||
|
class Ability {
|
||||||
|
|
||||||
|
#define AFTER_EXTRA
|
||||||
|
|
||||||
|
#undef AFTER_EXTRA
|
||||||
|
#ifndef DISABLE_CONSTRUCTOR_PREVENTION_ABILITY
|
||||||
|
public:
|
||||||
|
class Ability& operator=(class Ability const &) = delete;
|
||||||
|
Ability(class Ability const &) = delete;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
public:
|
||||||
|
#ifdef ENABLE_VIRTUAL_FAKESYMBOL_ABILITY
|
||||||
|
#endif
|
||||||
|
MCAPI Ability();
|
||||||
|
|
||||||
|
};
|
30
LiteLoader/Header/MC/AbilityCommand.hpp
Normal file
30
LiteLoader/Header/MC/AbilityCommand.hpp
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
// This Header is auto generated by BDSLiteLoader Toolchain
|
||||||
|
#pragma once
|
||||||
|
#define AUTO_GENERATED
|
||||||
|
#include "../Global.h"
|
||||||
|
#include "Command.hpp"
|
||||||
|
|
||||||
|
#define BEFORE_EXTRA
|
||||||
|
|
||||||
|
#undef BEFORE_EXTRA
|
||||||
|
|
||||||
|
class AbilityCommand : public Command {
|
||||||
|
|
||||||
|
#define AFTER_EXTRA
|
||||||
|
|
||||||
|
#undef AFTER_EXTRA
|
||||||
|
#ifndef DISABLE_CONSTRUCTOR_PREVENTION_ABILITYCOMMAND
|
||||||
|
public:
|
||||||
|
class AbilityCommand& operator=(class AbilityCommand const &) = delete;
|
||||||
|
AbilityCommand(class AbilityCommand const &) = delete;
|
||||||
|
AbilityCommand() = delete;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
public:
|
||||||
|
/*0*/ virtual ~AbilityCommand();
|
||||||
|
/*1*/ virtual void execute(class CommandOrigin const &, class CommandOutput &) const;
|
||||||
|
#ifdef ENABLE_VIRTUAL_FAKESYMBOL_ABILITYCOMMAND
|
||||||
|
#endif
|
||||||
|
MCAPI static void setup(class CommandRegistry &);
|
||||||
|
|
||||||
|
};
|
30
LiteLoader/Header/MC/AbsorptionMobEffect.hpp
Normal file
30
LiteLoader/Header/MC/AbsorptionMobEffect.hpp
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
// This Header is auto generated by BDSLiteLoader Toolchain
|
||||||
|
#pragma once
|
||||||
|
#define AUTO_GENERATED
|
||||||
|
#include "../Global.h"
|
||||||
|
#include "MobEffect.hpp"
|
||||||
|
|
||||||
|
#define BEFORE_EXTRA
|
||||||
|
|
||||||
|
#undef BEFORE_EXTRA
|
||||||
|
|
||||||
|
class AbsorptionMobEffect : public MobEffect {
|
||||||
|
|
||||||
|
#define AFTER_EXTRA
|
||||||
|
|
||||||
|
#undef AFTER_EXTRA
|
||||||
|
#ifndef DISABLE_CONSTRUCTOR_PREVENTION_ABSORPTIONMOBEFFECT
|
||||||
|
public:
|
||||||
|
class AbsorptionMobEffect& operator=(class AbsorptionMobEffect const &) = delete;
|
||||||
|
AbsorptionMobEffect(class AbsorptionMobEffect const &) = delete;
|
||||||
|
AbsorptionMobEffect() = delete;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
public:
|
||||||
|
/*0*/ virtual ~AbsorptionMobEffect();
|
||||||
|
/*1*/ virtual void applyEffects(class Actor *, int, int) const;
|
||||||
|
/*2*/ virtual void removeEffects(class Actor *);
|
||||||
|
#ifdef ENABLE_VIRTUAL_FAKESYMBOL_ABSORPTIONMOBEFFECT
|
||||||
|
#endif
|
||||||
|
|
||||||
|
};
|
67
LiteLoader/Header/MC/AbstractArrow.hpp
Normal file
67
LiteLoader/Header/MC/AbstractArrow.hpp
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
// This Header is auto generated by BDSLiteLoader Toolchain
|
||||||
|
#pragma once
|
||||||
|
#define AUTO_GENERATED
|
||||||
|
#include "../Global.h"
|
||||||
|
#include "Actor.hpp"
|
||||||
|
|
||||||
|
#define BEFORE_EXTRA
|
||||||
|
|
||||||
|
#undef BEFORE_EXTRA
|
||||||
|
|
||||||
|
class AbstractArrow : public Actor {
|
||||||
|
|
||||||
|
#define AFTER_EXTRA
|
||||||
|
|
||||||
|
#undef AFTER_EXTRA
|
||||||
|
#ifndef DISABLE_CONSTRUCTOR_PREVENTION_ABSTRACTARROW
|
||||||
|
public:
|
||||||
|
class AbstractArrow& operator=(class AbstractArrow const &) = delete;
|
||||||
|
AbstractArrow(class AbstractArrow const &) = delete;
|
||||||
|
AbstractArrow() = delete;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
public:
|
||||||
|
/*1*/ virtual void reloadHardcoded(enum Actor::InitializationMethod, class VariantParameterList const &);
|
||||||
|
/*7*/ virtual ~AbstractArrow();
|
||||||
|
/*30*/ virtual void __unk_vfn_30();
|
||||||
|
/*36*/ virtual void lerpTo(class Vec3 const &, class Vec2 const &, int);
|
||||||
|
/*37*/ virtual void lerpMotion(class Vec3 const &);
|
||||||
|
/*39*/ virtual void normalTick();
|
||||||
|
/*54*/ virtual void __unk_vfn_54();
|
||||||
|
/*61*/ virtual void __unk_vfn_61();
|
||||||
|
/*73*/ virtual float getShadowHeightOffs();
|
||||||
|
/*74*/ virtual float getShadowRadius() const;
|
||||||
|
/*76*/ virtual void __unk_vfn_76();
|
||||||
|
/*81*/ virtual void __unk_vfn_81();
|
||||||
|
/*82*/ virtual void playerTouch(class Player &);
|
||||||
|
/*88*/ virtual void __unk_vfn_88();
|
||||||
|
/*90*/ virtual void __unk_vfn_90();
|
||||||
|
/*98*/ virtual void __unk_vfn_98();
|
||||||
|
/*100*/ virtual void __unk_vfn_100();
|
||||||
|
/*121*/ virtual void __unk_vfn_121();
|
||||||
|
/*161*/ virtual struct ActorUniqueID getSourceUniqueID() const;
|
||||||
|
/*168*/ virtual bool canChangeDimensions() const;
|
||||||
|
/*169*/ virtual void __unk_vfn_169();
|
||||||
|
/*182*/ virtual void __unk_vfn_182();
|
||||||
|
/*206*/ virtual void __unk_vfn_206();
|
||||||
|
/*207*/ virtual void __unk_vfn_207();
|
||||||
|
/*228*/ virtual void __unk_vfn_228();
|
||||||
|
/*231*/ virtual void __unk_vfn_231();
|
||||||
|
/*238*/ virtual void __unk_vfn_238();
|
||||||
|
/*242*/ virtual void readAdditionalSaveData(class CompoundTag const &, class DataLoadHelper &);
|
||||||
|
/*243*/ virtual void addAdditionalSaveData(class CompoundTag &);
|
||||||
|
/*246*/ virtual void __unk_vfn_246();
|
||||||
|
/*257*/ virtual void __unk_vfn_257();
|
||||||
|
/*258*/ virtual void shoot(class Vec3 const &, float, float, class Vec3 const &);
|
||||||
|
/*259*/ virtual void _playPickupSound();
|
||||||
|
/*260*/ virtual class ItemStack _getPickupItem() const = 0;
|
||||||
|
#ifdef ENABLE_VIRTUAL_FAKESYMBOL_ABSTRACTARROW
|
||||||
|
#endif
|
||||||
|
MCAPI AbstractArrow(class ActorDefinitionGroup *, struct ActorDefinitionIdentifier const &);
|
||||||
|
|
||||||
|
//protected:
|
||||||
|
MCAPI bool _canPickup(class Player const &) const;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
};
|
29
LiteLoader/Header/MC/AcaciaTreeCanopy.hpp
Normal file
29
LiteLoader/Header/MC/AcaciaTreeCanopy.hpp
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
// This Header is auto generated by BDSLiteLoader Toolchain
|
||||||
|
#pragma once
|
||||||
|
#define AUTO_GENERATED
|
||||||
|
#include "../Global.h"
|
||||||
|
#include "TreeHelper.hpp"
|
||||||
|
|
||||||
|
#define BEFORE_EXTRA
|
||||||
|
|
||||||
|
#undef BEFORE_EXTRA
|
||||||
|
|
||||||
|
class AcaciaTreeCanopy {
|
||||||
|
|
||||||
|
#define AFTER_EXTRA
|
||||||
|
|
||||||
|
#undef AFTER_EXTRA
|
||||||
|
#ifndef DISABLE_CONSTRUCTOR_PREVENTION_ACACIATREECANOPY
|
||||||
|
public:
|
||||||
|
class AcaciaTreeCanopy& operator=(class AcaciaTreeCanopy const &) = delete;
|
||||||
|
AcaciaTreeCanopy(class AcaciaTreeCanopy const &) = delete;
|
||||||
|
AcaciaTreeCanopy() = delete;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
public:
|
||||||
|
/*0*/ virtual ~AcaciaTreeCanopy();
|
||||||
|
/*1*/ virtual class std::optional<class BlockPos> placeCanopy(class IBlockPlacementTarget &, class BlockPos const &, class Random &, struct TreeHelper::TreeParams const &) const;
|
||||||
|
#ifdef ENABLE_VIRTUAL_FAKESYMBOL_ACACIATREECANOPY
|
||||||
|
#endif
|
||||||
|
|
||||||
|
};
|
35
LiteLoader/Header/MC/AcaciaTreeTrunk.hpp
Normal file
35
LiteLoader/Header/MC/AcaciaTreeTrunk.hpp
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
// This Header is auto generated by BDSLiteLoader Toolchain
|
||||||
|
#pragma once
|
||||||
|
#define AUTO_GENERATED
|
||||||
|
#include "../Global.h"
|
||||||
|
#include "TreeHelper.hpp"
|
||||||
|
|
||||||
|
#define BEFORE_EXTRA
|
||||||
|
|
||||||
|
#undef BEFORE_EXTRA
|
||||||
|
|
||||||
|
class AcaciaTreeTrunk {
|
||||||
|
|
||||||
|
#define AFTER_EXTRA
|
||||||
|
|
||||||
|
#undef AFTER_EXTRA
|
||||||
|
#ifndef DISABLE_CONSTRUCTOR_PREVENTION_ACACIATREETRUNK
|
||||||
|
public:
|
||||||
|
class AcaciaTreeTrunk& operator=(class AcaciaTreeTrunk const &) = delete;
|
||||||
|
AcaciaTreeTrunk(class AcaciaTreeTrunk const &) = delete;
|
||||||
|
AcaciaTreeTrunk() = delete;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
public:
|
||||||
|
/*0*/ virtual ~AcaciaTreeTrunk();
|
||||||
|
/*1*/ virtual class std::optional<class BlockPos> placeTrunk(class IBlockPlacementTarget &, class BlockPos const &, class Random &, struct TreeHelper::TreeParams const &, class ITreeCanopy const *) const;
|
||||||
|
#ifdef ENABLE_VIRTUAL_FAKESYMBOL_ACACIATREETRUNK
|
||||||
|
#endif
|
||||||
|
|
||||||
|
//private:
|
||||||
|
MCAPI void _placeLeaningBranches(class IBlockPlacementTarget &, class BlockPos const &, class BlockPos const &, class Random &, int, int, int, struct TreeHelper::TreeParams const &) const;
|
||||||
|
MCAPI void _placeVerticalBranches(class IBlockPlacementTarget &, class BlockPos const &, class BlockPos const &, class Random &, struct TreeHelper::TreeParams const &) const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
};
|
27
LiteLoader/Header/MC/AchievementData.hpp
Normal file
27
LiteLoader/Header/MC/AchievementData.hpp
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
// This Header is auto generated by BDSLiteLoader Toolchain
|
||||||
|
#pragma once
|
||||||
|
#define AUTO_GENERATED
|
||||||
|
#include "../Global.h"
|
||||||
|
|
||||||
|
#define BEFORE_EXTRA
|
||||||
|
|
||||||
|
#undef BEFORE_EXTRA
|
||||||
|
|
||||||
|
class AchievementData {
|
||||||
|
|
||||||
|
#define AFTER_EXTRA
|
||||||
|
|
||||||
|
#undef AFTER_EXTRA
|
||||||
|
#ifndef DISABLE_CONSTRUCTOR_PREVENTION_ACHIEVEMENTDATA
|
||||||
|
public:
|
||||||
|
class AchievementData& operator=(class AchievementData const &) = delete;
|
||||||
|
AchievementData(class AchievementData const &) = delete;
|
||||||
|
AchievementData() = delete;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
public:
|
||||||
|
#ifdef ENABLE_VIRTUAL_FAKESYMBOL_ACHIEVEMENTDATA
|
||||||
|
#endif
|
||||||
|
MCAPI static std::string REWARD_META_TAG_PERSONA;
|
||||||
|
|
||||||
|
};
|
30
LiteLoader/Header/MC/ActivateToolDefinition.hpp
Normal file
30
LiteLoader/Header/MC/ActivateToolDefinition.hpp
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
// This Header is auto generated by BDSLiteLoader Toolchain
|
||||||
|
#pragma once
|
||||||
|
#define AUTO_GENERATED
|
||||||
|
#include "../Global.h"
|
||||||
|
#include "Json.hpp"
|
||||||
|
#include "BehaviorDefinition.hpp"
|
||||||
|
|
||||||
|
#define BEFORE_EXTRA
|
||||||
|
|
||||||
|
#undef BEFORE_EXTRA
|
||||||
|
|
||||||
|
class ActivateToolDefinition : public BehaviorDefinition {
|
||||||
|
|
||||||
|
#define AFTER_EXTRA
|
||||||
|
|
||||||
|
#undef AFTER_EXTRA
|
||||||
|
#ifndef DISABLE_CONSTRUCTOR_PREVENTION_ACTIVATETOOLDEFINITION
|
||||||
|
public:
|
||||||
|
class ActivateToolDefinition& operator=(class ActivateToolDefinition const &) = delete;
|
||||||
|
ActivateToolDefinition(class ActivateToolDefinition const &) = delete;
|
||||||
|
ActivateToolDefinition() = delete;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
public:
|
||||||
|
/*0*/ virtual ~ActivateToolDefinition();
|
||||||
|
/*1*/ virtual void load(class Json::Value, class BehaviorFactory const &);
|
||||||
|
#ifdef ENABLE_VIRTUAL_FAKESYMBOL_ACTIVATETOOLDEFINITION
|
||||||
|
#endif
|
||||||
|
|
||||||
|
};
|
29
LiteLoader/Header/MC/ActivateToolNode.hpp
Normal file
29
LiteLoader/Header/MC/ActivateToolNode.hpp
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
// This Header is auto generated by BDSLiteLoader Toolchain
|
||||||
|
#pragma once
|
||||||
|
#define AUTO_GENERATED
|
||||||
|
#include "../Global.h"
|
||||||
|
|
||||||
|
#define BEFORE_EXTRA
|
||||||
|
|
||||||
|
#undef BEFORE_EXTRA
|
||||||
|
|
||||||
|
class ActivateToolNode {
|
||||||
|
|
||||||
|
#define AFTER_EXTRA
|
||||||
|
|
||||||
|
#undef AFTER_EXTRA
|
||||||
|
#ifndef DISABLE_CONSTRUCTOR_PREVENTION_ACTIVATETOOLNODE
|
||||||
|
public:
|
||||||
|
class ActivateToolNode& operator=(class ActivateToolNode const &) = delete;
|
||||||
|
ActivateToolNode(class ActivateToolNode const &) = delete;
|
||||||
|
ActivateToolNode() = delete;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
public:
|
||||||
|
/*0*/ virtual ~ActivateToolNode();
|
||||||
|
/*1*/ virtual enum BehaviorStatus tick(class Actor &);
|
||||||
|
/*2*/ virtual void initializeFromDefinition(class Actor &);
|
||||||
|
#ifdef ENABLE_VIRTUAL_FAKESYMBOL_ACTIVATETOOLNODE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
};
|
60
LiteLoader/Header/MC/ActivatorRailBlock.hpp
Normal file
60
LiteLoader/Header/MC/ActivatorRailBlock.hpp
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
// This Header is auto generated by BDSLiteLoader Toolchain
|
||||||
|
#pragma once
|
||||||
|
#define AUTO_GENERATED
|
||||||
|
#include "../Global.h"
|
||||||
|
#include "BaseRailBlock.hpp"
|
||||||
|
|
||||||
|
#define BEFORE_EXTRA
|
||||||
|
|
||||||
|
#undef BEFORE_EXTRA
|
||||||
|
|
||||||
|
class ActivatorRailBlock : public BaseRailBlock {
|
||||||
|
|
||||||
|
#define AFTER_EXTRA
|
||||||
|
|
||||||
|
#undef AFTER_EXTRA
|
||||||
|
#ifndef DISABLE_CONSTRUCTOR_PREVENTION_ACTIVATORRAILBLOCK
|
||||||
|
public:
|
||||||
|
class ActivatorRailBlock& operator=(class ActivatorRailBlock const &) = delete;
|
||||||
|
ActivatorRailBlock(class ActivatorRailBlock const &) = delete;
|
||||||
|
ActivatorRailBlock() = delete;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
public:
|
||||||
|
/*0*/ virtual ~ActivatorRailBlock();
|
||||||
|
/*18*/ virtual void __unk_vfn_18();
|
||||||
|
/*24*/ virtual void __unk_vfn_24();
|
||||||
|
/*25*/ virtual void __unk_vfn_25();
|
||||||
|
/*26*/ virtual void __unk_vfn_26();
|
||||||
|
/*27*/ virtual void __unk_vfn_27();
|
||||||
|
/*28*/ virtual void __unk_vfn_28();
|
||||||
|
/*30*/ virtual void __unk_vfn_30();
|
||||||
|
/*31*/ virtual void __unk_vfn_31();
|
||||||
|
/*32*/ virtual void __unk_vfn_32();
|
||||||
|
/*33*/ virtual void __unk_vfn_33();
|
||||||
|
/*34*/ virtual void __unk_vfn_34();
|
||||||
|
/*35*/ virtual void __unk_vfn_35();
|
||||||
|
/*36*/ virtual void __unk_vfn_36();
|
||||||
|
/*38*/ virtual void __unk_vfn_38();
|
||||||
|
/*39*/ virtual void __unk_vfn_39();
|
||||||
|
/*40*/ virtual void __unk_vfn_40();
|
||||||
|
/*42*/ virtual void __unk_vfn_42();
|
||||||
|
/*43*/ virtual void __unk_vfn_43();
|
||||||
|
/*49*/ virtual void __unk_vfn_49();
|
||||||
|
/*52*/ virtual void __unk_vfn_52();
|
||||||
|
/*65*/ virtual void onRedstoneUpdate(class BlockSource &, class BlockPos const &, int, bool) const;
|
||||||
|
/*67*/ virtual void __unk_vfn_67();
|
||||||
|
/*73*/ virtual void __unk_vfn_73();
|
||||||
|
/*87*/ virtual void __unk_vfn_87();
|
||||||
|
/*95*/ virtual void __unk_vfn_95();
|
||||||
|
/*109*/ virtual void __unk_vfn_109();
|
||||||
|
/*116*/ virtual void __unk_vfn_116();
|
||||||
|
/*118*/ virtual void __unk_vfn_118();
|
||||||
|
/*119*/ virtual void __unk_vfn_119();
|
||||||
|
/*141*/ virtual int getVariant(class Block const &) const;
|
||||||
|
/*142*/ virtual void __unk_vfn_142();
|
||||||
|
/*158*/ virtual void __unk_vfn_158();
|
||||||
|
#ifdef ENABLE_VIRTUAL_FAKESYMBOL_ACTIVATORRAILBLOCK
|
||||||
|
#endif
|
||||||
|
|
||||||
|
};
|
34
LiteLoader/Header/MC/ActiveDirectoryIdentity.hpp
Normal file
34
LiteLoader/Header/MC/ActiveDirectoryIdentity.hpp
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
// This Header is auto generated by BDSLiteLoader Toolchain
|
||||||
|
#pragma once
|
||||||
|
#define AUTO_GENERATED
|
||||||
|
#include "../Global.h"
|
||||||
|
|
||||||
|
#define BEFORE_EXTRA
|
||||||
|
|
||||||
|
#undef BEFORE_EXTRA
|
||||||
|
|
||||||
|
class ActiveDirectoryIdentity {
|
||||||
|
|
||||||
|
#define AFTER_EXTRA
|
||||||
|
|
||||||
|
#undef AFTER_EXTRA
|
||||||
|
#ifndef DISABLE_CONSTRUCTOR_PREVENTION_ACTIVEDIRECTORYIDENTITY
|
||||||
|
public:
|
||||||
|
class ActiveDirectoryIdentity& operator=(class ActiveDirectoryIdentity const &) = delete;
|
||||||
|
ActiveDirectoryIdentity(class ActiveDirectoryIdentity const &) = delete;
|
||||||
|
ActiveDirectoryIdentity() = delete;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
public:
|
||||||
|
#ifdef ENABLE_VIRTUAL_FAKESYMBOL_ACTIVEDIRECTORYIDENTITY
|
||||||
|
#endif
|
||||||
|
MCAPI static std::string const IS_VALID_FIELD;
|
||||||
|
MCAPI static std::string const JWT_EXPIRATION_FIELD;
|
||||||
|
MCAPI static std::string const JWT_REQUEST_ID_FIELD;
|
||||||
|
MCAPI static std::string const MUTSUrl;
|
||||||
|
MCAPI static std::string const PAYLOAD_FIELD;
|
||||||
|
MCAPI static std::string const PUBLIC_KEY;
|
||||||
|
MCAPI static std::string const REQUEST_ID_FIELD;
|
||||||
|
MCAPI static std::string const RESPONSE_FIELD;
|
||||||
|
|
||||||
|
};
|
505
LiteLoader/Header/MC/Actor.hpp
Normal file
505
LiteLoader/Header/MC/Actor.hpp
Normal file
@ -0,0 +1,505 @@
|
|||||||
|
// This Header is auto generated by BDSLiteLoader Toolchain
|
||||||
|
#pragma once
|
||||||
|
#define AUTO_GENERATED
|
||||||
|
#include "../Global.h"
|
||||||
|
|
||||||
|
#define BEFORE_EXTRA
|
||||||
|
// Add include headers & pre-declares
|
||||||
|
#include "MobEffectInstance.hpp"
|
||||||
|
#include "Tick.hpp"
|
||||||
|
#include "ActorDamageSource.hpp"
|
||||||
|
class Actor;
|
||||||
|
class Player;
|
||||||
|
class NetworkIdentifier;
|
||||||
|
class CompoundTag;
|
||||||
|
class Vec2;
|
||||||
|
class BlockInstance;
|
||||||
|
class ItemStack;
|
||||||
|
class BlockSource;
|
||||||
|
enum class FaceID : char;
|
||||||
|
|
||||||
|
#undef BEFORE_EXTRA
|
||||||
|
|
||||||
|
class Actor {
|
||||||
|
|
||||||
|
#define AFTER_EXTRA
|
||||||
|
public:
|
||||||
|
enum InitializationMethod;
|
||||||
|
|
||||||
|
LIAPI std::string getTypeName() const;
|
||||||
|
LIAPI Vec3 getFeetPosition() const;
|
||||||
|
//LIAPI BlockSource* getBlockSource() const;
|
||||||
|
LIAPI Vec2* getDirection() const;
|
||||||
|
LIAPI ActorUniqueID getActorUniqueId() const;
|
||||||
|
LIAPI Vec3 getCameraPos() const;
|
||||||
|
LIAPI Tick* getLastTick() const;
|
||||||
|
LIAPI std::vector<std::string> getAllTags();
|
||||||
|
//LIAPI BlockInstance getBlockFromViewVector(bool includeLiquid = false, bool solidOnly = false, float maxDistance = 5.25f, bool ignoreBorderBlocks = true, bool fullOnly = false) const;
|
||||||
|
//LIAPI BlockInstance getBlockFromViewVector(FaceID& face, bool includeLiquid = false, bool solidOnly = false, float maxDistance = 5.25f, bool ignoreBorderBlocks = true, bool fullOnly = false) const;
|
||||||
|
//LIAPI UserEntityIdentifierComponent* getUserEntityIdentifierComponent() const;
|
||||||
|
//LIAPI Actor* getActorFromViewVector(float maxDistance);
|
||||||
|
LIAPI BlockPos getBlockPos();
|
||||||
|
LIAPI BlockInstance getBlockStandingOn() const;
|
||||||
|
|
||||||
|
LIAPI bool isPlayer(bool allowSimulatedPlayer = true) const;
|
||||||
|
LIAPI bool isItemActor() const;
|
||||||
|
LIAPI bool isOnGround() const;
|
||||||
|
//LIAPI bool setOnFire(int time, bool isEffect);
|
||||||
|
//LIAPI bool stopFire();
|
||||||
|
LIAPI bool hasTag(const string& tag);
|
||||||
|
//LIAPI bool hurtEntity(float damage, ActorDamageCause damageCause = ActorDamageCause::ActorDamageCause_Override);
|
||||||
|
//LIAPI bool teleport(Vec3 to, int dimID, float x, float y);
|
||||||
|
//LIAPI bool teleport(Vec3 pos,int dimid);
|
||||||
|
//LIAPI ItemStack* getHandSlot();
|
||||||
|
LIAPI bool rename(const string& name);
|
||||||
|
LIAPI std::unique_ptr<CompoundTag> getNbt();
|
||||||
|
LIAPI bool setNbt(CompoundTag* nbt);
|
||||||
|
LIAPI bool refreshActorData();
|
||||||
|
LIAPI bool addEffect(MobEffect::EffectType type, int tick, int level, bool ambient = false, bool showParticles = true, bool showAnimation = false);
|
||||||
|
LIAPI float quickEvalMolangScript(const string& expression);
|
||||||
|
//LIAPI Json::Value quickEvalMolangScriptAsJson(const string& expression);
|
||||||
|
|
||||||
|
inline Vec3 getPosition()
|
||||||
|
{
|
||||||
|
return getPos();
|
||||||
|
}
|
||||||
|
inline Vec3 getPosPrev()
|
||||||
|
{
|
||||||
|
return getPosOld();
|
||||||
|
}
|
||||||
|
|
||||||
|
#undef AFTER_EXTRA
|
||||||
|
#ifndef DISABLE_CONSTRUCTOR_PREVENTION_ACTOR
|
||||||
|
public:
|
||||||
|
class Actor& operator=(class Actor const &) = delete;
|
||||||
|
Actor(class Actor const &) = delete;
|
||||||
|
Actor() = delete;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
public:
|
||||||
|
/*0*/ virtual bool hasComponent(class HashedString const &) const;
|
||||||
|
/*1*/ virtual void reloadHardcoded(enum Actor::InitializationMethod, class VariantParameterList const &);
|
||||||
|
/*2*/ virtual void reloadHardcodedClient(enum Actor::InitializationMethod, class VariantParameterList const &);
|
||||||
|
/*3*/ virtual void initializeComponents(enum Actor::InitializationMethod, class VariantParameterList const &);
|
||||||
|
/*4*/ virtual void reloadComponents(enum Actor::InitializationMethod, class VariantParameterList const &);
|
||||||
|
/*5*/ virtual void _serverInitItemStackIds();
|
||||||
|
/*6*/ virtual void _doInitialMove();
|
||||||
|
/*7*/ virtual ~Actor();
|
||||||
|
/*8*/ virtual void reset();
|
||||||
|
/*9*/ virtual int getOnDeathExperience();
|
||||||
|
/*10*/ virtual enum ActorType getOwnerEntityType();
|
||||||
|
/*11*/ virtual void remove();
|
||||||
|
/*12*/ virtual void setPos(class Vec3 const &);
|
||||||
|
/*13*/ virtual class Vec3 const & getPos() const;
|
||||||
|
/*14*/ virtual class Vec3 const & getPosOld() const;
|
||||||
|
/*15*/ virtual class Vec3 const getPosExtrapolated(float) const;
|
||||||
|
/*16*/ virtual class Vec3 getAttachPos(enum ActorLocation, float) const;
|
||||||
|
/*17*/ virtual class Vec3 getFiringPos() const;
|
||||||
|
/*18*/ virtual void setRot(class Vec2 const &);
|
||||||
|
/*19*/ virtual void move(class Vec3 const &);
|
||||||
|
/*20*/ virtual class Vec3 getInterpolatedRidingPosition(float) const;
|
||||||
|
/*21*/ virtual float getInterpolatedBodyRot(float) const;
|
||||||
|
/*22*/ virtual float getInterpolatedHeadRot(float) const;
|
||||||
|
/*23*/ virtual float getInterpolatedBodyYaw(float) const;
|
||||||
|
/*24*/ virtual float getYawSpeedInDegreesPerSecond() const;
|
||||||
|
/*25*/ virtual float getInterpolatedWalkAnimSpeed(float) const;
|
||||||
|
/*26*/ virtual class Vec3 getInterpolatedRidingOffset(float) const;
|
||||||
|
/*27*/ virtual void checkBlockCollisions(class AABB const &);
|
||||||
|
/*28*/ virtual void checkBlockCollisions();
|
||||||
|
/*29*/ virtual bool isFireImmune() const;
|
||||||
|
/*30*/ virtual void __unk_vfn_30();
|
||||||
|
/*31*/ virtual void blockedByShield(class ActorDamageSource const &, class Actor &);
|
||||||
|
/*32*/ virtual void moveRelative(float, float, float, float);
|
||||||
|
/*33*/ virtual void teleportTo(class Vec3 const &, bool, int, int, struct ActorUniqueID const &);
|
||||||
|
/*34*/ virtual bool tryTeleportTo(class Vec3 const &, bool, bool, int, int);
|
||||||
|
/*35*/ virtual void chorusFruitTeleport(class Vec3 &);
|
||||||
|
/*36*/ virtual void lerpTo(class Vec3 const &, class Vec2 const &, int);
|
||||||
|
/*37*/ virtual void lerpMotion(class Vec3 const &);
|
||||||
|
/*38*/ virtual std::unique_ptr<class AddActorBasePacket> getAddPacket();
|
||||||
|
/*39*/ virtual void normalTick();
|
||||||
|
/*40*/ virtual void baseTick();
|
||||||
|
/*41*/ virtual void rideTick();
|
||||||
|
/*42*/ virtual void positionRider(class Actor &, float);
|
||||||
|
/*43*/ virtual float getRidingHeight();
|
||||||
|
/*44*/ virtual bool startRiding(class Actor &);
|
||||||
|
/*45*/ virtual void addRider(class Actor &);
|
||||||
|
/*46*/ virtual void flagRiderToRemove(class Actor &);
|
||||||
|
/*47*/ virtual std::string getExitTip(std::string const &, enum InputMode) const;
|
||||||
|
/*48*/ virtual bool intersects(class Vec3 const &, class Vec3 const &) const;
|
||||||
|
/*49*/ virtual bool isFree(class Vec3 const &, float);
|
||||||
|
/*50*/ virtual bool isFree(class Vec3 const &);
|
||||||
|
/*51*/ virtual bool isInWall() const;
|
||||||
|
/*52*/ virtual bool isInvisible() const;
|
||||||
|
/*53*/ virtual bool canShowNameTag() const;
|
||||||
|
/*54*/ virtual void __unk_vfn_54();
|
||||||
|
/*55*/ virtual void setNameTagVisible(bool);
|
||||||
|
/*56*/ virtual std::string const & getNameTag() const;
|
||||||
|
/*57*/ virtual unsigned __int64 getNameTagAsHash() const;
|
||||||
|
/*58*/ virtual std::string getFormattedNameTag() const;
|
||||||
|
/*59*/ virtual void filterFormattedNameTag(class UIProfanityContext const &);
|
||||||
|
/*60*/ virtual void setNameTag(std::string const &);
|
||||||
|
/*61*/ virtual void __unk_vfn_61();
|
||||||
|
/*62*/ virtual void setScoreTag(std::string const &);
|
||||||
|
/*63*/ virtual std::string const & getScoreTag() const;
|
||||||
|
/*64*/ virtual bool isInWater() const;
|
||||||
|
/*65*/ virtual bool hasEnteredWater() const;
|
||||||
|
/*66*/ virtual bool isImmersedInWater() const;
|
||||||
|
/*67*/ virtual bool isInWaterOrRain() const;
|
||||||
|
/*68*/ virtual bool isInLava() const;
|
||||||
|
/*69*/ virtual bool isUnderLiquid(enum MaterialType) const;
|
||||||
|
/*70*/ virtual bool isOverWater() const;
|
||||||
|
/*71*/ virtual void makeStuckInBlock(float);
|
||||||
|
/*72*/ virtual float getCameraOffset() const;
|
||||||
|
/*73*/ virtual float getShadowHeightOffs();
|
||||||
|
/*74*/ virtual float getShadowRadius() const;
|
||||||
|
/*75*/ virtual class Vec3 getHeadLookVector(float);
|
||||||
|
/*76*/ virtual void __unk_vfn_76();
|
||||||
|
/*77*/ virtual bool canSee(class Actor const &) const;
|
||||||
|
/*78*/ virtual bool canSee(class Vec3 const &) const;
|
||||||
|
/*79*/ virtual bool isSkyLit(float);
|
||||||
|
/*80*/ virtual float getBrightness(float) const;
|
||||||
|
/*81*/ virtual void __unk_vfn_81();
|
||||||
|
/*82*/ virtual void playerTouch(class Player &);
|
||||||
|
/*83*/ virtual void onAboveBubbleColumn(bool);
|
||||||
|
/*84*/ virtual void onInsideBubbleColumn(bool);
|
||||||
|
/*85*/ virtual bool isImmobile() const;
|
||||||
|
/*86*/ virtual bool isSilent();
|
||||||
|
/*87*/ virtual bool isPickable();
|
||||||
|
/*88*/ virtual void __unk_vfn_88();
|
||||||
|
/*89*/ virtual bool isSleeping() const;
|
||||||
|
/*90*/ virtual void __unk_vfn_90();
|
||||||
|
/*91*/ virtual bool isSneaking() const;
|
||||||
|
/*92*/ virtual void setSneaking(bool);
|
||||||
|
/*93*/ virtual bool isBlocking() const;
|
||||||
|
/*94*/ virtual bool isDamageBlocked(class ActorDamageSource const &) const;
|
||||||
|
/*95*/ virtual bool isAlive() const;
|
||||||
|
/*96*/ virtual bool isOnFire() const;
|
||||||
|
/*97*/ virtual bool isOnHotBlock() const;
|
||||||
|
/*98*/ virtual void __unk_vfn_98();
|
||||||
|
/*99*/ virtual bool isSurfaceMob() const;
|
||||||
|
/*100*/ virtual void __unk_vfn_100();
|
||||||
|
/*101*/ virtual bool canAttack(class Actor *, bool) const;
|
||||||
|
/*102*/ virtual void setTarget(class Actor *);
|
||||||
|
/*103*/ virtual class Actor * findAttackTarget();
|
||||||
|
/*104*/ virtual bool isValidTarget(class Actor *) const;
|
||||||
|
/*105*/ virtual bool attack(class Actor &);
|
||||||
|
/*106*/ virtual void performRangedAttack(class Actor &, float);
|
||||||
|
/*107*/ virtual void adjustDamageAmount(int &) const;
|
||||||
|
/*108*/ virtual int getEquipmentCount() const;
|
||||||
|
/*109*/ virtual void setOwner(struct ActorUniqueID);
|
||||||
|
/*110*/ virtual void setSitting(bool);
|
||||||
|
/*111*/ virtual void onTame();
|
||||||
|
/*112*/ virtual void onFailedTame();
|
||||||
|
/*113*/ virtual int getInventorySize() const;
|
||||||
|
/*114*/ virtual int getEquipSlots() const;
|
||||||
|
/*115*/ virtual int getChestSlots() const;
|
||||||
|
/*116*/ virtual void setStanding(bool);
|
||||||
|
/*117*/ virtual bool canPowerJump() const;
|
||||||
|
/*118*/ virtual void setCanPowerJump(bool);
|
||||||
|
/*119*/ virtual bool isJumping() const;
|
||||||
|
/*120*/ virtual bool isEnchanted() const;
|
||||||
|
/*121*/ virtual void __unk_vfn_121();
|
||||||
|
/*122*/ virtual void rideLanded(class Vec3 const &, class Vec3 const &);
|
||||||
|
/*123*/ virtual bool shouldRender() const;
|
||||||
|
/*124*/ virtual bool isInvulnerableTo(class ActorDamageSource const &) const;
|
||||||
|
/*125*/ virtual enum ActorDamageCause getBlockDamageCause(class Block const &) const;
|
||||||
|
/*126*/ virtual void actuallyHurt(int, class ActorDamageSource const &, bool);
|
||||||
|
/*127*/ virtual void animateHurt();
|
||||||
|
/*128*/ virtual bool doFireHurt(int);
|
||||||
|
/*129*/ virtual void onLightningHit();
|
||||||
|
/*130*/ virtual void onBounceStarted(class BlockPos const &, class Block const &);
|
||||||
|
/*131*/ virtual void feed(int);
|
||||||
|
/*132*/ virtual void handleEntityEvent(enum ActorEvent, int);
|
||||||
|
/*133*/ virtual float getPickRadius();
|
||||||
|
/*134*/ virtual class HashedString const & getActorRendererId() const;
|
||||||
|
/*135*/ virtual class ItemActor * spawnAtLocation(int, int);
|
||||||
|
/*136*/ virtual class ItemActor * spawnAtLocation(int, int, float);
|
||||||
|
/*137*/ virtual class ItemActor * spawnAtLocation(class Block const &, int);
|
||||||
|
/*138*/ virtual class ItemActor * spawnAtLocation(class Block const &, int, float);
|
||||||
|
/*139*/ virtual class ItemActor * spawnAtLocation(class ItemStack const &, float);
|
||||||
|
/*140*/ virtual void despawn();
|
||||||
|
/*141*/ virtual void killed(class Actor &);
|
||||||
|
/*142*/ virtual void awardKillScore(class Actor &, int);
|
||||||
|
/*143*/ virtual void setArmor(enum ArmorSlot, class ItemStack const &);
|
||||||
|
/*144*/ virtual class ItemStack const & getArmor(enum ArmorSlot) const;
|
||||||
|
/*145*/ virtual enum ArmorMaterialType getArmorMaterialTypeInSlot(enum ArmorSlot) const;
|
||||||
|
/*146*/ virtual enum ArmorTextureType getArmorMaterialTextureTypeInSlot(enum ArmorSlot) const;
|
||||||
|
/*147*/ virtual float getArmorColorInSlot(enum ArmorSlot, int) const;
|
||||||
|
/*148*/ virtual void setEquippedSlot(enum ArmorSlot, int, int);
|
||||||
|
/*149*/ virtual void setEquippedSlot(enum ArmorSlot, class ItemStack const &);
|
||||||
|
/*150*/ virtual class ItemStack const & getCarriedItem() const;
|
||||||
|
/*151*/ virtual void setCarriedItem(class ItemStack const &);
|
||||||
|
/*152*/ virtual void setOffhandSlot(class ItemStack const &);
|
||||||
|
/*153*/ virtual class ItemStack const & getEquippedTotem() const;
|
||||||
|
/*154*/ virtual bool consumeTotem();
|
||||||
|
/*155*/ virtual bool save(class CompoundTag &);
|
||||||
|
/*156*/ virtual void saveWithoutId(class CompoundTag &);
|
||||||
|
/*157*/ virtual bool load(class CompoundTag const &, class DataLoadHelper &);
|
||||||
|
/*158*/ virtual void loadLinks(class CompoundTag const &, std::vector<struct ActorLink> &, class DataLoadHelper &);
|
||||||
|
/*159*/ virtual enum ActorType getEntityTypeId() const;
|
||||||
|
/*160*/ virtual class HashedString const & queryEntityRenderer() const;
|
||||||
|
/*161*/ virtual struct ActorUniqueID getSourceUniqueID() const;
|
||||||
|
/*162*/ virtual void setOnFire(int);
|
||||||
|
/*163*/ virtual class AABB getHandleWaterAABB() const;
|
||||||
|
/*164*/ virtual void handleInsidePortal(class BlockPos const &);
|
||||||
|
/*165*/ virtual int getPortalCooldown() const;
|
||||||
|
/*166*/ virtual int getPortalWaitTime() const;
|
||||||
|
/*167*/ virtual class AutomaticID<class Dimension, int> getDimensionId() const;
|
||||||
|
/*168*/ virtual bool canChangeDimensions() const;
|
||||||
|
/*169*/ virtual void __unk_vfn_169();
|
||||||
|
/*170*/ virtual void changeDimension(class AutomaticID<class Dimension, int>, bool);
|
||||||
|
/*171*/ virtual struct ActorUniqueID getControllingPlayer() const;
|
||||||
|
/*172*/ virtual void checkFallDamage(float, bool);
|
||||||
|
/*173*/ virtual void causeFallDamage(float);
|
||||||
|
/*174*/ virtual void handleFallDistanceOnServer(float, bool);
|
||||||
|
/*175*/ virtual void playSynchronizedSound(enum LevelSoundEvent, class Vec3 const &, class Block const &, bool);
|
||||||
|
/*176*/ virtual void playSynchronizedSound(enum LevelSoundEvent, class Vec3 const &, int, bool);
|
||||||
|
/*177*/ virtual void onSynchedDataUpdate(int);
|
||||||
|
/*178*/ virtual bool canAddRider(class Actor &) const;
|
||||||
|
/*179*/ virtual bool canPickupItem(class ItemStack const &) const;
|
||||||
|
/*180*/ virtual bool canBePulledIntoVehicle() const;
|
||||||
|
/*181*/ virtual bool inCaravan() const;
|
||||||
|
/*182*/ virtual void __unk_vfn_182();
|
||||||
|
/*183*/ virtual void tickLeash();
|
||||||
|
/*184*/ virtual void sendMotionPacketIfNeeded();
|
||||||
|
/*185*/ virtual bool canSynchronizeNewEntity() const;
|
||||||
|
/*186*/ virtual void stopRiding(bool, bool, bool);
|
||||||
|
/*187*/ virtual void startSwimming();
|
||||||
|
/*188*/ virtual void stopSwimming();
|
||||||
|
/*189*/ virtual void buildDebugInfo(std::string &) const;
|
||||||
|
/*190*/ virtual enum CommandPermissionLevel getCommandPermissionLevel() const;
|
||||||
|
/*191*/ virtual class AttributeInstance * getMutableAttribute(class Attribute const &);
|
||||||
|
/*192*/ virtual class AttributeInstance const & getAttribute(class Attribute const &) const;
|
||||||
|
/*193*/ virtual int getDeathTime() const;
|
||||||
|
/*194*/ virtual void heal(int);
|
||||||
|
/*195*/ virtual bool isInvertedHealAndHarm() const;
|
||||||
|
/*196*/ virtual bool canBeAffected(int) const;
|
||||||
|
/*197*/ virtual bool canBeAffected(class MobEffectInstance const &) const;
|
||||||
|
/*198*/ virtual bool canBeAffectedByArrow(class MobEffectInstance const &) const;
|
||||||
|
/*199*/ virtual void onEffectAdded(class MobEffectInstance &);
|
||||||
|
/*200*/ virtual void onEffectUpdated(class MobEffectInstance const &);
|
||||||
|
/*201*/ virtual void onEffectRemoved(class MobEffectInstance &);
|
||||||
|
/*202*/ virtual class AnimationComponent & getAnimationComponent();
|
||||||
|
/*203*/ virtual void openContainerComponent(class Player &);
|
||||||
|
/*204*/ virtual void swing();
|
||||||
|
/*205*/ virtual void useItem(class ItemStack &, enum ItemUseMethod, bool);
|
||||||
|
/*206*/ virtual void __unk_vfn_206();
|
||||||
|
/*207*/ virtual void __unk_vfn_207();
|
||||||
|
/*208*/ virtual void getDebugText(std::vector<std::string> &);
|
||||||
|
/*209*/ virtual float getMapDecorationRotation() const;
|
||||||
|
/*210*/ virtual float getRiderYRotation(class Actor const &) const;
|
||||||
|
/*211*/ virtual float getYHeadRot() const;
|
||||||
|
/*212*/ virtual bool isWorldBuilder();
|
||||||
|
/*213*/ virtual bool isCreative() const;
|
||||||
|
/*214*/ virtual bool isAdventure() const;
|
||||||
|
/*215*/ virtual bool add(class ItemStack &);
|
||||||
|
/*216*/ virtual bool drop(class ItemStack const &, bool);
|
||||||
|
/*217*/ virtual bool getInteraction(class Player &, class ActorInteraction &, class Vec3 const &);
|
||||||
|
/*218*/ virtual bool canDestroyBlock(class Block const &) const;
|
||||||
|
/*219*/ virtual void setAuxValue(int);
|
||||||
|
/*220*/ virtual void setSize(float, float);
|
||||||
|
/*221*/ virtual int getLifeSpan() const;
|
||||||
|
/*222*/ virtual void onOrphan();
|
||||||
|
/*223*/ virtual void wobble();
|
||||||
|
/*224*/ virtual bool wasHurt();
|
||||||
|
/*225*/ virtual void startSpinAttack();
|
||||||
|
/*226*/ virtual void stopSpinAttack();
|
||||||
|
/*227*/ virtual void setDamageNearbyMobs(bool);
|
||||||
|
/*228*/ virtual void __unk_vfn_228();
|
||||||
|
/*229*/ virtual void reloadLootTable();
|
||||||
|
/*230*/ virtual void reloadLootTable(struct EquipmentTableDescription const *);
|
||||||
|
/*231*/ virtual void __unk_vfn_231();
|
||||||
|
/*232*/ virtual void kill();
|
||||||
|
/*233*/ virtual void die(class ActorDamageSource const &);
|
||||||
|
/*234*/ virtual bool shouldTick() const;
|
||||||
|
/*235*/ virtual void updateEntitySpecificMolangVariables(class RenderParams &);
|
||||||
|
/*236*/ virtual bool shouldTryMakeStepSound();
|
||||||
|
/*237*/ virtual float getNextStep(float);
|
||||||
|
/*238*/ virtual void __unk_vfn_238();
|
||||||
|
/*239*/ virtual void outOfWorld();
|
||||||
|
/*240*/ virtual bool _hurt(class ActorDamageSource const &, int, bool, bool);
|
||||||
|
/*241*/ virtual void markHurt();
|
||||||
|
/*242*/ virtual void readAdditionalSaveData(class CompoundTag const &, class DataLoadHelper &);
|
||||||
|
/*243*/ virtual void addAdditionalSaveData(class CompoundTag &);
|
||||||
|
/*244*/ virtual void _playStepSound(class BlockPos const &, class Block const &);
|
||||||
|
/*245*/ virtual void _playFlySound(class BlockPos const &, class Block const &);
|
||||||
|
/*246*/ virtual void __unk_vfn_246();
|
||||||
|
/*247*/ virtual void checkInsideBlocks(float);
|
||||||
|
/*248*/ virtual void pushOutOfBlocks(class Vec3 const &);
|
||||||
|
/*249*/ virtual bool updateWaterState();
|
||||||
|
/*250*/ virtual void doWaterSplashEffect();
|
||||||
|
/*251*/ virtual void spawnTrailBubbles();
|
||||||
|
/*252*/ virtual void updateInsideBlock();
|
||||||
|
/*253*/ virtual class LootTable * getLootTable();
|
||||||
|
/*254*/ virtual class LootTable * getDefaultLootTable();
|
||||||
|
/*255*/ virtual void _removeRider(struct ActorUniqueID const &, bool, bool, bool);
|
||||||
|
/*256*/ virtual void _onSizeUpdated();
|
||||||
|
#ifdef ENABLE_VIRTUAL_FAKESYMBOL_ACTOR
|
||||||
|
MCVAPI void _doAutoAttackOnTouch(class Actor &);
|
||||||
|
MCVAPI bool _makeFlySound() const;
|
||||||
|
MCVAPI bool breaksFallingBlocks() const;
|
||||||
|
MCVAPI bool canExistInPeaceful() const;
|
||||||
|
MCVAPI bool canMakeStepSound() const;
|
||||||
|
MCVAPI bool canSeeInvisible() const;
|
||||||
|
MCVAPI bool canSynchronizeNewEntity() const;
|
||||||
|
MCVAPI void changeDimension(class ChangeDimensionPacket const &);
|
||||||
|
MCVAPI bool getAlwaysShowNameTag() const;
|
||||||
|
MCVAPI float getDeletionDelayTimeSeconds() const;
|
||||||
|
MCVAPI int getOutputSignal() const;
|
||||||
|
MCVAPI bool hasOutputSignal(unsigned char) const;
|
||||||
|
MCVAPI bool interactPreventDefault();
|
||||||
|
MCVAPI bool isCreativeModeAllowed();
|
||||||
|
MCVAPI bool isFishable() const;
|
||||||
|
MCVAPI bool isLeashableType();
|
||||||
|
MCVAPI bool isShootable();
|
||||||
|
MCVAPI bool isTargetable() const;
|
||||||
|
MCVAPI void renderDebugServerState(class Options const &);
|
||||||
|
MCVAPI void rideJumped();
|
||||||
|
#endif
|
||||||
|
MCAPI Actor(class ActorDefinitionGroup *, struct ActorDefinitionIdentifier const &);
|
||||||
|
MCAPI Actor(class Level &);
|
||||||
|
MCAPI class Vec3 _randomHeartPos();
|
||||||
|
MCAPI void _sendDirtyActorData();
|
||||||
|
MCAPI bool _tryPlaceAt(class Vec3 const &);
|
||||||
|
MCAPI void addEffect(class MobEffectInstance const &);
|
||||||
|
MCAPI bool addTag(std::string const &);
|
||||||
|
MCAPI int calculateAttackDamage(class Actor &);
|
||||||
|
MCAPI bool canBeginOrContinueClimbingLadder() const;
|
||||||
|
MCAPI bool canCurrentlySwim() const;
|
||||||
|
MCAPI void celebrateHunt(int, bool);
|
||||||
|
MCAPI void dropLeash(bool, bool);
|
||||||
|
MCAPI void dropTowards(class ItemStack const &, class Vec3);
|
||||||
|
MCAPI std::vector<struct DistanceSortedActor> fetchNearbyActorsSorted(class Vec3 const &, enum ActorType);
|
||||||
|
MCAPI void forEachLeashedActor(class std::function<void (class gsl::not_null<class Actor *>)>);
|
||||||
|
MCAPI class BlockPos getBlockPosCurrentlyStandingOn(class Actor *) const;
|
||||||
|
MCAPI enum PaletteColor getColor() const;
|
||||||
|
MCAPI enum PaletteColor getColor2() const;
|
||||||
|
MCAPI int getControllingSeat();
|
||||||
|
MCAPI class MobEffectInstance const * getEffect(class MobEffect const &) const;
|
||||||
|
MCAPI std::vector<struct ActorLink> getLinks() const;
|
||||||
|
MCAPI int getMarkVariant() const;
|
||||||
|
MCAPI class ItemStack const & getOffhandSlot() const;
|
||||||
|
MCAPI class Mob * getOwner() const;
|
||||||
|
MCAPI struct ActorUniqueID const getOwnerId() const;
|
||||||
|
MCAPI std::unique_ptr<class CompoundTag> getPersistingTradeOffers();
|
||||||
|
MCAPI class Player * getPlayerOwner() const;
|
||||||
|
MCAPI class Random & getRandom() const;
|
||||||
|
MCAPI class Actor * getRideRoot() const;
|
||||||
|
MCAPI int getRiderIndex(class Actor &) const;
|
||||||
|
MCAPI class ActorRuntimeID getRuntimeID() const;
|
||||||
|
MCAPI int getSkinID() const;
|
||||||
|
MCAPI bool getStatusFlag(enum ActorFlags) const;
|
||||||
|
MCAPI int getStrength() const;
|
||||||
|
MCAPI int getStructuralIntegrity() const;
|
||||||
|
MCAPI class Actor * getTarget() const;
|
||||||
|
MCAPI class ITickingArea * getTickingArea();
|
||||||
|
MCAPI class MerchantRecipeList * getTradeOffers();
|
||||||
|
MCAPI class Player * getTradingPlayer() const;
|
||||||
|
MCAPI struct ActorUniqueID const & getUniqueID() const;
|
||||||
|
MCAPI int getVariant() const;
|
||||||
|
MCAPI class Vec3 getViewVector(float) const;
|
||||||
|
MCAPI bool hasEffect(class MobEffect const &) const;
|
||||||
|
MCAPI bool hasFamily(class HashedString const &) const;
|
||||||
|
MCAPI bool hasPlayerRider() const;
|
||||||
|
MCAPI bool hasRestriction() const;
|
||||||
|
MCAPI bool hasTag(std::string const &) const;
|
||||||
|
MCAPI bool hasTags() const;
|
||||||
|
MCAPI bool hasTickingArea() const;
|
||||||
|
MCAPI bool hurt(class ActorDamageSource const &, int, bool, bool);
|
||||||
|
MCAPI void initEntity(class EntityRegistryOwned &);
|
||||||
|
MCAPI bool isControlledByLocalInstance() const;
|
||||||
|
MCAPI bool isInRain() const;
|
||||||
|
MCAPI bool isInsideBorderBlock(float) const;
|
||||||
|
MCAPI bool isPacified() const;
|
||||||
|
MCAPI bool isRider(class Actor const &) const;
|
||||||
|
MCAPI bool isRiding() const;
|
||||||
|
MCAPI bool isUnderWaterfall() const;
|
||||||
|
MCAPI bool isWithinRestriction(class BlockPos const &) const;
|
||||||
|
MCAPI void loadEntityFlags(class CompoundTag const &, class DataLoadHelper &);
|
||||||
|
MCAPI void moveBBs(class Vec3 const &);
|
||||||
|
MCAPI void moveTo(class Vec3 const &, class Vec2 const &);
|
||||||
|
MCAPI bool onLadder() const;
|
||||||
|
MCAPI void pickUpItem(class ItemActor &, int);
|
||||||
|
MCAPI void playSound(enum LevelSoundEvent, class Vec3 const &, int);
|
||||||
|
MCAPI void positionAllRiders();
|
||||||
|
MCAPI bool pullInEntity(class Actor &);
|
||||||
|
MCAPI void pushBackActionEventToActionQueue(class ActionEvent);
|
||||||
|
MCAPI void reload();
|
||||||
|
MCAPI void removeAllEffects();
|
||||||
|
MCAPI void removeAllRiders(bool, bool);
|
||||||
|
MCAPI void removeEffect(int);
|
||||||
|
MCAPI void removeEffectParticles();
|
||||||
|
MCAPI void saveEntityFlags(class CompoundTag &);
|
||||||
|
MCAPI std::unique_ptr<class ListTag> saveLinks() const;
|
||||||
|
MCAPI void savePersistingTrade(std::unique_ptr<class CompoundTag>, int);
|
||||||
|
MCAPI void sendActorDefinitionEventTriggered(std::string const &);
|
||||||
|
MCAPI void sendMotionToServer();
|
||||||
|
MCAPI void setBaseDefinition(struct ActorDefinitionIdentifier const &, bool, bool);
|
||||||
|
MCAPI void setCanClimb(bool);
|
||||||
|
MCAPI void setCanFly(bool);
|
||||||
|
MCAPI void setColor(enum PaletteColor);
|
||||||
|
MCAPI void setColor2(enum PaletteColor);
|
||||||
|
MCAPI void setHurtDir(int);
|
||||||
|
MCAPI void setHurtTime(int);
|
||||||
|
MCAPI void setInLove(class Actor *);
|
||||||
|
MCAPI void setInvisible(bool);
|
||||||
|
MCAPI void setJumpDuration(int);
|
||||||
|
MCAPI void setLeashHolder(struct ActorUniqueID);
|
||||||
|
MCAPI void setLimitedLife(int);
|
||||||
|
MCAPI void setMarkVariant(int);
|
||||||
|
MCAPI void setPersistent();
|
||||||
|
MCAPI void setPreviousPosRot(class Vec3 const &, class Vec2 const &);
|
||||||
|
MCAPI void setSeatDescription(class Vec3 const &, struct SeatDescription const &);
|
||||||
|
MCAPI void setSkinID(int);
|
||||||
|
MCAPI bool setStatusFlag(enum ActorFlags, bool);
|
||||||
|
MCAPI void setStrength(int);
|
||||||
|
MCAPI void setStrengthMax(int);
|
||||||
|
MCAPI void setStructuralIntegrity(int);
|
||||||
|
MCAPI void setTradingPlayer(class Player *);
|
||||||
|
MCAPI void setVariant(int);
|
||||||
|
MCAPI bool shouldOrphan(class BlockSource &);
|
||||||
|
MCAPI void spawnBalloonPopParticles();
|
||||||
|
MCAPI void spawnDeathParticles();
|
||||||
|
MCAPI void spawnDustParticles(int);
|
||||||
|
MCAPI void spawnEatParticles(class ItemStack const &, int);
|
||||||
|
MCAPI void spawnTamingParticles(bool);
|
||||||
|
MCAPI void teleportRidersTo(class Vec3 const &, int, int);
|
||||||
|
MCAPI void testForCollidableMobs(class BlockSource &, class AABB const &, std::vector<class AABB> &);
|
||||||
|
MCAPI bool tick(class BlockSource &);
|
||||||
|
MCAPI void transferTickingArea(class Dimension &);
|
||||||
|
MCAPI void updateBBFromDescription();
|
||||||
|
MCAPI void updateDescription();
|
||||||
|
MCAPI void updateInBubbleColumnState();
|
||||||
|
MCAPI void updateInvisibilityStatus();
|
||||||
|
MCAPI void updateTickingData();
|
||||||
|
MCAPI static float const DEFAULT_AMBIENT_SOUND_INTERVAL;
|
||||||
|
MCAPI static float const DEFAULT_AMBIENT_SOUND_INTERVAL_RANGE;
|
||||||
|
MCAPI static int const MAX_BYTE_CHARGE_AMOUNT;
|
||||||
|
MCAPI static std::string const RIDING_TAG;
|
||||||
|
MCAPI static void checkEntityOnewayCollision(class BlockSource &, class BlockPos const &);
|
||||||
|
|
||||||
|
//protected:
|
||||||
|
MCAPI bool _damageSensorComponentHurt(int &, int, class ActorDamageSource const &);
|
||||||
|
MCAPI class Block const & _getBlockWhenClimbing() const;
|
||||||
|
MCAPI void _playMovementSound(bool);
|
||||||
|
MCAPI void _refreshAABB();
|
||||||
|
MCAPI void _setNetherPortalData(class AutomaticID<class Dimension, int>, class AutomaticID<class Dimension, int>, int);
|
||||||
|
|
||||||
|
//private:
|
||||||
|
MCAPI void _exitRide(class Actor const &, float);
|
||||||
|
MCAPI void _initializeLeashRopeSystem();
|
||||||
|
MCAPI void _manageRiders(class BlockSource &);
|
||||||
|
MCAPI void _moveHitboxTo(class Vec3 const &);
|
||||||
|
MCAPI void _sendLinkPacket(struct ActorLink const &) const;
|
||||||
|
MCAPI void _serializeComponents(class CompoundTag &);
|
||||||
|
MCAPI void _spawnPukeParticles();
|
||||||
|
MCAPI void _spawnTreasureHuntingParticles();
|
||||||
|
MCAPI void _tryPlantWitherRose();
|
||||||
|
MCAPI void _updateComposition(bool);
|
||||||
|
MCAPI void _updateOwnerChunk();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
};
|
29
LiteLoader/Header/MC/ActorAnimationController.hpp
Normal file
29
LiteLoader/Header/MC/ActorAnimationController.hpp
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
// This Header is auto generated by BDSLiteLoader Toolchain
|
||||||
|
#pragma once
|
||||||
|
#define AUTO_GENERATED
|
||||||
|
#include "../Global.h"
|
||||||
|
|
||||||
|
#define BEFORE_EXTRA
|
||||||
|
|
||||||
|
#undef BEFORE_EXTRA
|
||||||
|
|
||||||
|
class ActorAnimationController {
|
||||||
|
|
||||||
|
#define AFTER_EXTRA
|
||||||
|
|
||||||
|
#undef AFTER_EXTRA
|
||||||
|
#ifndef DISABLE_CONSTRUCTOR_PREVENTION_ACTORANIMATIONCONTROLLER
|
||||||
|
public:
|
||||||
|
class ActorAnimationController& operator=(class ActorAnimationController const &) = delete;
|
||||||
|
ActorAnimationController(class ActorAnimationController const &) = delete;
|
||||||
|
ActorAnimationController() = delete;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
public:
|
||||||
|
#ifdef ENABLE_VIRTUAL_FAKESYMBOL_ACTORANIMATIONCONTROLLER
|
||||||
|
#endif
|
||||||
|
MCAPI class std::shared_ptr<class ActorAnimationControllerState> & addState(class HashedString const &);
|
||||||
|
MCAPI unsigned __int64 findStateIndex(std::string const &, bool, unsigned __int64) const;
|
||||||
|
MCAPI void resolveTransitionStateIndices();
|
||||||
|
|
||||||
|
};
|
40
LiteLoader/Header/MC/ActorAnimationControllerGroup.hpp
Normal file
40
LiteLoader/Header/MC/ActorAnimationControllerGroup.hpp
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
// This Header is auto generated by BDSLiteLoader Toolchain
|
||||||
|
#pragma once
|
||||||
|
#define AUTO_GENERATED
|
||||||
|
#include "../Global.h"
|
||||||
|
#include "Core.hpp"
|
||||||
|
#include "JsonUtil.hpp"
|
||||||
|
#include "Json.hpp"
|
||||||
|
|
||||||
|
#define BEFORE_EXTRA
|
||||||
|
|
||||||
|
#undef BEFORE_EXTRA
|
||||||
|
|
||||||
|
class ActorAnimationControllerGroup {
|
||||||
|
|
||||||
|
#define AFTER_EXTRA
|
||||||
|
|
||||||
|
#undef AFTER_EXTRA
|
||||||
|
#ifndef DISABLE_CONSTRUCTOR_PREVENTION_ACTORANIMATIONCONTROLLERGROUP
|
||||||
|
public:
|
||||||
|
class ActorAnimationControllerGroup& operator=(class ActorAnimationControllerGroup const &) = delete;
|
||||||
|
ActorAnimationControllerGroup(class ActorAnimationControllerGroup const &) = delete;
|
||||||
|
ActorAnimationControllerGroup() = delete;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
public:
|
||||||
|
#ifdef ENABLE_VIRTUAL_FAKESYMBOL_ACTORANIMATIONCONTROLLERGROUP
|
||||||
|
#endif
|
||||||
|
MCAPI class std::shared_ptr<class ActorAnimationControllerInfo> getActorAnimationControllerInfo(class HashedString const &);
|
||||||
|
MCAPI void loadActorAnimationControllersSync(class ResourcePackManager &);
|
||||||
|
|
||||||
|
//private:
|
||||||
|
MCAPI void _loadActorAnimationController(std::string const &, class Core::Path const &, enum CurrentCmdVersion);
|
||||||
|
MCAPI static class std::shared_ptr<class JsonUtil::JsonSchemaObjectNode<class JsonUtil::EmptyClass, struct ActorAnimationControllerGroupParseMetaData>> _buildAnimationControllerFileSchema_v1_10();
|
||||||
|
MCAPI static class std::shared_ptr<class JsonUtil::JsonSchemaObjectNode<class JsonUtil::EmptyClass, bool>> _buildAnimationControllerFileSchema_v1_8();
|
||||||
|
MCAPI static class std::mutex & _getActorAnimationControllerLock();
|
||||||
|
MCAPI static bool upgrade_v1_8_to_v1_10(class Json::Value &);
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
};
|
38
LiteLoader/Header/MC/ActorAnimationControllerPlayer.hpp
Normal file
38
LiteLoader/Header/MC/ActorAnimationControllerPlayer.hpp
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
// This Header is auto generated by BDSLiteLoader Toolchain
|
||||||
|
#pragma once
|
||||||
|
#define AUTO_GENERATED
|
||||||
|
#include "../Global.h"
|
||||||
|
|
||||||
|
#define BEFORE_EXTRA
|
||||||
|
|
||||||
|
#undef BEFORE_EXTRA
|
||||||
|
|
||||||
|
class ActorAnimationControllerPlayer {
|
||||||
|
|
||||||
|
#define AFTER_EXTRA
|
||||||
|
|
||||||
|
#undef AFTER_EXTRA
|
||||||
|
#ifndef DISABLE_CONSTRUCTOR_PREVENTION_ACTORANIMATIONCONTROLLERPLAYER
|
||||||
|
public:
|
||||||
|
class ActorAnimationControllerPlayer& operator=(class ActorAnimationControllerPlayer const &) = delete;
|
||||||
|
ActorAnimationControllerPlayer(class ActorAnimationControllerPlayer const &) = delete;
|
||||||
|
ActorAnimationControllerPlayer() = delete;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
public:
|
||||||
|
/*0*/ virtual ~ActorAnimationControllerPlayer();
|
||||||
|
/*1*/ virtual void applyToPose(class RenderParams &, class std::unordered_map<enum SkeletalHierarchyIndex, std::vector<class BoneOrientation>, struct std::hash<enum SkeletalHierarchyIndex>, struct std::equal_to<enum SkeletalHierarchyIndex>, class std::allocator<struct std::pair<enum SkeletalHierarchyIndex const, std::vector<class BoneOrientation>>>> &, float);
|
||||||
|
/*2*/ virtual void resetAnimation();
|
||||||
|
/*3*/ virtual void __unk_vfn_3();
|
||||||
|
/*4*/ virtual void bindParticleEffects(class std::unordered_map<class StringKey, class ParticleEffectPtr, struct std::hash<class StringKey>, struct std::equal_to<class StringKey>, class std::allocator<struct std::pair<class StringKey const, class ParticleEffectPtr>>> const &);
|
||||||
|
/*5*/ virtual void bindSoundEffects(class std::unordered_map<class StringKey, std::string, struct std::hash<class StringKey>, struct std::equal_to<class StringKey>, class std::allocator<struct std::pair<class StringKey const, std::string>>> const &);
|
||||||
|
/*6*/ virtual bool hasAnimationFinished() const;
|
||||||
|
/*7*/ virtual class ActorAnimationPlayer * findAnimation(class HashedString const &);
|
||||||
|
/*8*/ virtual enum ActorAnimationType getAnimationType() const;
|
||||||
|
#ifdef ENABLE_VIRTUAL_FAKESYMBOL_ACTORANIMATIONCONTROLLERPLAYER
|
||||||
|
#endif
|
||||||
|
MCAPI ActorAnimationControllerPlayer(class HashedString const &, class ActorAnimationControllerPtr const &, class AnimationComponent &, class ExpressionNode const &);
|
||||||
|
MCAPI void applyStateAnimationToPose(class RenderParams &, class std::unordered_map<enum SkeletalHierarchyIndex, std::vector<class BoneOrientation>, struct std::hash<enum SkeletalHierarchyIndex>, struct std::equal_to<enum SkeletalHierarchyIndex>, class std::allocator<struct std::pair<enum SkeletalHierarchyIndex const, std::vector<class BoneOrientation>>>> &, float);
|
||||||
|
MCAPI void blendViaShortestPath(class std::unordered_map<enum SkeletalHierarchyIndex, std::vector<class BoneOrientation>, struct std::hash<enum SkeletalHierarchyIndex>, struct std::equal_to<enum SkeletalHierarchyIndex>, class std::allocator<struct std::pair<enum SkeletalHierarchyIndex const, std::vector<class BoneOrientation>>>> &, class std::unordered_map<enum SkeletalHierarchyIndex, std::vector<class BoneOrientation>, struct std::hash<enum SkeletalHierarchyIndex>, struct std::equal_to<enum SkeletalHierarchyIndex>, class std::allocator<struct std::pair<enum SkeletalHierarchyIndex const, std::vector<class BoneOrientation>>>> &, class std::unordered_map<enum SkeletalHierarchyIndex, std::vector<class BoneOrientation>, struct std::hash<enum SkeletalHierarchyIndex>, struct std::equal_to<enum SkeletalHierarchyIndex>, class std::allocator<struct std::pair<enum SkeletalHierarchyIndex const, std::vector<class BoneOrientation>>>> &, float, float);
|
||||||
|
|
||||||
|
};
|
28
LiteLoader/Header/MC/ActorAnimationControllerPtr.hpp
Normal file
28
LiteLoader/Header/MC/ActorAnimationControllerPtr.hpp
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
// This Header is auto generated by BDSLiteLoader Toolchain
|
||||||
|
#pragma once
|
||||||
|
#define AUTO_GENERATED
|
||||||
|
#include "../Global.h"
|
||||||
|
|
||||||
|
#define BEFORE_EXTRA
|
||||||
|
|
||||||
|
#undef BEFORE_EXTRA
|
||||||
|
|
||||||
|
class ActorAnimationControllerPtr {
|
||||||
|
|
||||||
|
#define AFTER_EXTRA
|
||||||
|
|
||||||
|
#undef AFTER_EXTRA
|
||||||
|
#ifndef DISABLE_CONSTRUCTOR_PREVENTION_ACTORANIMATIONCONTROLLERPTR
|
||||||
|
public:
|
||||||
|
class ActorAnimationControllerPtr& operator=(class ActorAnimationControllerPtr const &) = delete;
|
||||||
|
ActorAnimationControllerPtr(class ActorAnimationControllerPtr const &) = delete;
|
||||||
|
ActorAnimationControllerPtr() = delete;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
public:
|
||||||
|
#ifdef ENABLE_VIRTUAL_FAKESYMBOL_ACTORANIMATIONCONTROLLERPTR
|
||||||
|
#endif
|
||||||
|
MCAPI ~ActorAnimationControllerPtr();
|
||||||
|
MCAPI static class ActorAnimationControllerPtr const NONE;
|
||||||
|
|
||||||
|
};
|
29
LiteLoader/Header/MC/ActorAnimationControllerState.hpp
Normal file
29
LiteLoader/Header/MC/ActorAnimationControllerState.hpp
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
// This Header is auto generated by BDSLiteLoader Toolchain
|
||||||
|
#pragma once
|
||||||
|
#define AUTO_GENERATED
|
||||||
|
#include "../Global.h"
|
||||||
|
|
||||||
|
#define BEFORE_EXTRA
|
||||||
|
|
||||||
|
#undef BEFORE_EXTRA
|
||||||
|
|
||||||
|
class ActorAnimationControllerState {
|
||||||
|
|
||||||
|
#define AFTER_EXTRA
|
||||||
|
|
||||||
|
#undef AFTER_EXTRA
|
||||||
|
#ifndef DISABLE_CONSTRUCTOR_PREVENTION_ACTORANIMATIONCONTROLLERSTATE
|
||||||
|
public:
|
||||||
|
class ActorAnimationControllerState& operator=(class ActorAnimationControllerState const &) = delete;
|
||||||
|
ActorAnimationControllerState(class ActorAnimationControllerState const &) = delete;
|
||||||
|
ActorAnimationControllerState() = delete;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
public:
|
||||||
|
#ifdef ENABLE_VIRTUAL_FAKESYMBOL_ACTORANIMATIONCONTROLLERSTATE
|
||||||
|
#endif
|
||||||
|
MCAPI void setBlendTransitionTime(float);
|
||||||
|
MCAPI void setVariables(class RenderParams &) const;
|
||||||
|
MCAPI ~ActorAnimationControllerState();
|
||||||
|
|
||||||
|
};
|
38
LiteLoader/Header/MC/ActorAnimationControllerStatePlayer.hpp
Normal file
38
LiteLoader/Header/MC/ActorAnimationControllerStatePlayer.hpp
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
// This Header is auto generated by BDSLiteLoader Toolchain
|
||||||
|
#pragma once
|
||||||
|
#define AUTO_GENERATED
|
||||||
|
#include "../Global.h"
|
||||||
|
|
||||||
|
#define BEFORE_EXTRA
|
||||||
|
|
||||||
|
#undef BEFORE_EXTRA
|
||||||
|
|
||||||
|
class ActorAnimationControllerStatePlayer {
|
||||||
|
|
||||||
|
#define AFTER_EXTRA
|
||||||
|
|
||||||
|
#undef AFTER_EXTRA
|
||||||
|
#ifndef DISABLE_CONSTRUCTOR_PREVENTION_ACTORANIMATIONCONTROLLERSTATEPLAYER
|
||||||
|
public:
|
||||||
|
class ActorAnimationControllerStatePlayer& operator=(class ActorAnimationControllerStatePlayer const &) = delete;
|
||||||
|
ActorAnimationControllerStatePlayer(class ActorAnimationControllerStatePlayer const &) = delete;
|
||||||
|
ActorAnimationControllerStatePlayer() = delete;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
public:
|
||||||
|
/*0*/ virtual ~ActorAnimationControllerStatePlayer();
|
||||||
|
/*1*/ virtual void applyToPose(class RenderParams &, class std::unordered_map<enum SkeletalHierarchyIndex, std::vector<class BoneOrientation>, struct std::hash<enum SkeletalHierarchyIndex>, struct std::equal_to<enum SkeletalHierarchyIndex>, class std::allocator<struct std::pair<enum SkeletalHierarchyIndex const, std::vector<class BoneOrientation>>>> &, float);
|
||||||
|
/*2*/ virtual void resetAnimation();
|
||||||
|
/*3*/ virtual void __unk_vfn_3();
|
||||||
|
/*4*/ virtual void __unk_vfn_4();
|
||||||
|
/*5*/ virtual void __unk_vfn_5();
|
||||||
|
/*6*/ virtual bool hasAnimationFinished() const;
|
||||||
|
/*7*/ virtual class ActorAnimationPlayer * findAnimation(class HashedString const &);
|
||||||
|
/*8*/ virtual enum ActorAnimationType getAnimationType() const;
|
||||||
|
#ifdef ENABLE_VIRTUAL_FAKESYMBOL_ACTORANIMATIONCONTROLLERSTATEPLAYER
|
||||||
|
MCVAPI void bindParticleEffects(class std::unordered_map<class StringKey, class ParticleEffectPtr, struct std::hash<class StringKey>, struct std::equal_to<class StringKey>, class std::allocator<struct std::pair<class StringKey const, class ParticleEffectPtr>>> const &);
|
||||||
|
MCVAPI void bindSoundEffects(class std::unordered_map<class StringKey, std::string, struct std::hash<class StringKey>, struct std::equal_to<class StringKey>, class std::allocator<struct std::pair<class StringKey const, std::string>>> const &);
|
||||||
|
#endif
|
||||||
|
MCAPI ActorAnimationControllerStatePlayer(class HashedString const &, class ActorAnimationControllerPlayer &, class std::shared_ptr<class ActorAnimationControllerState>, class AnimationComponent &, class ExpressionNode const &);
|
||||||
|
|
||||||
|
};
|
31
LiteLoader/Header/MC/ActorAnimationEvent.hpp
Normal file
31
LiteLoader/Header/MC/ActorAnimationEvent.hpp
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
// This Header is auto generated by BDSLiteLoader Toolchain
|
||||||
|
#pragma once
|
||||||
|
#define AUTO_GENERATED
|
||||||
|
#include "../Global.h"
|
||||||
|
|
||||||
|
#define BEFORE_EXTRA
|
||||||
|
|
||||||
|
#undef BEFORE_EXTRA
|
||||||
|
|
||||||
|
class ActorAnimationEvent {
|
||||||
|
|
||||||
|
#define AFTER_EXTRA
|
||||||
|
|
||||||
|
#undef AFTER_EXTRA
|
||||||
|
#ifndef DISABLE_CONSTRUCTOR_PREVENTION_ACTORANIMATIONEVENT
|
||||||
|
public:
|
||||||
|
class ActorAnimationEvent& operator=(class ActorAnimationEvent const &) = delete;
|
||||||
|
ActorAnimationEvent(class ActorAnimationEvent const &) = delete;
|
||||||
|
ActorAnimationEvent() = delete;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
public:
|
||||||
|
#ifdef ENABLE_VIRTUAL_FAKESYMBOL_ACTORANIMATIONEVENT
|
||||||
|
#endif
|
||||||
|
MCAPI ActorAnimationEvent(float, std::string const &, enum CurrentCmdVersion);
|
||||||
|
MCAPI ActorAnimationEvent(class ActorAnimationEvent &&);
|
||||||
|
MCAPI void fire(class RenderParams &, class Actor *) const;
|
||||||
|
MCAPI class ActorAnimationEvent & operator=(class ActorAnimationEvent &&);
|
||||||
|
MCAPI ~ActorAnimationEvent();
|
||||||
|
|
||||||
|
};
|
30
LiteLoader/Header/MC/ActorAnimationGroup.hpp
Normal file
30
LiteLoader/Header/MC/ActorAnimationGroup.hpp
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
// This Header is auto generated by BDSLiteLoader Toolchain
|
||||||
|
#pragma once
|
||||||
|
#define AUTO_GENERATED
|
||||||
|
#include "../Global.h"
|
||||||
|
#include "Core.hpp"
|
||||||
|
|
||||||
|
#define BEFORE_EXTRA
|
||||||
|
|
||||||
|
#undef BEFORE_EXTRA
|
||||||
|
|
||||||
|
class ActorAnimationGroup {
|
||||||
|
|
||||||
|
#define AFTER_EXTRA
|
||||||
|
|
||||||
|
#undef AFTER_EXTRA
|
||||||
|
#ifndef DISABLE_CONSTRUCTOR_PREVENTION_ACTORANIMATIONGROUP
|
||||||
|
public:
|
||||||
|
class ActorAnimationGroup& operator=(class ActorAnimationGroup const &) = delete;
|
||||||
|
ActorAnimationGroup(class ActorAnimationGroup const &) = delete;
|
||||||
|
ActorAnimationGroup() = delete;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
public:
|
||||||
|
#ifdef ENABLE_VIRTUAL_FAKESYMBOL_ACTORANIMATIONGROUP
|
||||||
|
#endif
|
||||||
|
MCAPI class std::shared_ptr<class ActorAnimationInfo> getActorAnimationInfo(class HashedString const &);
|
||||||
|
MCAPI void loadActorAnimation(std::string const &, class Core::Path const &, class PackStats &, enum CurrentCmdVersion, bool);
|
||||||
|
MCAPI void loadActorAnimationsSync(class ResourcePackManager &);
|
||||||
|
|
||||||
|
};
|
29
LiteLoader/Header/MC/ActorAnimationPlayer.hpp
Normal file
29
LiteLoader/Header/MC/ActorAnimationPlayer.hpp
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
// This Header is auto generated by BDSLiteLoader Toolchain
|
||||||
|
#pragma once
|
||||||
|
#define AUTO_GENERATED
|
||||||
|
#include "../Global.h"
|
||||||
|
|
||||||
|
#define BEFORE_EXTRA
|
||||||
|
|
||||||
|
#undef BEFORE_EXTRA
|
||||||
|
|
||||||
|
class ActorAnimationPlayer {
|
||||||
|
|
||||||
|
#define AFTER_EXTRA
|
||||||
|
|
||||||
|
#undef AFTER_EXTRA
|
||||||
|
#ifndef DISABLE_CONSTRUCTOR_PREVENTION_ACTORANIMATIONPLAYER
|
||||||
|
public:
|
||||||
|
class ActorAnimationPlayer& operator=(class ActorAnimationPlayer const &) = delete;
|
||||||
|
ActorAnimationPlayer(class ActorAnimationPlayer const &) = delete;
|
||||||
|
ActorAnimationPlayer() = delete;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
public:
|
||||||
|
#ifdef ENABLE_VIRTUAL_FAKESYMBOL_ACTORANIMATIONPLAYER
|
||||||
|
MCVAPI void bindParticleEffects(class std::unordered_map<class StringKey, class ParticleEffectPtr, struct std::hash<class StringKey>, struct std::equal_to<class StringKey>, class std::allocator<struct std::pair<class StringKey const, class ParticleEffectPtr>>> const &);
|
||||||
|
MCVAPI void bindSoundEffects(class std::unordered_map<class StringKey, std::string, struct std::hash<class StringKey>, struct std::equal_to<class StringKey>, class std::allocator<struct std::pair<class StringKey const, std::string>>> const &);
|
||||||
|
MCVAPI void buildBoneToPartMapping(class AnimationComponent &);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
};
|
32
LiteLoader/Header/MC/ActorBlock.hpp
Normal file
32
LiteLoader/Header/MC/ActorBlock.hpp
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
// This Header is auto generated by BDSLiteLoader Toolchain
|
||||||
|
#pragma once
|
||||||
|
#define AUTO_GENERATED
|
||||||
|
#include "../Global.h"
|
||||||
|
|
||||||
|
#define BEFORE_EXTRA
|
||||||
|
|
||||||
|
#undef BEFORE_EXTRA
|
||||||
|
|
||||||
|
class ActorBlock {
|
||||||
|
|
||||||
|
#define AFTER_EXTRA
|
||||||
|
|
||||||
|
#undef AFTER_EXTRA
|
||||||
|
#ifndef DISABLE_CONSTRUCTOR_PREVENTION_ACTORBLOCK
|
||||||
|
public:
|
||||||
|
class ActorBlock& operator=(class ActorBlock const &) = delete;
|
||||||
|
ActorBlock(class ActorBlock const &) = delete;
|
||||||
|
ActorBlock() = delete;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
public:
|
||||||
|
#ifdef ENABLE_VIRTUAL_FAKESYMBOL_ACTORBLOCK
|
||||||
|
MCVAPI bool canBeSilkTouched() const;
|
||||||
|
MCVAPI class ItemInstance getEntityResourceItem(class Random &, class BlockActor const &, int) const;
|
||||||
|
MCVAPI void neighborChanged(class BlockSource &, class BlockPos const &, class BlockPos const &) const;
|
||||||
|
MCVAPI bool playerWillDestroy(class Player &, class BlockPos const &, class Block const &) const;
|
||||||
|
MCVAPI void spawnResources(class BlockSource &, class BlockPos const &, class Block const &, std::vector<class Item const *> *, float, int, bool) const;
|
||||||
|
MCVAPI void triggerEvent(class BlockSource &, class BlockPos const &, int, int) const;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
};
|
28
LiteLoader/Header/MC/ActorClassTree.hpp
Normal file
28
LiteLoader/Header/MC/ActorClassTree.hpp
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
// This Header is auto generated by BDSLiteLoader Toolchain
|
||||||
|
#pragma once
|
||||||
|
#define AUTO_GENERATED
|
||||||
|
#include "../Global.h"
|
||||||
|
|
||||||
|
#define BEFORE_EXTRA
|
||||||
|
|
||||||
|
#undef BEFORE_EXTRA
|
||||||
|
|
||||||
|
class ActorClassTree {
|
||||||
|
|
||||||
|
#define AFTER_EXTRA
|
||||||
|
|
||||||
|
#undef AFTER_EXTRA
|
||||||
|
#ifndef DISABLE_CONSTRUCTOR_PREVENTION_ACTORCLASSTREE
|
||||||
|
public:
|
||||||
|
class ActorClassTree& operator=(class ActorClassTree const &) = delete;
|
||||||
|
ActorClassTree(class ActorClassTree const &) = delete;
|
||||||
|
ActorClassTree() = delete;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
public:
|
||||||
|
#ifdef ENABLE_VIRTUAL_FAKESYMBOL_ACTORCLASSTREE
|
||||||
|
#endif
|
||||||
|
MCAPI static enum ActorType getEntityTypeIdLegacy(enum ActorType);
|
||||||
|
MCAPI static bool isInstanceOf(class Actor const &, enum ActorType);
|
||||||
|
|
||||||
|
};
|
41
LiteLoader/Header/MC/ActorCommandOrigin.hpp
Normal file
41
LiteLoader/Header/MC/ActorCommandOrigin.hpp
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
// This Header is auto generated by BDSLiteLoader Toolchain
|
||||||
|
#pragma once
|
||||||
|
#define AUTO_GENERATED
|
||||||
|
#include "../Global.h"
|
||||||
|
#include "Json.hpp"
|
||||||
|
#include "CommandOrigin.hpp"
|
||||||
|
|
||||||
|
#define BEFORE_EXTRA
|
||||||
|
|
||||||
|
#undef BEFORE_EXTRA
|
||||||
|
|
||||||
|
class ActorCommandOrigin : public CommandOrigin {
|
||||||
|
|
||||||
|
#define AFTER_EXTRA
|
||||||
|
|
||||||
|
#undef AFTER_EXTRA
|
||||||
|
#ifndef DISABLE_CONSTRUCTOR_PREVENTION_ACTORCOMMANDORIGIN
|
||||||
|
public:
|
||||||
|
class ActorCommandOrigin& operator=(class ActorCommandOrigin const &) = delete;
|
||||||
|
ActorCommandOrigin(class ActorCommandOrigin const &) = delete;
|
||||||
|
ActorCommandOrigin() = delete;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
public:
|
||||||
|
/*0*/ virtual ~ActorCommandOrigin();
|
||||||
|
/*1*/ virtual std::string const & getRequestId() const;
|
||||||
|
/*2*/ virtual std::string getName() const;
|
||||||
|
/*3*/ virtual class BlockPos getBlockPosition() const;
|
||||||
|
/*4*/ virtual class Vec3 getWorldPosition() const;
|
||||||
|
/*5*/ virtual class Level * getLevel() const;
|
||||||
|
/*6*/ virtual class Dimension * getDimension() const;
|
||||||
|
/*7*/ virtual class Actor * getEntity() const;
|
||||||
|
/*8*/ virtual enum CommandPermissionLevel getPermissionsLevel() const;
|
||||||
|
/*9*/ virtual std::unique_ptr<class CommandOrigin> clone() const;
|
||||||
|
/*17*/ virtual bool isSelectorExpansionAllowed() const;
|
||||||
|
/*21*/ virtual enum CommandOriginType getOriginType() const;
|
||||||
|
#ifdef ENABLE_VIRTUAL_FAKESYMBOL_ACTORCOMMANDORIGIN
|
||||||
|
#endif
|
||||||
|
MCAPI ActorCommandOrigin(class Actor &);
|
||||||
|
|
||||||
|
};
|
32
LiteLoader/Header/MC/ActorComponentFactory.hpp
Normal file
32
LiteLoader/Header/MC/ActorComponentFactory.hpp
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
// This Header is auto generated by BDSLiteLoader Toolchain
|
||||||
|
#pragma once
|
||||||
|
#define AUTO_GENERATED
|
||||||
|
#include "../Global.h"
|
||||||
|
|
||||||
|
#define BEFORE_EXTRA
|
||||||
|
|
||||||
|
#undef BEFORE_EXTRA
|
||||||
|
|
||||||
|
class ActorComponentFactory {
|
||||||
|
|
||||||
|
#define AFTER_EXTRA
|
||||||
|
|
||||||
|
#undef AFTER_EXTRA
|
||||||
|
#ifndef DISABLE_CONSTRUCTOR_PREVENTION_ACTORCOMPONENTFACTORY
|
||||||
|
public:
|
||||||
|
class ActorComponentFactory& operator=(class ActorComponentFactory const &) = delete;
|
||||||
|
ActorComponentFactory(class ActorComponentFactory const &) = delete;
|
||||||
|
ActorComponentFactory() = delete;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
public:
|
||||||
|
#ifdef ENABLE_VIRTUAL_FAKESYMBOL_ACTORCOMPONENTFACTORY
|
||||||
|
#endif
|
||||||
|
MCAPI ~ActorComponentFactory();
|
||||||
|
|
||||||
|
//private:
|
||||||
|
MCAPI void _initialize();
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
};
|
39
LiteLoader/Header/MC/ActorDamageByActorSource.hpp
Normal file
39
LiteLoader/Header/MC/ActorDamageByActorSource.hpp
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
// This Header is auto generated by BDSLiteLoader Toolchain
|
||||||
|
#pragma once
|
||||||
|
#define AUTO_GENERATED
|
||||||
|
#include "../Global.h"
|
||||||
|
#include "ActorDamageSource.hpp"
|
||||||
|
|
||||||
|
#define BEFORE_EXTRA
|
||||||
|
|
||||||
|
#undef BEFORE_EXTRA
|
||||||
|
|
||||||
|
class ActorDamageByActorSource : public ActorDamageSource {
|
||||||
|
|
||||||
|
#define AFTER_EXTRA
|
||||||
|
|
||||||
|
#undef AFTER_EXTRA
|
||||||
|
#ifndef DISABLE_CONSTRUCTOR_PREVENTION_ACTORDAMAGEBYACTORSOURCE
|
||||||
|
public:
|
||||||
|
class ActorDamageByActorSource& operator=(class ActorDamageByActorSource const &) = delete;
|
||||||
|
ActorDamageByActorSource(class ActorDamageByActorSource const &) = delete;
|
||||||
|
ActorDamageByActorSource() = delete;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
public:
|
||||||
|
/*0*/ virtual ~ActorDamageByActorSource();
|
||||||
|
/*1*/ virtual bool isEntitySource() const;
|
||||||
|
/*5*/ virtual struct std::pair<std::string, std::vector<std::string>> getDeathMessage(std::string, class Actor *) const;
|
||||||
|
/*6*/ virtual bool getIsCreative() const;
|
||||||
|
/*7*/ virtual bool getIsWorldBuilder() const;
|
||||||
|
/*8*/ virtual struct ActorUniqueID getEntityUniqueID() const;
|
||||||
|
/*9*/ virtual enum ActorType getEntityType() const;
|
||||||
|
/*10*/ virtual enum ActorCategory getEntityCategories() const;
|
||||||
|
/*13*/ virtual struct ActorUniqueID getDamagingEntityUniqueID() const;
|
||||||
|
/*14*/ virtual enum ActorType getDamagingEntityType() const;
|
||||||
|
/*16*/ virtual std::unique_ptr<class ActorDamageSource> clone() const;
|
||||||
|
#ifdef ENABLE_VIRTUAL_FAKESYMBOL_ACTORDAMAGEBYACTORSOURCE
|
||||||
|
#endif
|
||||||
|
MCAPI ActorDamageByActorSource(class Actor &, enum ActorDamageCause);
|
||||||
|
|
||||||
|
};
|
31
LiteLoader/Header/MC/ActorDamageByBlockSource.hpp
Normal file
31
LiteLoader/Header/MC/ActorDamageByBlockSource.hpp
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
// This Header is auto generated by BDSLiteLoader Toolchain
|
||||||
|
#pragma once
|
||||||
|
#define AUTO_GENERATED
|
||||||
|
#include "../Global.h"
|
||||||
|
#include "ActorDamageSource.hpp"
|
||||||
|
|
||||||
|
#define BEFORE_EXTRA
|
||||||
|
|
||||||
|
#undef BEFORE_EXTRA
|
||||||
|
|
||||||
|
class ActorDamageByBlockSource : public ActorDamageSource {
|
||||||
|
|
||||||
|
#define AFTER_EXTRA
|
||||||
|
|
||||||
|
#undef AFTER_EXTRA
|
||||||
|
#ifndef DISABLE_CONSTRUCTOR_PREVENTION_ACTORDAMAGEBYBLOCKSOURCE
|
||||||
|
public:
|
||||||
|
class ActorDamageByBlockSource& operator=(class ActorDamageByBlockSource const &) = delete;
|
||||||
|
ActorDamageByBlockSource(class ActorDamageByBlockSource const &) = delete;
|
||||||
|
ActorDamageByBlockSource() = delete;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
public:
|
||||||
|
/*0*/ virtual ~ActorDamageByBlockSource();
|
||||||
|
/*3*/ virtual bool isBlockSource() const;
|
||||||
|
/*5*/ virtual struct std::pair<std::string, std::vector<std::string>> getDeathMessage(std::string, class Actor *) const;
|
||||||
|
/*16*/ virtual std::unique_ptr<class ActorDamageSource> clone() const;
|
||||||
|
#ifdef ENABLE_VIRTUAL_FAKESYMBOL_ACTORDAMAGEBYBLOCKSOURCE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
};
|
37
LiteLoader/Header/MC/ActorDamageByChildActorSource.hpp
Normal file
37
LiteLoader/Header/MC/ActorDamageByChildActorSource.hpp
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
// This Header is auto generated by BDSLiteLoader Toolchain
|
||||||
|
#pragma once
|
||||||
|
#define AUTO_GENERATED
|
||||||
|
#include "../Global.h"
|
||||||
|
#include "ActorDamageByActorSource.hpp"
|
||||||
|
|
||||||
|
#define BEFORE_EXTRA
|
||||||
|
|
||||||
|
#undef BEFORE_EXTRA
|
||||||
|
|
||||||
|
class ActorDamageByChildActorSource : public ActorDamageByActorSource {
|
||||||
|
|
||||||
|
#define AFTER_EXTRA
|
||||||
|
|
||||||
|
#undef AFTER_EXTRA
|
||||||
|
#ifndef DISABLE_CONSTRUCTOR_PREVENTION_ACTORDAMAGEBYCHILDACTORSOURCE
|
||||||
|
public:
|
||||||
|
class ActorDamageByChildActorSource& operator=(class ActorDamageByChildActorSource const &) = delete;
|
||||||
|
ActorDamageByChildActorSource(class ActorDamageByChildActorSource const &) = delete;
|
||||||
|
ActorDamageByChildActorSource() = delete;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
public:
|
||||||
|
/*0*/ virtual ~ActorDamageByChildActorSource();
|
||||||
|
/*2*/ virtual bool isChildEntitySource() const;
|
||||||
|
/*5*/ virtual struct std::pair<std::string, std::vector<std::string>> getDeathMessage(std::string, class Actor *) const;
|
||||||
|
/*11*/ virtual bool getDamagingEntityIsCreative() const;
|
||||||
|
/*12*/ virtual bool getDamagingEntityIsWorldBuilder() const;
|
||||||
|
/*13*/ virtual struct ActorUniqueID getDamagingEntityUniqueID() const;
|
||||||
|
/*14*/ virtual enum ActorType getDamagingEntityType() const;
|
||||||
|
/*15*/ virtual enum ActorCategory getDamagingEntityCategories() const;
|
||||||
|
/*16*/ virtual std::unique_ptr<class ActorDamageSource> clone() const;
|
||||||
|
#ifdef ENABLE_VIRTUAL_FAKESYMBOL_ACTORDAMAGEBYCHILDACTORSOURCE
|
||||||
|
#endif
|
||||||
|
MCAPI ActorDamageByChildActorSource(class Actor &, class Actor &, enum ActorDamageCause);
|
||||||
|
|
||||||
|
};
|
45
LiteLoader/Header/MC/ActorDamageSource.hpp
Normal file
45
LiteLoader/Header/MC/ActorDamageSource.hpp
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
// This Header is auto generated by BDSLiteLoader Toolchain
|
||||||
|
#pragma once
|
||||||
|
#define AUTO_GENERATED
|
||||||
|
#include "../Global.h"
|
||||||
|
|
||||||
|
#define BEFORE_EXTRA
|
||||||
|
|
||||||
|
#undef BEFORE_EXTRA
|
||||||
|
|
||||||
|
class ActorDamageSource {
|
||||||
|
|
||||||
|
#define AFTER_EXTRA
|
||||||
|
|
||||||
|
#undef AFTER_EXTRA
|
||||||
|
#ifndef DISABLE_CONSTRUCTOR_PREVENTION_ACTORDAMAGESOURCE
|
||||||
|
public:
|
||||||
|
class ActorDamageSource& operator=(class ActorDamageSource const &) = delete;
|
||||||
|
ActorDamageSource(class ActorDamageSource const &) = delete;
|
||||||
|
ActorDamageSource() = delete;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
public:
|
||||||
|
/*0*/ virtual ~ActorDamageSource();
|
||||||
|
/*1*/ virtual bool isEntitySource() const;
|
||||||
|
/*2*/ virtual bool isChildEntitySource() const;
|
||||||
|
/*3*/ virtual bool isBlockSource() const;
|
||||||
|
/*4*/ virtual bool isFire() const;
|
||||||
|
/*5*/ virtual struct std::pair<std::string, std::vector<std::string>> getDeathMessage(std::string, class Actor *) const;
|
||||||
|
/*6*/ virtual bool getIsCreative() const;
|
||||||
|
/*7*/ virtual bool getIsWorldBuilder() const;
|
||||||
|
/*8*/ virtual struct ActorUniqueID getEntityUniqueID() const;
|
||||||
|
/*9*/ virtual enum ActorType getEntityType() const;
|
||||||
|
/*10*/ virtual enum ActorCategory getEntityCategories() const;
|
||||||
|
/*11*/ virtual bool getDamagingEntityIsCreative() const;
|
||||||
|
/*12*/ virtual bool getDamagingEntityIsWorldBuilder() const;
|
||||||
|
/*13*/ virtual struct ActorUniqueID getDamagingEntityUniqueID() const;
|
||||||
|
/*14*/ virtual enum ActorType getDamagingEntityType() const;
|
||||||
|
/*15*/ virtual enum ActorCategory getDamagingEntityCategories() const;
|
||||||
|
/*16*/ virtual std::unique_ptr<class ActorDamageSource> clone() const;
|
||||||
|
#ifdef ENABLE_VIRTUAL_FAKESYMBOL_ACTORDAMAGESOURCE
|
||||||
|
#endif
|
||||||
|
MCAPI static enum ActorDamageCause lookupCause(std::string const &);
|
||||||
|
MCAPI static std::string const & lookupCauseName(enum ActorDamageCause);
|
||||||
|
|
||||||
|
};
|
33
LiteLoader/Header/MC/ActorDefinition.hpp
Normal file
33
LiteLoader/Header/MC/ActorDefinition.hpp
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
// This Header is auto generated by BDSLiteLoader Toolchain
|
||||||
|
#pragma once
|
||||||
|
#define AUTO_GENERATED
|
||||||
|
#include "../Global.h"
|
||||||
|
#include "Json.hpp"
|
||||||
|
|
||||||
|
#define BEFORE_EXTRA
|
||||||
|
|
||||||
|
#undef BEFORE_EXTRA
|
||||||
|
|
||||||
|
class ActorDefinition {
|
||||||
|
|
||||||
|
#define AFTER_EXTRA
|
||||||
|
|
||||||
|
#undef AFTER_EXTRA
|
||||||
|
#ifndef DISABLE_CONSTRUCTOR_PREVENTION_ACTORDEFINITION
|
||||||
|
public:
|
||||||
|
class ActorDefinition& operator=(class ActorDefinition const &) = delete;
|
||||||
|
ActorDefinition(class ActorDefinition const &) = delete;
|
||||||
|
ActorDefinition() = delete;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
public:
|
||||||
|
#ifdef ENABLE_VIRTUAL_FAKESYMBOL_ACTORDEFINITION
|
||||||
|
#endif
|
||||||
|
MCAPI ActorDefinition(std::string const &);
|
||||||
|
MCAPI void parse(class Json::Value, class ActorDefinitionDescriptor &, class ActorFactory &, class SemVersion);
|
||||||
|
MCAPI void parseAttributes(class Json::Value &, class ActorDefinitionDescriptor &);
|
||||||
|
MCAPI void parseEntityDescription(class Json::Value &);
|
||||||
|
MCAPI void parseEvents(class Json::Value const &);
|
||||||
|
MCAPI ~ActorDefinition();
|
||||||
|
|
||||||
|
};
|
27
LiteLoader/Header/MC/ActorDefinitionAttribute.hpp
Normal file
27
LiteLoader/Header/MC/ActorDefinitionAttribute.hpp
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
// This Header is auto generated by BDSLiteLoader Toolchain
|
||||||
|
#pragma once
|
||||||
|
#define AUTO_GENERATED
|
||||||
|
#include "../Global.h"
|
||||||
|
|
||||||
|
#define BEFORE_EXTRA
|
||||||
|
|
||||||
|
#undef BEFORE_EXTRA
|
||||||
|
|
||||||
|
class ActorDefinitionAttribute {
|
||||||
|
|
||||||
|
#define AFTER_EXTRA
|
||||||
|
|
||||||
|
#undef AFTER_EXTRA
|
||||||
|
#ifndef DISABLE_CONSTRUCTOR_PREVENTION_ACTORDEFINITIONATTRIBUTE
|
||||||
|
public:
|
||||||
|
class ActorDefinitionAttribute& operator=(class ActorDefinitionAttribute const &) = delete;
|
||||||
|
ActorDefinitionAttribute(class ActorDefinitionAttribute const &) = delete;
|
||||||
|
ActorDefinitionAttribute() = delete;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
public:
|
||||||
|
#ifdef ENABLE_VIRTUAL_FAKESYMBOL_ACTORDEFINITIONATTRIBUTE
|
||||||
|
#endif
|
||||||
|
MCAPI ~ActorDefinitionAttribute();
|
||||||
|
|
||||||
|
};
|
42
LiteLoader/Header/MC/ActorDefinitionDescriptor.hpp
Normal file
42
LiteLoader/Header/MC/ActorDefinitionDescriptor.hpp
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
// This Header is auto generated by BDSLiteLoader Toolchain
|
||||||
|
#pragma once
|
||||||
|
#define AUTO_GENERATED
|
||||||
|
#include "../Global.h"
|
||||||
|
|
||||||
|
#define BEFORE_EXTRA
|
||||||
|
|
||||||
|
#undef BEFORE_EXTRA
|
||||||
|
|
||||||
|
class ActorDefinitionDescriptor {
|
||||||
|
|
||||||
|
#define AFTER_EXTRA
|
||||||
|
|
||||||
|
#undef AFTER_EXTRA
|
||||||
|
#ifndef DISABLE_CONSTRUCTOR_PREVENTION_ACTORDEFINITIONDESCRIPTOR
|
||||||
|
public:
|
||||||
|
ActorDefinitionDescriptor(class ActorDefinitionDescriptor const &) = delete;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
public:
|
||||||
|
#ifdef ENABLE_VIRTUAL_FAKESYMBOL_ACTORDEFINITIONDESCRIPTOR
|
||||||
|
#endif
|
||||||
|
MCAPI ActorDefinitionDescriptor();
|
||||||
|
MCAPI ActorDefinitionDescriptor(class ActorDefinitionDescriptor &&);
|
||||||
|
MCAPI class ActorDefinitionDescriptor & combine(class ActorDefinitionDescriptor const &);
|
||||||
|
MCAPI bool contains(class ActorDefinitionDescriptor const &) const;
|
||||||
|
MCAPI void executeEvent(class Actor &, std::string const &, class VariantParameterList const &);
|
||||||
|
MCAPI bool executeTrigger(class Actor &, class DefinitionTrigger const &, class VariantParameterList const &);
|
||||||
|
MCAPI void forceExecuteTrigger(class Actor &, class DefinitionTrigger const &, class VariantParameterList const &);
|
||||||
|
MCAPI class ActorDefinitionDescriptor & operator=(class ActorDefinitionDescriptor &&);
|
||||||
|
MCAPI class ActorDefinitionDescriptor & operator=(class ActorDefinitionDescriptor const &);
|
||||||
|
MCAPI bool overlaps(class ActorDefinitionDescriptor const &) const;
|
||||||
|
MCAPI class ActorDefinitionDescriptor & subtract(class ActorDefinitionDescriptor const &);
|
||||||
|
MCAPI ~ActorDefinitionDescriptor();
|
||||||
|
|
||||||
|
//private:
|
||||||
|
MCAPI void _executeEvent(class Actor &, std::string const &, std::vector<std::string> &, class VariantParameterList const &);
|
||||||
|
MCAPI void _forceExecuteTrigger(class Actor &, class DefinitionTrigger const &, std::vector<std::string> &, class VariantParameterList const &);
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
};
|
36
LiteLoader/Header/MC/ActorDefinitionDiffList.hpp
Normal file
36
LiteLoader/Header/MC/ActorDefinitionDiffList.hpp
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
// This Header is auto generated by BDSLiteLoader Toolchain
|
||||||
|
#pragma once
|
||||||
|
#define AUTO_GENERATED
|
||||||
|
#include "../Global.h"
|
||||||
|
|
||||||
|
#define BEFORE_EXTRA
|
||||||
|
|
||||||
|
#undef BEFORE_EXTRA
|
||||||
|
|
||||||
|
class ActorDefinitionDiffList {
|
||||||
|
|
||||||
|
#define AFTER_EXTRA
|
||||||
|
|
||||||
|
#undef AFTER_EXTRA
|
||||||
|
#ifndef DISABLE_CONSTRUCTOR_PREVENTION_ACTORDEFINITIONDIFFLIST
|
||||||
|
public:
|
||||||
|
class ActorDefinitionDiffList& operator=(class ActorDefinitionDiffList const &) = delete;
|
||||||
|
ActorDefinitionDiffList(class ActorDefinitionDiffList const &) = delete;
|
||||||
|
ActorDefinitionDiffList() = delete;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
public:
|
||||||
|
#ifdef ENABLE_VIRTUAL_FAKESYMBOL_ACTORDEFINITIONDIFFLIST
|
||||||
|
#endif
|
||||||
|
MCAPI void addDefinition(std::string const &);
|
||||||
|
MCAPI void clearChangedDescription();
|
||||||
|
MCAPI std::string definitionListToString(std::string const &) const;
|
||||||
|
MCAPI std::unique_ptr<class ActorDefinitionDescriptor> getDescription(bool);
|
||||||
|
MCAPI void removeDefinition(std::string const &);
|
||||||
|
|
||||||
|
//private:
|
||||||
|
MCAPI void _updateStack();
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
};
|
31
LiteLoader/Header/MC/ActorDefinitionEventSubcomponent.hpp
Normal file
31
LiteLoader/Header/MC/ActorDefinitionEventSubcomponent.hpp
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
// This Header is auto generated by BDSLiteLoader Toolchain
|
||||||
|
#pragma once
|
||||||
|
#define AUTO_GENERATED
|
||||||
|
#include "../Global.h"
|
||||||
|
#include "Json.hpp"
|
||||||
|
|
||||||
|
#define BEFORE_EXTRA
|
||||||
|
|
||||||
|
#undef BEFORE_EXTRA
|
||||||
|
|
||||||
|
class ActorDefinitionEventSubcomponent {
|
||||||
|
|
||||||
|
#define AFTER_EXTRA
|
||||||
|
|
||||||
|
#undef AFTER_EXTRA
|
||||||
|
#ifndef DISABLE_CONSTRUCTOR_PREVENTION_ACTORDEFINITIONEVENTSUBCOMPONENT
|
||||||
|
public:
|
||||||
|
class ActorDefinitionEventSubcomponent& operator=(class ActorDefinitionEventSubcomponent const &) = delete;
|
||||||
|
ActorDefinitionEventSubcomponent(class ActorDefinitionEventSubcomponent const &) = delete;
|
||||||
|
ActorDefinitionEventSubcomponent() = delete;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
public:
|
||||||
|
/*0*/ virtual ~ActorDefinitionEventSubcomponent();
|
||||||
|
/*1*/ virtual void readfromJSON(class Json::Value &);
|
||||||
|
/*2*/ virtual void writetoJSON(class Json::Value &) const;
|
||||||
|
/*3*/ virtual void doOnHitEffect(class Actor &, class ProjectileComponent &);
|
||||||
|
#ifdef ENABLE_VIRTUAL_FAKESYMBOL_ACTORDEFINITIONEVENTSUBCOMPONENT
|
||||||
|
#endif
|
||||||
|
|
||||||
|
};
|
48
LiteLoader/Header/MC/ActorDefinitionGroup.hpp
Normal file
48
LiteLoader/Header/MC/ActorDefinitionGroup.hpp
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
// This Header is auto generated by BDSLiteLoader Toolchain
|
||||||
|
#pragma once
|
||||||
|
#define AUTO_GENERATED
|
||||||
|
#include "../Global.h"
|
||||||
|
#include "Core.hpp"
|
||||||
|
#include "Json.hpp"
|
||||||
|
|
||||||
|
#define BEFORE_EXTRA
|
||||||
|
|
||||||
|
#undef BEFORE_EXTRA
|
||||||
|
|
||||||
|
class ActorDefinitionGroup {
|
||||||
|
|
||||||
|
#define AFTER_EXTRA
|
||||||
|
|
||||||
|
#undef AFTER_EXTRA
|
||||||
|
#ifndef DISABLE_CONSTRUCTOR_PREVENTION_ACTORDEFINITIONGROUP
|
||||||
|
public:
|
||||||
|
class ActorDefinitionGroup& operator=(class ActorDefinitionGroup const &) = delete;
|
||||||
|
ActorDefinitionGroup(class ActorDefinitionGroup const &) = delete;
|
||||||
|
ActorDefinitionGroup() = delete;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
public:
|
||||||
|
#ifdef ENABLE_VIRTUAL_FAKESYMBOL_ACTORDEFINITIONGROUP
|
||||||
|
#endif
|
||||||
|
MCAPI class ActorDefinitionPtr tryGetDefinition(std::string const &);
|
||||||
|
MCAPI class ActorDefinitionPtr tryGetDefinitionGroup(std::string const &, std::string const &);
|
||||||
|
MCAPI static bool loadActorDefinitionIdentifier(class Json::Value const &, class SemVersion const &, std::string &);
|
||||||
|
MCAPI static bool loadActorDefinitionRuntimeIdentifier(class Json::Value const &, class SemVersion const &, std::string &);
|
||||||
|
MCAPI static bool tryReadEntityResourceFile(class PackInstance &, class Core::Path const &, class Json::Value &);
|
||||||
|
|
||||||
|
//protected:
|
||||||
|
MCAPI void _addRef(class ActorDefinitionPtr &);
|
||||||
|
MCAPI void _removeRef(class ActorDefinitionPtr &);
|
||||||
|
|
||||||
|
//private:
|
||||||
|
MCAPI void _getResources(class Level &);
|
||||||
|
MCAPI struct ActorDefinitionGroup::LoadActorResult _loadActorDefinition(class Level &, class Json::Value &, class std::unordered_set<std::string, struct std::hash<std::string>, struct std::equal_to<std::string>, class std::allocator<std::string>> &);
|
||||||
|
MCAPI bool _loadDefinitionFromJSON(class SemVersion &, class Json::Value &, std::string const &, class Level &);
|
||||||
|
MCAPI void _loadTemplates(class Level &, std::string const &, class Json::Value, class SemVersion const &);
|
||||||
|
MCAPI void _setupAnimationResourceDefinitionMap(class ActorDefinition &, class Level &);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
};
|
39
LiteLoader/Header/MC/ActorDefinitionIdentifier.hpp
Normal file
39
LiteLoader/Header/MC/ActorDefinitionIdentifier.hpp
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
// This Header is auto generated by BDSLiteLoader Toolchain
|
||||||
|
#pragma once
|
||||||
|
#define AUTO_GENERATED
|
||||||
|
#include "../Global.h"
|
||||||
|
|
||||||
|
#define BEFORE_EXTRA
|
||||||
|
|
||||||
|
#undef BEFORE_EXTRA
|
||||||
|
|
||||||
|
struct ActorDefinitionIdentifier {
|
||||||
|
|
||||||
|
#define AFTER_EXTRA
|
||||||
|
|
||||||
|
#undef AFTER_EXTRA
|
||||||
|
#ifndef DISABLE_CONSTRUCTOR_PREVENTION_ACTORDEFINITIONIDENTIFIER
|
||||||
|
public:
|
||||||
|
ActorDefinitionIdentifier() = delete;
|
||||||
|
#endif
|
||||||
|
public:
|
||||||
|
#ifdef ENABLE_VIRTUAL_FAKESYMBOL_ACTORDEFINITIONIDENTIFIER
|
||||||
|
#endif
|
||||||
|
MCAPI ActorDefinitionIdentifier(std::string, std::string, std::string);
|
||||||
|
MCAPI ActorDefinitionIdentifier(struct ActorDefinitionIdentifier const &);
|
||||||
|
MCAPI ActorDefinitionIdentifier(struct ActorDefinitionIdentifier &&);
|
||||||
|
MCAPI ActorDefinitionIdentifier(std::string const &);
|
||||||
|
MCAPI ActorDefinitionIdentifier(enum ActorType);
|
||||||
|
MCAPI void initialize(std::string const &, std::string const &, std::string const &);
|
||||||
|
MCAPI struct ActorDefinitionIdentifier & operator=(struct ActorDefinitionIdentifier const &);
|
||||||
|
MCAPI bool operator==(struct ActorDefinitionIdentifier const &) const;
|
||||||
|
MCAPI ~ActorDefinitionIdentifier();
|
||||||
|
MCAPI static std::string const EVENT_BEGIN;
|
||||||
|
MCAPI static std::string const EVENT_END;
|
||||||
|
MCAPI static std::string const NAMESPACE_SEPARATOR;
|
||||||
|
|
||||||
|
//private:
|
||||||
|
MCAPI void _initialize();
|
||||||
|
MCAPI static void _extractIdentifier(std::string const &, struct ActorDefinitionIdentifier &);
|
||||||
|
|
||||||
|
};
|
28
LiteLoader/Header/MC/ActorDefinitionPtr.hpp
Normal file
28
LiteLoader/Header/MC/ActorDefinitionPtr.hpp
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
// This Header is auto generated by BDSLiteLoader Toolchain
|
||||||
|
#pragma once
|
||||||
|
#define AUTO_GENERATED
|
||||||
|
#include "../Global.h"
|
||||||
|
|
||||||
|
#define BEFORE_EXTRA
|
||||||
|
|
||||||
|
#undef BEFORE_EXTRA
|
||||||
|
|
||||||
|
class ActorDefinitionPtr {
|
||||||
|
|
||||||
|
#define AFTER_EXTRA
|
||||||
|
|
||||||
|
#undef AFTER_EXTRA
|
||||||
|
#ifndef DISABLE_CONSTRUCTOR_PREVENTION_ACTORDEFINITIONPTR
|
||||||
|
public:
|
||||||
|
class ActorDefinitionPtr& operator=(class ActorDefinitionPtr const &) = delete;
|
||||||
|
ActorDefinitionPtr(class ActorDefinitionPtr const &) = delete;
|
||||||
|
ActorDefinitionPtr() = delete;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
public:
|
||||||
|
#ifdef ENABLE_VIRTUAL_FAKESYMBOL_ACTORDEFINITIONPTR
|
||||||
|
#endif
|
||||||
|
MCAPI ~ActorDefinitionPtr();
|
||||||
|
MCAPI static class ActorDefinitionPtr const NONE;
|
||||||
|
|
||||||
|
};
|
30
LiteLoader/Header/MC/ActorEventCoordinator.hpp
Normal file
30
LiteLoader/Header/MC/ActorEventCoordinator.hpp
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
// This Header is auto generated by BDSLiteLoader Toolchain
|
||||||
|
#pragma once
|
||||||
|
#define AUTO_GENERATED
|
||||||
|
#include "../Global.h"
|
||||||
|
|
||||||
|
#define BEFORE_EXTRA
|
||||||
|
|
||||||
|
#undef BEFORE_EXTRA
|
||||||
|
|
||||||
|
class ActorEventCoordinator {
|
||||||
|
|
||||||
|
#define AFTER_EXTRA
|
||||||
|
|
||||||
|
#undef AFTER_EXTRA
|
||||||
|
#ifndef DISABLE_CONSTRUCTOR_PREVENTION_ACTOREVENTCOORDINATOR
|
||||||
|
public:
|
||||||
|
class ActorEventCoordinator& operator=(class ActorEventCoordinator const &) = delete;
|
||||||
|
ActorEventCoordinator(class ActorEventCoordinator const &) = delete;
|
||||||
|
ActorEventCoordinator() = delete;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
public:
|
||||||
|
#ifdef ENABLE_VIRTUAL_FAKESYMBOL_ACTOREVENTCOORDINATOR
|
||||||
|
#endif
|
||||||
|
MCAPI void sendActorAcquiredItem(class Actor &, class ItemInstance const &, unsigned int, enum ItemAcquisitionMethod, class Actor *);
|
||||||
|
MCAPI void sendActorCarriedItemChanged(class Actor &, class ItemInstance const &, class ItemInstance const &, enum HandSlot);
|
||||||
|
MCAPI void sendActorDroppedItem(class Actor &, class ItemInstance const &);
|
||||||
|
MCAPI void sendActorUseItem(class Actor &, class ItemInstance const &, enum ItemUseMethod);
|
||||||
|
|
||||||
|
};
|
49
LiteLoader/Header/MC/ActorEventListener.hpp
Normal file
49
LiteLoader/Header/MC/ActorEventListener.hpp
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
// This Header is auto generated by BDSLiteLoader Toolchain
|
||||||
|
#pragma once
|
||||||
|
#define AUTO_GENERATED
|
||||||
|
#include "../Global.h"
|
||||||
|
|
||||||
|
#define BEFORE_EXTRA
|
||||||
|
|
||||||
|
#undef BEFORE_EXTRA
|
||||||
|
|
||||||
|
class ActorEventListener {
|
||||||
|
|
||||||
|
#define AFTER_EXTRA
|
||||||
|
|
||||||
|
#undef AFTER_EXTRA
|
||||||
|
#ifndef DISABLE_CONSTRUCTOR_PREVENTION_ACTOREVENTLISTENER
|
||||||
|
public:
|
||||||
|
class ActorEventListener& operator=(class ActorEventListener const &) = delete;
|
||||||
|
ActorEventListener(class ActorEventListener const &) = delete;
|
||||||
|
ActorEventListener() = delete;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
public:
|
||||||
|
#ifdef ENABLE_VIRTUAL_FAKESYMBOL_ACTOREVENTLISTENER
|
||||||
|
MCVAPI enum EventResult onActorAcquiredItem(class Actor &, class ItemInstance const &, unsigned int, enum ItemAcquisitionMethod, class Actor *);
|
||||||
|
MCVAPI enum EventResult onActorAttack(class Actor &, class Actor &);
|
||||||
|
MCVAPI enum EventResult onActorAttackedActor(class Actor &, class Actor &);
|
||||||
|
MCVAPI enum EventResult onActorCarriedItemChanged(class Actor &, class ItemInstance const &, class ItemInstance const &, enum HandSlot);
|
||||||
|
MCVAPI enum EventResult onActorCreated(class Actor &);
|
||||||
|
MCVAPI enum EventResult onActorDeath(class Actor &, class ActorDamageSource const &);
|
||||||
|
MCVAPI enum EventResult onActorDefinitionEventTriggered(class Actor &, std::string const &);
|
||||||
|
MCVAPI enum EventResult onActorDroppedItem(class Actor &, class ItemInstance const &);
|
||||||
|
MCVAPI enum EventResult onActorEquippedArmor(class Actor &, class ItemInstance const &, enum ArmorSlot);
|
||||||
|
MCVAPI enum EventResult onActorHurt(class Actor &, class ActorDamageSource const &, int, int);
|
||||||
|
MCVAPI enum EventResult onActorMobInteraction(class Actor &, enum MinecraftEventing::InteractionType, enum ActorType);
|
||||||
|
MCVAPI enum EventResult onActorMove(class Actor &, class Vec3 const &);
|
||||||
|
MCVAPI enum EventResult onActorPlacedItem(class Actor &, class ItemInstance const &);
|
||||||
|
MCVAPI enum EventResult onActorRemoved(class Actor &);
|
||||||
|
MCVAPI enum EventResult onActorSneakChanged(class Actor &, bool);
|
||||||
|
MCVAPI enum EventResult onActorStartRiding(class Actor &, class Actor &);
|
||||||
|
MCVAPI enum EventResult onActorStopRiding(class Actor &, bool, bool, bool);
|
||||||
|
MCVAPI enum EventResult onActorTargetAcquired(class Actor &, class Actor &);
|
||||||
|
MCVAPI enum EventResult onActorTeleported(class Actor &);
|
||||||
|
MCVAPI enum EventResult onActorTick(class Actor &);
|
||||||
|
MCVAPI enum EventResult onActorUseItem(class Actor &, class ItemInstance const &, enum ItemUseMethod);
|
||||||
|
MCVAPI enum EventResult onActorUseItemOn(class Actor &, class ItemStack const &, class BlockPos const &, unsigned char);
|
||||||
|
MCVAPI enum EventResult onProjectileHit(class Actor &, class HitResult const &);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
};
|
32
LiteLoader/Header/MC/ActorEventPacket.hpp
Normal file
32
LiteLoader/Header/MC/ActorEventPacket.hpp
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
// This Header is auto generated by BDSLiteLoader Toolchain
|
||||||
|
#pragma once
|
||||||
|
#define AUTO_GENERATED
|
||||||
|
#include "../Global.h"
|
||||||
|
#include "Packet.hpp"
|
||||||
|
|
||||||
|
#define BEFORE_EXTRA
|
||||||
|
|
||||||
|
#undef BEFORE_EXTRA
|
||||||
|
|
||||||
|
class ActorEventPacket : public Packet {
|
||||||
|
|
||||||
|
#define AFTER_EXTRA
|
||||||
|
|
||||||
|
#undef AFTER_EXTRA
|
||||||
|
#ifndef DISABLE_CONSTRUCTOR_PREVENTION_ACTOREVENTPACKET
|
||||||
|
public:
|
||||||
|
class ActorEventPacket& operator=(class ActorEventPacket const &) = delete;
|
||||||
|
ActorEventPacket(class ActorEventPacket const &) = delete;
|
||||||
|
ActorEventPacket() = delete;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
public:
|
||||||
|
/*0*/ virtual ~ActorEventPacket();
|
||||||
|
/*1*/ virtual enum MinecraftPacketIds getId() const;
|
||||||
|
/*2*/ virtual std::string getName() const;
|
||||||
|
/*3*/ virtual void write(class BinaryStream &) const;
|
||||||
|
/*4*/ virtual enum StreamReadResult read(class ReadOnlyBinaryStream &);
|
||||||
|
#ifdef ENABLE_VIRTUAL_FAKESYMBOL_ACTOREVENTPACKET
|
||||||
|
#endif
|
||||||
|
|
||||||
|
};
|
46
LiteLoader/Header/MC/ActorFactory.hpp
Normal file
46
LiteLoader/Header/MC/ActorFactory.hpp
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
// This Header is auto generated by BDSLiteLoader Toolchain
|
||||||
|
#pragma once
|
||||||
|
#define AUTO_GENERATED
|
||||||
|
#include "../Global.h"
|
||||||
|
|
||||||
|
#define BEFORE_EXTRA
|
||||||
|
|
||||||
|
#undef BEFORE_EXTRA
|
||||||
|
|
||||||
|
class ActorFactory {
|
||||||
|
|
||||||
|
#define AFTER_EXTRA
|
||||||
|
|
||||||
|
#undef AFTER_EXTRA
|
||||||
|
#ifndef DISABLE_CONSTRUCTOR_PREVENTION_ACTORFACTORY
|
||||||
|
public:
|
||||||
|
class ActorFactory& operator=(class ActorFactory const &) = delete;
|
||||||
|
ActorFactory(class ActorFactory const &) = delete;
|
||||||
|
ActorFactory() = delete;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
public:
|
||||||
|
#ifdef ENABLE_VIRTUAL_FAKESYMBOL_ACTORFACTORY
|
||||||
|
#endif
|
||||||
|
MCAPI ActorFactory(class Level &);
|
||||||
|
MCAPI std::unique_ptr<class Actor> createBornEntity(struct ActorDefinitionIdentifier const &, class Actor *);
|
||||||
|
MCAPI std::unique_ptr<class Actor> createBornEntity(struct ActorDefinitionIdentifier const &, class BlockPos const &);
|
||||||
|
MCAPI std::unique_ptr<class Actor> createEntity(std::string const &, struct ActorDefinitionIdentifier const &, class Actor *, class Vec3 const &, class Vec2 const &);
|
||||||
|
MCAPI std::unique_ptr<class Actor> createSpawnedEntity(struct ActorDefinitionIdentifier const &, class Actor *, class Vec3 const &, class Vec2 const &);
|
||||||
|
MCAPI std::unique_ptr<class Actor> createSummonedEntity(struct ActorDefinitionIdentifier const &, class Actor *, class Vec3 const &);
|
||||||
|
MCAPI std::unique_ptr<class Actor> createTransformedEntity(struct ActorDefinitionIdentifier const &, class Actor *);
|
||||||
|
MCAPI std::unique_ptr<class Actor> loadEntity(class CompoundTag *, class DataLoadHelper &, class LevelChunk const *);
|
||||||
|
MCAPI ~ActorFactory();
|
||||||
|
MCAPI static std::vector<struct std::pair<std::string, struct ActorDefinitionIdentifier const *>> buildSummonEntityTypeEnum(bool);
|
||||||
|
MCAPI static class Actor * fixLegacyEntity(class BlockSource &, class CompoundTag const *);
|
||||||
|
MCAPI static enum ActorType lookupEntityType(struct ActorDefinitionIdentifier const &);
|
||||||
|
MCAPI static void registerEntityMapping(enum ActorType const &, bool, std::unique_ptr<class Actor> ( *const &)(class ActorDefinitionGroup *, struct ActorDefinitionIdentifier const &), bool);
|
||||||
|
|
||||||
|
//private:
|
||||||
|
MCAPI std::unique_ptr<class Actor> _constructActor(struct ActorDefinitionIdentifier const &, class Vec3 const &, class Vec2 const &);
|
||||||
|
MCAPI void _loadDefinitionGroups(class ActorDefinitionGroup *);
|
||||||
|
|
||||||
|
private:
|
||||||
|
MCAPI static std::vector<struct VanillaActorData> builtinEntityMappings;
|
||||||
|
|
||||||
|
};
|
26
LiteLoader/Header/MC/ActorFactoryData.hpp
Normal file
26
LiteLoader/Header/MC/ActorFactoryData.hpp
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
// This Header is auto generated by BDSLiteLoader Toolchain
|
||||||
|
#pragma once
|
||||||
|
#define AUTO_GENERATED
|
||||||
|
#include "../Global.h"
|
||||||
|
|
||||||
|
#define BEFORE_EXTRA
|
||||||
|
|
||||||
|
#undef BEFORE_EXTRA
|
||||||
|
|
||||||
|
struct ActorFactoryData {
|
||||||
|
|
||||||
|
#define AFTER_EXTRA
|
||||||
|
|
||||||
|
#undef AFTER_EXTRA
|
||||||
|
#ifndef DISABLE_CONSTRUCTOR_PREVENTION_ACTORFACTORYDATA
|
||||||
|
public:
|
||||||
|
struct ActorFactoryData& operator=(struct ActorFactoryData const &) = delete;
|
||||||
|
ActorFactoryData(struct ActorFactoryData const &) = delete;
|
||||||
|
#endif
|
||||||
|
public:
|
||||||
|
#ifdef ENABLE_VIRTUAL_FAKESYMBOL_ACTORFACTORYDATA
|
||||||
|
#endif
|
||||||
|
MCAPI ActorFactoryData();
|
||||||
|
MCAPI ~ActorFactoryData();
|
||||||
|
|
||||||
|
};
|
32
LiteLoader/Header/MC/ActorFallPacket.hpp
Normal file
32
LiteLoader/Header/MC/ActorFallPacket.hpp
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
// This Header is auto generated by BDSLiteLoader Toolchain
|
||||||
|
#pragma once
|
||||||
|
#define AUTO_GENERATED
|
||||||
|
#include "../Global.h"
|
||||||
|
#include "Packet.hpp"
|
||||||
|
|
||||||
|
#define BEFORE_EXTRA
|
||||||
|
|
||||||
|
#undef BEFORE_EXTRA
|
||||||
|
|
||||||
|
class ActorFallPacket : public Packet {
|
||||||
|
|
||||||
|
#define AFTER_EXTRA
|
||||||
|
|
||||||
|
#undef AFTER_EXTRA
|
||||||
|
#ifndef DISABLE_CONSTRUCTOR_PREVENTION_ACTORFALLPACKET
|
||||||
|
public:
|
||||||
|
class ActorFallPacket& operator=(class ActorFallPacket const &) = delete;
|
||||||
|
ActorFallPacket(class ActorFallPacket const &) = delete;
|
||||||
|
ActorFallPacket() = delete;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
public:
|
||||||
|
/*0*/ virtual ~ActorFallPacket();
|
||||||
|
/*1*/ virtual enum MinecraftPacketIds getId() const;
|
||||||
|
/*2*/ virtual std::string getName() const;
|
||||||
|
/*3*/ virtual void write(class BinaryStream &) const;
|
||||||
|
/*4*/ virtual enum StreamReadResult read(class ReadOnlyBinaryStream &);
|
||||||
|
#ifdef ENABLE_VIRTUAL_FAKESYMBOL_ACTORFALLPACKET
|
||||||
|
#endif
|
||||||
|
|
||||||
|
};
|
42
LiteLoader/Header/MC/ActorFilterGroup.hpp
Normal file
42
LiteLoader/Header/MC/ActorFilterGroup.hpp
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
// This Header is auto generated by BDSLiteLoader Toolchain
|
||||||
|
#pragma once
|
||||||
|
#define AUTO_GENERATED
|
||||||
|
#include "../Global.h"
|
||||||
|
#include "FilterGroup.hpp"
|
||||||
|
#include "Json.hpp"
|
||||||
|
|
||||||
|
#define BEFORE_EXTRA
|
||||||
|
|
||||||
|
#undef BEFORE_EXTRA
|
||||||
|
|
||||||
|
class ActorFilterGroup : public FilterGroup {
|
||||||
|
|
||||||
|
#define AFTER_EXTRA
|
||||||
|
|
||||||
|
#undef AFTER_EXTRA
|
||||||
|
#ifndef DISABLE_CONSTRUCTOR_PREVENTION_ACTORFILTERGROUP
|
||||||
|
public:
|
||||||
|
class ActorFilterGroup& operator=(class ActorFilterGroup const &) = delete;
|
||||||
|
ActorFilterGroup() = delete;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
public:
|
||||||
|
/*0*/ virtual ~ActorFilterGroup();
|
||||||
|
/*1*/ virtual class std::shared_ptr<class FilterGroup> _createSubgroup(enum FilterGroup::CollectionType) const;
|
||||||
|
/*3*/ virtual bool _handleUnknownMember(std::string const &, class Json::Value const &);
|
||||||
|
#ifdef ENABLE_VIRTUAL_FAKESYMBOL_ACTORFILTERGROUP
|
||||||
|
#endif
|
||||||
|
MCAPI ActorFilterGroup(enum FilterGroup::CollectionType);
|
||||||
|
MCAPI ActorFilterGroup(class ActorFilterGroup &&);
|
||||||
|
MCAPI ActorFilterGroup(class ActorFilterGroup const &);
|
||||||
|
MCAPI bool evaluateActor(class Actor const &, class VariantParameterList const &) const;
|
||||||
|
MCAPI static void initialize();
|
||||||
|
|
||||||
|
//protected:
|
||||||
|
MCAPI bool _addLegacyFilter(std::string const &, struct ActorFilterGroup::LegacyMapping const &, class FilterInput const &);
|
||||||
|
MCAPI bool _processLegacyArray(std::string const &, class Json::Value const &, struct ActorFilterGroup::LegacyMapping const &);
|
||||||
|
MCAPI bool _processLegacyMember(std::string const &, class Json::Value const &, struct ActorFilterGroup::LegacyMapping const &);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
};
|
31
LiteLoader/Header/MC/ActorHasAbilityTest.hpp
Normal file
31
LiteLoader/Header/MC/ActorHasAbilityTest.hpp
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
// This Header is auto generated by BDSLiteLoader Toolchain
|
||||||
|
#pragma once
|
||||||
|
#define AUTO_GENERATED
|
||||||
|
#include "../Global.h"
|
||||||
|
#include "FilterTest.hpp"
|
||||||
|
#include "Json.hpp"
|
||||||
|
|
||||||
|
#define BEFORE_EXTRA
|
||||||
|
|
||||||
|
#undef BEFORE_EXTRA
|
||||||
|
|
||||||
|
class ActorHasAbilityTest : public FilterTest {
|
||||||
|
|
||||||
|
#define AFTER_EXTRA
|
||||||
|
|
||||||
|
#undef AFTER_EXTRA
|
||||||
|
#ifndef DISABLE_CONSTRUCTOR_PREVENTION_ACTORHASABILITYTEST
|
||||||
|
public:
|
||||||
|
class ActorHasAbilityTest& operator=(class ActorHasAbilityTest const &) = delete;
|
||||||
|
ActorHasAbilityTest(class ActorHasAbilityTest const &) = delete;
|
||||||
|
ActorHasAbilityTest() = delete;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
public:
|
||||||
|
/*0*/ virtual ~ActorHasAbilityTest();
|
||||||
|
/*2*/ virtual bool evaluate(struct FilterContext const &) const;
|
||||||
|
/*4*/ virtual class gsl::basic_string_span<char const, -1> getName() const;
|
||||||
|
#ifdef ENABLE_VIRTUAL_FAKESYMBOL_ACTORHASABILITYTEST
|
||||||
|
#endif
|
||||||
|
|
||||||
|
};
|
31
LiteLoader/Header/MC/ActorHasComponentTest.hpp
Normal file
31
LiteLoader/Header/MC/ActorHasComponentTest.hpp
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
// This Header is auto generated by BDSLiteLoader Toolchain
|
||||||
|
#pragma once
|
||||||
|
#define AUTO_GENERATED
|
||||||
|
#include "../Global.h"
|
||||||
|
#include "FilterTest.hpp"
|
||||||
|
#include "Json.hpp"
|
||||||
|
|
||||||
|
#define BEFORE_EXTRA
|
||||||
|
|
||||||
|
#undef BEFORE_EXTRA
|
||||||
|
|
||||||
|
class ActorHasComponentTest : public FilterTest {
|
||||||
|
|
||||||
|
#define AFTER_EXTRA
|
||||||
|
|
||||||
|
#undef AFTER_EXTRA
|
||||||
|
#ifndef DISABLE_CONSTRUCTOR_PREVENTION_ACTORHASCOMPONENTTEST
|
||||||
|
public:
|
||||||
|
class ActorHasComponentTest& operator=(class ActorHasComponentTest const &) = delete;
|
||||||
|
ActorHasComponentTest(class ActorHasComponentTest const &) = delete;
|
||||||
|
ActorHasComponentTest() = delete;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
public:
|
||||||
|
/*0*/ virtual ~ActorHasComponentTest();
|
||||||
|
/*2*/ virtual bool evaluate(struct FilterContext const &) const;
|
||||||
|
/*4*/ virtual class gsl::basic_string_span<char const, -1> getName() const;
|
||||||
|
#ifdef ENABLE_VIRTUAL_FAKESYMBOL_ACTORHASCOMPONENTTEST
|
||||||
|
#endif
|
||||||
|
|
||||||
|
};
|
31
LiteLoader/Header/MC/ActorHasContainerOpenTest.hpp
Normal file
31
LiteLoader/Header/MC/ActorHasContainerOpenTest.hpp
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
// This Header is auto generated by BDSLiteLoader Toolchain
|
||||||
|
#pragma once
|
||||||
|
#define AUTO_GENERATED
|
||||||
|
#include "../Global.h"
|
||||||
|
#include "FilterTest.hpp"
|
||||||
|
#include "Json.hpp"
|
||||||
|
|
||||||
|
#define BEFORE_EXTRA
|
||||||
|
|
||||||
|
#undef BEFORE_EXTRA
|
||||||
|
|
||||||
|
class ActorHasContainerOpenTest : public FilterTest {
|
||||||
|
|
||||||
|
#define AFTER_EXTRA
|
||||||
|
|
||||||
|
#undef AFTER_EXTRA
|
||||||
|
#ifndef DISABLE_CONSTRUCTOR_PREVENTION_ACTORHASCONTAINEROPENTEST
|
||||||
|
public:
|
||||||
|
class ActorHasContainerOpenTest& operator=(class ActorHasContainerOpenTest const &) = delete;
|
||||||
|
ActorHasContainerOpenTest(class ActorHasContainerOpenTest const &) = delete;
|
||||||
|
ActorHasContainerOpenTest() = delete;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
public:
|
||||||
|
/*0*/ virtual ~ActorHasContainerOpenTest();
|
||||||
|
/*2*/ virtual bool evaluate(struct FilterContext const &) const;
|
||||||
|
/*4*/ virtual class gsl::basic_string_span<char const, -1> getName() const;
|
||||||
|
#ifdef ENABLE_VIRTUAL_FAKESYMBOL_ACTORHASCONTAINEROPENTEST
|
||||||
|
#endif
|
||||||
|
|
||||||
|
};
|
31
LiteLoader/Header/MC/ActorHasDamageTest.hpp
Normal file
31
LiteLoader/Header/MC/ActorHasDamageTest.hpp
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
// This Header is auto generated by BDSLiteLoader Toolchain
|
||||||
|
#pragma once
|
||||||
|
#define AUTO_GENERATED
|
||||||
|
#include "../Global.h"
|
||||||
|
#include "FilterTest.hpp"
|
||||||
|
#include "Json.hpp"
|
||||||
|
|
||||||
|
#define BEFORE_EXTRA
|
||||||
|
|
||||||
|
#undef BEFORE_EXTRA
|
||||||
|
|
||||||
|
class ActorHasDamageTest : public FilterTest {
|
||||||
|
|
||||||
|
#define AFTER_EXTRA
|
||||||
|
|
||||||
|
#undef AFTER_EXTRA
|
||||||
|
#ifndef DISABLE_CONSTRUCTOR_PREVENTION_ACTORHASDAMAGETEST
|
||||||
|
public:
|
||||||
|
class ActorHasDamageTest& operator=(class ActorHasDamageTest const &) = delete;
|
||||||
|
ActorHasDamageTest(class ActorHasDamageTest const &) = delete;
|
||||||
|
ActorHasDamageTest() = delete;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
public:
|
||||||
|
/*0*/ virtual ~ActorHasDamageTest();
|
||||||
|
/*2*/ virtual bool evaluate(struct FilterContext const &) const;
|
||||||
|
/*4*/ virtual class gsl::basic_string_span<char const, -1> getName() const;
|
||||||
|
#ifdef ENABLE_VIRTUAL_FAKESYMBOL_ACTORHASDAMAGETEST
|
||||||
|
#endif
|
||||||
|
|
||||||
|
};
|
35
LiteLoader/Header/MC/ActorHasEquipmentTest.hpp
Normal file
35
LiteLoader/Header/MC/ActorHasEquipmentTest.hpp
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
// This Header is auto generated by BDSLiteLoader Toolchain
|
||||||
|
#pragma once
|
||||||
|
#define AUTO_GENERATED
|
||||||
|
#include "../Global.h"
|
||||||
|
#include "FilterTest.hpp"
|
||||||
|
#include "Json.hpp"
|
||||||
|
|
||||||
|
#define BEFORE_EXTRA
|
||||||
|
|
||||||
|
#undef BEFORE_EXTRA
|
||||||
|
|
||||||
|
class ActorHasEquipmentTest {
|
||||||
|
|
||||||
|
#define AFTER_EXTRA
|
||||||
|
|
||||||
|
#undef AFTER_EXTRA
|
||||||
|
#ifndef DISABLE_CONSTRUCTOR_PREVENTION_ACTORHASEQUIPMENTTEST
|
||||||
|
public:
|
||||||
|
class ActorHasEquipmentTest& operator=(class ActorHasEquipmentTest const &) = delete;
|
||||||
|
ActorHasEquipmentTest(class ActorHasEquipmentTest const &) = delete;
|
||||||
|
ActorHasEquipmentTest() = delete;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
public:
|
||||||
|
/*0*/ virtual ~ActorHasEquipmentTest();
|
||||||
|
/*1*/ virtual bool setup(struct FilterTest::Definition const &, struct FilterInputs const &);
|
||||||
|
/*2*/ virtual bool evaluate(struct FilterContext const &) const;
|
||||||
|
/*3*/ virtual void __unk_vfn_3();
|
||||||
|
/*4*/ virtual class gsl::basic_string_span<char const, -1> getName() const;
|
||||||
|
/*5*/ virtual class Json::Value _serializeDomain() const;
|
||||||
|
/*6*/ virtual class Json::Value _serializeValue() const;
|
||||||
|
#ifdef ENABLE_VIRTUAL_FAKESYMBOL_ACTORHASEQUIPMENTTEST
|
||||||
|
#endif
|
||||||
|
|
||||||
|
};
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user