A typing & util lib for LLSE Python runtime
Project description
LLSE-Python Helper Lib
A typing & util lib for LLSE Python runtime
为 LLSE Python 运行时开发的 类型提示/工具库
Install / 安装
Use pdm
to install as plugin dependency
使用 pdm
作为插件依赖安装
pdm add llpy-helper-lib
or you can use lip to install in global LLSE Python site-packages
path
或者使用 lip
安装到全局 LLSE Python site-packages
目录
lip i llpy
Usage / 用法
from typing import cast
# you can input any ll's built-ins from `llpy`
# 可以从 `llpy` 导入所有的 LLSE 内置类
from llpy import (
LLSE_CommandOrigin,
LLSE_CommandOutput,
ParamType,
PermType,
Version,
colorLog,
ll,
logger,
mc,
)
# you can input some types from `llpy.types`
# 可以从 `llpy.types` 导入本补全库提供的类型
from llpy.types import T_CommandCallbackResult
# you can input some utils from `llpy.utils`
# 可以从 `llpy.utils` 导入本库提供的实用函数/类
from llpy.utils import command_callback, listener
# register a listener
# 注册一个监听器
mc.listen("onServerStarted", lambda: colorLog("green", "The Server Started!"))
# or you can use the decorator from `llpy.utils`
# 也可以用 `llpy.utils` 里的装饰器注册
@listener("onConsoleCmd")
def _(cmd: str):
logger.info(f'You typed "{cmd}"')
# register a command
# 注册一个指令
cmd = mc.newCommand("testcmd", "A Test Command", PermType.Any)
cmd.optional("input", ParamType.RawText)
cmd.overload(["input"])
# set callback using `command_callback` decorator from `llpy.utils`
# 可以使用 `llpy.utils` 里的装饰器设置指令回调函数
@command_callback(cmd)
def _(
_,
ori: LLSE_CommandOrigin,
out: LLSE_CommandOutput,
res: dict[str, T_CommandCallbackResult],
):
arg = cast(str | None, res.get("input"))
tip = f'§aYou inputed §r"§6§l{arg}§r"' if arg else "§cNothing inputted!"
player = ori.player
if player:
# if player exec the cmd, send a form
# 如果是玩家执行命令,发送表单
form = mc.newSimpleForm().setTitle("Test Form").setContent(tip)
player.sendForm(form, lambda _, __: None)
else:
# if not, send output to console
# 不是玩家执行则输出到控制台
out.success(tip) if arg else out.error(tip)
return True
cmd.setup() # set up it / 安装指令
# and more... / 更多...
# set plugin metadata
# 设置插件元信息
ll.registerPlugin(
"test",
"test",
[0, 0, 1, Version.Dev],
{"Author": "student_2333"},
)
Contact / 联系我
QQ:3076823485
QQ Group:1105946125
E-mail:lgc2333@126.com
Telegram: @lgc2333
Sponsor / 赞助
Thank you all for your patronage! Your patronage will be my encouragement to continue creating!
感谢大家的赞助!你们的赞助将是我继续创作的动力!
-
Sponsor QR Code / 赞助二维码
Alipay / WeChat Pay / QQ Pay
Click to Expand / 点击展开
Update Log / 更新日志
None / 暂无
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
llpy-helper-lib-0.1.0.tar.gz
(74.3 kB
view hashes)
Built Distribution
Close
Hashes for llpy_helper_lib-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4a47a012924249684e9c3df37691085c039005337cc35b86f5339a49276fd076 |
|
MD5 | 25182e533ff5ee12bde157e18e4e622f |
|
BLAKE2b-256 | ad050fe522b9a26e7b63a269968456166e4b85a431b034615f09a97676732e49 |