Defines the Lunar Client Bukkit protocol
Install the package:
$ npm install @minecraft-js/lunarbukkitapiAnd then import it in your JavaScript/TypeScript file
constLunarClient=require('@minecraft-js/lunarbukkitapi');// CommonJSimport*asLunarClientfrom'@minecraft-js/lunarbukkitapi';// ES6This library comes with a high level API for a player which means you can easily set cooldowns, set waypoints without even touching any packets!
For now since there's no MinecraftJS client/server library you need to set your own packet sending/receiving handling.
At the time of writing, the biggest client/server library is PrismarineJS and here is a simple example with that library
// PrismarineJSconstmc=require('minecraft-protocol');constserver=mc.createServer({ ... });server.on('login',(client)=>{
...
letplayerChannel='';constlunarPlayer=newLunarClient.LunarClientPlayer({customHandling: {registerPluginChannel(channel){playerChannel=channel;// PrismarineJS way of sending packetsclient.write('custom_payload',{channel: 'REGISTER',data: Buffer.from(channel+'\0')});},sendPacket(buffer){// PrismarineJS way of sending packetsclient.write('custom_payload',{channel: playerChannel,data: buffer})}}});// Sending a cooldown// with id of `pearl`// for 15s and an ender// pearl as item (368)lunarPlayer.addCooldown('pearl',15000,368);});Packet used in the benchmark: CooldownPacket
Computer specs: Ryzen 5 3600 - 16GB at 2100MHz
Reading x 836,146 ops/sec ±0.28% (97 runs sampled)
Writing x 432,880 ops/sec ±1.23% (95 runs sampled)
Run this command to run the benchmarks on your machine
$ npm run benchmark