Skip to content

Commit cd22523

Browse files
committed
First commit
1 parent 89996d0 commit cd22523

4 files changed

Lines changed: 89 additions & 0 deletions

File tree

.clang-format

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
BasedOnStyle: LLVM
3+
AccessModifierOffset: -4
4+
AllowShortFunctionsOnASingleLine: Empty
5+
AllowShortLambdasOnASingleLine: Empty
6+
AlwaysBreakTemplateDeclarations: Yes
7+
BinPackArguments: false
8+
BinPackParameters: false
9+
BreakBeforeBinaryOperators: All
10+
BreakConstructorInitializers: BeforeColon
11+
ColumnLimit: 80
12+
IncludeBlocks: Regroup
13+
IndentCaseLabels: true
14+
IndentPPDirectives: AfterHash
15+
IndentWidth: 4
16+
Language: Cpp
17+
SpaceAfterCStyleCast: true
18+
Standard: "c++17"
19+
TabWidth: 4

CMakeLists.txt

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
cmake_minimum_required(VERSION 3.25)
2+
3+
project(cpp_sample_plugin VERSION 1.0.0)
4+
5+
set(CMAKE_CXX_STANDARD 20)
6+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
7+
8+
include(FetchContent)
9+
10+
FetchContent_Declare(
11+
endstone
12+
GIT_REPOSITORY https://github.com/EndstoneMC/Endstone.git
13+
GIT_TAG main
14+
)
15+
16+
FetchContent_MakeAvailable(endstone)
17+
18+
add_library(cpp_sample_plugin SHARED src/sample_plugin.cpp)
19+
target_link_libraries(cpp_sample_plugin endstone::api)
20+
target_include_directories(cpp_sample_plugin PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
21+
target_compile_definitions(cpp_sample_plugin PRIVATE _ITERATOR_DEBUG_LEVEL=0)
22+
23+
install(TARGETS cpp_sample_plugin
24+
LIBRARY DESTINATION cpp_sample_plugin
25+
RUNTIME DESTINATION cpp_sample_plugin)

include/sample_plugin.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
//
2+
// Created by Vincent on 21/08/2023.
3+
//
4+
5+
#ifndef CPP_SAMPLE_PLUGIN_H
6+
#define CPP_SAMPLE_PLUGIN_H
7+
8+
#include "endstone/plugin/cpp/cpp_plugin.h"
9+
10+
class SamplePlugin : public CppPlugin {
11+
public:
12+
SamplePlugin() = default;
13+
const PluginDescription &getDescription() const override;
14+
void onLoad() override;
15+
void onEnable() override;
16+
void onDisable() override;
17+
18+
private:
19+
CppPluginDescription description_{"CppSamplePlugin", "1.0.0"};
20+
};
21+
22+
#endif // CPP_SAMPLE_PLUGIN_H

src/sample_plugin.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
//
2+
// Created by Vincent on 21/08/2023.
3+
//
4+
5+
#include "sample_plugin.h"
6+
7+
const PluginDescription &SamplePlugin::getDescription() const {
8+
return description_;
9+
}
10+
11+
void SamplePlugin::onLoad() {
12+
getLogger()->info("onLoad is called");
13+
}
14+
15+
void SamplePlugin::onEnable() {
16+
getLogger()->info("onEnable is called");
17+
}
18+
19+
void SamplePlugin::onDisable() {
20+
getLogger()->info("onDisable is called");
21+
}
22+
23+
ENDSTONE_PLUGIN_CLASS(SamplePlugin)

0 commit comments

Comments
 (0)