diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..344dea5 --- /dev/null +++ b/.clang-format @@ -0,0 +1,47 @@ +BasedOnStyle: LLVM +AccessModifierOffset: -4 +AlignAfterOpenBracket: BlockIndent +AlignArrayOfStructures: Left +AlignConsecutiveDeclarations: + Enabled: true + AcrossEmptyLines: false + AcrossComments: false +AlignConsecutiveAssignments: + Enabled: true + AcrossEmptyLines: false + AcrossComments: false + AlignCompound: true + PadOperators: true +AlignConsecutiveMacros: + Enabled: true + AcrossEmptyLines: false + AcrossComments: false +AllowAllParametersOfDeclarationOnNextLine: false +AllowAllArgumentsOnNextLine: false +AlignOperands: AlignAfterOperator +AlignConsecutiveBitFields: + Enabled: true + AcrossEmptyLines: false + AcrossComments: false +AllowShortLambdasOnASingleLine: All +AllowShortBlocksOnASingleLine: Empty +AllowShortIfStatementsOnASingleLine: AllIfsAndElse +AllowShortLoopsOnASingleLine: true +AlwaysBreakAfterDefinitionReturnType: None +AlwaysBreakTemplateDeclarations: 'Yes' +BinPackArguments: false +BinPackParameters: false +BreakBeforeBraces: Custom +BreakBeforeBinaryOperators: NonAssignment +ColumnLimit: 120 +CommentPragmas: '^ IWYU pragma:' +ConstructorInitializerIndentWidth: 0 +IndentWidth: 4 +Language: Cpp +MaxEmptyLinesToKeep: 2 +PackConstructorInitializers: CurrentLine +PointerAlignment: Left +TabWidth: 4 +UseTab: Never +SortIncludes: CaseSensitive +IncludeBlocks: Regroup diff --git a/.clang-tidy b/.clang-tidy new file mode 100644 index 0000000..915eee8 --- /dev/null +++ b/.clang-tidy @@ -0,0 +1,145 @@ +# Generated from CLion Inspection settings +--- +Checks: '-*, +bugprone-argument-comment, +bugprone-assert-side-effect, +bugprone-bad-signal-to-kill-thread, +bugprone-branch-clone, +bugprone-copy-constructor-init, +bugprone-dangling-handle, +bugprone-dynamic-static-initializers, +bugprone-fold-init-type, +bugprone-forward-declaration-namespace, +bugprone-forwarding-reference-overload, +bugprone-inaccurate-erase, +bugprone-incorrect-roundings, +bugprone-integer-division, +bugprone-lambda-function-name, +bugprone-macro-parentheses, +bugprone-macro-repeated-side-effects, +bugprone-misplaced-operator-in-strlen-in-alloc, +bugprone-misplaced-pointer-arithmetic-in-alloc, +bugprone-misplaced-widening-cast, +bugprone-move-forwarding-reference, +bugprone-multiple-statement-macro, +bugprone-no-escape, +bugprone-not-null-terminated-result, +bugprone-parent-virtual-call, +bugprone-posix-return, +bugprone-reserved-identifier, +bugprone-sizeof-container, +bugprone-sizeof-expression, +bugprone-spuriously-wake-up-functions, +bugprone-string-constructor, +bugprone-string-integer-assignment, +bugprone-string-literal-with-embedded-nul, +bugprone-suspicious-enum-usage, +bugprone-suspicious-include, +bugprone-suspicious-memory-comparison, +bugprone-suspicious-memset-usage, +bugprone-suspicious-missing-comma, +bugprone-suspicious-semicolon, +bugprone-suspicious-string-compare, +bugprone-swapped-arguments, +bugprone-terminating-continue, +bugprone-throw-keyword-missing, +bugprone-too-small-loop-variable, +bugprone-undefined-memory-manipulation, +bugprone-undelegated-constructor, +bugprone-unhandled-self-assignment, +bugprone-unused-raii, +bugprone-unused-return-value, +bugprone-use-after-move, +bugprone-virtual-near-miss, +cert-dcl21-cpp, +cert-dcl58-cpp, +cert-err34-c, +cert-err52-cpp, +cert-err60-cpp, +cert-flp30-c, +cert-msc50-cpp, +cert-msc51-cpp, +cert-str34-c, +cppcoreguidelines-interfaces-global-init, +cppcoreguidelines-narrowing-conversions, +cppcoreguidelines-pro-type-member-init, +cppcoreguidelines-slicing, +google-default-arguments, +google-explicit-constructor, +google-runtime-operator, +hicpp-exception-baseclass, +hicpp-multiway-paths-covered, +misc-misplaced-const, +misc-new-delete-overloads, +misc-non-copyable-objects, +misc-throw-by-value-catch-by-reference, +misc-unconventional-assign-operator, +misc-uniqueptr-reset-release, +modernize-avoid-bind, +modernize-concat-nested-namespaces, +modernize-deprecated-headers, +modernize-deprecated-ios-base-aliases, +modernize-loop-convert, +modernize-make-shared, +modernize-make-unique, +modernize-pass-by-value, +modernize-raw-string-literal, +modernize-redundant-void-arg, +modernize-replace-auto-ptr, +modernize-replace-disallow-copy-and-assign-macro, +modernize-replace-random-shuffle, +modernize-return-braced-init-list, +modernize-shrink-to-fit, +modernize-unary-static-assert, +modernize-use-auto, +modernize-use-bool-literals, +modernize-use-emplace, +modernize-use-equals-default, +modernize-use-equals-delete, +modernize-use-nodiscard, +modernize-use-noexcept, +modernize-use-nullptr, +modernize-use-override, +modernize-use-transparent-functors, +modernize-use-uncaught-exceptions, +mpi-buffer-deref, +mpi-type-mismatch, +openmp-use-default-none, +performance-faster-string-find, +performance-for-range-copy, +performance-implicit-conversion-in-loop, +performance-inefficient-algorithm, +performance-inefficient-string-concatenation, +performance-inefficient-vector-operation, +performance-move-const-arg, +performance-move-constructor-init, +performance-no-automatic-move, +performance-noexcept-move-constructor, +performance-trivially-destructible, +performance-type-promotion-in-math-fn, +performance-unnecessary-copy-initialization, +performance-unnecessary-value-param, +portability-simd-intrinsics, +readability-avoid-const-params-in-decls, +readability-const-return-type, +readability-container-size-empty, +readability-convert-member-functions-to-static, +readability-delete-null-pointer, +readability-deleted-default, +readability-inconsistent-declaration-parameter-name, +readability-make-member-function-const, +readability-misleading-indentation, +readability-misplaced-array-index, +readability-non-const-parameter, +readability-redundant-control-flow, +readability-redundant-declaration, +readability-redundant-function-ptr-dereference, +readability-redundant-smartptr-get, +readability-redundant-string-cstr, +readability-redundant-string-init, +readability-simplify-subscript-expr, +readability-static-accessed-through-instance, +readability-static-definition-in-anonymous-namespace, +readability-string-compare, +readability-uniqueptr-delete-release, +readability-use-anyofallof' diff --git a/.clangd b/.clangd new file mode 100644 index 0000000..a27982c --- /dev/null +++ b/.clangd @@ -0,0 +1,10 @@ +Diagnostics: + Suppress: + - "-Wmicrosoft-enum-forward-reference" + - "-Wc++11-narrowing" + - "-Wc++2b-extensions" + - "-Wmicrosoft-cast" +CompileFlags: + Add: + - "-ferror-limit=0" + - '-D__FUNCTION__="dummy"' diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml new file mode 100644 index 0000000..1c3513b --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -0,0 +1,55 @@ +name: Bug Report +description: Create a report to help us improve +title: "[Bug]: " +labels: ["bug"] +body: + - type: textarea + attributes: + label: Describe the bug + description: A clear and concise description of what the bug is. + validations: + required: true + + - type: textarea + attributes: + label: To Reproduce + description: Steps to reproduce the behavior. + validations: + required: true + + - type: textarea + attributes: + label: Expected behavior + description: A clear and concise description of what you expected to happen. + validations: + required: true + + - type: textarea + attributes: + label: Screenshots + description: If applicable, add screenshots to help explain your problem. + + - type: input + attributes: + label: Platform + description: The platform you are using. (e.g. Windows 10) + + - type: input + attributes: + label: BDS Version + description: The version of BDS you are using. (e.g. 1.20.32.1) + + - type: input + attributes: + label: LeviLamina Version + description: The version of LeviLamina you are using. (e.g. 1.0.0) + + - type: input + attributes: + label: Version + description: The version of the plugin you are using. (e.g. 1.0.0) + + - type: textarea + attributes: + label: Additional context + description: Add any other context about the problem here. diff --git a/.github/ISSUE_TEMPLATE/feature_request.yml b/.github/ISSUE_TEMPLATE/feature_request.yml new file mode 100644 index 0000000..b0f4b33 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.yml @@ -0,0 +1,28 @@ +name: Feature request +description: Suggest an idea for this project +title: "[Feature]: " +labels: ["enhancement"] +body: + - type: textarea + attributes: + label: Is your feature request related to a problem? Please describe. + description: A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] + validations: + required: true + + - type: textarea + attributes: + label: Describe the solution you'd like + description: A clear and concise description of what you want to happen. + validations: + required: true + + - type: textarea + attributes: + label: Describe alternatives you've considered + description: A clear and concise description of any alternative solutions or features you've considered. + + - type: textarea + attributes: + label: Additional context + description: Add any other context or screenshots about the feature request here. diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000..58da313 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,18 @@ +## What does this PR do? + + + +## Which issues does this PR resolve? + + + +## Checklist before merging + +Thank you for your contribution to the repository. +Before submitting this PR, please make sure: + +- [ ] Your code builds clean without any errors or warnings +- [ ] Your code follows [LeviLamina C++ Style Guide](https://github.com/LiteLDev/LeviLamina/wiki/CPP-Style-Guide) +- [ ] You have tested all functions +- [ ] You have not used code without license +- [ ] You have added statement for third-party code diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f5ad66f..079741c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,42 +1,42 @@ -name: build - -on: [workflow_dispatch] +on: + pull_request: + push: + workflow_dispatch: + jobs: build: - runs-on: windows-2022 - + runs-on: windows-latest steps: - - uses: actions/checkout@v3.2.0 + - uses: actions/checkout@v4 + + - uses: xmake-io/github-action-setup-xmake@v1 + + - run: | + xmake repo -u + + - run: | + xmake f -a x64 -m release -p windows -v -y + + - run: | + xmake -w -y + + - uses: actions/upload-artifact@v3 with: - submodules: "true" - - - name: Download Server - working-directory: ${{ env.GITHUB_WORKSPACE }} - run: | - cd ./SDK/tools - curl -L -o ./server.zip "https://minecraft.azureedge.net/bin-win/bedrock-server-1.20.30.02.zip" - unzip server.zip - shell: bash - - - name: Build Library - working-directory: ${{env.GITHUB_WORKSPACE}} - run: | - cd ./SDK/tools - ./PeEditor.exe -l - cp bedrock_server_var.lib ../lib - cp bedrock_server_api.lib ../lib - shell: bash - - - name: Build - working-directory: ${{env.GITHUB_WORKSPACE}} - run: | - mkdir build - cmake -B ./build -DCMAKE_BUILD_TYPE=Release - cmake --build ./build --config Release --target ALL_BUILD - shell: cmd - - - name: Upload Plugin - uses: actions/upload-artifact@v3.1.0 + name: ${{ github.event.repository.name }}-windows-x64-${{ github.sha }} + path: | + bin/ + + check-style: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-node@v3 with: - name: build - path: ${{ github.workspace }}/build/Release/ + node-version: 18 + + - run: | + npm install clang-format@1.8.0 + + - run: | + npx clang-format --dry-run --Werror $(find . -type f -name '*.cpp' -o -name '*.h') diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..42bf5e2 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,56 @@ +on: + release: + types: + - published + +jobs: + build: + runs-on: windows-latest + steps: + - uses: actions/checkout@v4 + + - uses: xmake-io/github-action-setup-xmake@v1 + + - run: | + xmake repo -u + + - run: | + xmake f -a x64 -m release -p windows -v -y + + - run: | + xmake -w -y + + - uses: actions/upload-artifact@v3 + with: + name: ${{ github.event.repository.name }}-windows-x64-${{ github.sha }} + path: | + bin/ + + upload-to-release: + needs: + - build + permissions: + contents: write + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: actions/download-artifact@v3 + with: + name: ${{ github.event.repository.name }}-windows-x64-${{ github.sha }} + path: release/ + + - run: | + cp LICENSE README.md release/ + + - name: Archive release + run: | + cd release + zip -r ../${{ github.event.repository.name }}-windows-x64.zip * + cd .. + + - uses: softprops/action-gh-release@v1 + with: + append_body: true + files: | + ${{ github.event.repository.name }}-windows-x64.zip diff --git a/.github/workflows/update_sdk.yml b/.github/workflows/update_sdk.yml deleted file mode 100644 index 65a1397..0000000 --- a/.github/workflows/update_sdk.yml +++ /dev/null @@ -1,20 +0,0 @@ -name: Update SDK - -on: - workflow_dispatch: - -jobs: - update_sdk: - name: Update SDK - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Update submodules - run: | - git submodule update --init --remote - git config --global user.name "github-actions[bot]" - git config --global user.email "github-actions[bot]@users.noreply.github.com" - git commit -am "Update SDK" || exit 0 - git push || exit 0 \ No newline at end of file diff --git a/.gitignore b/.gitignore index f219f9e..a652ac8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +# https://github.com/github/gitignore/blob/main/C++.gitignore # Prerequisites *.d @@ -31,10 +32,520 @@ *.out *.app -# Build -build -cmake-build-* -out -# Jetbrains IDEs -.idea +# https://github.com/github/gitignore/blob/main/CMake.gitignore +CMakeLists.txt.user +CMakeCache.txt +CMakeFiles +CMakeScripts +Testing +Makefile +cmake_install.cmake +install_manifest.txt +compile_commands.json +CTestTestfile.cmake +_deps + + +# https://github.com/github/gitignore/blob/main/Global/Ninja.gitignore +.ninja_deps +.ninja_log + + +# https://github.com/github/gitignore/blob/main/VisualStudio.gitignore +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +## +## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore + +# User-specific files +*.rsuser +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Mono auto generated files +mono_crash.* + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +[Ww][Ii][Nn]32/ +[Aa][Rr][Mm]/ +[Aa][Rr][Mm]64/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ +[Ll]ogs/ + +# Visual Studio 2015/2017 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# Visual Studio 2017 auto generated files +Generated\ Files/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUnit +*.VisualState.xml +TestResult.xml +nunit-*.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# Benchmark Results +BenchmarkDotNet.Artifacts/ + +# .NET Core +project.lock.json +project.fragment.lock.json +artifacts/ + +# ASP.NET Scaffolding +ScaffoldingReadMe.txt + +# StyleCop +StyleCopReport.xml + +# Files built by Visual Studio +*_i.c +*_p.c +*_h.h +*.ilk +*.meta +*.obj +*.iobj +*.pch +*.pdb +*.ipdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*_wpftmp.csproj +*.log +*.tlog +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# Visual Studio Trace Files +*.e2e + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# AxoCover is a Code Coverage Tool +.axoCover/* +!.axoCover/settings.json + +# Coverlet is a free, cross platform Code Coverage Tool +coverage*.json +coverage*.xml +coverage*.info + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# Note: Comment the next line if you want to checkin your web deploy settings, +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# NuGet Symbol Packages +*.snupkg +# The packages folder can be ignored because of Package Restore +**/[Pp]ackages/* +# except build/, which is used as an MSBuild target. +!**/[Pp]ackages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/[Pp]ackages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt +*.appx +*.appxbundle +*.appxupload + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!?*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +orleans.codegen.cs + +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) +#*.snk + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm +ServiceFabricBackup/ +*.rptproj.bak + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings +*.rptproj.rsuser +*- [Bb]ackup.rdl +*- [Bb]ackup ([0-9]).rdl +*- [Bb]ackup ([0-9][0-9]).rdl + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio 6 auto-generated project file (contains which files were open etc.) +*.vbp + +# Visual Studio 6 workspace and project file (working project files containing files to include in project) +*.dsw +*.dsp + +# Visual Studio 6 technical files +*.ncb +*.aps + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# CodeRush personal settings +.cr/personal + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Tabs Studio +*.tss + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs + +# OpenCover UI analysis results +OpenCover/ + +# Azure Stream Analytics local run output +ASALocalRun/ + +# MSBuild Binary and Structured Log +*.binlog + +# NVidia Nsight GPU debugger configuration file +*.nvuser + +# MFractors (Xamarin productivity tool) working folder +.mfractor/ + +# Local History for Visual Studio +.localhistory/ + +# Visual Studio History (VSHistory) files +.vshistory/ + +# BeatPulse healthcheck temp database +healthchecksdb + +# Backup folder for Package Reference Convert tool in Visual Studio 2017 +MigrationBackup/ + +# Ionide (cross platform F# VS Code tools) working folder +.ionide/ + +# Fody - auto-generated XML schema +FodyWeavers.xsd + +# VS Code files for those working on multiple tools +.vscode/* +*.code-workspace + +# Local History for Visual Studio Code +.history/ + +# Windows Installer files from build outputs +*.cab +*.msi +*.msix +*.msm +*.msp + +# JetBrains Rider +*.sln.iml + + +# https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore +.vscode/* + +# Local History for Visual Studio Code +.history/ + +# Built Visual Studio Code Extensions +*.vsix + + +# https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider +# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 + +# User-specific stuff +.idea/**/workspace.xml +.idea/**/tasks.xml +.idea/**/usage.statistics.xml +.idea/**/dictionaries +.idea/**/shelf + +# AWS User-specific +.idea/**/aws.xml + +# Generated files +.idea/**/contentModel.xml + +# Sensitive or high-churn files +.idea/**/dataSources/ +.idea/**/dataSources.ids +.idea/**/dataSources.local.xml +.idea/**/sqlDataSources.xml +.idea/**/dynamic.xml +.idea/**/uiDesigner.xml +.idea/**/dbnavigator.xml + +# Gradle +.idea/**/gradle.xml +.idea/**/libraries + +# Gradle and Maven with auto-import +# When using Gradle or Maven with auto-import, you should exclude module files, +# since they will be recreated, and may cause churn. Uncomment if using +# auto-import. +# .idea/artifacts +# .idea/compiler.xml +# .idea/jarRepositories.xml +# .idea/modules.xml +# .idea/*.iml +# .idea/modules +# *.iml +# *.ipr + +# CMake +cmake-build-*/ + +# Mongo Explorer plugin +.idea/**/mongoSettings.xml + +# File-based project format +*.iws + +# IntelliJ +out/ + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Cursive Clojure plugin +.idea/replstate.xml + +# SonarLint plugin +.idea/sonarlint/ + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties +fabric.properties + +# Editor-based Rest Client +.idea/httpRequests + +# Android studio 3.1+ serialized cache file +.idea/caches/build_file_checksums.ser + + +# XMake +/.xmake/ +/build/ +/CMakeLists.txt + + +# Project specific ignores +/.idea/ +/.vscode/ +/bin/ \ No newline at end of file diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index c530b90..0000000 --- a/.gitmodules +++ /dev/null @@ -1,4 +0,0 @@ -[submodule "SDK"] - path = SDK - url = https://github.com/LiteLDev/SDK-cpp.git - branch = main diff --git a/CMakeLists.txt b/CMakeLists.txt deleted file mode 100644 index 24a4686..0000000 --- a/CMakeLists.txt +++ /dev/null @@ -1,76 +0,0 @@ -cmake_minimum_required(VERSION 3.21) - -project(plugin) - -set(CMAKE_CXX_STANDARD 20) -set(CMAKE_BUILD_TYPE Release) - -file(GLOB_RECURSE SRC_FILES_DIR - ${PROJECT_SOURCE_DIR}/src/*.c - ${PROJECT_SOURCE_DIR}/src/*.cpp - ${PROJECT_SOURCE_DIR}/src/*.h -) - -include_directories( - ${CMAKE_SOURCE_DIR}/SDK/include -) - -link_directories( - ${CMAKE_SOURCE_DIR}/SDK/lib -) - -add_definitions( - -D"NDEBUG" - -D"NOMINMAX" - -D"TEMPLATE_EXPORTS" - -D"UNICODE" - -D"WIN32_LEAN_AND_MEAN" - -D"_AMD64_" - -D"_CRT_SECURE_NO_WARNINGS" - -D"_UNICODE" - -D"_USRDLL" - -D"_WINDLL" - -D"_WINDOWS" -) - -add_compile_options( - /diagnostics:column - /EHsc - /FC - /GL - /MD - /nologo - /permissive- - /sdl - /utf-8 - /Zc:inline - /Zi -) - -add_link_options( - /DEBUG - /DELAYLOAD:"bedrock_server.dll" - /DLL - /IGNORE:4199 - /INCREMENTAL:NO - /LTCG:INCREMENTAL - /MANIFESTUAC:NO - /MACHINE:X64 - /NOLOGO - /OPT:ICF - /OPT:REF - /SUBSYSTEM:CONSOLE -) - -add_library(${CMAKE_PROJECT_NAME} SHARED ${SRC_FILES_DIR}) - -target_link_libraries(${CMAKE_PROJECT_NAME} - "${CMAKE_SOURCE_DIR}/SDK/lib/LiteLoader.lib" - "${CMAKE_SOURCE_DIR}/SDK/lib/bedrock_server_api.lib" - "${CMAKE_SOURCE_DIR}/SDK/lib/bedrock_server_var.lib" - "${CMAKE_SOURCE_DIR}/SDK/lib/SymDBHelper.lib" -) - -add_custom_command(TARGET ${CMAKE_PROJECT_NAME} PRE_BUILD - COMMAND cmd /c ${PROJECT_SOURCE_DIR}/prepare_libraries.cmd ${PROJECT_SOURCE_DIR} -) diff --git a/CMakeSettings.json b/CMakeSettings.json deleted file mode 100644 index 4b63151..0000000 --- a/CMakeSettings.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "configurations": [ - { - "name": "Release", - "generator": "Visual Studio 17 2022 Win64", - "configurationType": "Release", - "inheritEnvironments": [ "msvc_x64_x64" ], - "buildRoot": "${projectDir}\\out\\build\\${name}", - "installRoot": "${projectDir}\\out\\install\\${name}", - "cmakeCommandArgs": "", - "buildCommandArgs": "", - "ctestCommandArgs": "" - } - ] -} \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..298a42c --- /dev/null +++ b/README.md @@ -0,0 +1,35 @@ +# LeviLamina Plugin Template + +A LeviLamina plugin template + +This plugin is a template for developing LeviLamina plugins. + +## Install + +Generate a new repository from this template. + +## Usage + +Before using this plugin template, make sure that you have installed XMake and a Minecraft Bedrock Server with LeviLamina. + +1. Clone the new repository into a local folder. + +1. Change the plugin name and the expected LeviLamina version in `xmake.lua`. + +1. Add your code. + +1. Run `xmake repo -u` in the root of the repository. + +1. Run `xmake` to build the plugin. + +Now the build is complete at `bin/`. + +## Contributing + +Ask questions by [creating an issue](https://github.com/LiteLDev/levilamina-plugin-template/issues/new/choose). + +PRs accepted. + +## License + +CC0-1.0 © LiteLDev diff --git a/SDK b/SDK deleted file mode 160000 index f27ad9c..0000000 --- a/SDK +++ /dev/null @@ -1 +0,0 @@ -Subproject commit f27ad9c50c232c47b08d7583cd9a629d371499af diff --git a/manifest.json b/manifest.json new file mode 100644 index 0000000..5063a09 --- /dev/null +++ b/manifest.json @@ -0,0 +1,5 @@ +{ + "name": "${pluginName}", + "entry": "${pluginFile}", + "type": "native" +} diff --git a/prepare_libraries.cmd b/prepare_libraries.cmd deleted file mode 100644 index 2db99a6..0000000 --- a/prepare_libraries.cmd +++ /dev/null @@ -1,11 +0,0 @@ -@echo off - -if not exist %1\SDK\Lib\bedrock_server_api.lib goto process -if not exist %1\SDK\Lib\bedrock_server_var.lib goto process -goto end - -:process -cd /d %1\SDK\tools\ -PeEditor.exe -c -l -o ../lib - -:end \ No newline at end of file diff --git a/scripts/after_build.lua b/scripts/after_build.lua new file mode 100644 index 0000000..9475b5a --- /dev/null +++ b/scripts/after_build.lua @@ -0,0 +1,118 @@ +function beautify_json(value, indent) + import("core.base.json") + local json_text = "" + local stack = {} + + local function escape_str(s) + return string.gsub(s, '[%c\\"]', function(c) + local replacements = {['\b'] = '\\b', ['\f'] = '\\f', ['\n'] = '\\n', ['\r'] = '\\r', ['\t'] = '\\t', ['"'] = '\\"', ['\\'] = '\\\\'} + return replacements[c] or string.format('\\u%04x', c:byte()) + end) + end + + local function is_null(v) + return v == json.null + end + + local function is_empty_table(t) + if type(t) ~= 'table' then return false end + for _ in pairs(t) do + return false + end + return true + end + + local function is_array(t) + return type(t) == 'table' and json.is_marked_as_array(t) or #t > 0 + end + + local function serialize(val, level) + local spaces = string.rep(" ", level * indent) + + if type(val) == "table" and not stack[val] then + if is_empty_table(val) then + json_text = json_text .. (is_array(val) and "[]" or "{}") + return + end + + stack[val] = true + local isArray = is_array(val) + json_text = json_text .. (isArray and "[\n" or "{\n") + + local keys = isArray and {} or {} + for k in pairs(val) do + table.insert(keys, k) + end + if not isArray then + table.sort(keys) + end + + for _, k in ipairs(keys) do + local v = val[k] + json_text = json_text .. spaces .. (isArray and "" or '"' .. escape_str(tostring(k)) .. '": ') + serialize(v, level + 1) + json_text = json_text .. ",\n" + end + + json_text = string.sub(json_text, 1, -3) .. "\n" .. string.rep(" ", (level - 1) * indent) .. (isArray and "]" or "}") + stack[val] = nil + elseif type(val) == "string" then + json_text = json_text .. '"' .. escape_str(val) .. '"' + elseif type(val) == "number" then + if val % 1 == 0 then + json_text = json_text .. tostring(math.floor(val)) + else + json_text = json_text .. tostring(val) + end + elseif type(val) == "boolean" then + json_text = json_text .. tostring(val) + elseif is_null(val) then + json_text = json_text .. "null" + else + error("Invalid value type: " .. type(val)) + end + end + serialize(value, 1) + return json_text +end + +function string_formatter(str, variables) + return str:gsub("%${(.-)}", function(var) + return variables[var] or "${" .. var .. "}" + end) +end + +function pack_plugin(target,plugin_define) + import("lib.detect.find_file") + + local manifest_path = find_file("manifest.json", os.projectdir()) + if manifest_path then + local manifest = io.readfile(manifest_path) + local bindir = path.join(os.projectdir(), "bin") + local outputdir = path.join(bindir, plugin_define.pluginName) + local targetfile = path.join(outputdir, plugin_define.pluginFile) + local pdbfile = path.join(outputdir, path.basename(plugin_define.pluginFile) .. ".pdb") + local manifestfile = path.join(outputdir, "manifest.json") + local oritargetfile = target:targetfile() + local oripdbfile = path.join(path.directory(oritargetfile), path.basename(oritargetfile) .. ".pdb") + + os.mkdir(outputdir) + os.cp(oritargetfile, targetfile) + if os.isfile(oripdbfile) then + os.cp(oripdbfile, pdbfile) + end + + formattedmanifest = string_formatter(manifest, plugin_define) + io.writefile(manifestfile,formattedmanifest) + cprint("${bright green}[Plugin Packer]: ${reset}plugin already generated to " .. outputdir) + else + cprint("${bright yellow}warn: ${reset}not found manifest.json in root dir!") + end +end + + +return { + pack_plugin = pack_plugin, + beautify_json = beautify_json, + string_formatter = string_formatter +} diff --git a/src/MinecartSpeedPlus.cpp b/src/MinecartSpeedPlus.cpp new file mode 100644 index 0000000..2423dcf --- /dev/null +++ b/src/MinecartSpeedPlus.cpp @@ -0,0 +1,131 @@ +#include +#include +#include + +ll::Logger logger("MinecartSpeedPlus"); + + +/** + * @brief The entrypoint of the plugin. DO NOT remove or rename this function. + * + */ + +struct { + float GoldenRailMul; + float CommonRailMul; +} gcfg; + +void PluginInit() { + std::filesystem::create_directories("./plugins/MinecartSpeedPlus/"); + if (std::filesystem::exists("./plugins/MinecartSpeedPlus/cfg.json")) { + std::ifstream fin("./plugins/MinecartSpeedPlus/cfg.json"); + std::string c, l; + while (std::getline(fin, l)) { + c += l + '\n'; + } + auto cfg = nlohmann::json::parse(c, nullptr, false, true); + gcfg.GoldenRailMul = cfg["GoldenRailMul"].get(); + gcfg.CommonRailMul = cfg["CommonRailMul"].get(); + } else { + std::ofstream fout("./plugins/MinecartSpeedPlus/cfg.json"); + fout << R"({"GoldenRailMul":0.0,"CommonRailMul":0.0})"; + gcfg.GoldenRailMul = 0.0; + gcfg.CommonRailMul = 0.0; + } + logger.info("MinecartSpeeedPlus by killcerr loaded"); +} + +// #include +// #include +#include +#include +#include + +bool flag = false; + +// TStaticHook( +// Vec3, +// "?calculateGoldenRailSpeedIncrease@RailMovementUtility@@SA?AVVec3@@" +// "AEBVIConstBlockSource@@AEBVBlockPos@@HV2@@Z", +// RailMovementUtility, +// class IConstBlockSource const& a, +// class BlockPos const& b, +// int c, +// class Vec3 d +// ) { +// auto res = original(a, b, c, d); +// // logger.info("calculateGoldenRailSpeedIncrease::speed:{},{},{}", res.x, +// // res.y, +// // res.z); +// flag = true; +// return res; +// } + +LL_AUTO_TYPE_STATIC_HOOK( + calculateGoldenRailSpeedIncreaseHook, + HookPriority::Normal, + RailMovementUtility, + "?calculateGoldenRailSpeedIncrease@RailMovementUtility@@SA?AVVec3@@AEBVIConstBlockSource@@AEBVBlockPos@@HV2@@Z", + Vec3, + class IConstBlockSource const& a, + class BlockPos const& b, + int c, + class Vec3 d +) { + auto res = origin(a, b, c, d); + // logger.info("calculateGoldenRailSpeedIncrease::speed:{},{},{}", res.x, + // res.y, + // res.z); + flag = true; + return res; +} + +// TStaticHook( +// Vec3, +// "?calculateMoveVelocity@RailMovementUtility@@SA?" +// "AVVec3@@AEBVBlock@@HM_NAEAV2@AEA_N3AEBV?$function@$$A6A_" +// "NAEAVVec3@@@Z@std@@@Z", +// RailMovementUtility, +// class Block const& a, +// int b, +// float c, +// bool d, +// class Vec3& e, +// bool& f, +// bool& g, +// class std::function const& h +// ) { +// auto res = original(a, b, c, d, e, f, g, h); +// if (!flag) res *= gcfg.CommonRailMul; +// else { +// flag = false; +// res *= gcfg.GoldenRailMul; +// } +// // logger.info("calculateMoveVelocity::speed:{},{},{}", res.x, res.y, res.z); +// return res; +// } + +LL_AUTO_TYPE_STATIC_HOOK( + calculateMoveVelocityHook, + HookPriority::Normal, + RailMovementUtility, + "?calculateGoldenRailSpeedIncrease@RailMovementUtility@@SA?AVVec3@@AEBVIConstBlockSource@@AEBVBlockPos@@HV2@@Z", + Vec3, + class Block const& a, + int b, + float c, + bool d, + class Vec3& e, + bool& f, + bool& g, + class std::function const& h +) { + auto res = origin(a, b, c, d, e, f, g, h); + if (!flag) res *= gcfg.CommonRailMul; + else { + flag = false; + res *= gcfg.GoldenRailMul; + } + // logger.info("calculateMoveVelocity::speed:{},{},{}", res.x, res.y, res.z); + return res; +} \ No newline at end of file diff --git a/src/Plugin.h b/src/Plugin.h new file mode 100644 index 0000000..db163c3 --- /dev/null +++ b/src/Plugin.h @@ -0,0 +1,32 @@ +#pragma once + +#include + +namespace plugin { + +class Plugin { +public: + explicit Plugin(ll::plugin::NativePlugin& self); + + Plugin(Plugin&&) = delete; + Plugin(const Plugin&) = delete; + Plugin& operator=(Plugin&&) = delete; + Plugin& operator=(const Plugin&) = delete; + + ~Plugin(); // NOLINT(performance-trivially-destructible) + + static Plugin& getInstance(); + + [[nodiscard]] ll::plugin::NativePlugin& getSelf() const; + + /// @return True if the plugin is enabled successfully. + bool enable(); + + /// @return True if the plugin is disabled successfully. + bool disable(); + +private: + ll::plugin::NativePlugin& mSelf; +}; + +} // namespace plugin diff --git a/src/dllmain.cpp b/src/dllmain.cpp deleted file mode 100644 index 80a2e07..0000000 --- a/src/dllmain.cpp +++ /dev/null @@ -1,63 +0,0 @@ -/** - * @file DLLMain.cpp - * @note DO NOT modify or remove this file! - */ - -#include -#include - -#include "version.h" - -void PluginInit(); - -Logger logger(PLUGIN_NAME); - -void CheckProtocolVersion() -{ - -#ifdef TARGET_BDS_PROTOCOL_VERSION - - auto current_protocol = ll::getServerProtocolVersion(); - if (TARGET_BDS_PROTOCOL_VERSION != current_protocol) - { - logger.warn("Protocol version mismatched! Target version: {}. Current version: {}.", - TARGET_BDS_PROTOCOL_VERSION, current_protocol); - logger.warn("This may result in crash. Please switch to the version matching the BDS version!"); - } - -#endif // TARGET_BDS_PROTOCOL_VERSION -} - -BOOL APIENTRY DllMain(HMODULE hModule, - DWORD ul_reason_for_call, - LPVOID lpReserved) -{ - switch (ul_reason_for_call) - { - case DLL_PROCESS_ATTACH: - ll::registerPlugin( - PLUGIN_NAME, - PLUGIN_INTRODUCTION, - ll::Version(PLUGIN_VERSION_MAJOR, PLUGIN_VERSION_MINOR, PLUGIN_VERSION_REVISION, PLUGIN_LLVERSION_STATUS), - std::map{ - {"Author", PLUGIN_AUTHOR}, - }); - break; - - case DLL_THREAD_ATTACH: - case DLL_THREAD_DETACH: - case DLL_PROCESS_DETACH: - break; - } - return TRUE; -} - -extern "C" -{ - _declspec(dllexport) void onPostInit() - { - std::ios::sync_with_stdio(false); - CheckProtocolVersion(); - PluginInit(); - } -} diff --git a/src/plugin.cpp b/src/plugin.cpp index 2151341..ac30e99 100644 --- a/src/plugin.cpp +++ b/src/plugin.cpp @@ -1,78 +1,58 @@ -/** - * @file plugin.cpp - * @brief The main file of the plugin - */ - -#include -#include - -#include "version.h" -#include -// We recommend using the global logger. -extern Logger logger; - -/** - * @brief The entrypoint of the plugin. DO NOT remove or rename this function. - * - */ - -struct { - float GoldenRailMul; - float CommonRailMul; -} gcfg; - -void PluginInit() { - std::filesystem::create_directories("./plugins/MinecartSpeedPlus/"); - if (std::filesystem::exists("./plugins/MinecartSpeedPlus/cfg.json")) { - std::ifstream fin("./plugins/MinecartSpeedPlus/cfg.json"); - std::string c, l; - while (std::getline(fin, l)) { - c += l + '\n'; - } - auto cfg = nlohmann::json::parse(c, nullptr, false, true); - gcfg.GoldenRailMul = cfg["GoldenRailMul"].get(); - gcfg.CommonRailMul = cfg["CommonRailMul"].get(); - } else { - std::ofstream fout("./plugins/MinecartSpeedPlus/cfg.json"); - fout << R"({"GoldenRailMul":0.0,"CommonRailMul":0.0})"; - gcfg.GoldenRailMul = 0.0; - gcfg.CommonRailMul = 0.0; - } - logger.info("MinecartSpeeedPlus by killcerr loaded"); -} - -#include -#include - -bool flag = false; - -TStaticHook(Vec3, - "?calculateGoldenRailSpeedIncrease@RailMovementUtility@@SA?AVVec3@@" - "AEBVIConstBlockSource@@AEBVBlockPos@@HV2@@Z", - RailMovementUtility, class IConstBlockSource const &a, - class BlockPos const &b, int c, class Vec3 d) { - auto res = original(a, b, c, d); - // logger.info("calculateGoldenRailSpeedIncrease::speed:{},{},{}", res.x, - // res.y, - // res.z); - flag = true; - return res; -} - -TStaticHook(Vec3, - "?calculateMoveVelocity@RailMovementUtility@@SA?" - "AVVec3@@AEBVBlock@@HM_NAEAV2@AEA_N3AEBV?$function@$$A6A_" - "NAEAVVec3@@@Z@std@@@Z", - RailMovementUtility, class Block const &a, int b, float c, bool d, - class Vec3 &e, bool &f, bool &g, - class std::function const &h) { - auto res = original(a, b, c, d, e, f, g, h); - if (!flag) - res *= gcfg.CommonRailMul; - else { - flag = false; - res *= gcfg.GoldenRailMul; - } - // logger.info("calculateMoveVelocity::speed:{},{},{}", res.x, res.y, res.z); - return res; -} +#include "Plugin.h" + +#include + +extern void PluginInit(); + +namespace plugin { + +Plugin::~Plugin() = default; + +static std::unique_ptr plugin{}; + +Plugin& Plugin::getInstance() { return *plugin; } + +Plugin::Plugin(ll::plugin::NativePlugin& self) : mSelf(self) { + mSelf.getLogger().info("loading..."); + + // Code for loading the plugin goes here. +} + +ll::plugin::NativePlugin& Plugin::getSelf() const { return mSelf; } + +bool Plugin::enable() { + mSelf.getLogger().info("enabling..."); + PluginInit(); + // Code for enabling the plugin goes here. + + return true; +} + +bool Plugin::disable() { + mSelf.getLogger().info("disabling..."); + + // Code for disabling the plugin goes here. + + return true; +} + +extern "C" { +_declspec(dllexport) bool ll_plugin_load(ll::plugin::NativePlugin& self) { + plugin = std::make_unique(self); + return true; +} + +/// @warning Unloading the plugin may cause a crash if the plugin has not released all of its +/// resources. If you are unsure, keep this function commented out. +// _declspec(dllexport) bool ll_plugin_unload(ll::plugin::Plugin&) { +// plugin.reset(); +// +// return true; +// } + +_declspec(dllexport) bool ll_plugin_enable(ll::plugin::NativePlugin&) { return plugin->enable(); } + +_declspec(dllexport) bool ll_plugin_disable(ll::plugin::NativePlugin&) { return plugin->disable(); } +} + +} // namespace plugin diff --git a/src/version.h b/src/version.h deleted file mode 100644 index 0f2b13b..0000000 --- a/src/version.h +++ /dev/null @@ -1,92 +0,0 @@ -/** - * @file version.h - * @note DO NOT remove this file unless you know what you are doing! - * DO NOT modify code outside the designated area! - */ - -#pragma once - -#define PLUGIN_VERSION_DEV 0 -#define PLUGIN_VERSION_BETA 1 -#define PLUGIN_VERSION_RELEASE 2 - -// *************************************************************************************** -// *************************************************************************************** -// *************************************************************************************** - -// Please FILL UP the content in this area before developing your plugin, and DO -// NOT modify any code outside this area. - -// The basic descriptions of your plugin -// Note that the the plugin name CAN ONLY CONTAIN Enlish alphabet, digit, -// dash(-) and underscore(_). -#define PLUGIN_NAME "MinecartSpeedPlus" -// Describe what your plugin does -// We recommend you start the introduction with a third-person singular verb. -#define PLUGIN_INTRODUCTION "" -#define PLUGIN_AUTHOR "killcerr" - -// The version of your plugin. If you do not know how to set it, please refer -// to https://semver.org/ . -#define PLUGIN_VERSION_MAJOR 0 -#define PLUGIN_VERSION_MINOR 1 -#define PLUGIN_VERSION_REVISION 0 -#define PLUGIN_VERSION_BUILD 0 -#define PLUGIN_VERSION_ACTIONS 0 - -// The stage of your plugin, which can be PLUGIN_VERSION_DEV, -// PLUGIN_VERSION_BETA and PLUGIN_VERSION_RELEASE -#define PLUGIN_VERSION_STATUS PLUGIN_VERSION_DEV - -// The target protocol version of your plugin. If you do not know how to set it, -// please start the latest version of LiteLoaderBDS and get the protocol -// version. If you are confident about the version compatibility of your plugin, -// you can just comment this line (NOT RECOMMENDED). - -// *************************************************************************************** -// *************************************************************************************** -// *************************************************************************************** - -// File version information, which is used in Resource.rc -#define __TO_VERSION_STRING(ver) #ver -#define TO_VERSION_STRING(ver) __TO_VERSION_STRING(ver) - -#if PLUGIN_VERSION_STATUS == PLUGIN_VERSION_BETA - -#define PLUGIN_FILE_VERSION_FLAG VS_FF_DEBUG -#define PLUGIN_LLVERSION_STATUS ll::Version::Beta -#define PLUGIN_FILE_VERSION_STRING \ - TO_VERSION_STRING(PLUGIN_VERSION_MAJOR.PLUGIN_VERSION_MINOR \ - .PLUGIN_VERSION_REVISION.PLUGIN_VERSION_ACTIONS BETA) - -#elif PLUGIN_VERSION_STATUS == PLUGIN_VERSION_DEV - -#define PLUGIN_FILE_VERSION_FLAG VS_FF_DEBUG -#define PLUGIN_LLVERSION_STATUS ll::Version::Dev -#define PLUGIN_FILE_VERSION_STRING \ - TO_VERSION_STRING(PLUGIN_VERSION_MAJOR.PLUGIN_VERSION_MINOR \ - .PLUGIN_VERSION_REVISION.PLUGIN_VERSION_ACTIONS DEV) - -#else - -#define PLUGIN_FILE_VERSION_FLAG 0x0L -#define PLUGIN_LLVERSION_STATUS ll::Version::Release -#define PLUGIN_FILE_VERSION_STRING \ - TO_VERSION_STRING(PLUGIN_VERSION_MAJOR.PLUGIN_VERSION_MINOR \ - .PLUGIN_VERSION_REVISION.PLUGIN_VERSION_ACTIONS) - -#endif - -#define FILE_VERSION_BLOCK_HEADER 0x04004B0L -#define FILE_VERSION_COMPANY_NAME PLUGIN_AUTHOR -#define FILE_VERSION_LEGAL_COPYRIGHT "Copyright (C) 2022" -#define FILE_VERSION_FILE_DESCRIPTION PLUGIN_INTRODUCTION -#define FILE_VERSION_FILE_VERSION_STRING PLUGIN_FILE_VERSION_STRING -#define FILE_VERSION_INTERNAL_NAME PLUGIN_NAME -#define FILE_VERSION_ORIGINAL_FILENAME PLUGIN_NAME ".dll" -#define FILE_VERSION_PRODUCT_NAME FILE_VERSION_INTERNAL_NAME -#define FILE_VERSION_PRODUCT_VERSION_STRING PLUGIN_FILE_VERSION_STRING -#define FILE_VERSION_FILE_VERSION \ - PLUGIN_VERSION_MAJOR, PLUGIN_VERSION_MINOR, PLUGIN_VERSION_REVISION, \ - PLUGIN_VERSION_BUILD -#define FILE_VERSION_PRODUCT_VERSION FILE_VERSION_FILE_VERSION diff --git a/update_sdk.cmd b/update_sdk.cmd deleted file mode 100644 index b4d238c..0000000 --- a/update_sdk.cmd +++ /dev/null @@ -1,25 +0,0 @@ -@echo off -setlocal enabledelayedexpansion - -rem Use system proxy to access git repo if found it configured -for /f "tokens=3* delims= " %%i in ('Reg query "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyEnable') do ( - if %%i==0x1 ( - echo [INFO] System Proxy enabled. Adapting proxy settings... - for /f "tokens=3* delims= " %%a in ('Reg query "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyServer') do set PROXY_ADDR=%%a - set http_proxy=http://!PROXY_ADDR! - set https_proxy=http://!PROXY_ADDR! - echo [INFO] Proxy settings adapted. - echo. - ) -) - -echo [INFO] Updating SDK... - -git submodule update --init --remote - -rem Delete out-of-date BDS libs -del /f SDK\Lib\bedrock_server_api.lib 2>nul -del /f SDK\Lib\bedrock_server_var.lib 2>nul - -echo [INFO] SDK updated. -pause \ No newline at end of file diff --git a/xmake.lua b/xmake.lua new file mode 100644 index 0000000..13c3061 --- /dev/null +++ b/xmake.lua @@ -0,0 +1,42 @@ +add_rules("mode.debug", "mode.release", "mode.releasedbg") + +add_repositories("liteldev-repo https://github.com/LiteLDev/xmake-repo.git") + +if not has_config("vs_runtime") then + set_runtimes("MD") +end + +add_requires("levilamina 0.5.1") + +target("MinecartSpeedPlus") + add_toolchains("msvc") + add_cxflags( + "/EHa", + "/utf-8" + ) + add_files( + "src/**.cpp" + ) + add_includedirs( + "src" + ) + add_packages( + "levilamina" + ) + add_shflags( + "/DELAYLOAD:bedrock_server.dll" + ) + set_exceptions("none") + set_kind("shared") + set_languages("cxx23") + + after_build(function (target) + local plugin_packer = import("scripts.after_build") + + local plugin_define = { + pluginName = target:name(), + pluginFile = path.filename(target:targetfile()), + } + + plugin_packer.pack_plugin(target,plugin_define) + end)