1818 - [ MCServer] ( #mcserver )
1919 - [ Flying-squid.createMCServer(options)] ( #flying-squidcreatemcserveroptions )
2020 - [ Properties] ( #properties )
21+ - [ serv.pluginsReady] ( #servpluginsready )
2122 - [ serv.entityMaxId] ( #serventitymaxid )
2223 - [ serv.players] ( #servplayers )
2324 - [ serv.uuidToPlayer] ( #servuuidtoplayer )
2425 - [ serv.overworld] ( #servoverworld )
2526 - [ serv.netherworld] ( #servnetherworld )
26- - [ serv.endworld] ( #servendworld )
2727 - [ serv.entities] ( #serventities )
2828 - [ serv.bannedPlayers] ( #servbannedplayers )
2929 - [ serv.time] ( #servtime )
3030 - [ serv.tickCount] ( #servtickcount )
3131 - [ serv.doDaylightCycle] ( #servdodaylightcycle )
3232 - [ serv.plugins] ( #servplugins )
33+ - [ serv.commands] ( #servcommands )
3334 - [ serv.tabComplete] ( #servtabcomplete )
3435 - [ Events] ( #events )
3536 - [ "error" (error)] ( #error-error )
3839 - [ "newPlayer" (player)] ( #newplayer-player )
3940 - [ "banned" (banner,bannedUsername,reason)] ( #banned-bannerbannedusernamereason )
4041 - [ "tick" (count)] ( #tick-count )
42+ - [ "pluginsReady"] ( #pluginsready )
4143 - [ Methods] ( #methods )
44+ - [ serv.formatMessage(message)] ( #servformatmessagemessage )
4245 - [ serv.createLog()] ( #servcreatelog )
4346 - [ serv.log(message)] ( #servlogmessage )
4447 - [ serv.info(message)] ( #servinfomessage )
6669 - [ server.playNoteBlock(world, position, pitch)] ( #serverplaynoteblockworld-position-pitch )
6770 - [ server.getNote(note)] ( #servergetnotenote )
6871 - [ server.emitParticle(particle, world, position, opt)] ( #serveremitparticleparticle-world-position-opt )
72+ - [ serv.selectorString(str, pos, world, allowUser = true, ctxEntityId)] ( #servselectorstringstr-pos-world-allowuser--true-ctxentityid )
6973 - [ Low level methods] ( #low-level-methods )
7074 - [ server._ writeAll(packetName, packetFields)] ( #server_writeallpacketname-packetfields )
7175 - [ server._ writeArray(packetName, packetFields, playerArray)] ( #server_writearraypacketname-packetfields-playerarray )
7276 - [ server._ writeNearby(packetName, packetFields, loc)] ( #server_writenearbypacketname-packetfields-loc )
73- - [ serv._ loadPlayerChunk(chunkX, chunkZ, player)] ( #serv_loadplayerchunk )
74- - [ serv._ unloadPlayerChunk(chunkX, chunkZ, player)] ( #serv_unloadplayerchunk )
77+ - [ serv._ loadPlayerChunk(chunkX, chunkZ, player)] ( #serv_loadplayerchunkchunkx-chunkz-player )
78+ - [ serv._ unloadPlayerChunk(chunkX, chunkZ, player)] ( #serv_unloadplayerchunkchunkx-chunkz-player )
7579 - [ Entity] ( #entity-1 )
7680 - [ Properties] ( #properties-1 )
7781 - [ entity.id] ( #entityid )
125129 - [ "disconnected"] ( #disconnected )
126130 - [ "chat" (message)] ( #chat-message )
127131 - [ "kicked" (kicker,reason)] ( #kicked-kickerreason )
132+ - [ "change_world"] ( #change_world )
133+ - [ "playerChangeRenderDistance" (newDistance=player.view, unloadFirst=false)] ( #playerchangerenderdistance-newdistanceplayerview-unloadfirstfalse )
128134 - [ "positionChanged"] ( #positionchanged )
129135 - [ Behaviors] ( #behaviors-1 )
130136 - [ "move"] ( #move-1 )
144150 - [ "attack"] ( #attack )
145151 - [ "requestRespawn"] ( #requestrespawn )
146152 - [ Methods] ( #methods-2 )
153+ - [ player.save()] ( #playersave )
147154 - [ player.login()] ( #playerlogin )
148155 - [ player.ban(reason)] ( #playerbanreason )
149156 - [ player.kick(reason)] ( #playerkickreason )
152159 - [ player.changeBlock(position,blockType,blockData)] ( #playerchangeblockpositionblocktypeblockdata )
153160 - [ player.sendBlock(position,blockType,blockData)] ( #playersendblockpositionblocktypeblockdata )
154161 - [ player.sendBlockAction(position,actionId,actionParam,blockType)] ( #playersendblockactionpositionactionidactionparamblocktype )
162+ - [ player.sendBrand(brand = 'flying-squid')] ( #playersendbrandbrand--flying-squid )
155163 - [ player.sendInitialPosition()] ( #playersendinitialposition )
156164 - [ player.setGameMode(gameMode)] ( #playersetgamemodegamemode )
157165 - [ player.handleCommand(command)] ( #playerhandlecommandcommand )
158166 - [ player.setBlock(position,blockType,blockData)] ( #playersetblockpositionblocktypeblockdata )
159167 - [ player.setBlockAction(position,actionId,actionParam)] ( #playersetblockactionpositionactionidactionparam )
160168 - [ player.updateHealth(health)] ( #playerupdatehealthhealth )
161- - [ player.updateFood(health )] ( #playerupdatefoodfood )
162- - [ player.updateFoodSaturation(health )] ( #playerupdatefoodsaturationfoodsaturation )
169+ - [ player.updateFood(food )] ( #playerupdatefoodfood )
170+ - [ player.updateFoodSaturation(foodSaturation )] ( #playerupdatefoodsaturationfoodsaturation )
163171 - [ player.changeWorld(world, opt)] ( #playerchangeworldworld-opt )
164172 - [ player.spawnAPlayer(spawnedPlayer)] ( #playerspawnaplayerspawnedplayer )
165173 - [ player.updateAndSpawnNearbyPlayers()] ( #playerupdateandspawnnearbyplayers )
171179 - [ Low level properties] ( #low-level-properties )
172180 - [ player._ client] ( #player_client )
173181 - [ Low level methods] ( #low-level-methods-1 )
174- - [ player._ unloadChunk(chunkX, chunkZ)] ( #player_unloadchunk )
175- - [ player._ unloadAllChunks] ( #player_unloadallchunks )
182+ - [ player._ unloadChunk(chunkX, chunkZ)] ( #player_unloadchunkchunkx-chunkz )
183+ - [ player._ unloadAllChunks() ] ( #player_unloadallchunks )
176184
177185<!-- END doctoc generated TOC please keep comment here to allow auto update -->
178186
@@ -254,6 +262,10 @@ Options is an object containing the following properties:
254262
255263### Properties
256264
265+ #### serv.pluginsReady
266+
267+ ` true ` if all async plugins are ready and the server is ready to accept connections.
268+
257269#### serv.entityMaxId
258270
259271The current maximum ID (i.e. the last entity that was spawned has that id)
@@ -321,7 +333,7 @@ serv.commands.add({
321333 parse (str ) {
322334 const args = str .split (' ' );
323335 if (args .length != 1 ) return false ;
324-
336+
325337 return {pseudo: args[0 ]};
326338 },
327339 action ({pseudo}, ctx ) {
@@ -368,8 +380,16 @@ Fires when `player` login, allow external player plugins.
368380
369381Fires when one tick has passed (default is 50ms). count is the total world ticks (same as serv.tickCount)
370382
383+ #### "pluginsReady"
384+
385+ Emitted when ` serv.pluginsReady ` is set to ` true ` .
386+
371387### Methods
372388
389+ #### serv.formatMessage(message)
390+
391+ You can override this function so you can process the message before sending it to the console.
392+
373393#### serv.createLog()
374394
375395Creates the log file
@@ -478,7 +498,7 @@ Sends a block action to all players of the same world.
478498
479499#### server.playSound(sound, world, position, opt)
480500
481- Plays ` sound ` (string, google "minecraft sound list") to all players in ` opt.radius ` .
501+ Plays ` sound ` (string, google "minecraft sound list") to all players in ` opt.radius ` .
482502If position is null, will play at the location of every player (taking into account whitelist and blacklist).
483503
484504Opt:
@@ -644,16 +664,16 @@ List of entities that the entity believes is nearby.
644664
645665Behaviors are very interesting. Let me explain to you how they work:
646666
647- Behaviors are a special type of event. They are editable and allow defaults to be cancellable making the powerful
648- for plugins to take control of and interact with each other. Three different events get called
667+ Behaviors are a special type of event. They are editable and allow defaults to be cancellable making the powerful
668+ for plugins to take control of and interact with each other. Three different events get called
649669for a behavior:
650670- EVENTNAME_cancel
651671- EVENTNAME
652672- EVENTNAME_done
653673
654674EVENTNAME_cancel passses the paramaters ` data ` (object of all info about behavior. Changing the data could have effects on outcome) and ` cancel ` , a function. This event is run before the default action. If ` cancel() ` is called, it will cancel the default action. More on this later.
655675
656- EVENTNAME passes ` data ` as well as ` cancelled ` so plugins can check if the default behavior has been cancelled. This is event is run
676+ EVENTNAME passes ` data ` as well as ` cancelled ` so plugins can check if the default behavior has been cancelled. This is event is run
657677before the default action.
658678
659679EVENTNAME_done passes ` data ` and ` cancelled ` . This event is run before the default action.
@@ -674,9 +694,9 @@ player.on('move', ({position}, cancelled) => {
674694})
675695```
676696
677- When a player normally moves, the server saves their position and sends it to all clients. Therefore, if a "move" behavior was truly cancelled,
678- the player would be able to move freely while the server and other players would see the player stationary. This doesn't happen because
679- behaviors can have "default cancel functions". In the case of a player's "move", the default cancel function sends them back where they
697+ When a player normally moves, the server saves their position and sends it to all clients. Therefore, if a "move" behavior was truly cancelled,
698+ the player would be able to move freely while the server and other players would see the player stationary. This doesn't happen because
699+ behaviors can have "default cancel functions". In the case of a player's "move", the default cancel function sends them back where they
680700came from. To prevent this from happening, use the "preventDefaultCancel" paramater: cancel(false);
681701
682702Plugin C
@@ -686,10 +706,10 @@ player.on('move_cancel', ({position}, cancel) => {
686706});
687707```
688708
689- If we keep Plugin B and replace Plugin A with Plugin C, we'll see that the player can move freely but will not receive the
709+ If we keep Plugin B and replace Plugin A with Plugin C, we'll see that the player can move freely but will not receive the
690710word "HI" and other players will be unable to see their movements.
691711
692- Finally, there is hidden cancel. This is the second parameter in cancel, and allows plugins to hide the fact that they cancelled
712+ Finally, there is hidden cancel. This is the second parameter in cancel, and allows plugins to hide the fact that they cancelled
693713the default action from other plugins. It's best not to use this, but I know somebody will someday need this.
694714
695715Plugin D
@@ -699,7 +719,7 @@ player.on('move_cancel', ({position}, cancel) => {
699719})
700720```
701721
702- Using Plugin B and D together, the player will be able to move freely and will be spammed with "HI", however the server will not store
722+ Using Plugin B and D together, the player will be able to move freely and will be spammed with "HI", however the server will not store
703723their position and other players will not see the player move.
704724
705725#### FORMAT
@@ -794,7 +814,7 @@ Level of xp the player has. Set this with player.setXpLevel()
794814
795815### Events
796816
797- #### "connected"
817+ #### "connected"
798818
799819Fires when the player is connected
800820
@@ -814,6 +834,14 @@ Fires when the player says `message`.
814834
815835` kicker ` kick the player with ` reason `
816836
837+ #### "change_world"
838+
839+ World of the player has been changed.
840+
841+ #### "playerChangeRenderDistance" (newDistance=player.view, unloadFirst=false)
842+
843+ Emit this event to change player render distance.
844+
817845#### "positionChanged"
818846
819847fires when the position changes in small amounts (walking, running, or flying)
@@ -1004,6 +1032,17 @@ Cancelled: Nothing. You monster.
10041032
10051033### Methods
10061034
1035+ #### player.save()
1036+
1037+ If ` worldFolder ` option is set, save player's data into ` <worldFolder>/playerdata/<UUID>.dat ` . Returns promise.
1038+ Example: save all players data to disk:
1039+
1040+ ``` js
1041+ for (const player of serv .players ) {
1042+ player .save ()
1043+ }
1044+ ```
1045+
10071046#### player.login()
10081047
10091048login
@@ -1028,7 +1067,7 @@ sends `message` to the player
10281067
10291068change the block at position ` position ` to ` blockType ` and ` blockData `
10301069
1031- this will not change the block for the user himself. It is mainly useful when a user places a block
1070+ this will not change the block for the user himself. It is mainly useful when a user places a block
10321071and only needs to send it to other players on the server
10331072
10341073#### player.sendBlock(position,blockType,blockData)
@@ -1041,7 +1080,7 @@ this will not make any changes on the server's world and only sends it to the us
10411080
10421081Set the block action at position ` position ` to ` actionId ` and ` actionParam ` .
10431082
1044- `` blockType `` is only required when the block at the location is a fake block.
1083+ `` blockType `` is only required when the block at the location is a fake block.
10451084This will only be caused by using `` player.sendBlock `` .
10461085
10471086This will not make any changes to the server's world and only sends it to the user as a local action.
0 commit comments