Skip to content
This repository has been archived by the owner on Nov 15, 2024. It is now read-only.

Commit

Permalink
updates to 1.0.1-release
Browse files Browse the repository at this point in the history
  • Loading branch information
VoxlDevv committed Jun 10, 2023
1 parent 72e2f2d commit cb962f9
Show file tree
Hide file tree
Showing 27 changed files with 507 additions and 190 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
node_modules
node_modules
test.js
217 changes: 133 additions & 84 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,91 +1,140 @@
# JustSkyAPI - Minecraft Bedrock Scripting API
<!--- this README.md is from @notbeer(https://github.com/notbeer) --->
<!--
This README.md template was NOT orginally created by me(JustSKyDev)! This is a fork of:
https://github.com/othneildrew/Best-README-Template
-->

<!-- LOGO -->

![Bedrock-API](https://socialify.git.ci/JustSkyDev/Bedrock-API/image?description=1&descriptionEditable=Minecraft%20Bedrock%20Custom%20Scripting%20API&font=Source%20Code%20Pro&forks=1&issues=1&logo=https%3A%2F%2Fraw.githubusercontent.com%2FJustSkyDev%2FBedrock-API%2Fmain%2Fpack_icon.png&name=1&owner=1&pattern=Floating%20Cogs&pulls=1&stargazers=1&theme=Light)

<br />
<div align="center">

<h3 align="center"><u>Bedrock API</u></h3>

<p align="center">
Bedrock API is a library built using Minecraft Bedrock Scripting API. This library will help you keep your code clean and make it easier to interact with the Scripting API, while including a lot of new classes/functions/methods for you to use! and some built-in custom command
<br />
<a href="#"><strong>Docs Coming soon »</strong></a>
<br />
<br />
<a href="https://github.com/JustSkyDev/Bedrock-API">View</a>
·
<a href="https://github.com/JustSkyDev/Bedrock-API/issues">Bug Report</a>
·
<a href="https://github.com/JustSkyDev/Bedrock-API/pulls">Feature Request</a>
</p>

---

[![MIT License](https://img.shields.io/github/license/JustSkyDev/Bedrock-API?style=for-the-badge)](https://github.com/notbeer/Gametest-API-Wrapper/blob/main/LICENSE.txt)
[![Discord](https://img.shields.io/discord/898202806052347984?color=blue&label=Discord&style=for-the-badge)](https://discord.gg/g4EJ38HZ7R)
[![YouTube](https://img.shields.io/youtube/channel/subscribers/UC9gjEs8-syrZcgftpm3gsyQ?label=YouTube&style=for-the-badge)](https://youtube.com/@JustSkyDev)
[![GitHub Releases](https://img.shields.io/github/downloads/JustSkyDev/JustSky-API/total?style=for-the-badge)
](https://github.com/JustSkyDev/JustSky-API/releases/latest)

<br>

![JustSky-API](https://socialify.git.ci/JustSkyDev/JustSky-API/image?description=1&descriptionEditable=Minecraft%20Bedrock%20Custom%20Scripting%20API&font=Source%20Code%20Pro&forks=1&issues=1&logo=https%3A%2F%2Fraw.githubusercontent.com%2FJustSkyDev%2FJustSky-API%2Fmain%2Fpack_icon.png&name=1&owner=1&pattern=Floating%20Cogs&pulls=1&stargazers=1&theme=Light)

`JustSky-API` is an API based on the Scripting API in Minecraft bedrock, this API is very easy to use

`Default Command Prefix`: **!**

## 💎 Features
- **Easy-to-use**
- **Fast**
- **Built-in plugins (Custom Commands and Chat Ranks)**
- **Include Database, Collection (Map Extension)**
- **Include Command Builder, PlayerClass, EntityClass, ChatClass**
- **Include Formatter, Validation, Timer, CooldownClass**
- **ETC**

## ⚙️ Experimental toggle
- Turn on the **Beta Api's** toggle in Experiments menu

## 🔧 Installation
- **It is recommended to put API folder to** `development_behavior_pack`, **every time you reload the world or run the /reload command, the API will automatically reload**

## 🛠️ Example usage
- **Command Builder**
- **PATH** PATH/Custom Command/yourCommand.js

```javascript
// Import these two Class
import { Command, CommandRegistration } from "../class.chain.js";

// Create the registration information
const registration = new CommandRegistration()
.setName("yourcommandname") // Command name
.setDescription("Command description")
.setAliases(["y"]) // Command aliases
.setCategory("Custom"); // Command category

// Build the command
Command.BuildCommand(registration, (interaction) => {
// Interaction list
const { DB, raw, sender, args, allCommandRegistration } = interaction;
/**
* DB is Database
* raw is Raw packet from ChatSendEvent
* sender is Who send the command
* args is Arguments, like player send command !help 2, args[0] would be "2"
* allCommandRegistration is Get all command registration from Command Builder
*/
});
```

- **Database**
```javascript
const DB = new Database("dbName"); // Create new database with name "dbName"
db.set("key", "value"); // Set data to database
db.get("key); // Get data from database, this would return "value"
```
- **Collection**
```javascript
const collect = new Collection(); // Create new collection
collect.set("key", "value"); // Set data to collection
collect.get("key"); // Get data from collection
```
- **Entity & Player Class**
```javascript
// Entity coming soon
// Player
const player = new PlayerClass(playerObject);
const score = player.getScore("money");
const isOnline = player.isOnline("playerName");
```
## 📑 Note
- **If you found bug or need more features, you can create/open Issues or Pull Request**
[![GitHub Releases](https://img.shields.io/github/downloads/JustSkyDev/Bedrock-API/total?style=for-the-badge)
](https://github.com/JustSkyDev/Bedrock-API/releases/latest)

---

</div>

<!-- TABLE OF CONTENTS -->
<details open="open">
<summary><h2 style="display: inline-block">Table of Contents</h2></summary>
<ol>
<li>
<a href="#about-the-project">About The Project</a>
<ul>
<li><a href="#built-with">Built With</a></li>
</ul>
</li>
<li>
<a href="#getting-started">Getting Started</a>
<ul>
<li><a href="#installation">Installation</a></li>
</ul>
</li>
<li><a href="#usage">Usage</a></li>
<li><a href="#contributing">Contributing</a></li>
<li><a href="#license">License</a></li>
<li><a href="#contact">Contact</a></li>
<li><a href="#acknowledgements">Acknowledgements</a></li>
</ol>
</details>

<!-- ABOUT THE PROJECT -->
<br />

## About The Project

JSBedrock-API will provide you with a lot of classes and methods for you to use. There be a lot of useful custom methods for you to use. There are also classes like Database and Collection. Scripting API doesn't come with a Database or Collection as of now, so I have added a way for you to easily store and get access to the data. There are a lot more stuff in this API/Lib!

### Built With

- [Scripting API Docs](https://learn.microsoft.com/en-us/minecraft/creator/scriptapi/)

<!-- GETTING STARTED -->
<br />

## Getting Started

Easy Method

- Download this zip folder and name it to `.mcpack` and import it by double clicking on the folder. This method will only work if you have Minecraft Bedrock Edition on the same device you are doing this action on.

Recommended Method

- Another Method would be to take the zipped folder and unzip/extract it. Take your folder and move it to the folder 'development_behavior_packs', which can be found in a path like `PATH/TO/development_behavior_packs`. This will make your life way easier, while developing this pack. It will update the content inside your game everytime you make any changes to the script. For the changes to apply you must leave and rejoin your world where the pack is applied at.

<br />

### Installation

1. Clone the repo
```sh
git clone https://github.com/JustSkyDev/Bedrock-API.git
```
<br />

## Usage

<strong>IMPORTANT: </strong>`If you are going to apply any Scripting related scripts to your world, please make a copy of your world before you do so! I'm not responsible if anything goes wrong-`

Create a new world, since Scripting API is still experimental. Make sure in your settings you have `Beta API's` in `Experiments` menu.
I have some examples on how you can use this library. Specifically on custom commands. Type in the game chat `!help` for the list of custom commands or `!help [command name]` to get information on a specific command!

<!-- ROADMAP -->
<br />

## Roadmap

See the [open issues](https://github.com/JustSkyDev/Bedrock-API/issues) for a list of proposed features (and known issues).

<!-- CONTRIBUTING -->
<br />

## License

Distributed under the MIT License. See `LICENSE` for more information.

<!-- CONTACT -->
<br />

## Contact

Discord - JustSky#2117

<!-- ACKNOWLEDGEMENTS -->
<br />

## Acknowledgements

- [Scripting API Docs](https://learn.microsoft.com/en-us/minecraft/creator/scriptapi/)

<!-- STAR -->
<br/>

## ⭐ Star
## Star

[![Star History Chart](https://api.star-history.com/svg?repos=JustSkyDev/Bedrock-API&type=Date)](https://star-history.com/#JustSkyDev/Bedrock-API&Date)

[![Star History Chart](https://api.star-history.com/svg?repos=JustSkyDev/JustSky-API&type=Date)](https://star-history.com/#JustSkyDev/JustSky-API&Date)
4 changes: 2 additions & 2 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"format_version": 2,
"header": {
"name": "§eJSAPI",
"name": "§eJSBedrock-API",
"description": "§cMade By §fJustSkyDev(YouTube)",
"uuid": "405e8f7a-db2d-11ed-afa1-0242ac120002",
"version": [1, 0, 0],
"version": [1, 0, 1],
"min_engine_version": [1, 20, 0]
},
"modules": [
Expand Down
3 changes: 2 additions & 1 deletion scripts/JS/@modules/export.modules.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ export { Command } from "./handlers/command/Command.Class.js";
export { CommandRegistration } from "./handlers/command/CommandRegistration.Class.js";
export { Collection } from "./handlers/data/Collection.Class.js";
export { PlayerClass } from "./handlers/entity/Player.Class.js";
//export { EntityClass } from "./handlers/entity/Entity.Class.js";
export { EntityClass } from "./handlers/entity/Entity.Class.js";
export { ChatClass } from "./handlers/message/Chat.Class.js";
export { ErrorClass } from "./handlers/message/Error.Class.js";
export { FailedClass } from "./handlers/message/Failed.Class.js";

export { Database } from "./storages/Database.Class.js";
Expand Down
26 changes: 26 additions & 0 deletions scripts/JS/@modules/handlers/command/Command.Class.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { world } from "@minecraft/server";
import { Collection } from "../data/Collection.Class.js";
import { FailedClass } from "../message/Failed.Class.js";
import { Database } from "../../storages/Database.Class.js";
import { ErrorClass } from "../message/Error.Class.js";
import * as Validation from "../../utils/Validation.Function.js";
import { Config } from "../../../config.js";

class CommandClass {
Expand All @@ -14,6 +16,8 @@ class CommandClass {
/**@private */
this.failed = new FailedClass();
/**@private */
this.error = new ErrorClass();
/**@private */
this.db = new Database("GlobalDB");
/**@private */
this.commandPrefix = this.db.get("commandPrefix") ?? Config.defaultPrefix;
Expand Down Expand Up @@ -62,6 +66,28 @@ class CommandClass {
return this.commandPrefix;
}

/**
* Set command prefix
* @param {String} prefix
*/
setPrefix(prefix) {
if (!prefix)
this.error.CustomError(
"CommandClass",
"setPrefix",
"prefix cannot be empty"
);

if (!Validation.isString(prefix))
this.error.CustomError(
"CommandClass",
"setPrefix",
"prefix must be string"
);

this.db.set("currentPrefix", prefix);
}

/**
* Execute
* @private
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Validation } from "../../export.modules.js";
import * as Validation from "../../utils/Validation.Function.js";

class CommandRegistration {
/**
Expand All @@ -12,15 +12,15 @@ class CommandRegistration {
/**@private */
this.private = false;
/**@private */
this.category = "";
this.category = "Global";
/**@private */
this.requireTags = [];
this.requireTags = [null];
/**@private */
this.aliases = [];
this.aliases = [null];
/**@private */
this.usage = [];
this.usage = [null];
/**@private */
this.example = [];
this.example = [null];
}
/**
* Set command name
Expand Down
63 changes: 63 additions & 0 deletions scripts/JS/@modules/handlers/entity/Entity.Class.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import { Entity } from "@minecraft/server";
import { ErrorClass } from "../message/Error.Class.js";

class EntityClass {
/**
* Entity class
* @param {Entity} entityObject - Entity object
*/
constructor(entityObject) {
/**@private */
this.entity = entityObject;
/**@private */
this.error = new ErrorClass();

if (!entityObject)
this.error.CustomError(
"EntityClass",
"constructor",
"EntityObject cannot be empty"
);
}

/**
* Get player all tag
* @returns {Array<String>}
* @example getTags();
*/
getTags() {
return this.entity.getTags();
}

/**
* Check player if had tag
* @param {String} tag - Tag
* @returns {Boolean}
* @example hasTag("tag");
*/
hasTag(tag) {
if (!tag)
this.error.CustomError("EntityClass", "hasTag", "tag cannot be empty");

return this.entity.hasTag(tag);
}

/**
* Get player specific tag
* @returns {Boolean|String}
* @example getSpecificTag("tag:");
*/
getSpecificTag(startswith) {
if (!this.startswith)
this.error.CustomError(
"EntityClass",
"getSpecificTagg",
"startswith cannot be empty"
);

const check = this.getTags()?.find((tag) => tag.startsWith(startswith));
return check ? check : false;
}
}

export { EntityClass };
Loading

0 comments on commit cb962f9

Please sign in to comment.