-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
312 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# Documents: https://clang.llvm.org/docs/ClangFormatStyleOptions.html | ||
Language: Cpp | ||
BasedOnStyle: LLVM | ||
AccessModifierOffset: -4 | ||
AlignAfterOpenBracket: Align | ||
AlignConsecutiveAssignments: None | ||
AlignConsecutiveDeclarations: None | ||
AlignOperands: Align | ||
AlwaysBreakTemplateDeclarations: Yes | ||
AlignTrailingComments: true | ||
AllowAllArgumentsOnNextLine: true | ||
AllowAllParametersOfDeclarationOnNextLine: true | ||
AllowShortBlocksOnASingleLine: Always | ||
AllowShortCaseLabelsOnASingleLine: false | ||
AllowShortIfStatementsOnASingleLine: false | ||
AllowShortLoopsOnASingleLine: false | ||
AllowShortFunctionsOnASingleLine: Empty | ||
AllowShortLambdasOnASingleLine: All | ||
AllowShortEnumsOnASingleLine: false | ||
AlwaysBreakAfterDefinitionReturnType: None | ||
BinPackArguments: true | ||
BinPackParameters: true | ||
ConstructorInitializerIndentWidth: 0 | ||
ConstructorInitializerAllOnOneLineOrOnePerLine: true | ||
BreakBeforeConceptDeclarations: Always | ||
RequiresClausePosition: OwnLine | ||
ColumnLimit: 120 | ||
CommentPragmas: '^ IWYU pragma:' | ||
PointerAlignment: Left | ||
IndentWidth: 4 | ||
SortIncludes: Never | ||
MaxEmptyLinesToKeep: 2 | ||
SpacesInSquareBrackets: false | ||
SpacesInParentheses: false | ||
SpaceBeforeAssignmentOperators: true | ||
SpacesInContainerLiterals: true | ||
IndentWrappedFunctionNames: true | ||
KeepEmptyLinesAtTheStartOfBlocks: true | ||
SeparateDefinitionBlocks: Always | ||
BreakConstructorInitializersBeforeComma: true | ||
SpaceAfterCStyleCast: false | ||
IndentCaseLabels: true | ||
TabWidth: 4 | ||
UseTab: Never | ||
BreakBeforeBraces: Custom | ||
BraceWrapping: | ||
AfterCaseLabel: false | ||
AfterClass: false | ||
AfterEnum: false | ||
AfterFunction: false | ||
AfterNamespace: false | ||
AfterStruct: false | ||
AfterUnion: false | ||
AfterExternBlock: false | ||
BeforeCatch: false | ||
BeforeElse: false | ||
IndentBraces: false | ||
SplitEmptyFunction: true | ||
SplitEmptyRecord: true | ||
SplitEmptyNamespace: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/.xmake/ | ||
/build/ | ||
/*.pdb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#pragma once | ||
#define PLUGIN_NAME "MyPlugin" | ||
#define PLUGIN_DESCRIPTION "My plugin description" | ||
#define PLUGIN_AUTHOR "My name" | ||
#define PLUGIN_VERSION_MAJOR 0 | ||
#define PLUGIN_VERSION_MINOR 1 | ||
#define PLUGIN_VERSION_PATCH 0 | ||
#define PLUGIN_VERSION_BUILD 0 | ||
#define PLUGIN_VERSION_STATUS Dev // Dev, Beta or Release | ||
#define PLUGIN_VERSION_IS_RELEASE false | ||
#define __TO_VERSION_STRING(ver) #ver | ||
#define TO_VERSION_STRING(ver) __TO_VERSION_STRING(ver) | ||
// clang-format off | ||
#if PLUGIN_VERSION_BUILD > 0 && PLUGIN_VERSION_IS_RELEASE | ||
#define PLUGIN_VERSION_STRING TO_VERSION_STRING(PLUGIN_VERSION_MAJOR.PLUGIN_VERSION_MINOR.PLUGIN_VERSION_PATCH-build.PLUGIN_VERSION_BUILD) | ||
#elif PLUGIN_VERSION_BUILD > 0 && !PLUGIN_VERSION_IS_RELEASE | ||
#define PLUGIN_VERSION_STRING TO_VERSION_STRING(PLUGIN_VERSION_MAJOR.PLUGIN_VERSION_MINOR.PLUGIN_VERSION_PATCH-PLUGIN_VERSION_STATUS-build.PLUGIN_VERSION_BUILD) | ||
#elif PLUGIN_VERSION_BUILD == 0 && PLUGIN_VERSION_IS_RELEASE | ||
#define PLUGIN_VERSION_STRING TO_VERSION_STRING(PLUGIN_VERSION_MAJOR.PLUGIN_VERSION_MINOR.PLUGIN_VERSION_PATCH) | ||
#elif PLUGIN_VERSION_BUILD == 0 && !PLUGIN_VERSION_IS_RELEASE | ||
#define PLUGIN_VERSION_STRING TO_VERSION_STRING(PLUGIN_VERSION_MAJOR.PLUGIN_VERSION_MINOR.PLUGIN_VERSION_PATCH-PLUGIN_VERSION_STATUS) | ||
#endif | ||
// clang-format on | ||
|
||
class Logger; | ||
|
||
namespace my_plugin { | ||
extern Logger logger; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#pragma once | ||
#include "Plugin.h" | ||
|
||
#if PLUGIN_VERSION_IS_RELEASE | ||
#define PLUGIN_FILE_VERSION_FLAG VS_FF_DEBUG | ||
#else | ||
#define PLUGIN_FILE_VERSION_FLAG 0x0L | ||
#endif | ||
|
||
#define FILE_VERSION_BLOCK_HEADER 0x04004B0L | ||
#define FILE_VERSION_COMPANY_NAME PLUGIN_AUTHOR | ||
#define FILE_VERSION_LEGAL_COPYRIGHT "Copyright " PLUGIN_AUTHOR " (c) 2022" | ||
#define FILE_VERSION_FILE_DESCRIPTION PLUGIN_DESCRIPTION | ||
#define FILE_VERSION_FILE_VERSION_STRING PLUGIN_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_VERSION_STRING | ||
#define FILE_VERSION_FILE_VERSION PLUGIN_VERSION_MAJOR, PLUGIN_VERSION_MINOR, PLUGIN_VERSION_PATCH, PLUGIN_VERSION_BUILD | ||
#define FILE_VERSION_PRODUCT_VERSION FILE_VERSION_FILE_VERSION |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#include <Windows.h> | ||
#include <llapi/LLAPI.h> | ||
#include <Plugin.h> | ||
|
||
BOOL APIENTRY DllMain(HMODULE, DWORD reasonForCall, LPVOID) { | ||
switch (reasonForCall) { | ||
case DLL_PROCESS_ATTACH: | ||
ll::registerPlugin(PLUGIN_NAME, PLUGIN_DESCRIPTION, | ||
ll::Version(PLUGIN_VERSION_MAJOR, PLUGIN_VERSION_MINOR, PLUGIN_VERSION_PATCH, | ||
ll::Version::PLUGIN_VERSION_STATUS), | ||
std::map<std::string, std::string>{{"Author", PLUGIN_AUTHOR}}); | ||
break; | ||
case DLL_THREAD_ATTACH: | ||
case DLL_THREAD_DETACH: | ||
case DLL_PROCESS_DETACH: | ||
break; | ||
} | ||
return TRUE; | ||
} | ||
|
||
namespace my_plugin { | ||
void Entry(); | ||
} | ||
|
||
extern "C" _declspec(dllexport) void onPostInit() { | ||
my_plugin::Entry(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#include <llapi/LoggerAPI.h> | ||
#include <llapi/EventAPI.h> | ||
#include <llapi/mc/Player.hpp> | ||
#include <Plugin.h> | ||
|
||
namespace my_plugin { | ||
|
||
Logger logger(PLUGIN_NAME); | ||
|
||
void Entry() { | ||
logger.info("Hello, world!"); | ||
Event::PlayerJoinEvent::subscribe([](const Event::PlayerJoinEvent& event) { | ||
logger.info("Player " + event.mPlayer->getName() + " joined the server!"); | ||
return true; | ||
}); | ||
} | ||
|
||
} // namespace my_plugin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
// Microsoft Visual C++ generated resource script. | ||
// | ||
#include "Resource.h" | ||
|
||
#define APSTUDIO_READONLY_SYMBOLS | ||
///////////////////////////////////////////////////////////////////////////// | ||
// | ||
// Generated from the TEXTINCLUDE 2 resource. | ||
// | ||
#include "winres.h" | ||
#include "Resource.h" | ||
|
||
///////////////////////////////////////////////////////////////////////////// | ||
#undef APSTUDIO_READONLY_SYMBOLS | ||
|
||
///////////////////////////////////////////////////////////////////////////// | ||
// 中文(简体,中国) resources | ||
|
||
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_CHS) | ||
LANGUAGE LANG_CHINESE, SUBLANG_CHINESE_SIMPLIFIED | ||
#pragma code_page(936) | ||
|
||
#ifdef APSTUDIO_INVOKED | ||
///////////////////////////////////////////////////////////////////////////// | ||
// | ||
// TEXTINCLUDE | ||
// | ||
|
||
1 TEXTINCLUDE | ||
BEGIN | ||
"Resource.h\0" | ||
END | ||
|
||
2 TEXTINCLUDE | ||
BEGIN | ||
"#include ""winres.h""\r\n" | ||
"\0" | ||
END | ||
|
||
3 TEXTINCLUDE | ||
BEGIN | ||
"\r\n" | ||
"\0" | ||
END | ||
|
||
#endif // APSTUDIO_INVOKED | ||
|
||
|
||
///////////////////////////////////////////////////////////////////////////// | ||
// | ||
// Version | ||
// | ||
|
||
VS_VERSION_INFO VERSIONINFO | ||
FILEVERSION FILE_VERSION_FILE_VERSION | ||
PRODUCTVERSION FILE_VERSION_PRODUCT_VERSION | ||
FILEFLAGSMASK 0x3fL | ||
FILEFLAGS PLUGIN_FILE_VERSION_FLAG | ||
FILEOS 0x40004L | ||
FILETYPE 0x0L | ||
FILESUBTYPE 0x0L | ||
BEGIN | ||
BLOCK "StringFileInfo" | ||
BEGIN | ||
BLOCK "040004b0" | ||
BEGIN | ||
VALUE "CompanyName", FILE_VERSION_COMPANY_NAME | ||
VALUE "FileDescription", FILE_VERSION_FILE_DESCRIPTION | ||
VALUE "FileVersion", FILE_VERSION_FILE_VERSION_STRING | ||
VALUE "InternalName", FILE_VERSION_INTERNAL_NAME | ||
VALUE "LegalCopyright", FILE_VERSION_LEGAL_COPYRIGHT | ||
VALUE "OriginalFilename", FILE_VERSION_ORIGINAL_FILENAME | ||
VALUE "ProductName", FILE_VERSION_PRODUCT_NAME | ||
VALUE "ProductVersion", FILE_VERSION_PRODUCT_VERSION_STRING | ||
END | ||
END | ||
BLOCK "VarFileInfo" | ||
BEGIN | ||
VALUE "Translation", 0x400, 1200 | ||
END | ||
END | ||
|
||
#endif // 中文(简体,中国) resources | ||
///////////////////////////////////////////////////////////////////////////// | ||
|
||
|
||
|
||
#ifndef APSTUDIO_INVOKED | ||
///////////////////////////////////////////////////////////////////////////// | ||
// | ||
// Generated from the TEXTINCLUDE 3 resource. | ||
// | ||
|
||
|
||
///////////////////////////////////////////////////////////////////////////// | ||
#endif // not APSTUDIO_INVOKED |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
target("MyPlugin") | ||
set_plat("windows") | ||
set_arch("x64") | ||
set_toolchains("msvc") | ||
set_rules("mode.release") | ||
|
||
set_kind("shared") | ||
add_files("src/*.cpp") | ||
add_files("src/*.rc") | ||
add_headerfiles("include/*.h") | ||
add_headerfiles("include/*.hpp") | ||
add_includedirs("SDK/include") | ||
add_includedirs("include") | ||
add_defines( | ||
"UNICODE", | ||
"_UNICODE", | ||
"NDEBUG", | ||
"WIN32_LEAN_AND_MEAN", | ||
"_CRT_SECURE_NO_WARNINGS", | ||
"_WINDOWS", | ||
"_USRDLL", | ||
"_AMD64_", | ||
"NOMINMAX" | ||
) | ||
set_warnings("all") | ||
set_optimize("fastest") | ||
set_runtimes("MD") | ||
set_languages("c17", "cxx20") | ||
add_linkdirs( | ||
"SDK/lib" | ||
) | ||
add_links( | ||
"LiteLoader", | ||
"SymDBHelper", | ||
"bedrock_server_api", | ||
"bedrock_server_var", | ||
"delayimp" | ||
) | ||
add_cxflags( | ||
"/utf-8", | ||
"/EHsc", | ||
"/GL", | ||
"/permissive-", | ||
"/sdl", | ||
"/Zc:inline", | ||
"/Zi", | ||
"/FS" | ||
) | ||
add_shflags( | ||
"/DELAYLOAD:bedrock_server.dll", | ||
"/DEBUG", | ||
"/SUBSYSTEM:CONSOLE" | ||
) | ||
on_load(function (target) | ||
if (not os.exists("SDK/lib/bedrock_server_api.lib") or not os.exists("SDK/lib/bedrock_server_var.lib")) then | ||
os.cd("SDK/tools") | ||
os.exec("./PeEditor.exe -c -l -o ../lib") | ||
end | ||
end) |