This repository has been archived by the owner on Nov 15, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
27 changed files
with
507 additions
and
190 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
node_modules | ||
node_modules | ||
test.js |
This file contains 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
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) |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
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 }; |
Oops, something went wrong.