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
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.dev7.tar.gz
(55.5 kB
view hashes)
Built Distribution
Close
Hashes for llpy-helper-lib-0.0.1.dev7.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1a7bbcd54bdea68b302ee416fd804ca40ef55572101d1daa2ef679f987356aa8 |
|
MD5 | 49acd9991ee468923519c11fc70af463 |
|
BLAKE2b-256 | 90421dc5ad86a117f8b16c4100d103951a000803edf5efd2de53d0f1315f1d63 |
Close
Hashes for llpy_helper_lib-0.0.1.dev7-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a67ff1d430fb1c5946cbe8bd857ca6bd7c2052f7188ae3edba48a7eb93e6f384 |
|
MD5 | 298a7cc4b2379f7801dee76af39deaf5 |
|
BLAKE2b-256 | 7aa5ff9ab608424b6f4bb446be7de06149d6cc5594a980d9f8865813280984ee |