Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
AnyBananaGAME committed Sep 20, 2024
1 parent 64fe07f commit 9fa0530
Show file tree
Hide file tree
Showing 22 changed files with 2,116 additions and 1,743 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@ U2NyZWV0/
plugins/
db/
src/tools/level
src/history/
src/history/
note.txt
bun.lockb
41 changes: 26 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,29 @@ npm i @sanctumterra/client
## 🚀 Usage Example

```typescript
import { Client, Logger } from "@sanctumterra/client";
import { TextPacket } from "@serenityjs/protocol"; // Import packet types
// Import the Client, logger from the @sanctumterra/client package
const { Client, Logger } = require("@sanctumterra/client");

// 🎮 Create a new client instance with the necessary configurations
// Create a new instance of the Client with the specified options
const client = new Client({
host: "127.0.0.1", // 🖥️ Server IP address
port: 19132, // 🌐 Server port
offline: false, // 🔒 Set to true if the server is offline
username: "SanctumTerra", // 🧑‍💻 Your Minecraft username
version: "1.21.20" // 📦 The Minecraft Bedrock version
host: "127.0.0.1", // The IP address of the server
port: 19133, // The port of the server
offline: true, // Whether the client is offline or not
username: "SanctumTerra", // The username of the client
tokensFolder: "./cache/tokens", // The folder where the tokens are stored
version: "1.21.20", // The version of the game
validateProtocol: false, // Whether to validate the protocol or not
loadPlugins: false // Whether to load plugins or not
});

// 🌐 Connect to the server
// Connect to the server
client.connect();

// 📥 Handle incoming TextPacket events
client.on(TextPacket.name, (packet: TextPacket): void => {
// Text Packet Event
client.on("TextPacket", (packet) => {
console.log(packet.message);
if (packet.parameters) {
// 🗨️ Handle standard chat messages
// 🗨️ Handle standard chat messages
if (packet.message.includes("chat.type.text")) {
return Logger.chat(`§f<${packet.parameters[0]}> ${packet.parameters[1]}`);
}
Expand All @@ -47,13 +51,20 @@ client.on(TextPacket.name, (packet: TextPacket): void => {
if (packet.message.includes("multiplayer.player.left")) {
return Logger.chat(`§e${packet.parameters[0]} left the game`);
}

// 📝 Log any other message types
console.log(packet.message);
if(packet.message.includes("%chat.type.announcement")) {
return Logger.chat(`§d<${packet.parameters[0]}> ${packet.parameters[1]}`);
}
}
// 📜 Default log for any packet message
Logger.chat(packet.message);
});

// Emitted when the client spawns.
client.on("spawn", () => {
// You may use any type of logger you want ;)
Logger.info("Spawned!");
});

```

---
Expand Down
13 changes: 7 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
{
"name": "@sanctumterra/client",
"version": "2.0.9",
"version": "2.0.10",
"description": "We'll be singing Baraye.",
"main": "./dist/index.js",
"type": "commonjs",
"scripts": {
"test": "node ./dist/tools/test.js",
"dev": "node ./src/tools/build.js && npm run test",
"build": "tsc --build tsconfig.json"
"build": "tsc --build tsconfig.json",
"format": "npx @biomejs/biome format --write ./src",
"lint": "npx @biomejs/biome lint --write ./src"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"@swc/core": "^1.7.21",
"@biomejs/biome": "1.9.2",
"@types/jsonwebtoken": "^9.0.6",
"@types/uuid-1345": "^0.99.25",
"chalk": "^5.3.0",
Expand All @@ -30,15 +32,14 @@
"dependencies": {
"@sanctumterra/raknet": "^1.0.19",
"@serenityjs/binarystream": "^2.6.6",
"@serenityjs/binarystream-linux-x64-gnu": "^2.6.6",
"@serenityjs/block": "^0.4.4",
"@serenityjs/network": "^0.4.4",
"@serenityjs/protocol": "0.4.4",
"@serenityjs/raknet": "^0.4.4",
"@serenityjs/world": "^0.4.4",
"@swc/helpers": "^0.5.12",
"@types/node": "^22.5.1",
"jose": "^5.8.0",
"jsonwebtoken": "^9.0.2",
"jose": "^5.9.2",
"prismarine-auth": "github:AnyBananaGAME/prismarine-auth",
"prismarine-realms": "^1.3.2",
"uuid-1345": "^1.0.2"
Expand Down
Loading

0 comments on commit 9fa0530

Please sign in to comment.