Skip to content

Commit

Permalink
feat: add 'name' property to Plugin class
Browse files Browse the repository at this point in the history
  • Loading branch information
wu-vincent committed Mar 5, 2024
1 parent 5379726 commit 86f72db
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
13 changes: 13 additions & 0 deletions include/endstone/plugin/plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,19 @@ class Plugin : public CommandExecutor {
return *server_;
}

/**
* Returns the name of the plugin.
*
* This should return the bare name of the plugin and should be used for
* comparison.
*
* @return name of the plugin
*/
[[nodiscard]] std::string getName() const
{
return getDescription().getName();
};

private:
friend class PluginLoader;

Expand Down
2 changes: 2 additions & 0 deletions python/src/endstone/plugin.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ class Plugin:
def plugin_loader(self) -> PluginLoader: ...
@property
def server(self) -> Server: ...
@property
def name(self) -> str: ...

class PluginManager:
def register_loader(self, loader: PluginLoader) -> None: ...
Expand Down
3 changes: 2 additions & 1 deletion src/endstone_python/plugin/plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ void def_plugin(py::module &m)
.def_property_readonly("logger", &Plugin::getLogger, py::return_value_policy::reference)
.def_property_readonly("plugin_loader", &Plugin::getPluginLoader, py::return_value_policy::reference)
.def_property_readonly("server", &Plugin::getServer, py::return_value_policy::reference)
.def_property_readonly("enabled", &Plugin::isEnabled);
.def_property_readonly("enabled", &Plugin::isEnabled)
.def_property_readonly("name", &Plugin::getName);
}

} // namespace endstone::detail

0 comments on commit 86f72db

Please sign in to comment.