This is scoreboard management for minecraft bedrock development
npm install @mxbe/scoreboard@mxbe/scoreboard A type-safe scoreboard management system for Minecraft Bedrock Edition (MCBE) add-ons. Provides a simple API for managing player scores with built-in zero-value protection.
@mxbe/scoreboard in your minecraft add-on project, you have two options:
bash
npx @mxbe/project init
`
1. Choose dependencies addons in prompt @mxbe/scoreboard
$3
1. Open a terminal and navigate to your project's root directory.
2. Run the following command to install the package:
`bash
npm i @mxbe/scoreboard
`
3. Use the module with ESBuild or Webpack
$3
1. Open a terminal and navigate to your project's root directory.
2. Run the following command to clone the repository:
`bash
git clone https://github.com/sausage404/mxbe-scoreboard.git
`
3. Copy the index.ts and index.d.ts or index.js file from the cloned repository into your project's scripts folder.
Basic Usage
Let's walk through how to use the scoreboard in your minecraft bedrock. We'll cover the essential operations with practical examples.
Create a scoreboard Instance With TypeScript
`typescript
import * as mc from "@minecraft/server";
import { Scoreboard } from "@mxbe/scoreboard";
// Define objective names
type ObjectiveNames = "money" | "level" | "xp";
// Initialize scoreboard with zero-value protection
const scoreboard = new Scoreboard(true);
// Get a player's score
const money = scoreboard.get("money", player);
console.log( ${player.name}'s money: ${money});
// Add points to a score
scoreboard.add("money", player, amount);
console.log(Added ${amount} money to ${player.name});
// Remove points from a score
scoreboard.delete("money", player, amount);
console.log(Removed ${amount} money from ${player.name});
// Reset a player's score
scoreboard.reset("money", player);
console.log(Reset ${player.name}'s money);
``