MCPcopy Create free account
hub / github.com/EndstoneMC/endstone / init_plugin

Function init_plugin

src/endstone/python/plugin.cpp:123–300  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

121} // namespace
122
123void init_plugin(py::module &m)
124{
125 py::native_enum<PluginLoadOrder>(m, "PluginLoadOrder", "enum.Enum",
126 "Represents the order in which a plugin should be initialized and enabled.")
127 .value("STARTUP", PluginLoadOrder::Startup)
128 .value("POSTWORLD", PluginLoadOrder::PostWorld)
129 .finalize();
130
131 auto plugin_loader = py::class_<PluginLoader, PyPluginLoader>(
132 m, "PluginLoader", "Represents a plugin loader, which handles direct access to specific types of plugins");
133 auto plugin_command = py::class_<PluginCommand, Command, std::shared_ptr<PluginCommand>>(
134 m, "PluginCommand", "Represents a Command belonging to a Plugin");
135
136 py::class_<PluginDescription>(
137 m, "PluginDescription", "Represents the basic information about a plugin that the plugin loader needs to know.")
138 .def(py::init(&createPluginDescription), py::arg("name"), py::arg("version"),
139 py::arg("description") = py::none(), py::arg("load") = py::none(), py::arg("authors") = py::none(),
140 py::arg("contributors") = py::none(), py::arg("website") = py::none(), py::arg("prefix") = py::none(),
141 py::arg("provides") = py::none(), py::arg("depend") = py::none(), py::arg("soft_depend") = py::none(),
142 py::arg("load_before") = py::none(), py::arg("default_permission") = py::none(),
143 py::arg("commands") = py::none(), py::arg("permissions") = py::none())
144 .def_property_readonly("name", &PluginDescription::getName,
145 "Gives the name of the plugin. This name is a unique identifier for plugins.")
146 .def_property_readonly("version", &PluginDescription::getVersion, "Gives the version of the plugin.")
147 .def_property_readonly("full_name", &PluginDescription::getFullName,
148 "Returns the name of a plugin, including the version.")
149 .def_property_readonly("api_version", &PluginDescription::getAPIVersion,
150 "Gives the API version which this plugin is designed to support.")
151 .def_property_readonly("description", &PluginDescription::getDescription,
152 "Gives a human-friendly description of the functionality the plugin provides.")
153 .def_property_readonly("load", &PluginDescription::getLoad,
154 "Gives the phase of server startup that the plugin should be loaded.")
155 .def_property_readonly("authors", &PluginDescription::getAuthors, "Gives the list of authors for the plugin.")
156 .def_property_readonly("contributors", &PluginDescription::getContributors,
157 "Gives the list of contributors for the plugin.")
158 .def_property_readonly("website", &PluginDescription::getWebsite,
159 "Gives the plugin's or plugin's author's website.")
160 .def_property_readonly("prefix", &PluginDescription::getPrefix,
161 "Gives the token to prefix plugin-specific logging messages with.")
162 .def_property_readonly("provides", &PluginDescription::getProvides,
163 "Gives the list of other plugin APIs which this plugin provides. These are usable for "
164 "other plugins to depend on.")
165 .def_property_readonly("depend", &PluginDescription::getDepend,
166 "Gives a list of other plugins that the plugin requires.")
167 .def_property_readonly("soft_depend", &PluginDescription::getSoftDepend,
168 "Gives a list of other plugins that the plugin requires for full functionality.")
169 .def_property_readonly("load_before", &PluginDescription::getLoadBefore,
170 "Gets the list of plugins that should consider this plugin a soft-dependency.")
171 .def_property_readonly("default_permission", &PluginDescription::getDefaultPermission,
172 "Gives the default value of permissions registered for the plugin.")
173 .def_property_readonly("commands", &PluginDescription::getCommands,
174 "Gives the list of commands the plugin will register at runtime.")
175 .def_property_readonly(
176 "permissions", &PluginDescription::getPermissions,
177 "Gives the list of permissions the plugin will register at runtime, immediately proceeding enabling.");
178
179 py::class_<Plugin, CommandExecutor, PyPlugin, py::smart_holder>(m, "Plugin", "Represents a Plugin")
180 .def(py::init<>())

Callers 1

PYBIND11_MODULEFunction · 0.85

Calls 3

initFunction · 0.85
valueMethod · 0.80
registerEventMethod · 0.45

Tested by

no test coverage detected