Created
March 10, 2021 17:20
-
-
Save sorae42/75ead50361575361aa1b1d08391fae21 to your computer and use it in GitHub Desktop.
Chat and Command logger for BDSX2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Enable the ability to log chat and commands, just like Java server. | |
| // soraboken / Rosetta Emerson (c) 2021 | |
| // YOUR SERVER NEED TO BE RUNNING BDSX2: https://github.com/bdsx/bdsx | |
| console.log("[LOGGER] Prepare logging, please wait...!"); | |
| import { command, nethook, MinecraftPacketIds } from 'bdsx'; | |
| nethook.before(MinecraftPacketIds.Text).on((packet, networkIdentifier) => { | |
| const name = packet.name; | |
| const message = packet.message; | |
| console.log(`[LOGGER] <${name}> ${message}`); | |
| }); | |
| nethook.after(MinecraftPacketIds.Login).on((ptr, networkIdentifier, packetId) => { | |
| const ip = networkIdentifier.getAddress(); | |
| const cert = ptr.connreq.cert; | |
| const name = cert.getId(); | |
| console.log(`[INFO] ${name} @ ${ip} connecting...`); | |
| }); | |
| command.hook.on((commandText, origin) => { | |
| console.log(`[LOGGER] ${origin} executed: ${commandText}`); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment