@mxbe/scoreboard
v0.0.2
Published
This is scoreboard management for minecraft bedrock development
Readme
Scoreboard Management for Minecraft Bedrock Development
@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.
Features
- Type-safe operations with TypeScript generics
- Zero-value protection option
- Asynchronous operations
- Chainable methods
- Error handling for non-existent objectives
- Promise-based API
Installation
To install @mxbe/scoreboard in your minecraft add-on project, you have two options:
Option 1: Use the package manager
- Open a terminal and navigate to your project's root directory.
- Run the following command to install the package:
npx @mxbe/project init- Choose dependencies addons in prompt
@mxbe/scoreboard
Option 2: Install via npm
- Open a terminal and navigate to your project's root directory.
- Run the following command to install the package:
npm i @mxbe/scoreboardOption 3: Clone the repository
- Open a terminal and navigate to your project's root directory.
- Run the following command to clone the repository:
git clone https://github.com/sausage404/mxbe-scoreboard.git- Copy the
index.tsandindex.d.tsorindex.jsfile 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
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<ObjectiveNames>(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`);License
@mxbe/scoreboard is released under the GNU General Public License v3.
Issues
If you encounter any problems or have suggestions, please file an issue on the GitHub repository.
