Skip to content

Commit

Permalink
feat: add python bindings for 'PermissionDefault' and 'ServerOperator…
Browse files Browse the repository at this point in the history
…' classes
  • Loading branch information
wu-vincent committed Mar 14, 2024
1 parent bcdfd80 commit 615ad68
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 2 deletions.
60 changes: 59 additions & 1 deletion python/src/endstone/_internal/endstone_python.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from __future__ import annotations
import typing
__all__ = ['ColorFormat', 'Command', 'CommandExecutor', 'CommandSender', 'Logger', 'Plugin', 'PluginCommand', 'PluginDescription', 'PluginLoader', 'PluginManager', 'Server']
__all__ = ['ColorFormat', 'Command', 'CommandExecutor', 'CommandSender', 'Logger', 'PermissionDefault', 'Plugin', 'PluginCommand', 'PluginDescription', 'PluginLoader', 'PluginManager', 'Server', 'ServerOperator']
class ColorFormat:
AQUA: typing.ClassVar[str] = '§b'
BLACK: typing.ClassVar[str] = '§0'
Expand Down Expand Up @@ -206,6 +206,55 @@ class Logger:
"""
Get the name of this Logger instance.
"""
class PermissionDefault:
"""
Members:
TRUE
FALSE
OP
OPERATOR
NOT_OP
NOT_OPERATOR
"""
FALSE: typing.ClassVar[PermissionDefault] # value = <PermissionDefault.FALSE: 1>
NOT_OP: typing.ClassVar[PermissionDefault] # value = <PermissionDefault.OP: 2>
NOT_OPERATOR: typing.ClassVar[PermissionDefault] # value = <PermissionDefault.NOT_OPERATOR: 3>
OP: typing.ClassVar[PermissionDefault] # value = <PermissionDefault.OP: 2>
OPERATOR: typing.ClassVar[PermissionDefault] # value = <PermissionDefault.OP: 2>
TRUE: typing.ClassVar[PermissionDefault] # value = <PermissionDefault.TRUE: 0>
__members__: typing.ClassVar[dict[str, PermissionDefault]] # value = {'TRUE': <PermissionDefault.TRUE: 0>, 'FALSE': <PermissionDefault.FALSE: 1>, 'OP': <PermissionDefault.OP: 2>, 'OPERATOR': <PermissionDefault.OP: 2>, 'NOT_OP': <PermissionDefault.OP: 2>, 'NOT_OPERATOR': <PermissionDefault.NOT_OPERATOR: 3>}
def __eq__(self, other: typing.Any) -> bool:
...
def __getstate__(self) -> int:
...
def __hash__(self) -> int:
...
def __index__(self) -> int:
...
def __init__(self, value: int) -> None:
...
def __int__(self) -> int:
...
def __ne__(self, other: typing.Any) -> bool:
...
def __repr__(self) -> str:
...
def __setstate__(self, state: int) -> None:
...
def __str__(self) -> str:
...
@property
def name(self) -> str:
...
@property
def value(self) -> int:
...
class Plugin(CommandExecutor):
def __init__(self) -> None:
...
Expand Down Expand Up @@ -390,3 +439,12 @@ class Server:
"""
Gets the version of this server implementation.
"""
class ServerOperator:
@property
def op(self) -> bool:
"""
The operator status of this object
"""
@op.setter
def op(self, arg1: bool) -> None:
...
17 changes: 16 additions & 1 deletion src/endstone_python/permissions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,25 @@

#include <pybind11/pybind11.h>

#include "endstone/permissions/permission_default.h"
#include "endstone/permissions/server_operator.h"

namespace py = pybind11;

namespace endstone::detail {

void init_permissions(py::module &m) {}
void init_permissions(py::module &m)
{
py::class_<ServerOperator, std::shared_ptr<ServerOperator>>(m, "ServerOperator")
.def_property("op", &ServerOperator::isOp, &ServerOperator::setOp, "The operator status of this object");

py::enum_<PermissionDefault>(m, "PermissionDefault")
.value("TRUE", PermissionDefault::True)
.value("FALSE", PermissionDefault::False)
.value("OP", PermissionDefault::Operator)
.value("OPERATOR", PermissionDefault::Operator)
.value("NOT_OP", PermissionDefault::Operator)
.value("NOT_OPERATOR", PermissionDefault::NotOperator);
}

} // namespace endstone::detail

0 comments on commit 615ad68

Please sign in to comment.