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.dev6.tar.gz
(51.2 kB
view hashes)
Built Distribution
Close
Hashes for llpy-helper-lib-0.0.1.dev6.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 94d5249328ee055edfd1554292dbe321a338680ac45069f56ed98f8daf5dc05d |
|
MD5 | 70961be0353f1850c5720e84ad6d454f |
|
BLAKE2b-256 | 68b273ddc2677fffcc035bd307d366b6b414b2b84684829dadd540024d2020be |
Close
Hashes for llpy_helper_lib-0.0.1.dev6-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 696b21ff3181668ce109e6f176e1a812d25dff64823e2d9fdc926983fc98ecd0 |
|
MD5 | 8d811b9633745bb3735dce22ae7e005a |
|
BLAKE2b-256 | 0004b23a0ca863e2927bec4596e278e1ccc8beafe83358f6df3cb762b8101087 |