BlocklyNukkit —— Efficient plugin development framework

BlocklyNukkit —— Efficient plugin development framework

Refactoring code loader code, refactoring the bnqqbot code, enhance stability, simplify interpreter
Add the function of BN plug-in package,. BNP (BN plug-in collection package) and. Bnpx (BN plug-in composite package) can be put into the blocklynukkit folder to run directly
The package can be operated by BNP command, and a BN plug-in package can be built by BNP build < makefile Path > command
Makefile is a package configuration file in JSON format, which consists of three fields: name, compress and plugins
Name is the name (string) of the packaged plug-in package, and compress is whether to compress the plug-in package (Boolean),
Plugins is a string array, which indicates the path of the BN plug-in to be typed into the package. It is loaded from top to bottom,
You can also type in the resource file in JSON YML XML TXT format, and the resource file will be decompressed sequentially to the relative position of the NK core when packaging.
You can use console in JS
Now JS plug-in error will display the correct file name
F (closure function) function is used to wrap closure
The; newline in bnapi now supports the use of \ \; to escape
Fixed the problem of F (closure) function return type error in PHP
Fixed the problem of logger (console) output null or nil error
Fixed a problem where the version command could not be modified
A new preprocessing statement pragma autoload false / true is added. Whether to let the BN interpreter load the plug-in automatically is true by default
Fixed an issue where archery does not trigger entitydamagebyentityevent
Fixed the problem that the URL could not be automatically encoded when HTTP processing
Update the PHP plug-in writing support based on Quercus PHP6 engine
For the running environment provided by Quercus, see
Compatible with all Java classes, nukkit API and BN base object, call BN API remember to add$
Updated the C / C + + plug-in writing support based on webassembly technology stack
It can directly call Java and interact with Java, compile once, run everywhere, and support Windows Linux MacOS
You can export the functions in the BN plug-in to the global environment through the export tag, and then you can use Java classes
The command exportdevjar < BN plug-in name > will export the function header of BN plug-in to a jar package for development
export function MyFun(arg1,arg2,arg3){}
def MyFun(arg1,arg2,arg3):
function BlockPlaceEvent(ent)-->export
static function PlayerJoinEvent($event){
-The function of logger has been enhanced, and now the object can be output in JSON format
-Localstorage: local storage manager
- void localStorage.cacheAll () -- read data from local and cache it to increase the speed of getting data at runtime
- String localStorage.cache (string key) -- read the specified data from local and cache it
- void localStorage.setItem (string key, string item) - set the data corresponding to the specified key to item
- String localStorage.getItem (string key) -- get the data corresponding to the specified key
- void localStorage.removeItem (string key) -- remove the data corresponding to the specified key
- String[] localStorage.getKeys () -- get all keys
- void () -- force to save the data immediately, BN will check and save the data every 3 seconds
-Memorystorage: memory shared storage manager
- void memoryStorage.setItem (object key, object item) -- set the data corresponding to the specified key to item
- String memoryStorage.getItem (object key) -- get the data corresponding to the specified key
- void memoryStorage.removeItem (object key) -- remove the data corresponding to the specified key
- Object[] localStorage.getKeys () -- get all keys
- Player[] getOnlinePlayers()
-String getresource (string name) -- read resource
-Void runcmd (string CMD) -- execute command line program
- boolean isPathExists(String path)
- String[] getFolderFiles(String path)
- int getFileSize(String path)
- void deleteFile(String path)
- void doPathCreate(String path)
- boolean isPathReadable(String path)
- boolean isPathWritable(String path)
- void copyFile(String fromPath,String toPath)
- void qq.stopBot ()
-Void interrupt (string info) -- forcibly interrupts the current function
- void downloadFromURL(String url,String saveDir,String saveName)
-Thread runthread (string functionname, object... Args) -- executes a function in a new thread and returns the thread synchronously
-Void requiremenversion (string minversion, string failmessage) -- check the BN interpreter version. If it is too low, stop running and issue a failmessage
- void shootArrow(Position from,Position to,boolean canPickUp,double multiply)
- void shootArrow(Position from,Position to,double multiply)
- void shootArrow(Position from,Position to,boolean canPickUp)
- void shootArrow(Position from,Position to)
- void lookAt(Entity e,Position pos)
-If the second text parameter of int [] setplayerbossbar starts with # XXXXXX or RGB (x, x, x), the custom color will be set for the boss blood bar
-Int [] setplayerbossbar can now be used in the text parameter; to add multiple ossbars
-Int [] setplayerbossbar (player, string text, float len) -- now returns an array containing the ID of each created ossbar
-Void removeplayerbossbar (player player, long ID) - related APIs now support the ID operation of specifying the ossbar
- double getLengthOfPlayerBossBar(Player player,long id)
- String getTextOfPlayerBossBar(Player player,long id)
-Void sendplayerxboxinfo (player from, player to) -- show the Xbox information of the player from to
-Void startedpoem (player) -- let the player begin to show the poem of the end on the screen
-Void setswingstyle (string style) -- set the style of swing
-Currently: darcula IntelliJ metal motif multi nimbus OS (system style)
- JFrame getStyledSwingWindow(String title,int width,int height,String iconPath)
-Get the swing window object according to the previously set style. If iconpath is null or "" will be replaced by bnlogo
- void showToPlayer(Player p,String callback,boolean acceptClose)
-Acceptclose is used to specify whether to call the callback function once when the window is closed
- buildButton(String text,String img)
- button(String text,String img)
- button(String text)
- setAction(String actionFunctionName/F function)
- action(String actionFunctionName/F function)
- setTitle(String title)
- title(String title)
- setContext(String context)
- context(String context)
- showToPlayer(Player p)
- showToPlayer(Player p,boolean acceptClose)
- showToPlayer(Player p,String callbackFunctionName/F function)
- showToPlayer(Player p,String callbackFunctionName/F function,boolean acceptClose)
- show(Player p)
- show(Player p,boolean accpetClose)
- show(Player p,String callbackFunctionName/F function)
- show(Player p,String callbackFunctionName/F function,boolean acceptClose)
- setTitle(String title)
- title(String title)
- setContext(String context)
- context(String context)
- setButton1(String text)
- setButton2(String text)
- button1(String text)
- button2(String text)
- setAction(String callbackFunctionName/F function)
- action(String callbackFunctionName/F function)
- showToPlayer(Player p)
- showToPlayer(Player p,boolean acceptClose)
- showToPlayer(Player p,String callbackFunctionName/F function)
- showToPlayer(Player p,String callbackFunctionName/F function,boolean acceptClose)
- show(Player p)
- show(Player p,boolean accpetClose)
- show(Player p,String callbackFunctionName/F function)
- show(Player p,String callbackFunctionName/F function,boolean acceptClose)
- setTitle(String title)
- showToPlayer(Player p)
- showToPlayer(Player p,boolean acceptClose)
- showToPlayer(Player p,String callbackFunctionName/F function)
- show(Player p)
- show(Player p,boolean accpetClose)
- show(Player p,String callbackFunctionName/F function)
- show(Player p,String callbackFunctionName/F function,boolean acceptClose)
- showToPlayer(Player p,String callbackFunctionName/F function,boolean acceptClose)
- showAsSetting(Player p, String callbackFunctionName/F function)
- showAsSetting(Player p, String imageURL, String callbackFunctionName/F function)
- buildLabel(String text)
- label(String text)
- buildInput(String title,String placeholder)
- input(String title,String placeholder)
- buildInput(String title,String placeholder,String defaulttext)
- input(String title,String placeholder,String defaulttext)
- buildToggle(String title)
- toggle(String title)
- buildToggle(String title,boolean open)
- toggle(String title,boolean open)
- buildDropdown(String title,String inner)
- dropdown(String title,String inner)
- buildDropdown(String title,String inner,int index)
- dropdown(String title,String inner,int index)
- buildSlider(String title,double min,double max,int step,double defaultvalue)
- slider(String title,double min,double max,int step,double defaultvalue)
- buildSlider(String title,double min,double max,int step)
- slider(String title,double min,double max,int step)
- buildSlider(String title,double min,double max)
- slider(String title,double min,double max)
- buildStepSlider(String title,String options)
- stepSlider(String title,String options)
- stepslider(String title,String options)
- buildStepSlider(String title,String options,int index)
- stepSlider(String title,String options,int index)
- stepslider(String title,String options,int index)
- setAction(String callbackFunctionName/F function)
- action(String callbackFunctionName/F function)
- void addExtraDropItem(Item item)
- boolean hasDropItem(Item item)
- void removeExtraDropItem(Item item)
- Item[] getExtraDropItems()
- Item[] getDropItems()
-Void setdrophand (Boolean drop / void) -- the default value is true when the parameter is not filled in
-Void setdropoffhand (Boolean drop / void) -- the default value is true when the parameter is not filled in
-Void adddropslot (int slot) -- specifies the slot of the backpack
- int[] getDropSlots()
- void removeDropSlot(int slot)
-Void doemote (string action / void) -- let NPC execute the specified facial expression action
-The action can be wave punch clap overthere hammer fall diamond pickaxe
-You can also fill in the corresponding Chinese wave boxing applause in that hammer fall diamond
-If not, choose one of the five actions above
-As for why there are only eight: because the rest can only get UUID after the purchase of krypton gold, it's cold and has no money
-Welcome to contribute UUID
-Boolean directmove (position to)
- void regenerateChunk(Position pos)
- void defineChunkRenderByName(String forLevel,String callback,int priority / void)
-Forlevel is the specified world name that the render can render
-Callback is the render callback function
-Priority is the priority. The higher the priority is, the higher the priority is. If it is not filled in, the default value is 0
- void drawPic(Position pos1,Position pos2,String img,int faceData)
-Draw the image on the IMG path from pos1 to pos2. Facedata specifies the orientation of the display box. Pos1 and pos2 must be in the same vertical plane
- void registerSolidBlock(int id,String name,double hardness,double resistance,int toolType,boolean isSilkTouchable,int dropMinExp,int dropMaxExp,int mineTier)
-Register solid blocks, the parameters are block ID (only the educational version of blocks can be overridden), block name, block hardness, block explosion resistance, mining tools, accurate collection effect, minimum drop experience, maximum drop experience, mining level
-The greater the hardness of the block, the longer the excavation time and the higher the explosion resistance, the less likely it is to be blasted
-Mining tools 0-none, 1-sword, 2-shovel, 3-pick, 4-axe, 5-scissors
-Mining level 0 - empty handed, 1 - wood, 2 - gold, 3 - stone, 4 - iron, 5 - diamond
- void registerSimpleItem(int id,String name)
-Registration of simple items heap can only override educational items

Bugs Fixed

- fix bnnpc walking in air
- fix nullpointer exception when player change the world
- new error ui


- <E> callFunction(String functionname,Object... args) --callFunction will return the return value of the function
- <E> getVariableFrom(String scriptName,String varName)
- void putVariableTo(String scriptName,String varName,<E> var)
- double getCPULoad()
- int getCPUCores()
- double getMemoryTotalSizeMB()
- double getMemoryUsedSizeMB()
- void forceDisconnect(Player player)
- Array<String> getEventFunctions(Event event)
- void getServerMotd(String host, int port, String callback)


- void setItemColor(Item item,int r,int g,int b)
- void setItemUnbreakable(Item item,boolean unbreakable)


- Item getEntityHelmet(Entity entity)
- Item getEntityChestplate(Entity entity)
- Item getEntityLeggings(Entity entity)
- Item getEntityBoots(Entity entity)
- Item getEntityItemInHand(Entity entity)
- Item getEntityItemInOffHand(Entity entity)
- void setEntityItemHelmet(Entity entity,Item item)
- void setEntityItemChestplate(Entity entity,Item item)
- void setEntityItemLeggings(Entity entity,Item item)
- void setEntityItemBoots(Entity entity,Item item)
- void setEntityItemInHand(Entity entity,Item item)
- void setEntityItemInOffHand(Entity entity,Item item)
- Item getInventorySlot(Inventory inv,int slot)


- void forceClearWindow(Player player)
- int getEventResponseIndex(PlayerFormRespondedEvent event)


- boolean isPlayer(Entity e)
- void spawnFallingBlock(Position pos, Block block, boolean enableGravity,boolean canBePlaced)

gameapi --新的基对象

- void createGame(String name,boolean useTeam,String startGameCallBack,String endGameCallBack,String mainLoopCallBack,String deathCallBack)
- void joinGame(Player player, String gameName)
- void leaveGame(Player player)
- boolean isPlayerInGame(Player player)
- GameBase getPlayerRoom(Player player)
- Array<GameBase> getAllRoomByName(String gameName)
- Array<String> getAllGameNames()
- Messager getMessager(String prefix)
- Messager getGameMessager(GameBase game)
- Multiline getMultiline(String messageType)
- InventoryMenu createInventoryMenu(String inventoryType, String title)
- FormMenu createFormMenu(String title, String content)
- void addMenuItem(InventoryMenu menu, int slot, Item item, String inventoryCallback)
- void addMenuButton(FormMenu menu,String buttonText,String imageData,String formCallback)
- Scoreboard getScoreboard(Player p)
- void setObjective(Scoreboard sb, String objectiveName,String displayName)

EventLoader --73 new

- BlockFadeEvent
- BlockFallEvent
- BlockFromToEvent
- BlockGrowEvent
- BlockIgniteEvent
- BlockPistonChangeEvent
- BlockRedstoneEvent
- DoorToggleEvent
- CreatureSpawnEvent
- CreeperPowerEvent
- EntityArmorChangeEvent
- EntityBlockChangeEvent
- EntityCombustByBlockEvent
- EntityCombustByEntityEvent
- EntityCombustEvent
- EntityDamageByBlockEvent
- EntityDamageByChildEntityEvent
- EntityExplodeEvent
- EntityMotionEvent
- EntityPortalEnterEvent
- EntityRegainHealthEvent
- EntityShootBowEvent
- EntityVehicleEnterEvent
- EntityVehicleExitEvent
- ExplosionPrimeEvent
- BrewEvent
- EnchantItemEvent
- InventoryMoveItemEvent
- StartBrewEvent
- ChunkLoadEvent
- ChunkPopulateEvent
- LevelInitEvent
- LevelLoadEvent
- LevelSaveEvent
- LevelUnloadEvent
- SpawnChangeEvent
- ThunderChangeEvent
- WeatherChangeEvent
- PlayerAchievementAwardedEvent
- PlayerAnimationEvent
- PlayerAsyncPreLoginEvent
- PlayerBlockPickEvent
- PlayerBucketEmptyEvent
- PlayerBucketFillEvent
- PlayerChangeSkinEvent
- PlayerChunkRequestEvent
- PlayerCreationEvent
- PlayerDropItemEvent
- PlayerEatFoodEvent
- PlayerEditBookEvent
- PlayerFoodLevelChangeEvent
- PlayerGameModeChangeEvent
- PlayerGlassBottleFillEvent
- PlayerInvalidMoveEvent
- PlayerItemConsumeEvent
- PlayerLocallyInitializedEvent
- PlayerMapInfoRequestEvent
- PlayerMouseOverEntityEvent
- PlayerServerSettingsRequestEvent
- PlayerSettingsRespondedEvent
- PluginDisableEvent
- PluginEnableEvent
- PotionApplyEvent
- PotionCollideEvent
- PlayerDataSerializeEvent
- RemoteServerCommandEvent
- EntityEnterVehicleEvent
- EntityExitVehicleEvent
- VehicleCreateEvent
- VehicleDamageEvent
- VehicleDestroyEvent
- VehicleMoveEvent
- VehicleUpdateEvent
- LightningStrikeEvent
Fix bugs
-Fixed the problem of bnnpc and BN floating words disappearing
New features
-Now you can add a line of comment //pragma es9 at the beginning of JS code to enable es9 language features, but there will be some performance loss, and the loss is not big, so you can use it with confidence
-The bninstall command has been abandoned, and all libraries are packaged into the BN interpreter jar. This is to save memory space, which can save up to 50MB of memory space.
Two member functions are added to the Advanced menu manager of customwindowbuilder
-Custom showasetting (player P, string callback) uses this advanced form as the player's server settings page
-Custom build dropdown (string title, string inner, int index) builds a drop-down menu and specifies default options
Eventloader adds 1 event
-Chunk unload event
Six new functions for entity
-Void setplayerexp (player player, int exp) sets player experience
-Int getplayerexp (player player)
-Void setplayer explevel (player player, int LEL) sets the player level
-Int getplayerexplevel (player player) to get player level
-Void setplayer Hunter (player player, int hunger) sets the player's hunger level
-Int getplayerhunger (player player) to get player hunger
Two new functions are added in window
-Void maketipsvar (string Varname, string providercallback) creates dynamic tips plug-in variables
-Void maketips static (string Varname, string to replace) creates static tips plug-in variables


- BNNPC buildNPC(Position pos,String name,String skinID,int calltick,String callfunction,String attackfunction)
- void showFloatingItem(Position pos,Item item)
- void removeFloatingItem(Position pos,Item item)


- Custom buildSlider(String title,double min,double max)
- Custom buildSlider(String title,double min,double max,int step)
- Custom buildSlider(String title,double min,double max,int step,double defaultvalue)
- Custom buildStepSlider(String title,String options)
- Custom buildStepSlider(String title,String options,int index)


- String getEventCustomVar(PlayerFormRespondedEvent event,int id,String mode)
- mode可以为input toggle dropdown slider stepslider


- void displaySwing()
- void setSwim(boolean swim)
- void setSwim()
- void setTickCallback(String callback)
- void setAttackCallback(String callback)


- void bStats(String pluginName,String pluginVer,String authorName,int pluginid)
- void callFunction(String functionname,Object... args) --修复了错误的拼写


- void loadScreenTP(Player player,Position pos)
- void loadScreenTP(Player player,Position pos,int loadScreenTick)
- void clearChunk(Position pos)


- PlayerHeldEvent
- InventoryClickEvent
Class library manager

-Now the class library manager can install the module directly. For now, there are only Python and database modules
-Use the command bninstall module name to install the class library


- void setBelowName(Player player,String str)


- void loadJar(String path)


- void setOceanGenerator(int seaLevel)


- BNNPC buildNPC(Position pos,String name,String skinID)
- BNNPC buildNPC(Position pos,String name,String skinID,int calltick,String callfunction)


- void turnRound(double yaw)
- void headUp(double pitch)
- void setEnableAttack(boolean attack)
- void setEnableAttack()
- void setEnableHurt(boolean hurt)
- void setEnableHurt()
- void displayHurt()
- void start()
- void setEnableGravity(boolean gravity)
- void setEnableGravity()
- void setG(double newg)
- void lookAt(Position pos)
- Player getNearestPlayer()

- boolean isSneak()

- void setSneak(boolean sneak)

- void setSneak()

- void jump()

- void setJumpHigh(double j)

- void setEnableKnockBack(boolean knock)

- void setEnableKnockBack()

- void setKnockBase(double base)

- boolean canMoveTo(Position to)

- boolean findAndMove(Position to)

- void setSpeed(double s)

- void setRouteMax(int m)

- void stopMove()

- void hit(Entity entity)

bug fixed:

-Some potions of entity effect do not display problems, but there are still some potions that cannot be displayed because NK does not support it

-Error in generating void and ocean by world

-Space world configuration loss

-SSH error reporting

-Now the window manager's operation function returns itself, which can be linked directly in the code


Now you can use Python 2.7 to make plug-ins

Add full support for Python development plug-ins, just download additional py support packages to use Python plug-ins

The support for Python development plug-ins will be synchronized with JavaScript. Python and JS use the same set of BN class libraries. All the BN class libraries of JS (except Java modules) can be called directly in Python without import

Support all Python 2.7 native standard syntax and standard library, run time is the same as JS, compiled to Java bytecode run, do not worry about inefficiency

Download the python for BN support module:

After downloading, put it directly under the. / plugins / blocklynukkit folder


- PlayerInteractEntityEvent

- PlayerDamageByPlayerEvent

- EntityKilledByEntityEvent

- PlayerDamageByEntityEvent

- EntityKilledByEntityEvent

- EntityKilledByPlayerEvent

- PlayerRespawnEvent


- void setPlayerBossBar(Player player,String text,float len)

- void removePlayerBossBar(Player player)

- double getLengthOfPlayerBossBar(Player player)

- String getTextOfPlayerBossBar(Player player)


- void createPermission(String per,String description,String defaultper)

- void removePermission(String per)

- boolean checkPlayerPermission(String per,Player player)

- String MD5Encryption(String str)

- String SHA1Encryption(String str)

- void createCommand(String name, String description, String callbackFunctionName, String per)

- void newCommand(String name, String description, Function jsFunction,String per)


- int getNetworkID(Entity entity)

- String getIDName(Entity entity)

- void spawnEntity(String name,Position pos)


- HornSongPlayer buildHorn(Song song, Position pos, boolean isloop, boolean isautodestroy)

- void addPlayerToHorn(HornSongPlayer SongPlayer, Player player)

- void removePlayerToHorn(HornSongPlayer SongPlayer, Player player)

- Array getPlayerInHorn(HornSongPlayer radioSongPlayer)

- void setHornStatus(HornSongPlayer radioSongPlayer, boolean isplaying)

- Song getSongInHorn(HornSongPlayer radioSongPlayer)


-New ocean world generator for genlevel

bug fixed

- setNameTagAlwaysVisable error


- String formatJSON(String json)

-Fixed the error that the WriteFile function could not automatically create a path

Performance optimization is carried out to force invokemethod optimization to be started when the underlying JS translates Java bytecode


For manager base objects:

New function:

String readFile(String path)

void wirteFile(String path,String text)

boolean isFileSame(String path1,String path2)

String JSONtoYAML(String json)

String YAMLtoJSON(String yaml)

void newCommand(String name, String description, Function fun)

int setTimeout(Function fun,int delay,<E+>... args)

void clearTimeout(int id)

int setInterval(Function fun,int delay,<E+>... args)

void clearInterval(int id)

void isWindows()

int getPlayerGameMode(Player player)

For JS loader:

What's new

Name indicates the name of the loaded JS file (it can prevent low-level name change and reselling)

24-hour mandatory update after new release

You can use let and const to define variables in Es5 syntax

For custom / Modal / simple window builders

New function:

- void showToPlayerCallLambda(Player p, Function fun)

For blockitem base objects:

New function:

Array<Enchantment> getItemEnchant(Item item)

int getEnchantID(Enchantment enchantment)

int getEnahcntLevel(Enchantment enchantment)

For event callers:

New event






Sandbox isolation for each JS file runtime, namespace and cross namespace calls are added, article NBT and window default values are added.
you can use FloatingText in BlocklyNukkit now
and other new functions
many bugs fixed
now you can use http api to call javascript functions and get the retun value.
now you can compile your js plugin to jar file