en
Switch Language
  1. PowerNukkitX
  2. Get Started
  3. Config

    1. server.properties
    2. nukkit.yml
    3. pnx-cli-config.ini
    4. Anti-xray
    5. Resource Encryption
    6. Compression Acceleration
    7. PNX with WaterDogPE
    8. Flat World
  4. FAQ

    1. To Newcomers
    2. How to use PNX-CLI
    3. Common Questions
    4. Terra Questions
    5. Spawn-point Questions
    6. Convert Worlds
  5. For Devs

    1. Java

      1. Goto JavaDoc
      2. Mod API

        1. Custom Block
        2. Custom Item
        3. Custom Entity
        4. Custom Enchantment
      3. Entity AI

        1. Behavior
        2. Memory
        3. Sensor
        4. Motion Controller
        5. Navigator
        6. Behavior Group
        7. Work Cycle
    2. JavaScript

      1. setup dev env
      2. Base LLSELib dev
      3. Hello World
      4. Basic knowledge
      5. Event Listener
      6. FAQ
    3. Resources

      1. Event List
      2. IDs(block & item)

Develop PNXJS plugin based on LLSE-Lib

LLSE is a plugin framework based on the LiteLoader scripting engine.
LiteLoader is a plugin loader for Bedrock Dedicated Server, the official server of Bedrock Edition.
For more news about LLSE, you can go to check here

The LLSE-Lib is an implementation of the LLSE plugin framework based on the PNX API. Plugin framework implementation, using it you can get LLSE simple and easy to use development experience on PNX, and after some modifications, you can easily run LLSE plugins on BDS. Also, the plug-ins you write can be easily run on the BDS LiteLoader plug-in loader after easy modifications.

Environment construction

1.Create a new folder

2.Clone JavaScript plugin template

First, make sure you have git installed before cloning, if you don't know what git is, search for it and look it up.
Open git bash in that folder and run

git clone --recursive https://github.com/PowerNukkitX/JavaScript-Template

3.Go to LLSE-Lib to download the latest complete library (@LLSELib-full.zip) as a complementary file

4.将@LLSELib-full.zip解压到当前目录, at which point your directory structure should read

D:
├─@LLSELib
└─JavaScript-Template

5.Configure plugin information

Rename the JavaScript-Template folder to @ plus the name of your plugin, e.g. @test. Using @test as an example, modify plugin.yml to

# Please replace xxx in the next line with the name of your plugin.
name: test
# Fill in the entry file of the plugin here, and the default in this template is index.js, if there are no special circumstances, you don't need to change.
main: index.js
version: "1.0.0"
api: ["1.0.14"]
# The loading sequence of plug-ins is here. Only startup or PostWorld can be filled in.
# STARTUP: at this time, the server has just started, and the worlds has not been loaded. It is usually used for libraries.
# POSTWORLD: at this time, all the worlds in the server are loaded. Usually, you can fill in POSTWORLD here.
load: POSTWORLD
# Please replace xxx in the next line with your name.
author: test
# Please replace xxx in the next line with the description of your plugin.
description: test
depend: [ "LLSELib" ]
features:
  - WsClient

The configuration items are modified according to your needs, LLSE's plug-in registration API is equivalent to the plugin.yml here
For more configuration items see this

6.Go to index.js, import the following module at the beginning, and then you can use LLSELib to write plugins happily

import {
    ll,
    mc,
    Format,
    PermType,
    ParamType,
    system,
    data,
    i18n,
    logger,
    File,
    JsonConfigFile,
    BinaryStream,
    colorLog,
    log,
    NbtEnd,
    NbtShort,
    NbtInt,
    NbtFloat,
    NbtDouble,
    NbtCompound,
    NbtList,
    NbtLong,
    NbtByte,
    NbtByteArray,
    NbtString,
    NBT
} from '@LLSELib/index.js';

© PowerNukkitX Dev team