Helper Lib for LLSE Python Runtime
Project description
LLSE-Python Helper Lib
Developing……
Install
Use pdm
to install, then you can import it in your plugin
pdm add llpy-helper-lib
or you can use lip
lip i github.com/lgc-LLSEDev/llpy-helper-lib
Usage
from typing import cast
# you can input any ll's built-ins from `llpy`
from llpy import (
LLSE_CommandOrigin,
LLSE_CommandOutput,
ParamType,
PermType,
Version,
colorLog,
ll,
logger,
mc,
)
# you can input some types from `llpy.types`
from llpy.types import T_CommandCallbackResult
# you can input some utils from `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`
@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`
@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"},
)
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.0.1.dev8.tar.gz
(60.9 kB
view hashes)
Built Distribution
Close
Hashes for llpy-helper-lib-0.0.1.dev8.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6c8710da6401f963ab87e5f76ffeabe9e29103ff954dc996d3c323437b3dc5b6 |
|
MD5 | 51ba65eb8890a32ef531a7d844b8fae9 |
|
BLAKE2b-256 | de2f9f7e412c819173c227e5109c3ba6f65a20e80009eeb96ef4f7dfe75f548a |
Close
Hashes for llpy_helper_lib-0.0.1.dev8-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1e78bd7bb91ae3c07f7ee548d023e2ffdb0dfed5d347758f447e90bc789adffb |
|
MD5 | 3147e3d7326b3f94b7055833ed219c31 |
|
BLAKE2b-256 | 6d729661a0acfec66c204f9c6f29fe20d72a43e274cbaf00778c6af8b7d0d6e6 |