├── .gitattributes ├── .github ├── ISSUE_TEMPLATE │ ├── bug_report.md │ └── feature_request.md ├── dependabot.yml └── workflows │ ├── cl.yml │ ├── dependency-update.yml │ └── lint-md.yml ├── .gitignore ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── legacyPackages.json ├── package-lock.json ├── package.json ├── packages └── minecraft-editor │ ├── @minecraft │ ├── server-editor-bindings.d.ts │ └── server-editor.d.ts │ ├── LICENSE.txt │ ├── README.md │ ├── ThirdPartyNotice.txt │ ├── _media │ ├── server-editor-bindings-vscode.png │ └── server-editor-vscode.png │ ├── index.d.ts │ ├── package-lock.json │ ├── package.json │ └── tsconfig.json ├── scripts ├── another-form │ ├── LICENSE │ ├── README.md │ └── index.js ├── anti-32k-event │ ├── README.md │ ├── index.js │ ├── index.ts │ └── tests.js ├── anti-32k │ ├── LICENSE │ ├── Notice.txt │ ├── README.md │ ├── index.js │ └── index.ts ├── anti-nuker │ ├── README.md │ └── index.js ├── assert │ ├── README.md │ ├── index.js │ └── index.ts ├── beta-tick-event │ ├── README.md │ └── index.js ├── bow-ding │ ├── LICENSE │ ├── README.md │ └── index.js ├── calc-player-view-offset │ ├── LICENSE │ ├── README.md │ └── index.js ├── calculate-distance │ ├── LICENSE │ ├── README.md │ └── index.js ├── chat-command │ ├── README.md │ └── index.js ├── chat-emoji-replacements │ ├── LICENSE │ ├── README.md │ └── index.js ├── chat-rank │ ├── chat-rank.js │ └── index.js ├── chat-ranks │ ├── README.md │ ├── index.d.ts │ ├── index.js │ ├── index.ts │ └── tests.js ├── color │ ├── README.md │ ├── index.js │ └── tests.js ├── command-builder │ ├── README.md │ └── index.js ├── command-handle │ ├── README.md │ └── index.js ├── command-handler │ ├── LICENSE │ ├── README.md │ └── index.js ├── command-types │ ├── README.md │ ├── blocks.d.ts │ ├── blocks.js │ ├── blocks.ts │ ├── endpoints.d.ts │ ├── endpoints.js │ ├── endpoints.ts │ ├── enums.d.ts │ ├── enums.js │ ├── enums.ts │ ├── index.d.ts │ ├── index.js │ ├── index.ts │ ├── items.d.ts │ ├── items.js │ ├── items.ts │ ├── tests.d.ts │ ├── tests.js │ ├── tests.ts │ ├── types.d.ts │ ├── types.js │ └── types.ts ├── commands │ ├── LICENSE │ ├── index.d.ts │ ├── index.js │ ├── index.ts │ ├── readme.md │ ├── tests.d.ts │ ├── tests.js │ ├── tests.ts │ └── tsconfig.json ├── compass-prompt │ ├── README.md │ └── index.js ├── con-database │ ├── LICENSE │ ├── README.md │ ├── index.d.ts │ ├── index.js │ └── test.js ├── cps-counter │ ├── LICENSE │ ├── README.md │ ├── index.js │ ├── index.ts │ └── tests.js ├── create-shockwave │ ├── LICENSE │ ├── README.md │ └── index.js ├── critical-hit │ ├── README.md │ └── index.js ├── custom-enchantments │ ├── README.md │ ├── index.d.ts │ ├── index.js │ ├── test2.js │ └── tests.js ├── database │ ├── LICENSE │ ├── README.md │ ├── index.d.ts │ ├── index.js │ ├── index.ts │ ├── tests.d.ts │ ├── tests.js │ └── tests.ts ├── delayed-function │ ├── LICENSE │ ├── README.md │ └── index.js ├── delete-command-blocks │ ├── LICENSE │ ├── README.md │ └── index.js ├── deprecate │ ├── README.md │ └── index.js ├── dimension-entities │ ├── README.md │ ├── index.js │ └── tests.js ├── dimensions │ └── index.js ├── display-names │ ├── README.md │ ├── blocks.js │ ├── blocks.ts │ ├── dimensions.js │ ├── dimensions.ts │ ├── effects.js │ ├── effects.ts │ ├── enchantments.js │ ├── enchantments.ts │ ├── entities.js │ ├── entities.ts │ ├── index.js │ ├── index.ts │ ├── items.js │ └── items.ts ├── entity-death-event │ ├── LICENSE │ ├── README.md │ ├── index.js │ └── tests.js ├── entity-hit │ ├── LICENSE │ ├── README.md │ └── index.js ├── event-listener │ ├── README.md │ ├── index.d.ts │ └── index.js ├── events-log │ ├── README.md │ ├── index.js │ └── index.ts ├── fetch-api │ ├── README.md │ └── index.js ├── fill-blocks │ ├── README.md │ ├── index.js │ └── index.ts ├── force-show │ ├── README.md │ ├── index.js │ ├── index.ts │ └── tests.js ├── full-moon │ ├── LICENSE │ ├── README.md │ └── index.js ├── gamemode │ ├── README.md │ ├── index.js │ └── tests.js ├── get-effects │ ├── README.md │ └── index.js ├── get-gamemode │ ├── README.md │ ├── index.d.ts │ ├── index.js │ ├── index.ts │ └── tests.js ├── get-item-amount │ ├── README.md │ └── index.js ├── get-level │ ├── README.md │ ├── index.js │ └── tests.js ├── get-score │ ├── README.md │ └── index.js ├── get-scores │ ├── LICENSE │ ├── get-scores-tests.js │ └── index.js ├── has-lore │ ├── README.md │ ├── index.js │ └── tests.js ├── has-permission │ ├── README.md │ ├── index.js │ └── tests.js ├── health-display │ ├── README.md │ ├── index.js │ └── index.ts ├── intl │ ├── LICENSE.txt │ ├── README.md │ ├── index.d.ts │ ├── index.js │ └── tests.js ├── is-host │ └── index.js ├── is-moving │ ├── README.md │ ├── index.js │ └── tests.js ├── is-not-op │ ├── README.md │ ├── index.js │ └── tests.js ├── is-operator │ ├── index.js │ └── tests.js ├── item-name │ ├── README.md │ └── index.js ├── jayly-task │ ├── README.md │ ├── index.js │ └── tests.js ├── jaylydb │ ├── index.d.ts │ ├── index.js │ ├── index.ts │ ├── readme.md │ ├── tests.js │ ├── tests │ │ ├── binary.js │ │ ├── corruptFix.js │ │ ├── exists.js │ │ ├── lz-string.d.ts │ │ ├── lz-string.js │ │ ├── perf.js │ │ └── sync.js │ └── tsconfig.json ├── jsconfig.json ├── json-stringify │ ├── LICENSE │ ├── README.md │ └── index.js ├── kill-death-counter │ ├── README.md │ └── index.js ├── knockback-from-point │ ├── LICENSE │ ├── README.md │ └── index.js ├── land-calculate │ ├── Readme.md │ ├── index.js │ └── tests.js ├── lz-string │ ├── LICENSE │ ├── README.md │ ├── index.d.ts │ ├── index.js │ └── lz-string-tests.js ├── minecraft-language │ ├── README.md │ ├── index.d.ts │ ├── index.js │ └── index.ts ├── net-auth │ ├── LICENSE │ ├── index.js │ ├── index.ts │ ├── package-lock.json │ ├── package.json │ ├── readme.md │ └── tests.js ├── offline-player │ ├── README.md │ ├── index.d.ts │ ├── index.js │ └── index.ts ├── page-form │ ├── README.md │ ├── example.gif │ ├── index.js │ └── tests.js ├── player-death-event │ ├── LICENSE │ ├── index.js │ ├── readme.md │ └── tests.js ├── player-exist-event │ ├── LICENSE │ ├── README.md │ ├── index.js │ └── tests.js ├── player-extra │ ├── README.md │ ├── index.d.ts │ ├── index.js │ └── index.ts ├── player-impulse │ ├── README.md │ ├── index.js │ ├── index.ts │ ├── tests.js │ └── tests.ts ├── player-leave-event │ ├── LICENSE │ ├── README.md │ ├── index.d.ts │ ├── index.js │ ├── index.ts │ └── tests.js ├── player-spawn │ ├── LICENSE │ ├── README.md │ └── index.js ├── player-velocity-fix │ ├── LICENSE │ ├── README.md │ ├── index.d.ts │ ├── index.js │ ├── index.ts │ └── tests.js ├── protoform │ ├── README.md │ ├── index.d.ts │ ├── index.js │ └── tests.js ├── quick-db │ ├── README.md │ └── index.js ├── radius-check │ ├── README.md │ └── index.js ├── random │ ├── README.md │ ├── index.js │ └── tests.js ├── remove-permission │ ├── index.js │ └── tests.js ├── restful │ ├── README.md │ ├── encoding.d.ts │ ├── encoding.js │ ├── encoding.ts │ ├── index.d.ts │ ├── index.js │ ├── index.ts │ ├── tests.d.ts │ ├── tests.js │ ├── tests.ts │ └── tsconfig.json ├── run-command-async │ ├── LICENSE │ ├── index.js │ └── run-command-async-tests.js ├── run-command │ ├── README.md │ ├── blockProperties.js │ ├── blockProperties.ts │ ├── index.js │ ├── index.ts │ └── mojang-commands.json ├── run-commands │ ├── README.md │ ├── index.js │ └── run-commands-tests.js ├── scoreboard-identity │ ├── README.md │ ├── index.js │ ├── index.ts │ ├── tests.js │ └── tests.ts ├── scoreboard-levelup │ ├── LICENSE │ ├── README.md │ └── index.js ├── scoreboard-m │ ├── README.md │ └── index.js ├── scoreboard │ ├── README.md │ ├── index.js │ └── index.ts ├── sell-items │ ├── LICENSE │ ├── README.md │ └── index.js ├── set-permission │ ├── index.js │ └── tests.js ├── set-score │ ├── README.md │ ├── getScore.js │ ├── index.js │ ├── index.ts │ └── tests.js ├── shop-wrapped │ ├── README.md │ └── index.js ├── shopui │ └── shopui.js ├── simple-db │ ├── README.md │ └── index.js ├── sleep │ ├── README.md │ └── index.js ├── spawn-simulated-player │ ├── LICENSE │ ├── README.md │ ├── index.d.ts │ ├── index.js │ ├── index.ts │ ├── tests.d.ts │ ├── tests.js │ ├── tests.ts │ └── tsconfig.json ├── structures │ ├── index.js │ └── readme.md ├── test-score │ ├── README.md │ └── index.js ├── tick-event │ ├── README.md │ ├── index.js │ └── tests.js ├── timers │ ├── LICENSE │ ├── README.md │ ├── index.d.ts │ ├── index.js │ ├── index.ts │ ├── package-lock.json │ ├── package.json │ ├── tests.d.ts │ ├── tests.js │ ├── tests.ts │ └── tsconfig.json ├── timing │ ├── README.md │ ├── index.d.ts │ └── index.js ├── to-roman-numeral │ ├── LICENSE │ ├── README.md │ └── index.js ├── trace-line-evenly-spaced │ ├── LICENSE │ ├── README.md │ └── index.js ├── tsconfig.json ├── ui-wrapper │ ├── ActionForm.js │ ├── ActionForm.ts │ ├── MessageForm.js │ ├── MessageForm.ts │ ├── ModalForm.js │ ├── ModalForm.ts │ ├── README.md │ ├── index.d.ts │ ├── index.js │ ├── index.ts │ ├── tests.js │ └── tests.ts ├── vanilla-types │ ├── README.md │ ├── index.js │ ├── index.min.js │ ├── index.ts │ ├── mojang-block.js │ ├── mojang-block.ts │ ├── mojang-cameraPresets.js │ ├── mojang-cameraPresets.ts │ ├── mojang-dimension.js │ ├── mojang-dimension.ts │ ├── mojang-effect.js │ ├── mojang-effect.ts │ ├── mojang-enchantment.js │ ├── mojang-enchantment.ts │ ├── mojang-entity.js │ ├── mojang-entity.ts │ ├── mojang-item.js │ ├── mojang-item.ts │ └── webpack.config.js ├── vanilla_data_library │ ├── README.md │ ├── index.d.ts │ ├── index.js │ └── index.ts ├── vector-polyfill │ ├── README.md │ ├── index.js │ └── tests.js ├── vector3-polyfill │ ├── BlockAreaSize.d.ts │ ├── BlockAreaSize.js │ ├── BlockAreaSize.ts │ ├── BlockLocation.d.ts │ ├── BlockLocation.js │ ├── BlockLocation.ts │ ├── Location.d.ts │ ├── Location.js │ ├── Location.ts │ ├── README.md │ ├── Vector.d.ts │ ├── Vector.js │ ├── Vector.ts │ ├── Vector3.d.ts │ ├── Vector3.js │ ├── Vector3.ts │ ├── index.d.ts │ ├── index.js │ ├── index.ts │ ├── tests.d.ts │ ├── tests.js │ ├── tests.ts │ └── tsconfig.json ├── wait-move │ ├── README.md │ └── index.js ├── world-border │ ├── README.md │ └── index.js └── world-time │ ├── README.md │ └── index.js ├── tools ├── dependency.ts ├── header-parser.ts ├── headerChecks.ts ├── index.ts ├── packageCheck.ts ├── packageReadme.ts ├── testScriptChecks.ts ├── tsconfig.json └── utils.ts ├── tsconfig-base.json └── tsconfig.json /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Report a bug about this repository 4 | title: '' 5 | labels: bug 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | 12 | **Expected behavior** 13 | 14 | **Screenshots** 15 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: enhancement 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | # To get started with Dependabot version updates, you'll need to specify which 2 | # package ecosystems to update and where the package manifests are located. 3 | # Please see the documentation for all configuration options: 4 | # https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates 5 | 6 | version: 2 7 | updates: 8 | - package-ecosystem: github-actions 9 | directory: / 10 | target-branch: "main" 11 | schedule: 12 | interval: monthly 13 | -------------------------------------------------------------------------------- /.github/workflows/lint-md.yml: -------------------------------------------------------------------------------- 1 | name: 'Link Checker' 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | pull_request: 8 | types: [ labeled ] 9 | 10 | jobs: 11 | markdown-link-check: 12 | ## this action only runs in one of the following conditons 13 | ## PR is labelled with docs tag 14 | ## It's a push commit 15 | if: ${{ (github.event.label.name == 'docs' && github.event_name == 'pull_request') || github.event_name == 'push' }} 16 | name: 'Check Links' 17 | runs-on: ubuntu-latest 18 | steps: 19 | - name: Checkout 20 | uses: actions/checkout@v4 21 | 22 | - name: Markdown links check 23 | uses: ruzickap/action-my-markdown-link-checker@v1 24 | with: 25 | exclude: | 26 | docs/ 27 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) each contributor listed at every package. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /legacyPackages.json: -------------------------------------------------------------------------------- 1 | { 2 | "packages": [ 3 | "chat-rank", 4 | "dimensions", 5 | "get-scores", 6 | "is-host", 7 | "is-operator", 8 | "lz-string", 9 | "remove-permission", 10 | "run-command-async", 11 | "set-permission", 12 | "shopui" 13 | ] 14 | } -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "script-api", 3 | "description": "this repository is filled with community driven scripts for Minecraft scripting", 4 | "version": "1.0.0", 5 | "scripts": { 6 | "test": "tsc", 7 | "build": "tsc --build", 8 | "tools": "cd tools && tsc", 9 | "ci": "cd scripts && tsc" 10 | }, 11 | "repository": { 12 | "type": "git", 13 | "url": "git+https://github.com/JaylyDev/ScriptAPI.git" 14 | }, 15 | "keywords": [], 16 | "license": "MIT", 17 | "bugs": { 18 | "url": "https://github.com/JaylyDev/ScriptAPI/issues" 19 | }, 20 | "homepage": "https://github.com/JaylyDev/ScriptAPI#readme", 21 | "overrides": { 22 | "@minecraft/server": "2.0.0-beta.1.21.80-preview.22", 23 | "@minecraft/vanilla-data": "1.21.80-preview.22" 24 | }, 25 | "dependencies": { 26 | "@minecraft/server-admin": "1.0.0-beta.1.21.80-preview.22", 27 | "@minecraft/server-editor": "0.1.0-beta.1.21.80-preview.22", 28 | "@minecraft/server-gametest": "1.0.0-beta.1.21.80-preview.22", 29 | "@minecraft/server-net": "1.0.0-beta.1.21.80-preview.22", 30 | "@minecraft/server-ui": "2.0.0-beta.1.21.80-preview.22" 31 | }, 32 | "devDependencies": { 33 | "@minecraft/math": "^2.2.1", 34 | "@npm/types": "^2.0.0", 35 | "@types/node": "^22.14.0", 36 | "@types/parsimmon": "^1.10.9", 37 | "axios": "^1.8.4", 38 | "parsimmon": "^1.18.1", 39 | "typescript": "^5.8.2" 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /packages/minecraft-editor/LICENSE.txt: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) Jayly. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /packages/minecraft-editor/_media/server-editor-bindings-vscode.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JaylyDev/ScriptAPI/fda8df9ad2061efade76806872a28c7c767f241a/packages/minecraft-editor/_media/server-editor-bindings-vscode.png -------------------------------------------------------------------------------- /packages/minecraft-editor/_media/server-editor-vscode.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JaylyDev/ScriptAPI/fda8df9ad2061efade76806872a28c7c767f241a/packages/minecraft-editor/_media/server-editor-vscode.png -------------------------------------------------------------------------------- /packages/minecraft-editor/index.d.ts: -------------------------------------------------------------------------------- 1 | // Type definitions for Minecraft Bedrock Edition editor APIs 0.3 2 | // Project: https://github.com/JaylyDev/ScriptAPI 3 | // Definitions by: Jayly 4 | /// 5 | /// 6 | -------------------------------------------------------------------------------- /packages/minecraft-editor/package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@jayly/minecraft-editor", 3 | "version": "0.3.7-0", 4 | "lockfileVersion": 2, 5 | "requires": true, 6 | "packages": { 7 | "": { 8 | "name": "@jayly/minecraft-editor", 9 | "version": "0.3.7-0", 10 | "license": "MIT", 11 | "dependencies": { 12 | "@minecraft/server": "1.4.0-beta.1.20.10-preview.23" 13 | } 14 | }, 15 | "node_modules/@minecraft/server": { 16 | "version": "1.4.0-beta.1.20.10-preview.23", 17 | "resolved": "https://registry.npmjs.org/@minecraft/server/-/server-1.4.0-beta.1.20.10-preview.23.tgz", 18 | "integrity": "sha512-FWVpE1L4t9JJnV17xzd1epA7eYBJHjaSaYVwAuSwcdU2Bo/EKjRP0V4lDpzvM1LvFvtZDccfJg2Z3ononrfmEQ==" 19 | } 20 | }, 21 | "dependencies": { 22 | "@minecraft/server": { 23 | "version": "1.4.0-beta.1.20.10-preview.23", 24 | "resolved": "https://registry.npmjs.org/@minecraft/server/-/server-1.4.0-beta.1.20.10-preview.23.tgz", 25 | "integrity": "sha512-FWVpE1L4t9JJnV17xzd1epA7eYBJHjaSaYVwAuSwcdU2Bo/EKjRP0V4lDpzvM1LvFvtZDccfJg2Z3ononrfmEQ==" 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /packages/minecraft-editor/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@jayly/minecraft-editor", 3 | "version": "0.3.7-0", 4 | "description": "Unofficial Minecraft Bedrock Editor API modules type definitions.", 5 | "types": "index.d.ts", 6 | "main": "", 7 | "repository": { 8 | "type": "git", 9 | "url": "git+https://github.com/JaylyDev/ScriptAPI.git" 10 | }, 11 | "author": "Jayly", 12 | "license": "MIT", 13 | "bugs": { 14 | "url": "https://github.com/JaylyDev/ScriptAPI/issues" 15 | }, 16 | "homepage": "https://github.com/JaylyDev/ScriptAPI#readme", 17 | "dependencies": { 18 | "@minecraft/server": "1.4.0-beta.1.20.10-preview.23" 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /packages/minecraft-editor/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "ES2022", 4 | "lib": ["es6"], 5 | "declaration": true, 6 | "esModuleInterop": true, 7 | "moduleResolution": "node", 8 | "target": "esnext", 9 | "forceConsistentCasingInFileNames": true, 10 | "strict": true, 11 | }, 12 | "files": ["index.d.ts", "@minecraft/server-editor.d.ts", "@minecraft/server-editor-bindings.d.ts"] 13 | } 14 | -------------------------------------------------------------------------------- /scripts/another-form/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 FrankyRayMS 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /scripts/another-form/README.md: -------------------------------------------------------------------------------- 1 | # another-form 2 | 3 | ## Description 4 | 5 | Demostration of showing another Minecraft UI form after a player confirms or cancels the dialog. 6 | 7 | ## Credits 8 | 9 | These scripts were written by [FrankyRayMS](https://github.com/FrankyRay) 10 | -------------------------------------------------------------------------------- /scripts/another-form/index.js: -------------------------------------------------------------------------------- 1 | // Script example for ScriptAPI 2 | // Author: FrankyRayMS 3 | // Project: https://github.com/JaylyDev/ScriptAPI 4 | 5 | import { world } from "@minecraft/server"; 6 | import { ActionFormData } from "@minecraft/server-ui" 7 | 8 | const player = [...world.getPlayers()][0]; 9 | new ActionFormData() 10 | .title("First form") 11 | .body("This is first form") 12 | .button("Button to another form") 13 | .show(player).then(r => { 14 | if (r.selection == 0) anotherUI(player) 15 | }); 16 | 17 | /** 18 | * @param {import("@minecraft/server").Player} player 19 | */ 20 | function anotherUI(player) { 21 | // This function ONLY hold one form 22 | // Not accessing another form 23 | // outside function 24 | const anotherForm = new ActionFormData() 25 | .title("Another Form") 26 | .body("This is another form") 27 | .button("Useless button") 28 | 29 | anotherForm.show(player).then() 30 | }; -------------------------------------------------------------------------------- /scripts/anti-32k-event/README.md: -------------------------------------------------------------------------------- 1 | # anti-32k-event 2 | 3 | ## Description 4 | 5 | Emits `incompatibleEnchantment` event when the script checks a players inventory every tick then it tests positive that they have any banned items. 6 | 7 | Usage: 8 | 9 | ```js 10 | import { incompatibleEnchantment } from "./index"; 11 | 12 | incompatibleEnchantment.subscribe((event) => { 13 | event.enchantment; 14 | event.exceedMaxLevel; 15 | event.incompatibleEnchantmentType; 16 | event.item; 17 | event.source; 18 | }); 19 | ``` 20 | 21 | ## Credits 22 | 23 | These scripts were written by [JaylyMC](https://github.com/JaylyDev) 24 | -------------------------------------------------------------------------------- /scripts/anti-32k-event/tests.js: -------------------------------------------------------------------------------- 1 | import { incompatibleEnchantment } from "anti-32k-event/index"; 2 | 3 | incompatibleEnchantment.subscribe((event) => { 4 | event.enchantment; 5 | event.exceedMaxLevel; 6 | event.incompatibleEnchantmentType; 7 | event.item; 8 | event.source; 9 | }); -------------------------------------------------------------------------------- /scripts/anti-32k/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 JaylyDev 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /scripts/anti-32k/README.md: -------------------------------------------------------------------------------- 1 | # anti-32k 2 | 3 | ## Description 4 | 5 | Minecraft Bedrock Anti Hacked Items 6 | 7 | This is a anti hacked items, meaning it checks a players inventory every tick then it tests if they have any banned items, then checks if they have items that have hacked enchants and clears the item from inventory. 8 | 9 | ## Credits 10 | 11 | These scripts were written by [Smell of curry](https://github.com/smell-of-curry), [JaylyMC](https://github.com/JaylyDev), [Remember M9](https://github.com/Remember-M9) 12 | -------------------------------------------------------------------------------- /scripts/anti-nuker/README.md: -------------------------------------------------------------------------------- 1 | # anti-nuker 2 | 3 | ## Description 4 | 5 | This script checks whether a player has the hack "Nuker" enabled through the use of block break event. 6 | 7 | ## Credits 8 | 9 | These scripts were written by [iBlqzed](https://github.com/iBlqzed) 10 | -------------------------------------------------------------------------------- /scripts/assert/README.md: -------------------------------------------------------------------------------- 1 | # assert 2 | 3 | ## Description 4 | A function to test if a value is equal to true, an error is thrown otherwise. Used for unit tests. 5 | 6 | ## Credits 7 | These scripts were written by [Jayly](https://github.com/JaylyDev) 8 | -------------------------------------------------------------------------------- /scripts/beta-tick-event/README.md: -------------------------------------------------------------------------------- 1 | # beta-tick-event 2 | 3 | ## Description 4 | 5 | Tick Event wrapper that was released when Minecraft first announce removal of `TickEvent` 6 | 7 | ## Credits 8 | 9 | These scripts were written by [mrpatches123](https://github.com/mrpatches123) 10 | -------------------------------------------------------------------------------- /scripts/bow-ding/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 JaylyDev 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /scripts/bow-ding/README.md: -------------------------------------------------------------------------------- 1 | # bow-ding 2 | 3 | ## Description 4 | 5 | Creates a 'ding' sound when a player hits the other player with a bow. 6 | 7 | ## Credits 8 | 9 | These scripts were written by [JaylyDev](https://github.com/JaylyDev) 10 | -------------------------------------------------------------------------------- /scripts/bow-ding/index.js: -------------------------------------------------------------------------------- 1 | // Script example for ScriptAPI 2 | // Author: JaylyDev 3 | // Project: https://github.com/JaylyDev/ScriptAPI 4 | import { Player, world } from "@minecraft/server"; 5 | 6 | world.afterEvents.entitySpawn.subscribe(({ entity }) => { 7 | // Since you cannot retrive projectile infomation from projectileHit event, we have to 8 | // subscribe to entitySpawn event to compare with the projectile information fired by projectileHit event. 9 | if (entity.typeId !== "minecraft:arrow") return; 10 | 11 | const callback = world.afterEvents.projectileHitEntity.subscribe((arg) => { 12 | const { source, projectile } = arg; 13 | const hitInfo = arg.getEntityHit(); 14 | 15 | if (hitInfo?.entity instanceof Player && source instanceof Player && projectile === entity) { 16 | /** @type {import("@minecraft/server").PlayerSoundOptions} */ 17 | const soundOption = { 18 | volume: 0.4, 19 | pitch: 0.5, 20 | } 21 | 22 | source.playSound("random.orb", soundOption); 23 | world.afterEvents.projectileHitEntity.unsubscribe(callback); 24 | }; 25 | }); 26 | }); 27 | 28 | -------------------------------------------------------------------------------- /scripts/calc-player-view-offset/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 GlitchyTurtle32 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /scripts/calc-player-view-offset/README.md: -------------------------------------------------------------------------------- 1 | # calc-player-view-offset 2 | 3 | ## Description 4 | 5 | Calculate player's vector offset. 6 | 7 | ## Credits 8 | 9 | These scripts were written by [GlitchyTurtle32](https://github.com/GlitchyTurtle) 10 | -------------------------------------------------------------------------------- /scripts/calc-player-view-offset/index.js: -------------------------------------------------------------------------------- 1 | // Script example for ScriptAPI 2 | // Author: GlitchyTurtle32 3 | // Project: https://github.com/JaylyDev/ScriptAPI 4 | 5 | import { Player } from "@minecraft/server"; 6 | 7 | /** 8 | * @param {import("@minecraft/server").Vector3} vector 9 | * @param {number} s 10 | */ 11 | function normalizeVector (vector,s) { 12 | let l = Math.hypot(vector.x,vector.y,vector.z) 13 | return { 14 | x: s * (vector.x/l), 15 | y: s * (vector.y/l), 16 | z: s * (vector.z/l) 17 | } 18 | } 19 | 20 | /** 21 | * @param {Player} player 22 | * @param {number} xf 23 | * @param {number} yf 24 | * @param {number} zf 25 | */ 26 | export function calcVectorOffset (player, xf, yf, zf, d = player.getViewDirection(), l = player.location) { 27 | let m = Math.hypot(d.x, d.z); 28 | let xx = normalizeVector({ 29 | x: d.z, 30 | y: 0, 31 | z: -d.x 32 | }, xf); 33 | let yy = normalizeVector({ 34 | x: (d.x / m) * -d.y, 35 | y: m, 36 | z: (d.z / m) * -d.y 37 | }, yf); 38 | let zz = normalizeVector(d, zf); 39 | 40 | return { 41 | x: l.x + xx.x + yy.x + zz.x, 42 | y: l.y + xx.y + yy.y + zz.y, 43 | z: l.z + xx.z + yy.z + zz.z 44 | }; 45 | } -------------------------------------------------------------------------------- /scripts/calculate-distance/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 GlitchyTurtle32 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /scripts/calculate-distance/README.md: -------------------------------------------------------------------------------- 1 | # calculate-distance 2 | 3 | ## Description 4 | 5 | Calculate distance 6 | 7 | ## Credits 8 | 9 | These scripts were written by [GlitchyTurtle32](https://github.com/GlitchyTurtle) 10 | -------------------------------------------------------------------------------- /scripts/calculate-distance/index.js: -------------------------------------------------------------------------------- 1 | // Script example for ScriptAPI 2 | // Author: GlitchyTurtle32 3 | // Project: https://github.com/JaylyDev/ScriptAPI 4 | function magnitude(vector) { 5 | return Math.sqrt(vector.x * vector.x + vector.y * vector.y + vector.z * vector.z); 6 | } 7 | 8 | function calculateDistance(posA, posB) { 9 | let direction = { 10 | x: posA.x - posB.x, 11 | y: posA.y - posB.y, 12 | z: posA.z - posB.z 13 | }; 14 | return magnitude(direction); 15 | } -------------------------------------------------------------------------------- /scripts/chat-command/README.md: -------------------------------------------------------------------------------- 1 | # chat-command 2 | 3 | ## Description 4 | 5 | Creates a `!help` command. 6 | 7 | ## Credits 8 | 9 | These scripts were written by 𝖘𝖆𝖓 𝕵𝖚𝖌𝖘#9251 on Bedrock Add-Ons 10 | -------------------------------------------------------------------------------- /scripts/chat-command/index.js: -------------------------------------------------------------------------------- 1 | // Script example for ScriptAPI 2 | // Author: 𝖘𝖆𝖓 𝕵𝖚𝖌𝖘#9251 3 | // Project: https://github.com/JaylyDev/ScriptAPI 4 | 5 | import * as Minecraft from "@minecraft/server"; 6 | 7 | let prefix = "!"; 8 | 9 | Minecraft.world.beforeEvents.chatSend.subscribe((data) => { 10 | if (data.message.toLowerCase().startsWith(`${prefix}help`)) { 11 | data.cancel = true; 12 | data.sender.runCommandAsync(`tellraw @s {"rawtext":[{"text":"hello"}]}`); 13 | } 14 | }); 15 | -------------------------------------------------------------------------------- /scripts/chat-emoji-replacements/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 GlitchyTurtle32 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /scripts/chat-emoji-replacements/README.md: -------------------------------------------------------------------------------- 1 | # chat-emoji-replacements 2 | 3 | ## Description 4 | 5 | Replaces chat emoji when a player types name of emojis in chat. 6 | 7 | ## Credits 8 | 9 | These scripts were written by [GlitchyTurtle32](https://github.com/GlitchyTurtle) 10 | -------------------------------------------------------------------------------- /scripts/chat-emoji-replacements/index.js: -------------------------------------------------------------------------------- 1 | // Script example for ScriptAPI 2 | // Author: GlitchyTurtle32 3 | // Project: https://github.com/JaylyDev/ScriptAPI 4 | import { world } from "@minecraft/server"; 5 | 6 | // How to create emojis? https://wiki.bedrock.dev/concepts/emojis.html 7 | const replacements = { 8 | "armor": "", 9 | "minecoin": "", 10 | "food": "" 11 | }; 12 | 13 | /** 14 | * @param {import("@minecraft/server").ChatSendBeforeEvent} msg 15 | */ 16 | function beforeChat(msg) { 17 | const player = msg.sender; 18 | 19 | let message = msg.message; 20 | let regex = new RegExp(":" + Object.keys(replacements).join(":|:") + ":", "g"); 21 | 22 | // Replaces the word with emoji if it has :: around it. :armor: ->  23 | message = message.replace(regex, (/** @type {string} */ match) => { return replacements[match.replaceAll(":", "")] + "§r" }); 24 | 25 | world.sendMessage(`<${player.name}> ${message.replace(/\\"/g, '"')}`); 26 | msg.cancel = true; 27 | } 28 | 29 | world.beforeEvents.chatSend.subscribe(msg => beforeChat(msg)); -------------------------------------------------------------------------------- /scripts/chat-rank/chat-rank.js: -------------------------------------------------------------------------------- 1 | import { world } from "@minecraft/server"; 2 | 3 | world.beforeEvents.chatSend.subscribe((data) => { 4 | world.sendMessage({ 5 | rawtext: [ 6 | { 7 | text: 8 | "§l§8[§r" + 9 | (data.sender 10 | .getTags() 11 | .find((tag) => tag.startsWith("rank:")) 12 | ?.substring(5) 13 | ?.replaceAll("--", "§r§l§8][§r") ?? "§bMember") + 14 | `§l§8]§r §7${data.sender.nameTag}:§r ${data.message}`, 15 | }, 16 | ], 17 | }); 18 | data.cancel = true; 19 | }); 20 | -------------------------------------------------------------------------------- /scripts/chat-rank/index.js: -------------------------------------------------------------------------------- 1 | // Script examples for ScriptAPI 2 | // Author: WavePlayz 3 | 4 | // command: /tag @s add rank:Owner 5 | import { world } from "@minecraft/server"; 6 | 7 | world.beforeEvents.chatSend.subscribe((eventData) => { 8 | const { message, sender } = eventData; 9 | 10 | let rank = sender 11 | .getTags() 12 | .find((tag) => tag.startsWith("rank:")) 13 | ?.split(":")[1]; 14 | 15 | if (!rank) return; 16 | 17 | eventData.cancel = true; 18 | 19 | world.sendMessage(rank + " " + sender.name + ": " + message); 20 | }); 21 | -------------------------------------------------------------------------------- /scripts/chat-ranks/README.md: -------------------------------------------------------------------------------- 1 | # chat-ranks 2 | 3 | ## Description 4 | 5 | Gets chat ranks from a player and display in chat when player messages. 6 | 7 | ## Credits 8 | 9 | These scripts were written by [Smell of curry](https://github.com/smell-of-curry) 10 | -------------------------------------------------------------------------------- /scripts/chat-ranks/index.d.ts: -------------------------------------------------------------------------------- 1 | export {}; 2 | -------------------------------------------------------------------------------- /scripts/chat-ranks/index.js: -------------------------------------------------------------------------------- 1 | // Script example for ScriptAPI 2 | // Author: Smell of curry 3 | // Project: https://github.com/JaylyDev/ScriptAPI 4 | import { world } from "@minecraft/server"; 5 | /** 6 | * The prefix that is added before a rank tag 7 | * @example `/tag @s add "RANK_PREFIX"member` 8 | */ 9 | const RANK_PREFIX = "rank:"; 10 | /** 11 | * The default Rank that the player has in chat with no ranks 12 | */ 13 | const DEFAULT_RANK = "§bMember"; 14 | /** 15 | * Gets chat ranks from a player 16 | * @param player 17 | * @returns ranks player has 18 | */ 19 | function getRanks(player) { 20 | const ranks = player 21 | .getTags() 22 | .map((v) => { 23 | if (!v.startsWith(RANK_PREFIX)) 24 | return null; 25 | return v.substring(RANK_PREFIX.length); 26 | }) 27 | .filter((x) => x); 28 | return ranks.length == 0 ? [DEFAULT_RANK] : ranks; 29 | } 30 | world.beforeEvents.chatSend.subscribe((data) => { 31 | const ranks = getRanks(data.sender).join("§r§l§8][§r"); 32 | const message = data.message; 33 | world.sendMessage(`§r§l§8[§r${ranks}§r§l§8]§r§7 ${data.sender.name}:§r ${message}`); 34 | data.cancel = true; 35 | }); 36 | -------------------------------------------------------------------------------- /scripts/chat-ranks/index.ts: -------------------------------------------------------------------------------- 1 | // Script example for ScriptAPI 2 | // Author: Smell of curry 3 | // Project: https://github.com/JaylyDev/ScriptAPI 4 | import { Player, world } from "@minecraft/server"; 5 | 6 | /** 7 | * The prefix that is added before a rank tag 8 | * @example `/tag @s add "RANK_PREFIX"member` 9 | */ 10 | const RANK_PREFIX = "rank:"; 11 | 12 | /** 13 | * The default Rank that the player has in chat with no ranks 14 | */ 15 | const DEFAULT_RANK = "§bMember"; 16 | 17 | /** 18 | * Gets chat ranks from a player 19 | * @param player 20 | * @returns ranks player has 21 | */ 22 | function getRanks(player: Player): string[] { 23 | const ranks = player 24 | .getTags() 25 | .map((v) => { 26 | if (!v.startsWith(RANK_PREFIX)) return null; 27 | return v.substring(RANK_PREFIX.length); 28 | }) 29 | .filter((x) => x); 30 | return ranks.length == 0 ? [DEFAULT_RANK] : ranks; 31 | } 32 | 33 | world.beforeEvents.chatSend.subscribe((data) => { 34 | const ranks = getRanks(data.sender).join("§r§l§8][§r"); 35 | const message = data.message; 36 | world.sendMessage(`§r§l§8[§r${ranks}§r§l§8]§r§7 ${data.sender.name}:§r ${message}`); 37 | data.cancel = true; 38 | }); 39 | -------------------------------------------------------------------------------- /scripts/chat-ranks/tests.js: -------------------------------------------------------------------------------- 1 | import { system, world } from "@minecraft/server"; 2 | import isHost from "is-host/index"; 3 | 4 | world.afterEvents.playerSpawn.subscribe(({player}) => { 5 | system.run(() => { 6 | if (isHost(player)) player.addTag('rank:Owner'); 7 | }); 8 | }); -------------------------------------------------------------------------------- /scripts/color/README.md: -------------------------------------------------------------------------------- 1 | # color 2 | 3 | ## Description 4 | 5 | Class for Color interface in `@minecraft/server` - Represents a fully customizable color within Minecraft. 6 | 7 | ## Credits 8 | 9 | These scripts were written by [xKingDark](https://github.com/DarkGamerYT) 10 | -------------------------------------------------------------------------------- /scripts/color/index.js: -------------------------------------------------------------------------------- 1 | // Script example for ScriptAPI 2 | // Author: xKingDark 3 | // Project: https://github.com/DarkGamerYT/Bedrock-Editor-Extension 4 | export class Color { 5 | /** 6 | * 7 | * @param {number} r 8 | * @param {number} g 9 | * @param {number} b 10 | * @param {number} a 11 | * @returns 12 | */ 13 | constructor(r, g, b, a) { 14 | this.red = r; 15 | this.green = g; 16 | this.blue = b; 17 | this.alpha = a; 18 | }; 19 | }; -------------------------------------------------------------------------------- /scripts/color/tests.js: -------------------------------------------------------------------------------- 1 | import { Color } from "./index"; 2 | 3 | const color = new Color(1, 1, 1, 1); 4 | 5 | color.red 6 | color.green 7 | color.blue 8 | color.alpha 9 | -------------------------------------------------------------------------------- /scripts/command-handle/README.md: -------------------------------------------------------------------------------- 1 | # command-handle 2 | 3 | ## Description 4 | 5 | A script that detects a chat message then the script handles all custom command inputs and outputs 6 | 7 | ## Credits 8 | 9 | These scripts were written by [Smell of Curry](https://github.com/smell-of-curry) 10 | -------------------------------------------------------------------------------- /scripts/command-handler/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 JaylyDev 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /scripts/command-handler/README.md: -------------------------------------------------------------------------------- 1 | # command-handler 2 | 3 | ## Description 4 | 5 | Wrapper of running commands via `Dimension.runCommand` 6 | 7 | ## Credits 8 | 9 | These scripts were written by [Jayly](https://github.com/JaylyDev) 10 | -------------------------------------------------------------------------------- /scripts/command-handler/index.js: -------------------------------------------------------------------------------- 1 | // Script example for ScriptAPI 2 | // Author: Jayly 3 | // Project: https://github.com/JaylyDev/ScriptAPI 4 | import { world } from "@minecraft/server"; 5 | 6 | /** 7 | * @param {string} command 8 | */ 9 | export function runCommand(command) { 10 | try { 11 | return world.getDimension('overworld').runCommand(command); 12 | } catch (e) { 13 | return JSON.parse(e) 14 | }; 15 | } 16 | -------------------------------------------------------------------------------- /scripts/command-types/README.md: -------------------------------------------------------------------------------- 1 | # command-types 2 | 3 | ## Description 4 | 5 | 6 | ## Credits 7 | These scripts were written by [bot174](https://github.com/bot174) 8 | -------------------------------------------------------------------------------- /scripts/command-types/endpoints.js: -------------------------------------------------------------------------------- 1 | export {}; 2 | -------------------------------------------------------------------------------- /scripts/command-types/index.d.ts: -------------------------------------------------------------------------------- 1 | export * from './blocks'; 2 | export * from './endpoints'; 3 | export * from './enums'; 4 | export * from './items'; 5 | export * from './types'; 6 | -------------------------------------------------------------------------------- /scripts/command-types/index.js: -------------------------------------------------------------------------------- 1 | // Script example for ScriptAPI 2 | // Author: bot174 3 | // Project: https://github.com/JaylyDev/ScriptAPI 4 | export * from './blocks'; 5 | export * from './endpoints'; 6 | export * from './enums'; 7 | export * from './items'; 8 | export * from './types'; 9 | -------------------------------------------------------------------------------- /scripts/command-types/index.ts: -------------------------------------------------------------------------------- 1 | // Script example for ScriptAPI 2 | // Author: bot174 3 | // Project: https://github.com/JaylyDev/ScriptAPI 4 | export * from './blocks'; 5 | export * from './endpoints'; 6 | export * from './enums'; 7 | export * from './items'; 8 | export * from './types'; -------------------------------------------------------------------------------- /scripts/command-types/tests.d.ts: -------------------------------------------------------------------------------- 1 | import { CommandEndpoints } from "./index"; 2 | export declare function runCommandAsync(commandString: CommandEndpoints): Promise; 3 | -------------------------------------------------------------------------------- /scripts/command-types/tests.js: -------------------------------------------------------------------------------- 1 | import { world } from "@minecraft/server"; 2 | export function runCommandAsync(commandString) { 3 | return world.getDimension("overworld").runCommandAsync(commandString); 4 | } 5 | ; 6 | runCommandAsync("setblock 0 100 0 air"); 7 | -------------------------------------------------------------------------------- /scripts/command-types/tests.ts: -------------------------------------------------------------------------------- 1 | import { CommandEndpoints } from "./index"; 2 | import { world } from "@minecraft/server"; 3 | 4 | export function runCommandAsync (commandString: CommandEndpoints) { 5 | return world.getDimension("overworld").runCommandAsync(commandString); 6 | }; 7 | 8 | runCommandAsync("setblock 0 100 0 air"); -------------------------------------------------------------------------------- /scripts/command-types/types.d.ts: -------------------------------------------------------------------------------- 1 | export type ID = string; 2 | export type SELECTION = string; 3 | export type VAL = number; 4 | export type RVAL = VAL; 5 | export type INT = number; 6 | export type POSITION = `${number | "~"} ${number | "~"} ${number | "~"}`; 7 | export type POSITION_FLOAT = POSITION; 8 | export type BLOCK_STATE_ARRAY = string; 9 | export type JSON_OBJECT = string; 10 | export type SLASHCOMMAND = string; 11 | export type postfix_l = `${number}l`; 12 | export type RAWTEXT = string; 13 | export type MESSAGE_ROOT = string; 14 | export type WILDCARDSELECTION = SELECTION; 15 | export type OPERATOR = "==" | "!=" | "<" | ">" | "<=" | ">="; 16 | export type COMPAREOPERATOR = OPERATOR; 17 | export type WILDCARDINT = number; 18 | export type PATHCOMMAND = string; 19 | export type FULLINTEGERRANGE = number; 20 | export type Postfix_l = `${number}l`; 21 | -------------------------------------------------------------------------------- /scripts/command-types/types.js: -------------------------------------------------------------------------------- 1 | export {}; 2 | -------------------------------------------------------------------------------- /scripts/command-types/types.ts: -------------------------------------------------------------------------------- 1 | export type ID = string; 2 | export type SELECTION = string; 3 | export type VAL = number; 4 | export type RVAL = VAL; 5 | export type INT = number; 6 | export type POSITION = `${number | "~"} ${number | "~"} ${number | "~"}`; 7 | export type POSITION_FLOAT = POSITION; 8 | export type BLOCK_STATE_ARRAY = string; 9 | export type JSON_OBJECT = string; 10 | export type SLASHCOMMAND = string; 11 | export type postfix_l = `${number}l`; 12 | export type RAWTEXT = string; 13 | export type MESSAGE_ROOT = string; 14 | export type WILDCARDSELECTION = SELECTION; 15 | export type OPERATOR = "==" | "!=" | "<" | ">" | "<=" | ">="; 16 | export type COMPAREOPERATOR = OPERATOR; 17 | export type WILDCARDINT = number; 18 | export type PATHCOMMAND = string; 19 | export type FULLINTEGERRANGE = number; 20 | export type Postfix_l = `${number}l`; 21 | -------------------------------------------------------------------------------- /scripts/commands/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 JaylyDev 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /scripts/commands/tests.d.ts: -------------------------------------------------------------------------------- 1 | export {}; 2 | -------------------------------------------------------------------------------- /scripts/commands/tests.js: -------------------------------------------------------------------------------- 1 | import { Commands } from "./index.js"; 2 | let timerB = Date.now(); 3 | Commands.runAsync("say Hello World in async"); 4 | console.warn(`Commands.runAsync time: ${Date.now() - timerB} ms`); 5 | Commands.register("#", "sayhi", function (res) { 6 | res.player.runCommandAsync(`say hi ${[...res.argv].join(", ")}`); 7 | }); 8 | console.log("End of test"); 9 | -------------------------------------------------------------------------------- /scripts/commands/tests.ts: -------------------------------------------------------------------------------- 1 | import { Commands } from "./index.js"; 2 | 3 | let timerB = Date.now(); 4 | Commands.runAsync("say Hello World in async"); 5 | console.warn(`Commands.runAsync time: ${Date.now() - timerB} ms`); 6 | 7 | Commands.register("#", "sayhi", function (res) { 8 | res.player.runCommandAsync(`say hi ${[...res.argv].join(", ")}`); 9 | }); 10 | 11 | console.log("End of test"); -------------------------------------------------------------------------------- /scripts/commands/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ES5", 4 | "lib": ["ES2015", "DOM"], 5 | "forceConsistentCasingInFileNames": true, 6 | "noImplicitAny": true, 7 | "noImplicitThis": true, 8 | "strictFunctionTypes": true, 9 | "strictNullChecks": true, 10 | "baseUrl": ".", 11 | "types": [], 12 | "downlevelIteration": true 13 | }, 14 | "files": [ 15 | "index.ts", 16 | "tests.ts" 17 | ], 18 | "extends": "../tsconfig.json" 19 | } -------------------------------------------------------------------------------- /scripts/compass-prompt/README.md: -------------------------------------------------------------------------------- 1 | # compass-prompt 2 | 3 | ## Description 4 | 5 | Showcase of popup a dialog whenever user interacts with a compass 6 | 7 | ## Credits 8 | 9 | These scripts were written by [Jayly](https://github.com/JaylyDev) 10 | -------------------------------------------------------------------------------- /scripts/compass-prompt/index.js: -------------------------------------------------------------------------------- 1 | // Script example for ScriptAPI 2 | // Author: Jayly 3 | // Project: https://github.com/JaylyDev/ScriptAPI 4 | import { Player, world } from "@minecraft/server" 5 | import { ActionFormData } from "@minecraft/server-ui" 6 | 7 | const gui = new ActionFormData() 8 | gui.title('§l§bServer Gui') 9 | gui.body('§l§fHere are all functions you can use in this gui') 10 | gui.button('§l§aShop') 11 | gui.button('§l§cWarps') 12 | gui.button('§l§8Teleport request') 13 | gui.button('§l§bBank') 14 | gui.button('§l§eMoney Transactions') 15 | 16 | world.beforeEvents.itemUse.subscribe(data => { 17 | const source = data.source 18 | if (!(source instanceof Player)) return; 19 | if (data.itemStack.typeId === 'minecraft:compass') gui.show(source).then(result => { 20 | if (result.canceled) console.warn('GUI was canceled') 21 | if (result.selection === 0) source.runCommandAsync('give @s diamond 1') 22 | if (result.selection === 1) source.runCommandAsync('give @s diamond 1') 23 | if (result.selection === 2) source.runCommandAsync('give @s diamond 1') 24 | if (result.selection === 3) source.runCommandAsync('give @s diamond 1') 25 | if (result.selection === 2) source.runCommandAsync('give @s diamond 1') 26 | }) 27 | }); 28 | -------------------------------------------------------------------------------- /scripts/con-database/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 ConMaster2112 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /scripts/con-database/test.js: -------------------------------------------------------------------------------- 1 | import { JsonDatabase } from "./index"; 2 | 3 | const a = new JsonDatabase("SUS").load(); 4 | a.set("sussy",(a.get("sussy")??0) + 1); 5 | 6 | console.warn("Current sussy count is " + a.get("sussy")); -------------------------------------------------------------------------------- /scripts/cps-counter/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 JaylyDev 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /scripts/cps-counter/README.md: -------------------------------------------------------------------------------- 1 | # cps-counter 2 | 3 | ## Description 4 | 5 | A function to get player's clicks in a second 6 | 7 | ## Credits 8 | 9 | These scripts were written by [Jayly](https://github.com/JaylyDev) 10 | -------------------------------------------------------------------------------- /scripts/cps-counter/tests.js: -------------------------------------------------------------------------------- 1 | import { world } from "@minecraft/server"; 2 | import { getPlayerCPS } from "./index"; 3 | 4 | world.beforeEvents.chatSend.subscribe((evd) => { 5 | evd.sender.runCommandAsync(`say CPS: ${getPlayerCPS(evd.sender)}`); 6 | }); -------------------------------------------------------------------------------- /scripts/create-shockwave/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 GlitchyTurtle32 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /scripts/create-shockwave/README.md: -------------------------------------------------------------------------------- 1 | # create-shockwave 2 | 3 | ## Description 4 | 5 | Creates shockwave for player 6 | 7 | ## Credits 8 | 9 | These scripts were written by [GlitchyTurtle32](https://github.com/GlitchyTurtle) 10 | -------------------------------------------------------------------------------- /scripts/critical-hit/README.md: -------------------------------------------------------------------------------- 1 | # critical-hit 2 | 3 | ## Description 4 | > This README is auto generated, Edit the README so that users know what this package does. 5 | 6 | ## Credits 7 | These scripts were written by [Jayly](https://github.com/JaylyDev) 8 | -------------------------------------------------------------------------------- /scripts/custom-enchantments/README.md: -------------------------------------------------------------------------------- 1 | # custom-enchantments 2 | 3 | ## Description 4 | 5 | Custom enchantments 6 | 7 | ## Credits 8 | 9 | These scripts were written by [iBlqzed](https://github.com/iBlqzed) 10 | -------------------------------------------------------------------------------- /scripts/custom-enchantments/test2.js: -------------------------------------------------------------------------------- 1 | // Script examples for ScriptAPI 2 | // Author: Jayly#1397 3 | // Project: https://github.com/JaylyDev/ScriptAPI 4 | // https://github.com/JaylyDev/ScriptAPI/issues/112 5 | 6 | import { Container, world } from "@minecraft/server" 7 | import { addEnchant, Enchant } from "./index" 8 | 9 | const bleedEnchant = new Enchant({ 10 | name: "bleed", 11 | display: "§cBleed" 12 | }) 13 | 14 | bleedEnchant.onHurt(data => { 15 | data.hurtEntity.runCommandAsync(`say testeo`) 16 | world.sendMessage("hello world") 17 | }) 18 | 19 | world.beforeEvents.chatSend.subscribe(data => { 20 | /** 21 | * @type {Container} 22 | */ 23 | //@ts-ignore 24 | const inv = data.sender.getComponent("inventory").container 25 | const item = inv.getItem(data.sender.selectedSlotIndex) 26 | addEnchant(item, 'bleed', 5) 27 | inv.setItem(data.sender.selectedSlotIndex, item) 28 | }) 29 | -------------------------------------------------------------------------------- /scripts/custom-enchantments/tests.js: -------------------------------------------------------------------------------- 1 | import { Container, world } from "@minecraft/server" 2 | import { addEnchant, Enchant } from "./index" 3 | 4 | const bleedEnchant = new Enchant({ 5 | name: "bleed", 6 | display: "§cBleed" 7 | }) 8 | 9 | bleedEnchant.onHurt(data => { 10 | data.hurtEntity.runCommandAsync(`damage @s 2`) 11 | }) 12 | 13 | world.beforeEvents.chatSend.subscribe(data => { 14 | /** 15 | * @type {Container} 16 | */ 17 | //@ts-ignore 18 | const inv = data.sender.getComponent("inventory").container 19 | const item = inv.getItem(data.sender.selectedSlotIndex) 20 | addEnchant(item, 'bleed', 5) 21 | inv.setItem(data.sender.selectedSlotIndex, item) 22 | }) 23 | -------------------------------------------------------------------------------- /scripts/database/LICENSE: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JaylyDev/ScriptAPI/fda8df9ad2061efade76806872a28c7c767f241a/scripts/database/LICENSE -------------------------------------------------------------------------------- /scripts/database/README.md: -------------------------------------------------------------------------------- 1 | # database 2 | 3 | ## Description 4 | 5 | Database 6 | 7 | ## Credits 8 | 9 | These scripts were written by [iBlqzed](https://github.com/iBlqzed) 10 | -------------------------------------------------------------------------------- /scripts/database/tests.d.ts: -------------------------------------------------------------------------------- 1 | export {}; 2 | -------------------------------------------------------------------------------- /scripts/database/tests.js: -------------------------------------------------------------------------------- 1 | // Script example for ScriptAPI 2 | // Author: iBlqzed 3 | // Project: https://github.com/JaylyDev/ScriptAPI 4 | import { Database } from "./index.js"; 5 | const myDatabase = new Database("thing"); 6 | myDatabase.set("key", "value"); 7 | myDatabase.get("key"); //Should return "value" 8 | -------------------------------------------------------------------------------- /scripts/database/tests.ts: -------------------------------------------------------------------------------- 1 | // Script example for ScriptAPI 2 | // Author: iBlqzed 3 | // Project: https://github.com/JaylyDev/ScriptAPI 4 | import { Database } from "./index.js"; 5 | 6 | const myDatabase = new Database("thing") 7 | myDatabase.set("key", "value") 8 | myDatabase.get("key") //Should return "value" -------------------------------------------------------------------------------- /scripts/delayed-function/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 GlitchyTurtle32 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /scripts/delayed-function/README.md: -------------------------------------------------------------------------------- 1 | # delayed-function 2 | 3 | ## Description 4 | 5 | Demostration of delaying a function 6 | 7 | ## Credits 8 | 9 | These scripts were written by [GlitchyTurtle32](https://github.com/GlitchyTurtle) 10 | -------------------------------------------------------------------------------- /scripts/delayed-function/index.js: -------------------------------------------------------------------------------- 1 | // Script example for ScriptAPI 2 | // Author: GlitchyTurtle32 3 | // Project: https://github.com/JaylyDev/ScriptAPI 4 | import { Player, system } from "@minecraft/server"; 5 | 6 | /** 7 | * @param {Player} player 8 | * @param {(arg0: Player) => void} func 9 | */ 10 | export function delayedFunc(player, func, tickDelay = 1) { 11 | const sched_ID = system.runInterval(()=>{ 12 | system.clearRun(sched_ID); 13 | func(player); 14 | }, tickDelay); 15 | }; -------------------------------------------------------------------------------- /scripts/delete-command-blocks/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 JaylyDev 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /scripts/delete-command-blocks/README.md: -------------------------------------------------------------------------------- 1 | # delete-command-blocks 2 | 3 | ## Description 4 | 5 | Delete command blocks all around the world. 6 | 7 | ## Credits 8 | 9 | These scripts were written by [JaylyDev](https://github.com/JaylyDev) 10 | -------------------------------------------------------------------------------- /scripts/delete-command-blocks/index.js: -------------------------------------------------------------------------------- 1 | // Script example for ScriptAPI 2 | // Author: JaylyDev 3 | // Project: https://github.com/JaylyDev/ScriptAPI 4 | import { 5 | world, 6 | system, 7 | BlockPermutation, 8 | BlockVolume, 9 | } from "@minecraft/server"; 10 | import { MinecraftBlockTypes } from "@minecraft/vanilla-data"; 11 | 12 | const commandBlocks = [ 13 | MinecraftBlockTypes.CommandBlock, 14 | MinecraftBlockTypes.ChainCommandBlock, 15 | MinecraftBlockTypes.RepeatingCommandBlock, 16 | ]; 17 | 18 | function DeleteCommandBlocks() { 19 | for (const player of world.getPlayers()) { 20 | for (let commandBlock of commandBlocks) { 21 | for (let index = 0; index < 384 / 32; index++) { 22 | const { x, z } = player.location; 23 | const y = index * 32 - 64; 24 | 25 | player.dimension.fillBlocks( 26 | new BlockVolume( 27 | { 28 | x: x - 15, 29 | y: y, 30 | z: z - 15, 31 | }, 32 | { 33 | x: x + 16, 34 | y: y + 31, 35 | z: z + 16, 36 | } 37 | ), 38 | MinecraftBlockTypes.Air, 39 | { 40 | blockFilter: { 41 | includePermutations: [BlockPermutation.resolve(commandBlock)], 42 | }, 43 | } 44 | ); 45 | } 46 | } 47 | } 48 | } 49 | 50 | system.runInterval(DeleteCommandBlocks); 51 | -------------------------------------------------------------------------------- /scripts/deprecate/README.md: -------------------------------------------------------------------------------- 1 | # deprecate 2 | 3 | ## Description 4 | 5 | Deprecate a function 6 | 7 | ## Credits 8 | 9 | These scripts were written by Jayly#1397 on Jayly Discord 10 | -------------------------------------------------------------------------------- /scripts/dimension-entities/README.md: -------------------------------------------------------------------------------- 1 | # dimension-entities 2 | 3 | ## Description 4 | > This README is auto generated, Edit the README so that users know what this package does. 5 | 6 | ## Credits 7 | These scripts were written by Jayly#1397 on Jayly Discord 8 | -------------------------------------------------------------------------------- /scripts/dimension-entities/index.js: -------------------------------------------------------------------------------- 1 | // Script example for ScriptAPI 2 | // Author: Jayly#1397 3 | // Project: https://github.com/JaylyDev/ScriptAPI 4 | import { Dimension, world } from "@minecraft/server"; 5 | 6 | /** 7 | * Get entities that are in specific dimension 8 | * @param {Dimension} dimension 9 | * @param {import("@minecraft/server").EntityQueryOptions} [options] 10 | */ 11 | export function getEntities(dimension, options) { 12 | const mergedOptions = { 13 | minDistance: 0, 14 | ...(typeof options.minDistance !== 'undefined' ? { minDistance: options.minDistance } : {}) 15 | }; 16 | return dimension.getEntities(mergedOptions); 17 | }; 18 | 19 | /** 20 | * Get players that are in specific dimension 21 | * @param {Dimension} dimension 22 | * @param {import("@minecraft/server").EntityQueryOptions} [options] 23 | */ 24 | export function getPlayers(dimension, options) { 25 | const mergedOptions = { 26 | minDistance: 0, 27 | ...(typeof options.minDistance !== 'undefined' ? { minDistance: options.minDistance } : {}) 28 | }; 29 | return dimension.getPlayers(mergedOptions); 30 | }; -------------------------------------------------------------------------------- /scripts/dimension-entities/tests.js: -------------------------------------------------------------------------------- 1 | import { GameMode, world } from "@minecraft/server"; 2 | import { getEntities, getPlayers } from "dimension-entities/index"; 3 | import { MinecraftEffectTypes } from "@minecraft/vanilla-data"; 4 | 5 | const overworldEntities = getEntities(world.getDimension('overworld')); 6 | 7 | for (const entity of overworldEntities) { 8 | entity.addEffect(MinecraftEffectTypes.Absorption, 10); 9 | }; 10 | 11 | const netherCreativePlayers = getPlayers(world.getDimension('nether'), { 12 | 'gameMode': GameMode.creative 13 | }); 14 | 15 | for (const player of netherCreativePlayers) { 16 | player.sendMessage('Hello nether!'); 17 | } -------------------------------------------------------------------------------- /scripts/display-names/README.md: -------------------------------------------------------------------------------- 1 | # display-names 2 | 3 | ## Description 4 | 5 | Library for enum mapping to Minecraft internal translation keys. 6 | 7 | ```js 8 | import { MinecraftBlocks, MinecraftItems } from "display-blocks"; 9 | player.sendMessage("10x " + MinecraftBlocks.EndRod); 10 | // 10x End Rod 11 | player.sendMessage("20x " + MinecraftItems.Slimeball); 12 | // 20x Slimeball 13 | ``` 14 | 15 | ## Credits 16 | 17 | These scripts were written by [bot174](https://github.com/bot174) 18 | -------------------------------------------------------------------------------- /scripts/display-names/dimensions.js: -------------------------------------------------------------------------------- 1 | /** 2 | * All possible MinecraftDimensions 3 | */ 4 | export var MinecraftDimensions; 5 | (function (MinecraftDimensions) { 6 | MinecraftDimensions["Nether"] = "%dimension.dimensionName1"; 7 | MinecraftDimensions["Overworld"] = "%dimension.dimensionName0"; 8 | MinecraftDimensions["TheEnd"] = "%dimension.dimensionName2"; 9 | })(MinecraftDimensions || (MinecraftDimensions = {})); 10 | -------------------------------------------------------------------------------- /scripts/display-names/dimensions.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * All possible MinecraftDimensions 3 | */ 4 | export enum MinecraftDimensions { 5 | Nether = "%dimension.dimensionName1", 6 | Overworld = "%dimension.dimensionName0", 7 | TheEnd = "%dimension.dimensionName2" 8 | } 9 | -------------------------------------------------------------------------------- /scripts/display-names/effects.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * All possible MinecraftEffects 3 | */ 4 | export enum MinecraftEffects { 5 | Absorption = "%potion.absorption", 6 | BadOmen = "%effect.badOmen", 7 | Blindness = "%potion.blindness", 8 | ConduitPower = "%potion.conduitPower", 9 | Darkness = "%effect.darkness", 10 | Empty = "%potion.empty", 11 | FatalPoison = "%potion.poison", 12 | FireResistance = "%potion.fireResistance", 13 | Haste = "%potion.digSpeed", 14 | HealthBoost = "%potion.healthBoost", 15 | Hunger = "%potion.hunger", 16 | InstantDamage = "%potion.harm", 17 | InstantHealth = "%potion.heal", 18 | Invisibility = "%potion.invisibility", 19 | JumpBoost = "%potion.jump", 20 | Levitation = "%potion.levitation", 21 | MiningFatigue = "%potion.digSlowDown", 22 | Nausea = "%potion.confusion", 23 | NightVision = "%potion.nightVision", 24 | Poison = "%potion.poison", 25 | Regeneration = "%potion.regeneration", 26 | Resistance = "%potion.resistance", 27 | Saturation = "%potion.saturation", 28 | SlowFalling = "%potion.slowFalling", 29 | Slowness = "%potion.slowness", 30 | Speed = "%potion.speed", 31 | Strength = "%potion.damageBoost", 32 | VillageHero = "%effect.villageHero", 33 | WaterBreathing = "%potion.waterBreathing", 34 | Weakness = "%potion.weakness", 35 | Wither = "%potion.wither" 36 | } 37 | -------------------------------------------------------------------------------- /scripts/display-names/index.js: -------------------------------------------------------------------------------- 1 | // Script example for ScriptAPI 2 | // Author: bot174 3 | // Project: https://github.com/JaylyDev/ScriptAPI 4 | export * from './blocks'; 5 | export * from './dimensions'; 6 | export * from './effects'; 7 | export * from './enchantments'; 8 | export * from './entities'; 9 | export * from './items'; 10 | -------------------------------------------------------------------------------- /scripts/display-names/index.ts: -------------------------------------------------------------------------------- 1 | // Script example for ScriptAPI 2 | // Author: bot174 3 | // Project: https://github.com/JaylyDev/ScriptAPI 4 | export * from './blocks'; 5 | export * from './dimensions'; 6 | export * from './effects'; 7 | export * from './enchantments'; 8 | export * from './entities'; 9 | export * from './items'; 10 | -------------------------------------------------------------------------------- /scripts/entity-death-event/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 JaylyDev 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /scripts/entity-death-event/README.md: -------------------------------------------------------------------------------- 1 | # entity-death-event 2 | 3 | ## Description 4 | 5 | Fires a callback when an entity dies 6 | 7 | ## Credits 8 | 9 | These scripts were written by Jayly#1397 on Jayly Discord 10 | -------------------------------------------------------------------------------- /scripts/entity-death-event/tests.js: -------------------------------------------------------------------------------- 1 | // Script example for ScriptAPI 2 | // Author: Jayly#1397 3 | // Project: https://github.com/JaylyDev/ScriptAPI 4 | import { EntityDeathEventSignal } from "./index.js"; 5 | 6 | const entityDeath = new EntityDeathEventSignal(); 7 | 8 | let callback = entityDeath.subscribe((evd) => { 9 | evd.hurtEntity.runCommandAsync("say this entity is dead"); 10 | 11 | entityDeath.unsubscribe(callback); 12 | }); -------------------------------------------------------------------------------- /scripts/entity-hit/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 MajestikButter 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /scripts/entity-hit/README.md: -------------------------------------------------------------------------------- 1 | # entity-hit 2 | 3 | ## Description 4 | 5 | Kills entity if they have been hit by an entity (not player) 6 | 7 | ## Credits 8 | 9 | These scripts were written by [MajestikButter](https://github.com/MajestikButter) 10 | -------------------------------------------------------------------------------- /scripts/entity-hit/index.js: -------------------------------------------------------------------------------- 1 | // Script example for ScriptAPI 2 | // Author: MajestikButter 3 | // Project: https://github.com/JaylyDev/ScriptAPI 4 | import { EntityHealthComponent, world } from "@minecraft/server"; 5 | 6 | world.afterEvents.entityHitEntity.subscribe((evd) => { 7 | if (evd.damagingEntity.typeId !== 'minecraft:player') return; 8 | 9 | const ent = evd.hitEntity; 10 | if (!ent) return; 11 | 12 | /** 13 | * @type {EntityHealthComponent} 14 | */ 15 | // @ts-ignore 16 | const h = ent.getComponent('health'); 17 | if (!h) return; 18 | h.setCurrentValue(h.currentValue - 100); 19 | }); 20 | -------------------------------------------------------------------------------- /scripts/event-listener/README.md: -------------------------------------------------------------------------------- 1 | # event-listener 2 | 3 | ## Description 4 | 5 | Wrapper for listening world and system events. 6 | 7 | ## Credits 8 | 9 | These scripts were written by [JaylyDev](https://github.com/JaylyDev) 10 | -------------------------------------------------------------------------------- /scripts/event-listener/index.d.ts: -------------------------------------------------------------------------------- 1 | // Script example for ScriptAPI 2 | // Author: JaylyDev 3 | // Project: https://github.com/JaylyDev/ScriptAPI 4 | import { WorldAfterEvents, SystemAfterEvents } from "@minecraft/server"; 5 | declare type OnSystemEvent = [0]>(eventType: eventType, listener: listener) => listener; 6 | declare type OffSystemEvent = (eventType: eventType, listener: Parameters[0]) => void; 7 | declare const addSystemEventListener: OnSystemEvent; 8 | declare const removeSystemEventListener: OffSystemEvent; 9 | export { addSystemEventListener, removeSystemEventListener }; 10 | declare type OnEvent = [0]>(eventType: eventType, listener: listener) => listener; 11 | declare type OffEvent = (eventType: eventType, listener: Parameters[0]) => void; 12 | declare const addEventListener: OnEvent; 13 | declare const removeEventListener: OffEvent; 14 | export { addEventListener, removeEventListener }; 15 | -------------------------------------------------------------------------------- /scripts/event-listener/index.js: -------------------------------------------------------------------------------- 1 | // Script example for ScriptAPI 2 | // Author: JaylyDev 3 | // Project: https://github.com/JaylyDev/ScriptAPI 4 | import { system, world } from "@minecraft/server"; 5 | const addSystemEventListener = (eventType, listener) => { 6 | return system.afterEvents[eventType].subscribe(listener); 7 | }; 8 | const removeSystemEventListener = (eventType, listener) => { 9 | return system.afterEvents[eventType].unsubscribe(listener); 10 | }; 11 | export { addSystemEventListener, removeSystemEventListener }; 12 | const addEventListener = (eventType, listener) => { 13 | return world.afterEvents[eventType].subscribe(listener); 14 | }; 15 | const removeEventListener = (eventType, listener) => { 16 | return world.afterEvents[eventType].unsubscribe(listener); 17 | }; 18 | export { addEventListener, removeEventListener }; 19 | -------------------------------------------------------------------------------- /scripts/events-log/README.md: -------------------------------------------------------------------------------- 1 | # events-log 2 | 3 | ## Description 4 | Event logger. 5 | 6 | ## Credits 7 | These scripts were written by [bot174](https://github.com/bot174) 8 | -------------------------------------------------------------------------------- /scripts/events-log/index.js: -------------------------------------------------------------------------------- 1 | // Script example for ScriptAPI 2 | // Author: bot174 3 | // Project: https://github.com/JaylyDev/ScriptAPI 4 | import { system, world } from "@minecraft/server"; 5 | // This is a callback function. It will be called when the event is triggered. 6 | // This code is run in an engine with JSON stringify exposes native objects directly. 7 | const callback = (event) => { 8 | console.log(JSON.stringify(event)); 9 | world.sendMessage(system.currentTick + ' - ' + event.constructor.name); 10 | }; 11 | system.afterEvents.scriptEventReceive.subscribe(callback); 12 | -------------------------------------------------------------------------------- /scripts/events-log/index.ts: -------------------------------------------------------------------------------- 1 | // Script example for ScriptAPI 2 | // Author: bot174 3 | // Project: https://github.com/JaylyDev/ScriptAPI 4 | import { system, world } from "@minecraft/server"; 5 | 6 | // This is a callback function. It will be called when the event is triggered. 7 | // This code is run in an engine with JSON stringify exposes native objects directly. 8 | const callback = (event: object) => { 9 | console.log(JSON.stringify(event)); 10 | world.sendMessage(system.currentTick + ' - ' + event.constructor.name); 11 | }; 12 | 13 | system.afterEvents.scriptEventReceive.subscribe(callback); 14 | 15 | -------------------------------------------------------------------------------- /scripts/fill-blocks/README.md: -------------------------------------------------------------------------------- 1 | # fill-blocks 2 | 3 | ## Description 4 | 5 | Fills an area between begin and end with block of type block, with no fill limit of 32768. 6 | 7 | ### Parameters 8 | 9 | - `dimension` Dimension to fill blocks in. 10 | - `begin` The lower northwest starting corner of the area. 11 | - `end` The upper southeast ending corner of the area. 12 | - `block` Type of block to fill the volume with. 13 | - `options` A set of additional options, such as a matching block to potentially replace this fill block with. 14 | 15 | ### returns 16 | 17 | Number of blocks filled 18 | 19 | ### example 20 | 21 | `fillBlocks.js` 22 | 23 | ```js 24 | fillBlocks( 25 | world.getDimension("overworld"), 26 | { x, y, z }, 27 | { x: x + 10000, y: y + 10, z: z + 100 }, 28 | MinecraftBlockTypes.stone 29 | ); 30 | ``` 31 | 32 | ## Credits 33 | 34 | These scripts were written by Jayly#1397 on Jayly Discord 35 | -------------------------------------------------------------------------------- /scripts/force-show/README.md: -------------------------------------------------------------------------------- 1 | # force-show 2 | 3 | ## Description 4 | 5 | Force the game to show a UI form to player. 6 | 7 | ## Credits 8 | 9 | These scripts were written by Jayly#1397 on Jayly Discord, Worldwidebrine#9037 on Bedrock Add-Ons 10 | -------------------------------------------------------------------------------- /scripts/force-show/index.js: -------------------------------------------------------------------------------- 1 | // Script example for ScriptAPI 2 | // Author: Jayly 3 | // Worldwidebrine#9037 4 | // Project: https://github.com/JaylyDev/ScriptAPI 5 | import { system } from "@minecraft/server"; 6 | import { FormCancelationReason } from "@minecraft/server-ui"; 7 | /** 8 | * @remarks 9 | * Creates and force the API to show a popup form to player. 10 | * Returns asynchronously when the player confirms or cancels the dialog. 11 | * @param player Player to show this dialog to. 12 | * @param form Dialog to show the player to. 13 | * @param timeout Amount of time, in ticks, before the request times out and is abandoned. 14 | * @throws This function can throw errors. 15 | */ 16 | export async function forceShow(player, form, timeout = Infinity) { 17 | const startTick = system.currentTick; 18 | while ((system.currentTick - startTick) < timeout) { 19 | const response = await form.show(player); 20 | if (response.cancelationReason !== FormCancelationReason.UserBusy) { 21 | return response; 22 | } 23 | ; 24 | } 25 | ; 26 | throw new Error(`Timed out after ${timeout} ticks`); 27 | } 28 | ; 29 | -------------------------------------------------------------------------------- /scripts/full-moon/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 GlitchyTurtle32 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /scripts/full-moon/README.md: -------------------------------------------------------------------------------- 1 | # full-moon 2 | 3 | ## Description 4 | 5 | Check if it's full moon 6 | 7 | ## Credits 8 | 9 | These scripts were written by [GlitchyTurtle32](https://github.com/GlitchyTurtle) 10 | -------------------------------------------------------------------------------- /scripts/full-moon/index.js: -------------------------------------------------------------------------------- 1 | // Script example for ScriptAPI 2 | // Author: GlitchyTurtle32 3 | // Project: https://github.com/JaylyDev/ScriptAPI 4 | import { world } from "@minecraft/server"; 5 | 6 | const FULL_MOON = ((world.getAbsoluteTime() - world.getTimeOfDay()) / 24000) % 8 == 0; 7 | const NIGHT_TIME = world.getTimeOfDay() > 12000; 8 | 9 | if (FULL_MOON && NIGHT_TIME) { 10 | // Code goes here! 11 | } -------------------------------------------------------------------------------- /scripts/gamemode/README.md: -------------------------------------------------------------------------------- 1 | # gamemode 2 | 3 | ## Description 4 | 5 | Get/Set the game mode for an entity. 6 | 7 | ## Credits 8 | 9 | These scripts were written by Jayly#1397 on Jayly Discord 10 | -------------------------------------------------------------------------------- /scripts/gamemode/tests.js: -------------------------------------------------------------------------------- 1 | import { getGamemode, setGamemode } from 'gamemode/index'; 2 | import { world, GameMode } from '@minecraft/server'; 3 | 4 | world.afterEvents.chatSend.subscribe(({sender}) => { 5 | getGamemode(sender).then(res => { sender.sendMessage(res) }); 6 | setGamemode(sender, GameMode.creative); 7 | }); 8 | -------------------------------------------------------------------------------- /scripts/get-effects/README.md: -------------------------------------------------------------------------------- 1 | # GetEffects 2 | 3 | Return list of object contain `EffectType` class and `Effecf` class. This will allow us to get the effect identifier when `Effect` class doesn't have `typeId` property. 4 | 5 | ## How to use? 6 | 7 | ```js 8 | import { system } from "@minecraft/server"; 9 | import getEffects from "./getEffects"; 10 | 11 | // Check if player has absorbtion effect 12 | system.runInterval(() => { 13 | for (const player of world.getPlayers()) { 14 | const absorbtion = getEffects(player) 15 | .find((eff) => eff.effectType.getName() === "minecraft:absorbtion"); 16 | if (!absorbtion) continue; 17 | 18 | console.warn(`${player.name} has absorbtion`) 19 | } 20 | }, 20) 21 | ``` 22 | 23 | ## Properties 24 | 25 | - `effectType: EffectType` 26 | Get effect identifier 27 | `return`: [EffectType](https://learn.microsoft.com/en-us/minecraft/creator/scriptapi/minecraft/server/effecttype) 28 | 29 | - `effect: Effect` 30 | Get effect amplifier and duration 31 | `return`: [Effect](https://learn.microsoft.com/en-us/minecraft/creator/scriptapi/minecraft/server/effect) 32 | -------------------------------------------------------------------------------- /scripts/get-effects/index.js: -------------------------------------------------------------------------------- 1 | // Script example for ScriptAPI 2 | // Author: FrankyRayMS 3 | // Project: https://github.com/JaylyDev/ScriptAPI 4 | 5 | import { 6 | /* Typings only */ 7 | Entity, 8 | Player, 9 | Effect, 10 | EffectType, 11 | EffectTypes 12 | } from "@minecraft/server"; 13 | 14 | /** 15 | * Get every effect from the entity 16 | * 17 | * @param {Entity|Player} entity 18 | * Entity or Player class 19 | * 20 | * @return {{ effectType: EffectType, effect: Effect }[]} 21 | */ 22 | export function getEffects(entity) { 23 | const effectList = []; 24 | for (const eff of EffectTypes.getAll()) { 25 | const effect = entity.getEffect(eff); 26 | if (!effect) continue; 27 | effectList.push({ 28 | effectType: eff, 29 | effect: effect 30 | }); 31 | }; 32 | 33 | return effectList; 34 | }; 35 | -------------------------------------------------------------------------------- /scripts/get-gamemode/README.md: -------------------------------------------------------------------------------- 1 | # get-gamemode 2 | 3 | ## Description 4 | 5 | Gets the Gamemode of a player 6 | 7 | ## Credits 8 | 9 | These scripts were written by Jayly#1397 on Jayly Discord, [Smell of Curry](https://github.com/smell-of-curry) 10 | -------------------------------------------------------------------------------- /scripts/get-gamemode/index.d.ts: -------------------------------------------------------------------------------- 1 | import { GameMode, Player } from "@minecraft/server"; 2 | /** 3 | * Gets the Gamemode of a player 4 | * @author Smell of Curry 5 | * @param {Player} player player to get 6 | * @returns {GameMode} 7 | * @example if (getGamemode(player) == "creative") return; 8 | */ 9 | export declare function getGamemode(player: Player): GameMode; 10 | -------------------------------------------------------------------------------- /scripts/get-gamemode/index.js: -------------------------------------------------------------------------------- 1 | // Script example for ScriptAPI 2 | // Author: Jayly#1397 3 | // Smell of Curry 4 | // Project: https://github.com/JaylyDev/ScriptAPI 5 | import { GameMode, world } from "@minecraft/server"; 6 | /** 7 | * Gets the Gamemode of a player 8 | * @author Smell of Curry 9 | * @param {Player} player player to get 10 | * @returns {GameMode} 11 | * @example if (getGamemode(player) == "creative") return; 12 | */ 13 | export function getGamemode(player) { 14 | return Object.values(GameMode).find((g) => [...world.getPlayers({ name: player.name, gameMode: g })].length); 15 | } 16 | -------------------------------------------------------------------------------- /scripts/get-gamemode/index.ts: -------------------------------------------------------------------------------- 1 | // Script example for ScriptAPI 2 | // Author: Jayly#1397 3 | // Smell of Curry 4 | // Project: https://github.com/JaylyDev/ScriptAPI 5 | import { GameMode, Player, world } from "@minecraft/server"; 6 | 7 | /** 8 | * Gets the Gamemode of a player 9 | * @author Smell of Curry 10 | * @param {Player} player player to get 11 | * @returns {GameMode} 12 | * @example if (getGamemode(player) == "creative") return; 13 | */ 14 | export function getGamemode(player: Player): GameMode { 15 | return Object.values(GameMode).find( 16 | (g) => [...world.getPlayers({ name: player.name, gameMode: g })].length 17 | ); 18 | } -------------------------------------------------------------------------------- /scripts/get-gamemode/tests.js: -------------------------------------------------------------------------------- 1 | // Script example for ScriptAPI 2 | // Author: Jayly#1397 3 | import { world } from "@minecraft/server"; 4 | import { getGamemode } from "get-gamemode/index"; 5 | 6 | world.beforeEvents.chatSend.subscribe((event) => { 7 | if (event.message !== 'gamemode') return; 8 | const gamemode = getGamemode(event.sender); 9 | event.sender.sendMessage('GameMode' + gamemode); 10 | }) -------------------------------------------------------------------------------- /scripts/get-item-amount/README.md: -------------------------------------------------------------------------------- 1 | # get-item-amount 2 | 3 | ## Description 4 | 5 | Check item amount from a player inventory 6 | 7 | ## Credits 8 | 9 | These scripts were written by Herobrine64#3928 on Bedrock Add-Ons 10 | -------------------------------------------------------------------------------- /scripts/get-item-amount/index.js: -------------------------------------------------------------------------------- 1 | // Script example for ScriptAPI 2 | // Author: Herobrine64#3928 3 | // Project: https://github.com/JaylyDev/ScriptAPI 4 | 5 | import { EntityInventoryComponent, Player } from "@minecraft/server"; 6 | 7 | /** 8 | * Check item amount from a player inventory 9 | * @param {Player} player 10 | * @param {string} itemId 11 | * @param {boolean} clearItems 12 | * @returns {number} item amount 13 | */ 14 | export function checkItemAmount(player, itemId, clearItems = false) { 15 | const component = player.getComponent("minecraft:inventory"); 16 | const inventory = component.container; 17 | let itemAmount = 0; 18 | for (let i = 0; i < 36; i++) { 19 | let item = inventory.getItem(i); 20 | if (item?.typeId != itemId) continue; 21 | itemAmount += item.amount; 22 | if (clearItems) inventory.setItem(i); 23 | }; 24 | return itemAmount; 25 | } 26 | -------------------------------------------------------------------------------- /scripts/get-level/README.md: -------------------------------------------------------------------------------- 1 | # get-level 2 | 3 | ## Description 4 | 5 | Get player experience level without using runCommand 6 | 7 | ## Credits 8 | 9 | These scripts were written by [Jayly#1397](https://github.com/JaylyDev) 10 | -------------------------------------------------------------------------------- /scripts/get-level/index.js: -------------------------------------------------------------------------------- 1 | // Script example for ScriptAPI 2 | // Author: Jayly#1397 3 | // Project: https://github.com/JaylyDev/ScriptAPI 4 | 5 | import { world, Player } from '@minecraft/server'; 6 | 7 | /** 8 | * Get player experience level without using runCommand 9 | * @param {Player} player 10 | * @returns Player experience level 11 | */ 12 | export function getPlayerExperienceLevel (player) { 13 | let minLevel = 0; 14 | let maxLevel = 24791; 15 | let distance = maxLevel - minLevel; 16 | let playerIndex = -1; 17 | 18 | // bisection algorithm is used here to find level 19 | while (minLevel !== maxLevel) { 20 | playerIndex = [...world.getPlayers({ minLevel, maxLevel })].findIndex((pl) => pl === player); 21 | if (playerIndex > -1) { 22 | maxLevel -= Math.round(distance / 2); 23 | } 24 | else if (playerIndex === -1) { 25 | minLevel = maxLevel; 26 | maxLevel = maxLevel * 2; 27 | }; 28 | distance = maxLevel - minLevel; 29 | }; 30 | 31 | if (minLevel === 0 && maxLevel === 0 && playerIndex === 0) return 0; 32 | else return minLevel + 1; 33 | }; 34 | -------------------------------------------------------------------------------- /scripts/get-level/tests.js: -------------------------------------------------------------------------------- 1 | import { system, world } from "@minecraft/server"; 2 | import { getPlayerExperienceLevel } from "get-level/index"; 3 | 4 | system.runInterval(() => { 5 | for (const player of world.getAllPlayers()) { 6 | player.sendMessage(`Player level: ${getPlayerExperienceLevel(player)}`); 7 | } 8 | }); -------------------------------------------------------------------------------- /scripts/get-score/README.md: -------------------------------------------------------------------------------- 1 | # get-score 2 | 3 | ## Description 4 | 5 | Gets the score recorded for {displayName} on {objective} 6 | 7 | ### Parameters 8 | 9 | `player: Player` or entity on the scoreboard 10 | `objectiveId: String` Objective Identifer to get from 11 | `rNull: Boolean` If the return should be null if its not found or 0. 12 | 13 | ### returns 14 | 15 | `Number` - Score that Was recorded for {Player} on {Objective} 16 | 17 | ### example 18 | 19 | ```js 20 | getScore(player, "objective"): number 21 | ``` 22 | 23 | ## Credits 24 | 25 | These scripts were written by [iBlqzed](https://github.com/iblqzed) 26 | -------------------------------------------------------------------------------- /scripts/get-score/index.js: -------------------------------------------------------------------------------- 1 | // Script example for ScriptAPI 2 | // Author: iBlqzed 3 | // Project: https://github.com/JaylyDev/ScriptAPI 4 | 5 | import { Player, world } from "@minecraft/server"; 6 | /** 7 | * Gets the score recorded for {displayName} on {objective} 8 | * @param {Player} player or entity on the scoreboard 9 | * @param {String} objectiveId Objective Identifer to get from 10 | * @param {Boolean} rNull If the return should be null if its not found or 0. 11 | * @returns {Number} Score that Was recorded for {Player} on {Objective} 12 | * @example getScore(player, "objective"): number 13 | */ 14 | export function getScore(player, objectiveId, rNull = false) { 15 | try { 16 | return world.scoreboard 17 | .getObjective(objectiveId) 18 | .getScore(player.scoreboardIdentity); 19 | } catch (error) { 20 | return rNull ? null : 0; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /scripts/get-scores/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 JaylyDev 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /scripts/get-scores/get-scores-tests.js: -------------------------------------------------------------------------------- 1 | import { getScore, getScores } from "./index.js"; 2 | import { world } from "@minecraft/server"; 3 | 4 | let player = [...world.getPlayers()][0]; 5 | 6 | getScores(player); 7 | 8 | getScore(player, "myObjective"); 9 | -------------------------------------------------------------------------------- /scripts/get-scores/index.js: -------------------------------------------------------------------------------- 1 | import { Player, Entity, world, ScoreboardIdentityType, ScoreboardIdentity, ScoreboardObjective } from "@minecraft/server"; 2 | 3 | /** 4 | * Get all scoreboard scores from a player or entity. 5 | * Does not support fake player. 6 | * @param {Player | Entity} target 7 | * @return {object} 8 | */ 9 | export function getScores (target) { 10 | let objectives = world.scoreboard.getObjectives(); 11 | let targetScoreboard = {}; 12 | 13 | if (!(target.scoreboardIdentity instanceof ScoreboardIdentity)) return targetScoreboard; 14 | for (const objective of objectives) targetScoreboard[objective.id] = objective.getScores().find((score) => score.participant.type !== ScoreboardIdentityType.FakePlayer ? score.participant.getEntity() === target : false)?.score; 15 | return targetScoreboard; 16 | }; 17 | 18 | /** 19 | * Get scoreboard scores from a player or entity. 20 | * Does not support fake player. 21 | * @param {Player | Entity} target 22 | * @param {string} objectiveId 23 | * @return {number} 24 | */ 25 | export function getScore (target, objectiveId) { 26 | let objective = world.scoreboard.getObjective(objectiveId); 27 | 28 | if (!(target.scoreboardIdentity instanceof ScoreboardIdentity)) return; 29 | if (!(objective instanceof ScoreboardObjective)) return; 30 | 31 | try { 32 | return objective.getScore(target.scoreboardIdentity); 33 | } catch (err) { 34 | console.error(err); 35 | }; 36 | }; 37 | -------------------------------------------------------------------------------- /scripts/has-lore/README.md: -------------------------------------------------------------------------------- 1 | # has-lore 2 | 3 | ## Description 4 | 5 | Returns true if item has lore 6 | 7 | ## Credits 8 | 9 | These scripts were written by Andrew2005#8409 on Bedrock Add-Ons, Remember M9#8416 on Bedrock Add-Ons, ! MP09#1650 on Bedrock Add-Ons 10 | -------------------------------------------------------------------------------- /scripts/has-lore/index.js: -------------------------------------------------------------------------------- 1 | // Script example for ScriptAPI 2 | // Author: Andrew2005#8409 3 | // Remember M9#8416 4 | // ! MP09#1650 5 | // Project: https://github.com/JaylyDev/ScriptAPI 6 | 7 | import { ItemStack } from '@minecraft/server'; 8 | /** 9 | * @param {ItemStack} item 10 | */ 11 | export function hasLore (item) { 12 | return item.getLore().length > 0 13 | } 14 | -------------------------------------------------------------------------------- /scripts/has-lore/tests.js: -------------------------------------------------------------------------------- 1 | // Script example for ScriptAPI 2 | // Author: Andrew2005#8409 3 | // Project: https://github.com/JaylyDev/ScriptAPI 4 | import { hasLore } from './index'; 5 | import { world } from '@minecraft/server'; 6 | 7 | world.beforeEvents.itemUse.subscribe(({itemStack}) => { 8 | if (hasLore(itemStack)) world.sendMessage("Item has lore!"); 9 | }); -------------------------------------------------------------------------------- /scripts/has-permission/README.md: -------------------------------------------------------------------------------- 1 | # has-permission 2 | 3 | ## Description 4 | 5 | Returns true if player is operator 6 | 7 | ## Credits 8 | 9 | These scripts were written by [Jayly](https://github.com/JaylyDev) 10 | -------------------------------------------------------------------------------- /scripts/has-permission/index.js: -------------------------------------------------------------------------------- 1 | // Script example for ScriptAPI 2 | // Author: Jayly 3 | // Project: https://github.com/JaylyDev/ScriptAPI 4 | import { Player } from "@minecraft/server"; 5 | import { isOperator } from "is-operator/index"; 6 | 7 | /** 8 | * 9 | * @param {Player} player 10 | * @returns 11 | */ 12 | export function hasPermission (player) { 13 | return isOperator(player); 14 | }; -------------------------------------------------------------------------------- /scripts/has-permission/tests.js: -------------------------------------------------------------------------------- 1 | import { world } from "@minecraft/server"; 2 | import { hasPermission } from "./index"; 3 | 4 | hasPermission([...world.getPlayers()][0]); -------------------------------------------------------------------------------- /scripts/health-display/README.md: -------------------------------------------------------------------------------- 1 | # Health display 2 | 3 | Display player's health below player's name tag using scripts. 4 | -------------------------------------------------------------------------------- /scripts/health-display/index.js: -------------------------------------------------------------------------------- 1 | // Script example for ScriptAPI 2 | // Author: Jayly 3 | // Project: https://github.com/JaylyDev/ScriptAPI 4 | import { EntityHealthComponent, system, world } from "@minecraft/server"; 5 | system.runInterval(() => { 6 | for (const player of world.getPlayers()) { 7 | const health = player.getComponent(EntityHealthComponent.componentId); 8 | player.nameTag = `${player.name}\n§c❤️ ${health.currentValue.toFixed(1)}`; 9 | } 10 | }); 11 | -------------------------------------------------------------------------------- /scripts/health-display/index.ts: -------------------------------------------------------------------------------- 1 | // Script example for ScriptAPI 2 | // Author: Jayly 3 | // Project: https://github.com/JaylyDev/ScriptAPI 4 | 5 | import { EntityHealthComponent, system, world } from "@minecraft/server"; 6 | 7 | system.runInterval(() => { 8 | for (const player of world.getPlayers()) { 9 | const health = player.getComponent(EntityHealthComponent.componentId) as EntityHealthComponent; 10 | player.nameTag = `${player.name}\n§c❤️ ${health.currentValue.toFixed(1)}`; 11 | } 12 | }); 13 | -------------------------------------------------------------------------------- /scripts/intl/README.md: -------------------------------------------------------------------------------- 1 | # intl 2 | 3 | ## Description 4 | 5 | Polyfill for Intl module. 6 | 7 | ## Credits 8 | 9 | These scripts were written by [Andy Earnshaw](https://github.com/andyearnshaw/Intl.js) 10 | -------------------------------------------------------------------------------- /scripts/intl/index.d.ts: -------------------------------------------------------------------------------- 1 | // Script example for ScriptAPI 2 | // Author: Muhammad Ragib Hasin 3 | // Project: https://github.com/andyearnshaw/Intl.js 4 | 5 | // Type definitions for intl 1.2 6 | // Project: https://github.com/andyearnshaw/Intl.js 7 | // Definitions by: Muhammad Ragib Hasin 8 | // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped 9 | 10 | export = Intl; 11 | -------------------------------------------------------------------------------- /scripts/intl/tests.js: -------------------------------------------------------------------------------- 1 | // Script example for ScriptAPI 2 | // Author: Andy Earnshaw 3 | // Project: https://github.com/andyearnshaw/Intl.js 4 | 5 | import Intl from 'intl/index.js'; 6 | 7 | const locales = 'en-US' 8 | Intl.Collator(locales).compare('10', '20'); 9 | Intl.DateTimeFormat(locales).format(new Date()); 10 | Intl.DisplayNames; 11 | Intl.NumberFormat(locales).format(1000000000); 12 | Intl.PluralRules(locales).select(10); 13 | -------------------------------------------------------------------------------- /scripts/is-host/index.js: -------------------------------------------------------------------------------- 1 | import { Player } from "@minecraft/server"; 2 | 3 | /** 4 | * Check if player is host 5 | * @param {Player} player 6 | */ 7 | export default function isHost (player) { 8 | return player.id === '-4294967295'; 9 | } -------------------------------------------------------------------------------- /scripts/is-moving/README.md: -------------------------------------------------------------------------------- 1 | # is-moving 2 | 3 | ## Description 4 | 5 | Returns True if player is movings 6 | 7 | ## Credits 8 | 9 | These scripts were written by Jayly#1397 on Jayly Discord 10 | -------------------------------------------------------------------------------- /scripts/is-moving/index.js: -------------------------------------------------------------------------------- 1 | // Script example for ScriptAPI 2 | // Author: Jayly#1397 3 | // Project: https://github.com/JaylyDev/ScriptAPI 4 | import { Entity, Player } from "@minecraft/server"; 5 | 6 | /** 7 | * 8 | * @param {number} x 9 | */ 10 | function MathRound (x) { 11 | return Math.round(x * 1000) / 1000; 12 | }; 13 | 14 | /** 15 | * Returns `true` if entity is movings 16 | * @param {Entity} entity 17 | */ 18 | function isMoving (entity) { 19 | if (!(entity instanceof Player) && !(entity instanceof Entity)) throw new TypeError('Parameter is not Entity or Player'); 20 | 21 | /** 22 | * @type {import("@minecraft/server").Vector3} 23 | */ 24 | const vector = { 25 | x: MathRound(entity.getVelocity().x), 26 | y: MathRound(entity.getVelocity().y), 27 | z: MathRound(entity.getVelocity().z) 28 | }; 29 | 30 | if (vector.x === 0 && vector.y === 0 && vector.z === 0) return false; 31 | else return true; 32 | };; 33 | 34 | export default isMoving; -------------------------------------------------------------------------------- /scripts/is-moving/tests.js: -------------------------------------------------------------------------------- 1 | // Script example for ScriptAPI 2 | // Author: Jayly#1397 3 | import { system, world } from "@minecraft/server"; 4 | import isMoving from "is-moving/index"; 5 | 6 | system.runInterval(() => { 7 | for (const player of world.getPlayers()) { 8 | if (!isMoving(player)) { 9 | player.kill(); 10 | world.sendMessage(`${player.name} stopped moving!`); 11 | } 12 | } 13 | }); -------------------------------------------------------------------------------- /scripts/is-not-op/README.md: -------------------------------------------------------------------------------- 1 | # is-not-op 2 | 3 | ## Description 4 | 5 | Check if player is not an operator 6 | 7 | ## Credits 8 | 9 | These scripts were written by [Jayly](https://github.com/JaylyDev) 10 | -------------------------------------------------------------------------------- /scripts/is-not-op/index.js: -------------------------------------------------------------------------------- 1 | // Script example for ScriptAPI 2 | // Author: Jayly 3 | // Project: https://github.com/JaylyDev/ScriptAPI 4 | import { Player } from "@minecraft/server"; 5 | import { isOperator } from "is-operator/index"; 6 | 7 | /** 8 | * returns true if player is not operator 9 | * @param {Player} player 10 | */ 11 | export function isNotOp (player) { 12 | return isOperator(player) === false; 13 | }; -------------------------------------------------------------------------------- /scripts/is-not-op/tests.js: -------------------------------------------------------------------------------- 1 | import { world } from "@minecraft/server"; 2 | import { isNotOp } from "./index"; 3 | 4 | isNotOp([...world.getPlayers()][0]); -------------------------------------------------------------------------------- /scripts/is-operator/index.js: -------------------------------------------------------------------------------- 1 | import { Player } from "@minecraft/server"; 2 | 3 | /** 4 | * returns if player is operator 5 | * @param {Player} player 6 | */ 7 | export function isOperator (player) { 8 | return player.isOp(); 9 | }; -------------------------------------------------------------------------------- /scripts/is-operator/tests.js: -------------------------------------------------------------------------------- 1 | import { world } from "@minecraft/server"; 2 | import { isOperator } from "./index"; 3 | 4 | isOperator([...world.getPlayers()][0]); -------------------------------------------------------------------------------- /scripts/item-name/README.md: -------------------------------------------------------------------------------- 1 | # item-name 2 | 3 | ## Description 4 | > This README is auto generated, Edit the README so that users know what this package does. 5 | 6 | ## Credits 7 | These scripts were written by Unknown on Bedrock Add-Ons 8 | -------------------------------------------------------------------------------- /scripts/item-name/index.js: -------------------------------------------------------------------------------- 1 | // Script example for ScriptAPI 2 | // Author: Unknown 3 | // Project: https://discord.gg/bedrock-addons 4 | /** 5 | * @param {import("@minecraft/server").ItemStack} item 6 | */ 7 | const getItemName = (item) => { 8 | return item.nameTag ?? item.typeId.split(":")[1].split('_').map(v => v[0].toUpperCase() + v.slice(1).toLowerCase()).join(" ") 9 | } 10 | 11 | export { getItemName } 12 | -------------------------------------------------------------------------------- /scripts/jayly-task/README.md: -------------------------------------------------------------------------------- 1 | # jayly-task 2 | 3 | ## Description 4 | 5 | Run multiple commands in a tick. 6 | 7 | ## Credits 8 | 9 | These scripts were written by Jayly#1397 on Jayly Discord 10 | -------------------------------------------------------------------------------- /scripts/jayly-task/index.js: -------------------------------------------------------------------------------- 1 | // Script example for ScriptAPI 2 | // Author: Jayly#1397 3 | // Project: https://github.com/JaylyDev/ScriptAPI 4 | import { MinecraftDimensionTypes, system, world } from "@minecraft/server"; 5 | 6 | /** 7 | * @param {string} taskName 8 | * @param {string[]} commands 9 | * @param {boolean} loop 10 | */ 11 | export function task (taskName, commands, loop = false) { 12 | if (typeof taskName !== 'string' || typeof loop !== 'boolean') throw new TypeError('Native type conversion failed.'); 13 | if (commands.filter((value) => typeof value !== 'string').length > 0) throw new TypeError('Native variant type conversion failed.'); 14 | 15 | let id = system.runInterval(function runCommands () { 16 | let line = 0; 17 | system.clearRun(id); 18 | 19 | try { 20 | for (const command of commands) { 21 | line++; 22 | world.getDimension(MinecraftDimensionTypes.overworld).runCommand(command); 23 | }; 24 | if (loop) id = system.runInterval(runCommands); 25 | } catch (reason) { 26 | console.warn(`Task ${taskName} failed to load correctly with error(s):`); 27 | console.warn(`Error on line ${line}: command failed to parse with error '${reason}'`); 28 | }; 29 | }); 30 | }; -------------------------------------------------------------------------------- /scripts/jayly-task/tests.js: -------------------------------------------------------------------------------- 1 | // Script example for ScriptAPI 2 | // Author: Jayly#1397 3 | // Project: https://github.com/JaylyDev/ScriptAPI 4 | import { task } from "./index"; 5 | 6 | task( 7 | "test1", 8 | ["say hello", 'tellraw @a {"rawtext":[{"text":"tellraw"}]}', "scoreboard objectives add test dummy"], 9 | false 10 | ); 11 | task( 12 | "test1", 13 | ["say loop", 'tellraw @a {"rawtext":[{"text":"loop 1"}]}', "execute as @a run say loop 2"], 14 | true 15 | ); 16 | -------------------------------------------------------------------------------- /scripts/jaylydb/tests.js: -------------------------------------------------------------------------------- 1 | import { world } from "@minecraft/server"; 2 | import * as perf from "./tests/perf"; 3 | import * as exists from "./tests/exists"; 4 | import * as sync from "./tests/sync"; 5 | import * as corruptFix from "./tests/corruptFix"; 6 | 7 | world.afterEvents.worldInitialize.subscribe(() => { 8 | console.log("Starting benchmark"); 9 | exists.Main(); 10 | perf.Main(); 11 | sync.Main(); 12 | corruptFix.Main(); 13 | console.log("Benchmark complete"); 14 | }); 15 | -------------------------------------------------------------------------------- /scripts/jaylydb/tests/binary.js: -------------------------------------------------------------------------------- 1 | import { world } from "@minecraft/server"; 2 | import { JaylyDB } from "../index"; 3 | import LZString from "./lz-string"; 4 | 5 | const db = new JaylyDB("test"); 6 | 7 | world.afterEvents.chatSend.subscribe(event => { 8 | db.set(Date.now().toString(), LZString.compress(event.message)); 9 | }); -------------------------------------------------------------------------------- /scripts/jaylydb/tests/corruptFix.js: -------------------------------------------------------------------------------- 1 | import { JaylyDB } from "../index"; 2 | import { assert } from "assert/index"; 3 | import { world } from "@minecraft/server"; 4 | 5 | export function Main () { 6 | const db = new JaylyDB("yes"); 7 | db.set("hello", "world"); 8 | 9 | world.scoreboard.removeObjective("jaylydb:yes"); 10 | world.scoreboard.addObjective("jaylydb:yes", "yes"); 11 | 12 | assert(db.get("hello") === "world"); 13 | }; -------------------------------------------------------------------------------- /scripts/jaylydb/tests/exists.js: -------------------------------------------------------------------------------- 1 | import { JaylyDB } from "../index"; 2 | import { AssertionError, assert } from "assert/index"; 3 | 4 | export function Main () { 5 | const datab = new JaylyDB("hello world"); 6 | const expected = "test41"; 7 | datab.set("test1", expected); 8 | assert(datab.get("test1") === expected, new AssertionError({ actual: datab.get("test1"), operator: "!=", expected })); 9 | datab.clear(); 10 | } -------------------------------------------------------------------------------- /scripts/jaylydb/tests/lz-string.d.ts: -------------------------------------------------------------------------------- 1 | declare namespace LZString { 2 | export function compressToBase64(input: string): string; 3 | export function decompressFromBase64(input: string): string; 4 | 5 | export function compressToUTF16(input: string): string; 6 | export function decompressFromUTF16(compressed: string): string; 7 | 8 | export function compressToUint8Array(uncompressed: string): Uint8Array; 9 | export function decompressFromUint8Array(compressed: Uint8Array): string; 10 | 11 | export function compressToEncodedURIComponent(input: string): string; 12 | export function decompressFromEncodedURIComponent(compressed: string): string; 13 | 14 | export function compress(input: string): string; 15 | export function decompress(compressed: string): string; 16 | } 17 | 18 | export default LZString; -------------------------------------------------------------------------------- /scripts/jaylydb/tests/sync.js: -------------------------------------------------------------------------------- 1 | import { assert } from "assert/index.js"; 2 | import { JaylyDB } from "../index.js"; 3 | 4 | export function Main () { 5 | const db = new JaylyDB("hello"); 6 | const db2 = new JaylyDB("hello"); 7 | db.set("hello", "world"); 8 | db2.set("hello2", "world2"); 9 | 10 | assert(db.get("hello2") === "world2"); 11 | }; -------------------------------------------------------------------------------- /scripts/jaylydb/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions":{ 3 | "target":"es6", 4 | "moduleResolution":"node", 5 | "module":"es2020", 6 | "declaration":true, 7 | "noLib":false, 8 | "emitDecoratorMetadata":true, 9 | "experimentalDecorators":true, 10 | "sourceMap":false, 11 | "pretty":true, 12 | "forceConsistentCasingInFileNames": true, 13 | "strict": true, 14 | "allowUnreachableCode":true, 15 | "allowUnusedLabels":true, 16 | "noImplicitAny":true, 17 | "noImplicitReturns":false, 18 | "noImplicitUseStrict":false, 19 | "rootDir": ".", 20 | "listFiles":false, 21 | "stripInternal": true, 22 | "noEmitHelpers":true 23 | }, 24 | "include":[ 25 | "index.ts" 26 | ], 27 | "exclude":[ 28 | "node_modules" 29 | ], 30 | "compileOnSave":false 31 | } -------------------------------------------------------------------------------- /scripts/jsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig-base.json", 3 | "compilerOptions": { 4 | "baseUrl": "./", 5 | "allowJs": true, 6 | "checkJs": true, 7 | "noEmit": true 8 | }, 9 | "include": ["**/*.ts", "**/*.js"], 10 | "exclude": [] 11 | } -------------------------------------------------------------------------------- /scripts/json-stringify/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 JaylyDev 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /scripts/json-stringify/README.md: -------------------------------------------------------------------------------- 1 | # json-stringify 2 | 3 | ## Description 4 | 5 | Modified JSON stringify function. 6 | Converts a JavaScript value to a JavaScript Object Notation (JSON) string. 7 | 8 | **param** `any` value A JavaScript value, usually an object or array, to be converted. 9 | **param** `(this: any, key: string, value: any) => any` replacer A function that transforms the results. 10 | **param** `string | number` space Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read. 11 | 12 | **returns** `string` JavaScript Object Notation (JSON) string. 13 | 14 | ## Credits 15 | 16 | These scripts were written by [JaylyMC](https://github.com/JaylyDev) 17 | -------------------------------------------------------------------------------- /scripts/kill-death-counter/README.md: -------------------------------------------------------------------------------- 1 | # kill-death-counter 2 | 3 | ## Description 4 | 5 | Tracks how many times player has killed or died 6 | 7 | ## Credits 8 | 9 | These scripts were written by Jayly#1397 on Jayly Discord, mrpatches123#0348 on Bedrock Scripting API 10 | -------------------------------------------------------------------------------- /scripts/kill-death-counter/index.js: -------------------------------------------------------------------------------- 1 | // Script example for ScriptAPI 2 | // Author: Jayly#1397 3 | // mrpatches123#0348 4 | // Project: https://github.com/JaylyDev/ScriptAPI 5 | 6 | import { world, Player, EntityHealthComponent } from "@minecraft/server"; 7 | 8 | const overworld = world.getDimension("overworld"), 9 | nether = world.getDimension("nether"), 10 | end = world.getDimension("the end"); 11 | 12 | overworld 13 | .runCommandAsync("scoreboard objectives add deaths dummy") 14 | .catch((error) => console.warn(error)); 15 | overworld 16 | .runCommandAsync("scoreboard objectives add kills dummy") 17 | .catch((error) => console.warn(error)); 18 | world.afterEvents.entityHurt.subscribe( 19 | ({ hurtEntity, damageSource }) => { 20 | /** @type {EntityHealthComponent} */ 21 | // @ts-ignore 22 | const health = hurtEntity.getComponent("health"); 23 | if (health.currentValue > 0) return; 24 | hurtEntity.runCommandAsync("scoreboard players add @s deaths 1"); 25 | if (!(damageSource.damagingEntity instanceof Player)) return; 26 | damageSource.damagingEntity.runCommandAsync("scoreboard players add @s kills 1"); 27 | }, 28 | { entityTypes: ["minecraft:player"] } 29 | ); 30 | -------------------------------------------------------------------------------- /scripts/knockback-from-point/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 GlitchyTurtle32 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /scripts/knockback-from-point/README.md: -------------------------------------------------------------------------------- 1 | # knockback-from-point 2 | 3 | ## Description 4 | 5 | Returns `Vector3` of Knockback from point 6 | 7 | ## Credits 8 | 9 | These scripts were written by [GlitchyTurtle32](https://github.com/GlitchyTurtle) 10 | -------------------------------------------------------------------------------- /scripts/land-calculate/Readme.md: -------------------------------------------------------------------------------- 1 | # Description 2 | This Class to Calculate Land [X,Z] 3 | 4 | ### Method 5 | - testInBox({ start: [x,z], end: [x,z] }) 6 | - getTile({ start: [x,z], end: [x,z] }) 7 | 8 | check `tests.js` 9 | 10 | # Credits 11 | @Nperma 12 | -------------------------------------------------------------------------------- /scripts/land-calculate/tests.js: -------------------------------------------------------------------------------- 1 | import * as mc from "@minecraft/server"; 2 | import { MATH } from "./index.js"; 3 | 4 | const AreaLobby = { start: [200, -200], end: [-200, 200] }; // Center 0,0 5 | 6 | let playerLog = {}; 7 | 8 | mc.system.runInterval(async () => { 9 | mc.world.getPlayers().forEach((ply) => { 10 | if (!playerLog[ply.name]) { 11 | playerLog[ply.name] = { 12 | status: "out land", 13 | }; 14 | } 15 | 16 | const playerLocation = new MATH([ply.location.x, ply.location.z]); 17 | 18 | if (playerLocation.testInbox(AreaLobby) && playerLog[ply.name].status === "out land") { 19 | ply.sendMessage("§7You are inside this Area Lobby"); 20 | playerLog[ply.name].status = "in land"; 21 | } else if (!playerLocation.testInbox(AreaLobby) && playerLog[ply.name].status === "in land") { 22 | ply.sendMessage("§7You are out of this Area Lobby!!"); 23 | playerLog[ply.name].status = "out land"; 24 | } 25 | }); 26 | }); 27 | -------------------------------------------------------------------------------- /scripts/lz-string/LICENSE: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JaylyDev/ScriptAPI/fda8df9ad2061efade76806872a28c7c767f241a/scripts/lz-string/LICENSE -------------------------------------------------------------------------------- /scripts/lz-string/README.md: -------------------------------------------------------------------------------- 1 | # lz-string 2 | 3 | LZ-based compression algorithm for JavaScript 4 | 5 | This package is a fork and a modified version of the original 'lz-string' library, available in following websites: 6 | 7 | - [npm](https://www.npmjs.com/package/lz-string) 8 | - [Repository](https://github.com/pieroxy/lz-string) 9 | - [Homepage](https://github.com/pieroxy/lz-string) 10 | 11 | lz-string - v1.4.4 is created by Pieroxy, and is licensed under WTFPL and MIT. 12 | -------------------------------------------------------------------------------- /scripts/lz-string/index.d.ts: -------------------------------------------------------------------------------- 1 | export default LZString; 2 | declare namespace LZString { 3 | function compress(uncompressed: string): string; 4 | function decompress(compressed: string): string; 5 | } 6 | -------------------------------------------------------------------------------- /scripts/lz-string/lz-string-tests.js: -------------------------------------------------------------------------------- 1 | import LZString from "./index.js"; 2 | import { http, HttpRequest } from "@minecraft/server-net"; 3 | import { world } from "@minecraft/server"; 4 | 5 | async function Main () { 6 | const response = await http.request(new HttpRequest('https://docs.microsoft.com/en-us/minecraft/creator/opbuildpdf/toc.pdf')); 7 | console.log("Response size:", response.body.length); 8 | 9 | let times = 3; 10 | while ((10 ** times) < response.body.length) { 11 | let time = Date.now(); 12 | let compressed = LZString.compress(response.body.substring(0, 10 ** times)); 13 | console.log(`Uncompressed size: ${10 ** times} | Compressed size: ${compressed.length} | Time: ${Date.now() - time}ms`); 14 | times++; 15 | }; 16 | }; 17 | 18 | let started = false; 19 | world.beforeEvents.chatSend.subscribe(() => { 20 | if (started) return; 21 | 22 | world.sendMessage("Unit test starts"); 23 | started = true; 24 | Main().catch((err) => { 25 | console.error(err); 26 | }); 27 | }); -------------------------------------------------------------------------------- /scripts/minecraft-language/README.md: -------------------------------------------------------------------------------- 1 | # minecraft-language 2 | 3 | ## Description 4 | 5 | 6 | ## Credits 7 | These scripts were written by [bot174](https://github.com/bot174) 8 | -------------------------------------------------------------------------------- /scripts/net-auth/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 JaylyDev 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /scripts/net-auth/package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "mojang-net-auth", 3 | "version": "1.0.0", 4 | "lockfileVersion": 3, 5 | "requires": true, 6 | "packages": { 7 | "": { 8 | "name": "mojang-net-auth", 9 | "version": "1.0.0", 10 | "license": "ISC" 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /scripts/net-auth/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "mojang-net-auth", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "node.js", 6 | "scripts": { 7 | "build": "npm run build_node && npm run build_gametest", 8 | "build_node": "tsc node.ts", 9 | "build_gametest": "tsc gametest.ts --module es2020" 10 | }, 11 | "keywords": [], 12 | "author": "", 13 | "license": "ISC" 14 | } 15 | -------------------------------------------------------------------------------- /scripts/net-auth/tests.js: -------------------------------------------------------------------------------- 1 | import * as netauth from "net-auth/index"; 2 | 3 | netauth.auth("jayly"); 4 | 5 | netauth.http.get("https://example.com").then(res => { 6 | console.log(res.body); 7 | }); -------------------------------------------------------------------------------- /scripts/page-form/README.md: -------------------------------------------------------------------------------- 1 | # Page Form 2 | 3 | split buttons to different forms 4 | 5 | ![video](./example.gif) 6 | 7 | Dependencies: 8 | 9 | - [`force-show`](../force-show/index.js) 10 | 11 | Example: 12 | 13 | ```js 14 | import { Player, world } from "@minecraft/server"; 15 | import FormatActionFormButtons from "page-form"; 16 | 17 | world.afterEvents.itemUse.subscribe(({ source }) => { 18 | if (source instanceof Player) 19 | FormatActionFormButtons( 20 | { 21 | titleText: "title", 22 | bodyText: "body", 23 | buttons: [ 24 | { text: "text" }, 25 | { text: "text" }, 26 | { text: "text" }, 27 | { text: "text" }, 28 | { text: "text" }, 29 | ], 30 | }, 31 | 3, 32 | source 33 | ).then(console.warn); 34 | }); 35 | ``` 36 | -------------------------------------------------------------------------------- /scripts/page-form/example.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JaylyDev/ScriptAPI/fda8df9ad2061efade76806872a28c7c767f241a/scripts/page-form/example.gif -------------------------------------------------------------------------------- /scripts/page-form/tests.js: -------------------------------------------------------------------------------- 1 | import { Player, world } from "@minecraft/server"; 2 | import FormatActionFormButtons from "page-form/index"; 3 | 4 | world.afterEvents.itemUse.subscribe(({ source }) => { 5 | if (source instanceof Player) 6 | FormatActionFormButtons( 7 | { 8 | titleText: "title", 9 | bodyText: "body", 10 | buttons: [ 11 | { text: "text" }, 12 | { text: "text" }, 13 | { text: "text" }, 14 | { text: "text" }, 15 | { text: "text" }, 16 | ], 17 | }, 18 | 3, 19 | source 20 | ).then(console.warn); 21 | }); 22 | -------------------------------------------------------------------------------- /scripts/player-death-event/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 JaylyDev 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /scripts/player-death-event/readme.md: -------------------------------------------------------------------------------- 1 | # Deprecated 2 | 3 | PlayerDeathEvent class is deprecated. Use [EntityDeathEvent](../entity-death-event) instead. 4 | 5 | --- 6 | 7 | This package detects player death event 8 | 9 | # Usage 10 | 11 | ```js 12 | import { PlayerDeathEventSignal } from "./PlayerDeathEvent.js"; 13 | 14 | let playerDeath = new PlayerDeathEventSignal(); 15 | 16 | // event callback function 17 | let callback = playerDeath.subscribe(({ player }) => { 18 | // unsubscribe the callback function 19 | playerDeath.unsubscribe(callback); 20 | }); 21 | ``` 22 | 23 | # Typing 24 | 25 | ```ts 26 | import { Player } from "@minecraft/server"; 27 | 28 | export class PlayerDeathEvent { 29 | player: Player; 30 | private constructor(player: Player); 31 | } 32 | 33 | export class PlayerDeathEventSignal { 34 | subscribe( 35 | arg: (arg: PlayerDeathEvent) => void 36 | ): (arg: PlayerDeathEvent) => void; 37 | unsubscribe(arg: (arg: PlayerDeathEvent) => void): void; 38 | constructor(); 39 | } 40 | ``` 41 | -------------------------------------------------------------------------------- /scripts/player-death-event/tests.js: -------------------------------------------------------------------------------- 1 | import { PlayerDeathEventSignal } from "./index"; 2 | 3 | let playerDeath = new PlayerDeathEventSignal(); 4 | 5 | let callback = playerDeath.subscribe(({player}) => { 6 | // callback function 7 | playerDeath.unsubscribe(callback); // unsubscribes 8 | }); -------------------------------------------------------------------------------- /scripts/player-exist-event/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 JaylyDev 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /scripts/player-exist-event/README.md: -------------------------------------------------------------------------------- 1 | # Deprecated 2 | 3 | player-exist-event is no longer supported, as [PlayerSpawnAfterEvent class](https://learn.microsoft.com/en-us/minecraft/creator/scriptapi/minecraft/server/PlayerSpawnAfterEvent) is being added as a native event in @minecraft/server module in Minecraft 1.19.60 4 | 5 | For 1.1.0-beta, use index.js 6 | For 0.1.0, use PlayerExistEvent_old.js 7 | 8 | --- 9 | -------------------------------------------------------------------------------- /scripts/player-exist-event/tests.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JaylyDev/ScriptAPI/fda8df9ad2061efade76806872a28c7c767f241a/scripts/player-exist-event/tests.js -------------------------------------------------------------------------------- /scripts/player-extra/README.md: -------------------------------------------------------------------------------- 1 | # player-extra 2 | 3 | ## Description 4 | 5 | 6 | ## Credits 7 | These scripts were written by [Jayly](https://github.com/JaylyDev) 8 | -------------------------------------------------------------------------------- /scripts/player-extra/index.d.ts: -------------------------------------------------------------------------------- 1 | import * as mc from "@minecraft/server"; 2 | import { ActionFormData, MessageFormData, ModalFormData } from "@minecraft/server-ui"; 3 | type FormResult = >>(form: formType, callback: (response: formResponse) => void) => void; 4 | interface PlayerExtra extends mc.Player { 5 | /** 6 | * Get player GameMode 7 | */ 8 | getGameMode(): mc.GameMode; 9 | /** 10 | * Kick the player from the server 11 | */ 12 | kick(reason: string): void; 13 | /** 14 | * Get player score from an objective 15 | */ 16 | getScore(objectiveId: string): number; 17 | /** 18 | * Show UI forms 19 | */ 20 | showForm: FormResult; 21 | } 22 | export default function Player(player: mc.Player): PlayerExtra; 23 | export {}; 24 | -------------------------------------------------------------------------------- /scripts/player-extra/index.js: -------------------------------------------------------------------------------- 1 | // Script example for ScriptAPI 2 | // Author: Jayly 3 | // Project: https://github.com/JaylyDev/ScriptAPI 4 | import * as mc from "@minecraft/server"; 5 | import { getGamemode } from "get-gamemode/index"; 6 | export default function Player(player) { 7 | return Object.assign({ 8 | getGameMode() { 9 | return getGamemode(player); 10 | }, 11 | kick(reason) { 12 | player.runCommand(`kick "${player.name}" ${reason}`); 13 | }, 14 | getScore(objectiveId) { 15 | return mc.world.scoreboard 16 | .getObjective(objectiveId) 17 | .getScore(player.scoreboardIdentity); 18 | }, 19 | showForm(form, callback) { 20 | form.show(player).then(callback); 21 | }, 22 | }, player); 23 | } 24 | -------------------------------------------------------------------------------- /scripts/player-impulse/README.md: -------------------------------------------------------------------------------- 1 | # player-impulse 2 | 3 | ## Description 4 | 5 | Remake `setVelocity` for players. 6 | 7 | ## Usage 8 | 9 | ```js 10 | import { applyImpulse } from "./index"; 11 | 12 | applyImpulse(player, vector); 13 | ``` 14 | 15 | ## Credits 16 | 17 | This script is made by [SI Silicon](https://github.com/SIsilicon), updated by Remember M9#8416 and Usernam#2058 -------------------------------------------------------------------------------- /scripts/player-impulse/index.js: -------------------------------------------------------------------------------- 1 | // Script example for ScriptAPI 2 | // Author: Usernam#2058 3 | // Remember M9#8416 4 | // SI Silicon 5 | // Project: https://github.com/JaylyDev/ScriptAPI 6 | /** 7 | * Workaround to apply impulse vector to the current velocity of the player. 8 | * @param player Only Player class, not Entity. 9 | * @param vector 10 | */ 11 | export function applyImpulse(player, vector) { 12 | const { x, y, z } = vector; 13 | const horizontal = Math.sqrt(x * x + z * z) * 2.0; 14 | const vertical = y < 0.0 ? 0.5 * y : y; 15 | player.applyKnockback(x, z, horizontal, vertical); 16 | } 17 | -------------------------------------------------------------------------------- /scripts/player-impulse/index.ts: -------------------------------------------------------------------------------- 1 | // Script example for ScriptAPI 2 | // Author: Usernam#2058 3 | // Remember M9#8416 4 | // SI Silicon 5 | // Project: https://github.com/JaylyDev/ScriptAPI 6 | 7 | import { Player, Vector3 } from "@minecraft/server"; 8 | 9 | /** 10 | * Workaround to apply impulse vector to the current velocity of the player. 11 | * @param player Only Player class, not Entity. 12 | * @param vector 13 | */ 14 | export function applyImpulse(player: Player, vector: Vector3) { 15 | const { x, y, z } = vector; 16 | const horizontal = Math.sqrt(x * x + z * z) * 2.0; 17 | const vertical = y < 0.0 ? 0.5 * y : y; 18 | player.applyKnockback(x, z, horizontal, vertical); 19 | } 20 | -------------------------------------------------------------------------------- /scripts/player-impulse/tests.js: -------------------------------------------------------------------------------- 1 | // Script example for ScriptAPI 2 | // Author: Usernam#2058 3 | // Project: https://github.com/JaylyDev/ScriptAPI 4 | import { applyImpulse } from "./index"; 5 | import { world } from "@minecraft/server"; 6 | const armorStand = [...world.getDimension("overworld").getEntities({ type: 'minecraft:armor_stand' })][0]; 7 | const player = world.getAllPlayers()[0]; 8 | const vector = { x: 0, y: 2, z: 0 }; 9 | armorStand.applyImpulse(vector); 10 | applyImpulse(player, vector); 11 | -------------------------------------------------------------------------------- /scripts/player-impulse/tests.ts: -------------------------------------------------------------------------------- 1 | // Script example for ScriptAPI 2 | // Author: Usernam#2058 3 | // Project: https://github.com/JaylyDev/ScriptAPI 4 | 5 | import { applyImpulse } from "./index"; 6 | import { Vector3, world } from "@minecraft/server"; 7 | 8 | const armorStand = [...world.getDimension("overworld").getEntities({ type: 'minecraft:armor_stand' })][0]; 9 | const player = world.getAllPlayers()[0]; 10 | const vector: Vector3 = { x: 0, y: 2, z: 0 }; 11 | 12 | armorStand.applyImpulse(vector); 13 | applyImpulse(player, vector); 14 | -------------------------------------------------------------------------------- /scripts/player-leave-event/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 JaylyDev 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /scripts/player-leave-event/README.md: -------------------------------------------------------------------------------- 1 | `PlayerLeaveEvent` 2 | 3 | The goal of this PlayerLeaveEvent is to return the player object instead of player name like GameTest native. 4 | 5 | > [!CAUTION] 6 | > This package has been deprecated. Please use `@minecraft/server.PlayerLeaveBeforeEvent` 7 | 8 | ```js 9 | import { world } from "@minecraft/server"; 10 | world.beforeEvents.playerLeave.subscribe(({ player }) => { 11 | world.sendMessage(`[${new Date().toISOString()}]` + player.name + "left the server"); 12 | }); 13 | ``` -------------------------------------------------------------------------------- /scripts/player-leave-event/tests.js: -------------------------------------------------------------------------------- 1 | import { EntityHealthComponent, world } from "@minecraft/server"; 2 | import { PlayerLeaveEventSignal } from "./index"; 3 | 4 | let playerLeave = new PlayerLeaveEventSignal(); 5 | 6 | let callback = playerLeave.subscribe(({player}) => { 7 | console.warn(`[${new Date().toISOString()}]`, player.name, "left the server"); 8 | 9 | /** 10 | * @type {EntityHealthComponent} 11 | */ 12 | // @ts-ignore 13 | let health = player.getComponent("health"); 14 | player.dimension.runCommandAsync(`say ${player.name} left the server with ${health.currentValue} HP`); 15 | player.dimension.runCommandAsync(`say ${player.name} Location: ${player.location.x} ${player.location.y} ${player.location.z}`); 16 | 17 | // unsubscribe 18 | playerLeave.unsubscribe(callback); 19 | }); 20 | 21 | 22 | world.beforeEvents.playerLeave.subscribe(({ player }) => { 23 | world.sendMessage(`[${new Date().toISOString()}]` + player.name + "left the server"); 24 | }); -------------------------------------------------------------------------------- /scripts/player-spawn/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 GlitchyTurtle32 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /scripts/player-spawn/README.md: -------------------------------------------------------------------------------- 1 | # player-spawn 2 | 3 | ## Description 4 | 5 | Usage of PlayerSpawnAfterEvent, when player first join 6 | 7 | ## Credits 8 | 9 | These scripts were written by [GlitchyTurtle32](https://github.com/GlitchyTurtle) 10 | -------------------------------------------------------------------------------- /scripts/player-spawn/index.js: -------------------------------------------------------------------------------- 1 | // Script example for ScriptAPI 2 | // Author: GlitchyTurtle32 3 | // Project: https://github.com/JaylyDev/ScriptAPI 4 | import { world } from "@minecraft/server"; 5 | 6 | world.afterEvents.playerSpawn.subscribe((eventData) => { 7 | let { player, initialSpawn } = eventData; 8 | if(!initialSpawn) return; 9 | 10 | // This runs when the player joins the game for the first time! 11 | }) -------------------------------------------------------------------------------- /scripts/player-velocity-fix/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 JaylyDev 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /scripts/player-velocity-fix/README.md: -------------------------------------------------------------------------------- 1 | # Player.setVelocity 2 | 3 | This package aims to create a velocity on players without the use of `Player.setVelocity` method for @minecraft/server module version '1.0.0-beta'. 4 | 5 | This is one of the methods to get around the `Player.setVelocity` that it will now throw an exception when called on player types in module version '1.0.0-beta' of '@minecraft/server' module. 6 | 7 | This function is experimental, please improve the script by submit a pull request. 8 | 9 | ## Files 10 | 11 | - `index.js` / `index.ts` - Original source file 12 | - `player-velocity-fix.js` - All in one JavaScript file, no need to import external modules from this repository. However external modules may be out of date. 13 | -------------------------------------------------------------------------------- /scripts/player-velocity-fix/index.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @license MIT 3 | * @author JaylyMC 4 | * @project https://github.com/JaylyDev/GametestDB/ 5 | */ 6 | import { Vector3, Player } from "@minecraft/server"; 7 | /** 8 | * @remarks 9 | * Sets a velocity for the entity to move with. 10 | * Fixes GameTest native player.setVelocity 11 | * @param {Vector3} velocity 12 | * @param {Player} player 13 | * @throws This function can throw errors. 14 | */ 15 | export declare function setVelocity(velocity: Vector3, player: Player): void; 16 | -------------------------------------------------------------------------------- /scripts/player-velocity-fix/tests.js: -------------------------------------------------------------------------------- 1 | import { world } from "@minecraft/server"; 2 | import { setVelocity } from "./index.js"; 3 | 4 | world.afterEvents.chatSend.subscribe(({sender}) => { 5 | setVelocity(sender.getViewDirection(), sender); 6 | }); -------------------------------------------------------------------------------- /scripts/protoform/index.d.ts: -------------------------------------------------------------------------------- 1 | import { Player } from "@minecraft/server"; 2 | import { MessageFormData, ActionFormData, ModalFormData } from "@minecraft/server-ui"; 3 | interface FormResponse { 4 | [key: string]: any; 5 | } 6 | 7 | declare class ProtoForm { 8 | constructor(options: { 9 | title: string; 10 | fields?: [string, any[]][]; 11 | body?: string; 12 | btn1?: string; 13 | btn2?: string; 14 | btns?: (string | [string] | [string, string | undefined])[]; 15 | response?: (result: FormResponse) => void; 16 | }); 17 | 18 | form: MessageFormData | ActionFormData | ModalFormData | null; 19 | response: (result: FormResponse) => void; 20 | 21 | show(player: Player): Promise; 22 | } 23 | -------------------------------------------------------------------------------- /scripts/protoform/tests.js: -------------------------------------------------------------------------------- 1 | import { 2 | world,Player 3 | } from "@minecraft/server"; 4 | import { ProtoForm } from "index.js"; 5 | const actionform = new ProtoForm({ 6 | title: "Test ActionForm", 7 | body: "Body...", 8 | btns: [["Hey","Texture Path"],["Btn2","Path2"],"btn3","btn4",["btn5"]], 9 | response: ({selection:s}) => { 10 | console.warn("selected no" + s) 11 | } 12 | }) 13 | world.afterEvents.entityHitBlock.subscribe(({damagingEntity: player}) => { 14 | if (player instanceof Player) { 15 | actionform.show(player) 16 | } 17 | }) 18 | -------------------------------------------------------------------------------- /scripts/radius-check/index.js: -------------------------------------------------------------------------------- 1 | // Script example for ScriptAPI 2 | // Author: THE BOSS9345#0193 3 | // Project: https://github.com/JaylyDev/ScriptAPI 4 | 5 | import { Player } from "@minecraft/server"; 6 | 7 | /** 8 | * Checks if the player is located within a specific radius of a block 9 | * @param {Player} player The player to check 10 | * @param {number} x The X coordinate of the block to check 11 | * @param {number} y The Y coordinate of the block to check 12 | * @param {number} z The Z coordinate of the block to check 13 | * @param {number} radius The radius to check 14 | * @returns {boolean} True if the player is located within the specified radius of the block, false otherwise 15 | * @example radiusCheck(player, 0, 0, 0, 10) 16 | */ 17 | 18 | function radiusCheck(player, x, y, z, radius) { 19 | const playerLocation = player.location; 20 | const playerX = playerLocation.x; 21 | const playerY = playerLocation.y; 22 | const playerZ = playerLocation.z; 23 | const distanceSquared = (playerX - x) ** 2 + (playerY - y) ** 2 + (playerZ - z) ** 2; 24 | const radiusSquared = radius ** 2; 25 | if (distanceSquared <= radiusSquared) { 26 | return true; 27 | } else { 28 | return false; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /scripts/remove-permission/index.js: -------------------------------------------------------------------------------- 1 | import { Player } from "@minecraft/server"; 2 | 3 | /** 4 | * Remove player permission 5 | * @param {Player} player 6 | */ 7 | export function removePermission (player) { 8 | player.setOp(false); 9 | }; -------------------------------------------------------------------------------- /scripts/remove-permission/tests.js: -------------------------------------------------------------------------------- 1 | import { world } from "@minecraft/server"; 2 | import { removePermission } from "./index"; 3 | 4 | removePermission([...world.getPlayers()][0]); -------------------------------------------------------------------------------- /scripts/restful/README.md: -------------------------------------------------------------------------------- 1 | # Restful (REST) 2 | 3 | A Minecraft scripting api port of REST APIs are used to access and manipulate data using a common set of stateless operations. 4 | 5 | This package is experimental. 6 | 7 | ## Example 8 | 9 | ```js 10 | import { world } from "@minecraft/server"; 11 | import { RequestMethod, REST } from "./index"; 12 | 13 | const rest = new REST("demo"); // id is demo, lower case 14 | 15 | (async () => { 16 | await rest.request("/players", { method: RequestMethod.POST }); // create a route 17 | 18 | // save data for all players into a table 19 | for (const player of world.getAllPlayers()) { 20 | await rest.request("/players", { 21 | method: RequestMethod.PUT, 22 | key: player.name, 23 | value: player.id, 24 | }); 25 | } 26 | })().catch(console.error); 27 | 28 | world.afterEvents.chatSend.subscribe((event) => { 29 | /** 30 | * Get player id from REST 31 | */ 32 | const playerId = rest.request("/players", { 33 | method: RequestMethod.GET, 34 | key: event.sender.name, 35 | }); 36 | event.sender.tell("Player ID: " + playerId); 37 | }); 38 | ``` 39 | -------------------------------------------------------------------------------- /scripts/restful/encoding.d.ts: -------------------------------------------------------------------------------- 1 | declare function utf8_to_b64(str: string): string; 2 | declare function b64_to_utf8(str: string): string; 3 | export { utf8_to_b64, b64_to_utf8 }; 4 | -------------------------------------------------------------------------------- /scripts/restful/tests.d.ts: -------------------------------------------------------------------------------- 1 | export {}; 2 | -------------------------------------------------------------------------------- /scripts/restful/tests.js: -------------------------------------------------------------------------------- 1 | import { world } from "@minecraft/server"; 2 | import { RequestMethod, REST } from "./index"; 3 | const rest = new REST('demo'); // id is demo, lower case 4 | (async () => { 5 | await rest.request('/players', { method: RequestMethod.POST }); // create a route 6 | // save data for all players into a table 7 | for (const player of world.getAllPlayers()) { 8 | await rest.request('/players', { 9 | method: RequestMethod.PUT, 10 | key: player.name, 11 | value: player.id 12 | }); 13 | } 14 | ; 15 | })().catch(console.error); 16 | world.afterEvents.chatSend.subscribe((event) => { 17 | /** 18 | * Get player id from REST 19 | */ 20 | const playerId = rest.request('/players', { 21 | method: RequestMethod.GET, 22 | key: event.sender.name 23 | }); 24 | if (playerId !== event.sender.id) 25 | event.sender.kill(); 26 | rest.request('/players', { 27 | method: RequestMethod.PATCH, 28 | key: event.sender.name, 29 | value: event.sender.id 30 | }); 31 | event.sender.sendMessage('Player ID: ' + playerId); 32 | // remove property 33 | rest.request('/players', { 34 | method: RequestMethod.DELETE, 35 | key: event.sender.name 36 | }); 37 | }); 38 | -------------------------------------------------------------------------------- /scripts/restful/tests.ts: -------------------------------------------------------------------------------- 1 | import { world } from "@minecraft/server"; 2 | import { RequestMethod, REST } from "./index"; 3 | 4 | const rest = new REST('demo'); // id is demo, lower case 5 | 6 | (async () => { 7 | await rest.request('/players', { method: RequestMethod.POST }); // create a route 8 | 9 | // save data for all players into a table 10 | for (const player of world.getAllPlayers()) { 11 | await rest.request('/players', { 12 | method: RequestMethod.PUT, 13 | key: player.name, 14 | value: player.id 15 | }); 16 | }; 17 | })().catch(console.error); 18 | 19 | world.afterEvents.chatSend.subscribe((event) => { 20 | /** 21 | * Get player id from REST 22 | */ 23 | const playerId = rest.request('/players', { 24 | method: RequestMethod.GET, 25 | key: event.sender.name 26 | }); 27 | 28 | if (playerId !== event.sender.id) event.sender.kill(); 29 | 30 | rest.request('/players', { 31 | method: RequestMethod.PATCH, 32 | key: event.sender.name, 33 | value: event.sender.id 34 | }); 35 | 36 | event.sender.sendMessage('Player ID: ' + playerId); 37 | 38 | // remove property 39 | rest.request('/players', { 40 | method: RequestMethod.DELETE, 41 | key: event.sender.name 42 | }); 43 | }); -------------------------------------------------------------------------------- /scripts/restful/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "esModuleInterop": true 4 | }, 5 | "files": [ "index.ts", "encoding.ts", "tests.ts" ], 6 | "extends": "../tsconfig.json" 7 | } -------------------------------------------------------------------------------- /scripts/run-command-async/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 JaylyDev 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /scripts/run-command-async/index.js: -------------------------------------------------------------------------------- 1 | import { Dimension, Player, Entity } from "@minecraft/server"; 2 | 3 | export class CommandResult { 4 | 'successCount' = 1; 5 | constructor() {}; 6 | }; 7 | 8 | Dimension.prototype.runCommandAsync = async function (commandString) { 9 | this.runCommandAsync(await commandString); 10 | return new CommandResult(); 11 | }; 12 | 13 | Player.prototype.runCommandAsync = async function (commandString) { 14 | this.runCommandAsync(await commandString); 15 | return new CommandResult(); 16 | }; 17 | 18 | Entity.prototype.runCommandAsync = async function (commandString) { 19 | this.runCommandAsync(await commandString); 20 | return new CommandResult(); 21 | }; 22 | -------------------------------------------------------------------------------- /scripts/run-command-async/run-command-async-tests.js: -------------------------------------------------------------------------------- 1 | import { world } from "@minecraft/server"; 2 | 3 | let commands = [ 4 | () => world.getDimension("overworld").runCommandAsync("say Dimension native runCommandAsync"), 5 | () => [...world.getPlayers()][0].runCommandAsync("say Player native runCommandAsync"), 6 | () => [...world.getDimension("overworld").getEntities()][0].runCommandAsync("say Entity native runCommandAsync") 7 | ]; 8 | 9 | // native runCommandAsync 10 | for (let command of commands) { 11 | let time = new Date().getTime(); 12 | command(); 13 | world.getDimension("overworld").runCommandAsync(`say ${new Date().getTime() - time}`); 14 | }; 15 | 16 | //custom runCommandAsync 17 | import "./index.js"; 18 | for (let command of commands) { 19 | let time = new Date().getTime(); 20 | command(); 21 | world.getDimension("overworld").runCommandAsync(`say ${new Date().getTime() - time}`); 22 | }; -------------------------------------------------------------------------------- /scripts/run-command/README.md: -------------------------------------------------------------------------------- 1 | # run-command 2 | 3 | ## Description 4 | 5 | 6 | ## Credits 7 | 8 | -------------------------------------------------------------------------------- /scripts/run-command/blockProperties.js: -------------------------------------------------------------------------------- 1 | export {}; 2 | -------------------------------------------------------------------------------- /scripts/run-commands/README.md: -------------------------------------------------------------------------------- 1 | # run-commands 2 | 3 | ## Description 4 | 5 | Function that runs multiple commands in same tick 6 | 7 | ## Credits 8 | 9 | These scripts were written by Jayly#1397 on Jayly Discord 10 | -------------------------------------------------------------------------------- /scripts/run-commands/index.js: -------------------------------------------------------------------------------- 1 | // Script example for ScriptAPI 2 | // Author: Jayly#1397 3 | // Project: https://github.com/JaylyDev/ScriptAPI 4 | import { Entity, Dimension } from "@minecraft/server"; 5 | 6 | /** 7 | * Run commands in one function 8 | * @param {Entity | Dimension} target 9 | * @param {...string} commandString 10 | */ 11 | export function runCommands (target, ...commandString) { 12 | const results = []; 13 | for (const command of commandString) { 14 | results.push(target.runCommand(command)); 15 | }; 16 | return results; 17 | }; 18 | 19 | /** 20 | * Run commands asynchronously in one function 21 | * @param {Entity | Dimension} target 22 | * @param {...string} commandString 23 | */ 24 | export async function runCommandsAsync (target, ...commandString) { 25 | const results = { 'successCount': 0 }; 26 | for (const command of commandString) { 27 | await target.runCommandAsync(command); 28 | results.successCount++; 29 | }; 30 | return results; 31 | }; -------------------------------------------------------------------------------- /scripts/run-commands/run-commands-tests.js: -------------------------------------------------------------------------------- 1 | import { world } from '@minecraft/server'; 2 | import { runCommands, runCommandsAsync } from './index.js'; 3 | 4 | // spawns a zombie then runs commands 5 | runCommands( 6 | world.getDimension('overworld').spawnEntity('minecraft:zombie', { 7 | x: 0, 8 | y: 64, 9 | z: 0 10 | }), 11 | 'say Hello World!', 12 | 'scoreboard players add @s zombies 1' 13 | ); 14 | 15 | // run commands on a player 16 | runCommands([...world.getPlayers()][0], 'clear @s stone'); 17 | 18 | // run commands on a dimension or script engine 19 | runCommandsAsync( 20 | world.getDimension('overworld'), 21 | 'teleport @a 0 64 0', 22 | 'effect @e night_vision 10 0', 23 | 'say Dimension' 24 | ); -------------------------------------------------------------------------------- /scripts/scoreboard-identity/README.md: -------------------------------------------------------------------------------- 1 | # scoreboard-identity 2 | 3 | ## Description 4 | > This README is auto generated, Edit the README so that users know what this package does. 5 | 6 | ## Credits 7 | These scripts were written by [bot174](https://github.com/bot174) 8 | -------------------------------------------------------------------------------- /scripts/scoreboard-identity/index.js: -------------------------------------------------------------------------------- 1 | // Script example for ScriptAPI 2 | // Author: bot174 3 | // Project: https://github.com/bot174/ScriptAPI 4 | import { world, MinecraftDimensionTypes } from "@minecraft/server"; 5 | function createScoreboardIdentity(objective, displayName) { 6 | world.getDimension(MinecraftDimensionTypes.overworld).runCommand(`scoreboard players add "${displayName}" "${objective.id}" 0`); 7 | const participant = objective.getParticipants().find(participant => participant.displayName === displayName); 8 | return participant; 9 | } 10 | ; 11 | export default createScoreboardIdentity; 12 | -------------------------------------------------------------------------------- /scripts/scoreboard-identity/index.ts: -------------------------------------------------------------------------------- 1 | // Script example for ScriptAPI 2 | // Author: bot174 3 | // Project: https://github.com/bot174/ScriptAPI 4 | import { world, ScoreboardObjective, MinecraftDimensionTypes } from "@minecraft/server"; 5 | 6 | function createScoreboardIdentity (objective: ScoreboardObjective, displayName: string) { 7 | world.getDimension(MinecraftDimensionTypes.overworld).runCommand(`scoreboard players add "${displayName}" "${objective.id}" 0`); 8 | const participant = objective.getParticipants().find(participant => participant.displayName === displayName); 9 | return participant; 10 | }; 11 | 12 | export default createScoreboardIdentity; 13 | -------------------------------------------------------------------------------- /scripts/scoreboard-identity/tests.js: -------------------------------------------------------------------------------- 1 | import { world } from "@minecraft/server"; 2 | import createScoreboardIdentity from "./index"; 3 | const objective = world.scoreboard.addObjective("HelloWorld", "HelloWorld"); 4 | const participant = createScoreboardIdentity(objective, "My Helo"); 5 | console.warn(participant.displayName); 6 | objective.removeParticipant(participant); 7 | -------------------------------------------------------------------------------- /scripts/scoreboard-identity/tests.ts: -------------------------------------------------------------------------------- 1 | import { world } from "@minecraft/server"; 2 | import createScoreboardIdentity from "./index"; 3 | 4 | const objective = world.scoreboard.addObjective("HelloWorld", "HelloWorld"); 5 | const participant = createScoreboardIdentity(objective, "My Helo"); 6 | console.warn(participant.displayName); 7 | objective.removeParticipant(participant); 8 | -------------------------------------------------------------------------------- /scripts/scoreboard-levelup/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 JaylyDev 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /scripts/scoreboard-levelup/README.md: -------------------------------------------------------------------------------- 1 | # scoreboard-levelup 2 | 3 | ## Description 4 | 5 | Level up player if player has reached score in `xpmax` objective and score `level` objective is less than 100. 6 | 7 | ## Credits 8 | 9 | These scripts were written by Jayly#1397 on Jayly Discord 10 | -------------------------------------------------------------------------------- /scripts/scoreboard-levelup/index.js: -------------------------------------------------------------------------------- 1 | // Script example for ScriptAPI 2 | // Author: Jayly#1397 3 | // Project: https://github.com/JaylyDev/ScriptAPI 4 | import { Player, world } from "@minecraft/server" 5 | 6 | /** 7 | * Get score 8 | * @param {string} objective 9 | * @param {Player | string} target 10 | * @param {boolean} useZero 11 | * @returns 12 | */ 13 | function getScore(objective, target, useZero = false) { 14 | try { 15 | const obj = world.scoreboard.getObjective(objective); 16 | if (typeof target == 'string') { 17 | return obj.getScore(obj.getParticipants().find(v => v.displayName === target)); 18 | } 19 | return obj.getScore(target.scoreboardIdentity); 20 | } catch { 21 | return useZero ? 0 : NaN; 22 | } 23 | } 24 | 25 | function levelup() { 26 | for (let player of world.getPlayers()) { 27 | let xp = getScore('xp', player, true); 28 | let xpmax = getScore('xpmax', player, true); 29 | let level = getScore('level', player, true); 30 | if (xp == xpmax && level <= 100) { 31 | player.runCommand(`scoreboard players add @s level 1`) 32 | player.runCommand(`scoreboard players set @s xp 0`) 33 | xpmax += xpmax + (xpmax * 0.03) 34 | player.runCommand(`scoreboard players set @s xpmax ${xpmax}`) 35 | } 36 | } 37 | } 38 | export { levelup } 39 | -------------------------------------------------------------------------------- /scripts/scoreboard/README.md: -------------------------------------------------------------------------------- 1 | # scoreboard 2 | 3 | ## Description 4 | 5 | Very simple `getScore`, `setScore` and `addScore` functions. Compatible with @minecraft/server v1.4.0 or above 6 | 7 | ## Credits 8 | 9 | These scripts were written by [Jayly](https://github.com/JaylyDev) 10 | -------------------------------------------------------------------------------- /scripts/sell-items/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 IBlqzed 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /scripts/sell-items/README.md: -------------------------------------------------------------------------------- 1 | # sell-items 2 | 3 | ## Description 4 | 5 | Sell all items in a player's inventory 6 | 7 | ## Credits 8 | 9 | These scripts were written by iBlqzed#3612 on Bedrock Add-Ons 10 | -------------------------------------------------------------------------------- /scripts/sell-items/index.js: -------------------------------------------------------------------------------- 1 | // Script example for ScriptAPI 2 | // Author: iBlqzed#3612 3 | // Project: https://github.com/JaylyDev/ScriptAPI 4 | import { Player, Container } from "@minecraft/server"; 5 | 6 | let sellItems = [{ 7 | id: 'minecraft:sand', 8 | value: 2 9 | }, { 10 | id: 'minecraft:gravel', 11 | value: 4 12 | }, { 13 | id: 'minecraft:log', 14 | value: 5 15 | }] 16 | 17 | /** 18 | * Sell all items in a player's inventory 19 | * @param {Player} player Player 20 | * @returns {number} The amount that of money that the player made 21 | */ 22 | export const sell = (player) => { 23 | /** 24 | * @type {Container} The player's inventory container 25 | */ 26 | // @ts-ignore 27 | const inv = player.getComponent('inventory').container, { size } = inv 28 | let amount = 0; 29 | for (let i = 0; i < size; i++) { 30 | const item = inv.getItem(i) 31 | if (!item) continue; 32 | const soldItem = sellItems.find(element => element.id === item.typeId) 33 | if (!soldItem) continue; 34 | amount = amount + soldItem.value * item.amount 35 | inv.setItem(i); 36 | } 37 | player.runCommand(`scoreboard players add @s Money ${amount}`) 38 | return amount 39 | } -------------------------------------------------------------------------------- /scripts/set-permission/index.js: -------------------------------------------------------------------------------- 1 | import { Player } from "@minecraft/server"; 2 | 3 | /** 4 | * player becomes op 5 | * @param {Player} player 6 | */ 7 | export function setPermission (player) { 8 | player.setOp(true); 9 | }; -------------------------------------------------------------------------------- /scripts/set-permission/tests.js: -------------------------------------------------------------------------------- 1 | import { world } from "@minecraft/server"; 2 | import { setPermission } from "./index"; 3 | 4 | setPermission([...world.getPlayers()][0]); -------------------------------------------------------------------------------- /scripts/set-score/README.md: -------------------------------------------------------------------------------- 1 | # set-score 2 | 3 | ## Description 4 | 5 | A wrapped function that set/add/remove entity score and fetch scoreboard objective display. 6 | 7 | - `entity: Entity` Entity's scoreboard to change 8 | - `objectiveId: string` Objective to apply the score to. 9 | - `score: number` Score value 10 | - `action: ScoreboardAction` Decides whether to add, remove, or set score to entity (default = set) 11 | - `fetch: boolean` Fetch scoreboard objective display (default = true) 12 | 13 | ## Usage 14 | 15 | Add score: 16 | 17 | ```js 18 | import { setScore, ScoreboardAction } from "./index"; 19 | setScore (entity, "objectiveId", 10, ScoreboardAction.add); 20 | ``` 21 | 22 | Remove score: 23 | 24 | ```js 25 | import { setScore, ScoreboardAction } from "./index"; 26 | setScore (entity, "objectiveId", 10, ScoreboardAction.remove); 27 | ``` 28 | 29 | Set score: 30 | 31 | ```js 32 | import { setScore, ScoreboardAction } from "./index"; 33 | setScore (entity, "objectiveId", 10); 34 | ``` 35 | 36 | This function fetches scoreboard objective display by default, to disable this set 5th parameter to `false`: 37 | 38 | ```js 39 | import { setScore, ScoreboardAction } from "./index"; 40 | setScore (entity, "objectiveId", 10, ScoreboardAction.set, false); 41 | ``` 42 | 43 | ## Credits 44 | 45 | These scripts were written by [Jayly](https://github.com/JaylyDev). 46 | -------------------------------------------------------------------------------- /scripts/set-score/getScore.js: -------------------------------------------------------------------------------- 1 | // Script example for ScriptAPI 2 | // Author: Jayly#1397 3 | // Project: https://github.com/JaylyDev/ScriptAPI 4 | import { Player, world } from "@minecraft/server"; 5 | /** 6 | * Gets the score recorded for {displayName} on {objective} 7 | * @param {Player} player or entity on the scoreboard 8 | * @param {String} objectiveId Objective Identifer to get from 9 | * @param {Boolean} rNull If the return should be null if its not found or 0. 10 | * @returns {Number} Score that Was recorded for {Player} on {Objective} 11 | * @example getScore(player, "objective"): number 12 | */ 13 | export function getScore(player, objectiveId, rNull = false) { 14 | try { 15 | return world.scoreboard 16 | .getObjective(objectiveId) 17 | .getScore(player.scoreboardIdentity); 18 | } catch (error) { 19 | return rNull ? null : 0; 20 | } 21 | } -------------------------------------------------------------------------------- /scripts/set-score/tests.js: -------------------------------------------------------------------------------- 1 | // Script example for ScriptAPI 2 | // Author: Jayly#1397 3 | // Project: https://github.com/JaylyDev/ScriptAPI 4 | import { world } from "@minecraft/server"; 5 | import { setScore } from "./index"; 6 | import { getScore } from "./getScore"; 7 | 8 | world.afterEvents.chatSend.subscribe((event) => { 9 | if (!event.sender.scoreboardIdentity) return; 10 | 11 | const score = getScore(event.sender, 'messages'); 12 | setScore(event.sender, 'messages', score + 1); 13 | }) -------------------------------------------------------------------------------- /scripts/shop-wrapped/README.md: -------------------------------------------------------------------------------- 1 | # shop-wrapped 2 | 3 | ## Description 4 | > This README is auto generated, Edit the README so that users know what this package does. 5 | 6 | ## Credits 7 | These scripts were written by [Nperma](https://github.com/nperma) 8 | -------------------------------------------------------------------------------- /scripts/shopui/shopui.js: -------------------------------------------------------------------------------- 1 | import { world } from "@minecraft/server"; 2 | import * as MinecraftUi from "@minecraft/server-ui"; 3 | 4 | const player = [...world.getPlayers()][0]; 5 | const Shopitems = [ 6 | { 7 | liste_item: "liste_item", 8 | prix: 10, 9 | Icons: "textures/blocks/bedrock" 10 | } 11 | ]; 12 | 13 | // Menu Shop 14 | let shopui = new MinecraftUi.ActionFormData() 15 | .title("§r§aOcto §eShop§r") 16 | .button("§2Objets§8", "textures/items/apple.png") 17 | .button("§2Utilitaires§8", "textures/ui/debug_glyph_color.png"); 18 | shopui.show(player).then((res) => { 19 | if (res.canceled == true) 20 | return player.runCommandAsync( 21 | `tellraw ${player.name} {"rawtext": [{"text": "§r§8[§aOcto §eShop§8] §cAchat annulé!§r"}]}` 22 | ); 23 | 24 | // MENU BLOCK 25 | if (res.selection == 0) { 26 | let blocksui = new MinecraftUi.ActionFormData(); 27 | blocksui.title("§r§aOcto §eShop§r"); 28 | for (const itemm of Shopitems) { 29 | blocksui.button( 30 | `§c${itemm.liste_item} \n[${itemm.prix} pcs]`, 31 | `${itemm.Icons}` 32 | ); 33 | } 34 | blocksui.show(player).then((res) => { 35 | // Code here 36 | }); 37 | } 38 | }); 39 | -------------------------------------------------------------------------------- /scripts/simple-db/README.md: -------------------------------------------------------------------------------- 1 | # simple-db 2 | 3 | ## Description 4 | A Simple DB For Minecraft 1.19.70 5 | 6 | Here is a example 7 | ```javascript 8 | import { Database } from "index.js"; 9 | 10 | let db = new Database("name") 11 | 12 | db.new("id","val")// this will save the value "val" with identifier "id". 13 | 14 | db.get("id") //this should return "val" 15 | 16 | db.set("id","val2") //this will change the value of identifier "id" with value "val2". 17 | 18 | db.getAll() //this should return String array containing all identifiers , but in this example we will only get "["id"]" as a result. The different the db different the result 19 | 20 | db.del("id") //this will delete identifier "id" along with value "val2". 21 | 22 | ``` 23 | 24 | ## Credits 25 | These scripts were written by GamerFile on Bedrock Add-ons 26 | -------------------------------------------------------------------------------- /scripts/sleep/README.md: -------------------------------------------------------------------------------- 1 | # sleep 2 | 3 | ## Description 4 | 5 | Python's sleep function in script api. 6 | 7 | ## Credits 8 | 9 | These scripts were written by [stackoverflow](https://stackoverflow.com/a/41957152) 10 | -------------------------------------------------------------------------------- /scripts/sleep/index.js: -------------------------------------------------------------------------------- 1 | // Script example for ScriptAPI 2 | // Author: stackoverflow 3 | // Project: https://github.com/JaylyDev/ScriptAPI 4 | import { system } from "@minecraft/server"; 5 | 6 | /** 7 | * sleep 8 | * @param {number} ticks Amount of time, in ticks, before the timeouts will be 9 | * called. 10 | * @returns {Promise} 11 | */ 12 | export function sleep(ticks) { 13 | return new Promise((resolve) => { 14 | system.runTimeout(resolve, ticks); 15 | }); 16 | }; -------------------------------------------------------------------------------- /scripts/spawn-simulated-player/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 JaylyDev 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /scripts/spawn-simulated-player/README.md: -------------------------------------------------------------------------------- 1 | A function that spawns simulated player 2 | 3 | # index.d.ts 4 | 5 | ```ts 6 | import * as server from "@minecraft/server"; 7 | import { SimulatedPlayer } from "../simulated-player/SimulatedPlayer.js"; 8 | /** 9 | * Spawns a simulated player 10 | * @param target The player the simulated player is going to spawn at 11 | * @param callback Implementation of the simulated player 12 | */ 13 | export function SpawnSimulatedPlayer( 14 | target: server.Player, 15 | callback: (player: SimulatedPlayer) => void 16 | ): void; 17 | ``` 18 | -------------------------------------------------------------------------------- /scripts/spawn-simulated-player/index.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @license MIT 3 | * @author JaylyMC 4 | * @project https://github.com/JaylyDev/GametestDB/ 5 | */ 6 | import * as MinecraftServer from "@minecraft/server"; 7 | import { SimulatedPlayer } from "../simulated-player/index"; 8 | /** 9 | * Spawns a simulated player 10 | * @param target The player the simulated player is going to spawn at 11 | * @param callback Implementation of the simulated player 12 | */ 13 | export declare function SpawnSimulatedPlayer(target: MinecraftServer.Player, callback: (player: SimulatedPlayer) => void): void; 14 | -------------------------------------------------------------------------------- /scripts/spawn-simulated-player/index.js: -------------------------------------------------------------------------------- 1 | // Script example for ScriptAPI 2 | // Author: Jayly 3 | // Project: https://github.com/JaylyDev/ScriptAPI 4 | /** 5 | * @license MIT 6 | * @author JaylyMC 7 | * @project https://github.com/JaylyDev/GametestDB/ 8 | */ 9 | import * as MinecraftServer from "@minecraft/server"; 10 | import * as GameTest from "@minecraft/server-gametest"; 11 | ; 12 | /** 13 | * Spawns a simulated player 14 | * @param target The player the simulated player is going to spawn at 15 | * @param callback Implementation of the simulated player 16 | */ 17 | export function SpawnSimulatedPlayer(target, callback) { 18 | const testClassName = "Jayly"; 19 | const testName = "SpawnSimulatedPlayer"; 20 | if (!(target instanceof MinecraftServer.Player)) 21 | throw new TypeError("Native type conversion failed."); 22 | GameTest.registerAsync(testClassName, testName, async function (test) { 23 | let simulatedplayer = test.spawnSimulatedPlayer({ x: 0, y: 1, z: 0, }); 24 | simulatedplayer.despawn = () => test.removeSimulatedPlayer(simulatedplayer); 25 | callback(simulatedplayer); 26 | }) 27 | .structureName("DebugTests:always_succeed") 28 | .tag(GameTest.Tags.suiteDefault) 29 | .maxTicks(0x7fffffff); 30 | target.runCommandAsync(`gametest run ${testClassName}:${testName}`); 31 | } 32 | -------------------------------------------------------------------------------- /scripts/spawn-simulated-player/tests.d.ts: -------------------------------------------------------------------------------- 1 | export {}; 2 | -------------------------------------------------------------------------------- /scripts/spawn-simulated-player/tests.js: -------------------------------------------------------------------------------- 1 | import { world, ItemStack, } from "@minecraft/server"; 2 | import { MinecraftEffectTypes } from "@minecraft/vanilla-data"; 3 | import { SpawnSimulatedPlayer } from "./index.js"; 4 | let host = [...world.getPlayers()][0]; 5 | const money = world.scoreboard.getObjective("money") ?? world.scoreboard.addObjective("money", "money"); 6 | SpawnSimulatedPlayer(host, function (simulatedPlayer) { 7 | simulatedPlayer.addEffect(MinecraftEffectTypes.Absorption, 1); 8 | simulatedPlayer.attack(); 9 | simulatedPlayer.dimension.createExplosion(simulatedPlayer.location, 5); 10 | simulatedPlayer.giveItem(new ItemStack("minecraft:acacia_boat")); 11 | money.addScore(simulatedPlayer, 1); 12 | simulatedPlayer.teleport({ x: 0, y: 0, z: 0 }, { dimension: simulatedPlayer.dimension, rotation: { x: 0, y: 0 } }); 13 | simulatedPlayer.despawn(); 14 | }); 15 | -------------------------------------------------------------------------------- /scripts/spawn-simulated-player/tests.ts: -------------------------------------------------------------------------------- 1 | import { 2 | world, 3 | ItemStack, 4 | } from "@minecraft/server"; 5 | import { MinecraftEffectTypes } from "@minecraft/vanilla-data"; 6 | import { SpawnSimulatedPlayer } from "./index.js"; 7 | 8 | let host = [...world.getPlayers()][0]; 9 | 10 | const money = world.scoreboard.getObjective("money") ?? world.scoreboard.addObjective("money", "money"); 11 | 12 | SpawnSimulatedPlayer(host, function (simulatedPlayer) { 13 | simulatedPlayer.addEffect(MinecraftEffectTypes.Absorption, 1); 14 | simulatedPlayer.attack(); 15 | simulatedPlayer.dimension.createExplosion(simulatedPlayer.location, 5); 16 | simulatedPlayer.giveItem(new ItemStack("minecraft:acacia_boat")); 17 | money.addScore(simulatedPlayer, 1); 18 | simulatedPlayer.teleport({ x: 0, y: 0, z: 0 }, { dimension: simulatedPlayer.dimension, rotation: { x: 0, y: 0 }}); 19 | simulatedPlayer.despawn(); 20 | }); 21 | -------------------------------------------------------------------------------- /scripts/spawn-simulated-player/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "declaration": true 4 | }, 5 | "files": [ 6 | "index.ts", 7 | "tests.ts" 8 | ], 9 | "extends": "../tsconfig.json" 10 | } -------------------------------------------------------------------------------- /scripts/structures/readme.md: -------------------------------------------------------------------------------- 1 | # structures 2 | 3 | ## Description 4 | Includes vanilla structures path and vanilla structure size. Mirror from [DarkGamerYT/Bedrock-Editor-Extension](https://github.com/DarkGamerYT/Bedrock-Editor-Extension). 5 | 6 | ## Credits 7 | These scripts were written by [xKingDark](https://github.com/DarkGamerYT), [JaylyDev](https://github.com/JaylyDev), [Mojang](https://github.com/Mojang), [SmokeyStack](https://github.com/SmokeyStack) 8 | -------------------------------------------------------------------------------- /scripts/test-score/README.md: -------------------------------------------------------------------------------- 1 | # test-score 2 | 3 | ## Description 4 | 5 | Test target's score on specific number range 6 | 7 | ## Credits 8 | 9 | These scripts were written by FrankyRayMS#7172 on Bedrock Add-Ons 10 | -------------------------------------------------------------------------------- /scripts/tick-event/README.md: -------------------------------------------------------------------------------- 1 | # tick-event 2 | 3 | ## Description 4 | 5 | Simple tick event wrapper. 6 | 7 | ## Credits 8 | 9 | These scripts were written by Jayly#1397 on Jayly Discord 10 | -------------------------------------------------------------------------------- /scripts/tick-event/index.js: -------------------------------------------------------------------------------- 1 | // Script example for ScriptAPI 2 | // Author: Jayly#1397 3 | // Project: https://github.com/JaylyDev/ScriptAPI 4 | import { system } from "@minecraft/server"; 5 | 6 | let lastTick = NaN; 7 | /** 8 | * @typedef {{ currentTick: number, deltaTime: number }} TickEvent 9 | */ 10 | /** 11 | * @type {((event: TickEvent) => void)[]} 12 | */ 13 | const callbacks = []; 14 | 15 | system.runInterval(() => { 16 | const { currentTick } = system; 17 | const deltaTime = (Date.now() - lastTick) / 1000; 18 | lastTick = Date.now(); 19 | 20 | for (const callback of callbacks) { 21 | callback({ deltaTime, currentTick }); 22 | }; 23 | }); 24 | 25 | export class TickEventSignal { 26 | /** 27 | * @param {(event: TickEvent) => void} callback 28 | */ 29 | subscribe (callback) { 30 | callbacks.push(callback); 31 | return callback; 32 | } 33 | /** 34 | * @param {(event: TickEvent) => void} callback 35 | */ 36 | unsubscribe (callback) { 37 | const index = callbacks.indexOf(callback); 38 | callbacks.splice(index, 1); 39 | } 40 | }; 41 | 42 | export const tick = new TickEventSignal(); 43 | -------------------------------------------------------------------------------- /scripts/tick-event/tests.js: -------------------------------------------------------------------------------- 1 | import { tick } from "tick-event/index"; 2 | 3 | tick.subscribe((event) => { 4 | console.log(event.currentTick, event.deltaTime); 5 | }) -------------------------------------------------------------------------------- /scripts/timers/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 JaylyDev 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /scripts/timers/README.md: -------------------------------------------------------------------------------- 1 | # Timers module 2 | 3 | `setTimeout()`, `setImmediate()`, and `setInterval()` simple replica for Minecraft Bedrock Edition script APIs (experimental). 4 | 5 | ## Usage 6 | 7 | ```js 8 | import { setTimeout } from "./timers.js"; 9 | 10 | setTimeout(() => { 11 | console.log("Hello World"); 12 | }, 1000); 13 | ``` 14 | 15 | ## Compile & Test 16 | 17 | ### Compile only 18 | 19 | ``` 20 | tsc 21 | ``` 22 | 23 | ### Unit test (include tsc) 24 | 25 | ``` 26 | npm run test 27 | ``` 28 | -------------------------------------------------------------------------------- /scripts/timers/package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "timers", 3 | "version": "1.1.0", 4 | "lockfileVersion": 3, 5 | "requires": true, 6 | "packages": { 7 | "": { 8 | "name": "timers", 9 | "version": "1.1.0", 10 | "license": "MIT" 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /scripts/timers/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "module", 3 | "name": "timers", 4 | "version": "1.1.0", 5 | "main": "timers.js", 6 | "scripts": { 7 | "test": "tsc && node timers-test.js" 8 | }, 9 | "keywords": [], 10 | "author": "", 11 | "license": "MIT", 12 | "description": "" 13 | } 14 | -------------------------------------------------------------------------------- /scripts/timers/tests.d.ts: -------------------------------------------------------------------------------- 1 | export {}; 2 | -------------------------------------------------------------------------------- /scripts/timers/tests.js: -------------------------------------------------------------------------------- 1 | import { setTimeout, setImmediate, setInterval, clearImmediate, clearInterval, clearTimeout } from "./index.js"; 2 | import { world } from "@minecraft/server"; 3 | function stdout(...data) { 4 | return world.getDimension("overworld").runCommandAsync(`say §r` + data.join(" ")); 5 | } 6 | ; 7 | function stderr(...data) { 8 | return world.getDimension("overworld").runCommandAsync(`say §c` + data.join(" ")); 9 | } 10 | ; 11 | // timeout test 12 | setTimeout(function (arg, arg1) { 13 | stdout("arg", arg, "arg1", arg1); 14 | }, 1000, "hello", "world", 1); 15 | stdout("setTimeout passed"); 16 | // cleartimeout test 17 | let timeout2 = setTimeout(function () { 18 | stderr("clearTimeout failed"); 19 | }, 1000); 20 | clearTimeout(timeout2); 21 | stdout("clearTimeout passed"); 22 | // setinterval test 23 | let interval = setInterval(function (arg, arg1) { 24 | stdout("arg", arg, "arg1", arg1); 25 | }, 1000, "set", "interval", 1); 26 | stdout("setTimeout passed"); 27 | // clearinterval test 28 | interval._onTimeout = () => { 29 | stderr("clearInterval failed"); 30 | }; 31 | clearInterval(interval); 32 | stdout("clearInterval passed"); 33 | // setimmediate test 34 | setImmediate(function () { 35 | stdout("setImmediate passed"); 36 | }); 37 | // clearimmediate test 38 | let immediate = setImmediate(function () { 39 | stderr("setImmediate failed"); 40 | }); 41 | clearImmediate(immediate); 42 | stdout("clearImmediate passed"); 43 | -------------------------------------------------------------------------------- /scripts/timers/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ES5", 4 | "lib": ["ES2015"], 5 | "forceConsistentCasingInFileNames": true, 6 | "noImplicitAny": true, 7 | "noImplicitThis": true, 8 | "strictFunctionTypes": true, 9 | "strictNullChecks": true, 10 | }, 11 | "files": [ 12 | "index.ts", 13 | "tests.ts" 14 | ], 15 | "extends": "../tsconfig.json" 16 | } -------------------------------------------------------------------------------- /scripts/timing/README.md: -------------------------------------------------------------------------------- 1 | # timing 2 | 3 | ## Description 4 | > This README is auto generated, Edit the README so that users know what this package does. 5 | 6 | ## Credits 7 | These scripts were written by [bot174](https://github.com/bot174) 8 | -------------------------------------------------------------------------------- /scripts/timing/index.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * The `setInterval()` method, repeatedly calls a function, with a fixed time delay between each call. 3 | * This method returns an ID which uniquely identifies the interval, so you can remove it later by calling `clearInterval()`. 4 | */ 5 | declare function setInterval(handler: () => void, timeout?: number): number; 6 | /** 7 | * The `setTimeout()` method sets a timer which executes a function or specified piece of code once the timer expires. 8 | */ 9 | declare function setTimeout(handler: () => void, timeout?: number): number; 10 | /** 11 | * The `clearInterval()` method cancels a timed, repeating action which was previously established by a call to `setInterval()`. 12 | */ 13 | declare function clearInterval(id: number | undefined): void; 14 | /** 15 | * The `clearTimeout()` method cancels a timeout previously established by calling `setTimeout()`. 16 | */ 17 | declare function clearTimeout(id: number | undefined): void; 18 | 19 | export { setInterval, setTimeout, clearInterval, clearTimeout }; 20 | -------------------------------------------------------------------------------- /scripts/to-roman-numeral/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 GlitchyTurtle32 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /scripts/to-roman-numeral/README.md: -------------------------------------------------------------------------------- 1 | # to-roman-numeral 2 | 3 | ## Description 4 | 5 | To roman numeral 6 | 7 | ## Credits 8 | 9 | These scripts were written by [GlitchyTurtle32](https://github.com/GlitchyTurtle) 10 | -------------------------------------------------------------------------------- /scripts/to-roman-numeral/index.js: -------------------------------------------------------------------------------- 1 | // Script example for ScriptAPI 2 | // Author: GlitchyTurtle32 3 | // Project: https://github.com/JaylyDev/ScriptAPI 4 | /** 5 | * @param {number} num 6 | */ 7 | function toRomanNumeral(num) { 8 | var lookup = {M:1000, CM:900, D:500, CD:400, C:100, XC:90, L:50, XL:40, X:10, IX:9, V:5, IV:4, I:1}, roman = '', i; 9 | for ( i in lookup ) { 10 | while ( num >= lookup[i] ) { 11 | roman += i; 12 | num -= lookup[i]; 13 | } 14 | } 15 | return roman; 16 | } -------------------------------------------------------------------------------- /scripts/trace-line-evenly-spaced/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 GlitchyTurtle32 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /scripts/trace-line-evenly-spaced/README.md: -------------------------------------------------------------------------------- 1 | # trace-line-evenly-spaced 2 | 3 | ## Description 4 | 5 | trace line evenly spaced 6 | 7 | ## Credits 8 | 9 | These scripts were written by [GlitchyTurtle32](https://github.com/GlitchyTurtle) 10 | -------------------------------------------------------------------------------- /scripts/trace-line-evenly-spaced/index.js: -------------------------------------------------------------------------------- 1 | // Script example for ScriptAPI 2 | // Author: GlitchyTurtle32 3 | // Project: https://github.com/JaylyDev/ScriptAPI 4 | /** 5 | * @param {import("@minecraft/server").Vector3} startPoint 6 | * @param {import("@minecraft/server").Vector3} endPoint 7 | * @param {number} numOfPoints 8 | */ 9 | function traceLine(startPoint, endPoint, numOfPoints) { 10 | class Point { 11 | /** 12 | * @param {number} x 13 | * @param {number} y 14 | * @param {number} z 15 | */ 16 | constructor(x, y, z) { 17 | this.x = x; 18 | this.y = y; 19 | this.z = z; 20 | } 21 | } 22 | 23 | let pStart = new Point(startPoint.x, startPoint.y, startPoint.z); 24 | let pEnd = new Point(endPoint.x, endPoint.y, endPoint.z); 25 | 26 | for (let i = 1; i <= numOfPoints; i++) { 27 | const position = {x: ((pStart.x - pEnd.x) / numOfPoints) * i + pEnd.x, y: ((pStart.y - pEnd.y) / numOfPoints) * i + pEnd.y, z: ((pStart.z - pEnd.z) / numOfPoints) * i + pEnd.z}; 28 | // Code per point goes here! 29 | } 30 | } -------------------------------------------------------------------------------- /scripts/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig-base.json", 3 | "compilerOptions": { 4 | "baseUrl": "./", 5 | }, 6 | "include": ["**/*.ts", "**/*.js"], 7 | "exclude": [] 8 | } -------------------------------------------------------------------------------- /scripts/ui-wrapper/ActionForm.js: -------------------------------------------------------------------------------- 1 | import { ActionFormData } from "@minecraft/server-ui"; 2 | export class ActionFormButton { 3 | constructor(text, iconPath) { 4 | this.text = text; 5 | this.iconPath = iconPath; 6 | } 7 | ; 8 | } 9 | ; 10 | /** 11 | * Builds a simple player form with buttons that let the player 12 | * take action. 13 | */ 14 | export class ActionFormBuilder { 15 | constructor() { 16 | /** 17 | * Buttons of the the modal dialog. 18 | */ 19 | this.buttons = []; 20 | } 21 | body(bodyText) { 22 | this.bodyText = bodyText; 23 | return this; 24 | } 25 | button(text, iconPath) { 26 | this.buttons.push(new ActionFormButton(text, iconPath)); 27 | return this; 28 | } 29 | show(player) { 30 | const form = new ActionFormData(); 31 | if (!!this.titleText) 32 | form.title(this.titleText); 33 | if (!!this.bodyText) 34 | form.body(this.bodyText); 35 | this.buttons.forEach(item => form.button(item.text, item.iconPath)); 36 | return form.show(player); 37 | } 38 | title(titleText) { 39 | this.titleText = titleText; 40 | return this; 41 | } 42 | } 43 | ; 44 | -------------------------------------------------------------------------------- /scripts/ui-wrapper/MessageForm.js: -------------------------------------------------------------------------------- 1 | import { MessageFormData } from "@minecraft/server-ui"; 2 | export class MessageFormButton { 3 | constructor(text) { 4 | this.text = text; 5 | } 6 | ; 7 | } 8 | ; 9 | /** 10 | * Builds a simple player form with buttons that let the player 11 | * take action. 12 | */ 13 | export class MessageFormBuilder { 14 | constructor() { 15 | this.buttons = []; 16 | } 17 | body(bodyText) { 18 | this.bodyText = bodyText; 19 | return this; 20 | } 21 | button1(text) { 22 | this.buttons[0] = new MessageFormButton(text); 23 | return this; 24 | } 25 | button2(text) { 26 | this.buttons[1] = new MessageFormButton(text); 27 | return this; 28 | } 29 | show(player) { 30 | const [button1, button2] = this.buttons; 31 | const form = new MessageFormData(); 32 | if (!!this.titleText) 33 | form.title(this.titleText); 34 | if (!!this.bodyText) 35 | form.body(this.bodyText); 36 | if (!!button1) 37 | form.button1(button1.text); 38 | if (!!button2) 39 | form.button2(button2.text); 40 | return form.show(player); 41 | } 42 | title(titleText) { 43 | this.titleText = titleText; 44 | return this; 45 | } 46 | } 47 | ; 48 | -------------------------------------------------------------------------------- /scripts/ui-wrapper/README.md: -------------------------------------------------------------------------------- 1 | # UI Forms Wrapper 2 | 3 | Wrapper for UI forms to expose content of form data. 4 | 5 | ## ModalFormData 6 | 7 | To migrate from native `ModalFormData`: 8 | - import `ModalFormBuilder` from index.js 9 | - Rename all `ModalFormData` to `ModalFormBuilder` 10 | 11 | To access Modal form content: 12 | - `ModalFormBuilder.titleText`: Title text of the modal form 13 | - `ModalFormBuilder.content`: Content of the modal form 14 | 15 | ## MessageFormData 16 | 17 | To migrate from native `MessageFormData`: 18 | - import `MessageFormBuilder` from index.js 19 | - Rename all `MessageFormData` to `MessageFormBuilder` 20 | 21 | To access message form content: 22 | - `MessageFormBuilder.titleText`: Title text of the message form 23 | - `MessageFormBuilder.bodyText`: Body text of the message form 24 | - `MessageFormBuilder.buttons`: `button1` and `button2` text of the message form (`[button1, button2]`) 25 | 26 | ## ActionFormData 27 | 28 | To migrate from native `ActionFormData`: 29 | - import `ActionFormBuilder` from index.js 30 | - Rename all `ActionFormData` to `ActionFormBuilder` 31 | 32 | To access Modal form content: 33 | - `ActionFormBuilder.titleText`: Title text of the modal form 34 | - `ActionFormBuilder.bodyText`: Body text of the modal form 35 | - `ActionFormBuilder.buttons`: Buttons of the modal form 36 | -------------------------------------------------------------------------------- /scripts/ui-wrapper/index.js: -------------------------------------------------------------------------------- 1 | // Script example for ScriptAPI 2 | // Author: Jayly 3 | // Project: https://github.com/JaylyDev/ScriptAPI 4 | export * from "./ModalForm"; 5 | export * from "./MessageForm"; 6 | export * from "./ActionForm"; 7 | -------------------------------------------------------------------------------- /scripts/ui-wrapper/index.ts: -------------------------------------------------------------------------------- 1 | // Script example for ScriptAPI 2 | // Author: Jayly 3 | // Project: https://github.com/JaylyDev/ScriptAPI 4 | 5 | export * from "./ModalForm"; 6 | export * from "./MessageForm"; 7 | export * from "./ActionForm"; 8 | -------------------------------------------------------------------------------- /scripts/vanilla-types/README.md: -------------------------------------------------------------------------------- 1 | Basically @minecraft/vanilla-data, unlike enums the static properties returns corresponding type classes -------------------------------------------------------------------------------- /scripts/vanilla-types/index.js: -------------------------------------------------------------------------------- 1 | // Script example for ScriptAPI 2 | // Author: Jayly 3 | // Project: https://github.com/JaylyDev/ScriptAPI 4 | export * from './mojang-block'; 5 | export * from './mojang-cameraPresets'; 6 | export * from './mojang-dimension'; 7 | export * from './mojang-effect'; 8 | export * from './mojang-enchantment'; 9 | export * from './mojang-entity'; 10 | export * from './mojang-item'; 11 | -------------------------------------------------------------------------------- /scripts/vanilla-types/index.ts: -------------------------------------------------------------------------------- 1 | // Script example for ScriptAPI 2 | // Author: Jayly 3 | // Project: https://github.com/JaylyDev/ScriptAPI 4 | export * from './mojang-block'; 5 | export * from './mojang-cameraPresets'; 6 | export * from './mojang-dimension'; 7 | export * from './mojang-effect'; 8 | export * from './mojang-enchantment'; 9 | export * from './mojang-entity'; 10 | export * from './mojang-item'; 11 | -------------------------------------------------------------------------------- /scripts/vanilla-types/mojang-cameraPresets.js: -------------------------------------------------------------------------------- 1 | /** 2 | * All possible MinecraftCameraPresetsTypes 3 | */ 4 | export var MinecraftCameraPresetsTypes; 5 | (function (MinecraftCameraPresetsTypes) { 6 | MinecraftCameraPresetsTypes["FirstPerson"] = "minecraft:first_person"; 7 | MinecraftCameraPresetsTypes["Free"] = "minecraft:free"; 8 | MinecraftCameraPresetsTypes["ThirdPerson"] = "minecraft:third_person"; 9 | MinecraftCameraPresetsTypes["ThirdPersonFront"] = "minecraft:third_person_front"; 10 | })(MinecraftCameraPresetsTypes || (MinecraftCameraPresetsTypes = {})); 11 | -------------------------------------------------------------------------------- /scripts/vanilla-types/mojang-cameraPresets.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * All possible MinecraftCameraPresetsTypes 3 | */ 4 | export enum MinecraftCameraPresetsTypes { 5 | FirstPerson = "minecraft:first_person", 6 | Free = "minecraft:free", 7 | ThirdPerson = "minecraft:third_person", 8 | ThirdPersonFront = "minecraft:third_person_front" 9 | } 10 | /** 11 | * Union type equivalent of the MinecraftCameraPresetsTypes enum. 12 | */ 13 | export type MinecraftCameraPresetsTypesUnion = keyof typeof MinecraftCameraPresetsTypes; 14 | -------------------------------------------------------------------------------- /scripts/vanilla-types/mojang-dimension.js: -------------------------------------------------------------------------------- 1 | import { world, DimensionTypes } from "@minecraft/server"; 2 | /** 3 | * All possible MinecraftDimensionTypes 4 | */ 5 | export class MinecraftDimensionTypes { 6 | constructor() { 7 | throw new TypeError("Illegal constructor"); 8 | } 9 | ; 10 | static get(typeName) { 11 | return world.getDimension(typeName); 12 | } 13 | ; 14 | static getAll() { 15 | return DimensionTypes.getAll().map(dimension => world.getDimension(dimension.typeId)); 16 | } 17 | ; 18 | static get Nether() { return world.getDimension("minecraft:nether"); } 19 | ; 20 | static get Overworld() { return world.getDimension("minecraft:overworld"); } 21 | ; 22 | static get TheEnd() { return world.getDimension("minecraft:the_end"); } 23 | ; 24 | } 25 | -------------------------------------------------------------------------------- /scripts/vanilla-types/mojang-dimension.ts: -------------------------------------------------------------------------------- 1 | import { Dimension, world, DimensionTypes } from "@minecraft/server"; 2 | 3 | /** 4 | * All possible MinecraftDimensionTypes 5 | */ 6 | export class MinecraftDimensionTypes { 7 | private constructor() { 8 | throw new TypeError("Illegal constructor"); 9 | }; 10 | static get(typeName: string): Dimension | undefined { 11 | return world.getDimension(typeName); 12 | }; 13 | static getAll(): Dimension[] { 14 | return DimensionTypes.getAll().map(dimension => world.getDimension(dimension.typeId)); 15 | }; 16 | static get Nether() { return world.getDimension("minecraft:nether"); }; 17 | static get Overworld() { return world.getDimension("minecraft:overworld"); }; 18 | static get TheEnd() { return world.getDimension("minecraft:the_end"); }; 19 | } 20 | /** 21 | * Union type equivalent of the MinecraftDimensionTypes enum. 22 | */ 23 | export type MinecraftDimensionTypesUnion = keyof typeof MinecraftDimensionTypes; 24 | -------------------------------------------------------------------------------- /scripts/vanilla-types/webpack.config.js: -------------------------------------------------------------------------------- 1 | // webpack.config.js 2 | // @ts-nocheck 3 | const path = require('path'); 4 | 5 | const config = { 6 | entry: './index.js', 7 | output: { 8 | path: __dirname, 9 | filename: 'index.min.js', 10 | library: { 11 | type: 'module' 12 | }, 13 | 14 | }, 15 | mode: "production", 16 | experiments: { 17 | outputModule: true, 18 | }, 19 | externalsType: "module", 20 | externals: { 21 | "@minecraft/server": '@minecraft/server', 22 | } 23 | 24 | }; 25 | 26 | module.exports = config; 27 | -------------------------------------------------------------------------------- /scripts/vanilla_data_library/README.md: -------------------------------------------------------------------------------- 1 | # @minecraft/vanilla-data 2 | 3 | This module contains type definitions and enumarations for vanilla content within the game, such as Blocks, Items, Entities, and more. This module is versioned accordingly with Minecraft release and preview versions, and contain the up to date types available in the game. -------------------------------------------------------------------------------- /scripts/vector3-polyfill/BlockAreaSize.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @beta 3 | * Holds information for expressing the net size of a volume of 4 | * blocks. 5 | */ 6 | export declare class BlockAreaSize { 7 | /** 8 | * X size (west to east) component of this block area. 9 | */ 10 | x: number; 11 | /** 12 | * Y size (down to up) of this block area size. 13 | */ 14 | y: number; 15 | /** 16 | * Z size (south to north) of this block area size. 17 | */ 18 | z: number; 19 | /** 20 | * @remarks 21 | * Creates a new BlockAreaSize object. 22 | * @param x 23 | * @param y 24 | * @param z 25 | */ 26 | constructor(x: number, y: number, z: number); 27 | /** 28 | * @remarks 29 | * Tests whether this block area size is equal to another 30 | * BlockAreaSize object. 31 | * @param other 32 | */ 33 | equals(other: BlockAreaSize): boolean; 34 | } 35 | -------------------------------------------------------------------------------- /scripts/vector3-polyfill/BlockAreaSize.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @beta 3 | * Holds information for expressing the net size of a volume of 4 | * blocks. 5 | */ 6 | export class BlockAreaSize { 7 | /** 8 | * @remarks 9 | * Creates a new BlockAreaSize object. 10 | * @param x 11 | * @param y 12 | * @param z 13 | */ 14 | constructor(x, y, z) { 15 | this.x = Math.floor(x); 16 | this.y = Math.floor(y); 17 | this.z = Math.floor(z); 18 | } 19 | /** 20 | * @remarks 21 | * Tests whether this block area size is equal to another 22 | * BlockAreaSize object. 23 | * @param other 24 | */ 25 | equals(other) { 26 | if (this.x === other.x && this.y === other.y && this.z === other.z) 27 | return true; 28 | else 29 | return false; 30 | } 31 | ; 32 | } 33 | -------------------------------------------------------------------------------- /scripts/vector3-polyfill/BlockAreaSize.ts: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * @beta 4 | * Holds information for expressing the net size of a volume of 5 | * blocks. 6 | */ 7 | export class BlockAreaSize { 8 | /** 9 | * X size (west to east) component of this block area. 10 | */ 11 | x: number; 12 | /** 13 | * Y size (down to up) of this block area size. 14 | */ 15 | y: number; 16 | /** 17 | * Z size (south to north) of this block area size. 18 | */ 19 | z: number; 20 | /** 21 | * @remarks 22 | * Creates a new BlockAreaSize object. 23 | * @param x 24 | * @param y 25 | * @param z 26 | */ 27 | constructor(x: number, y: number, z: number) { 28 | this.x = Math.floor(x); 29 | this.y = Math.floor(y); 30 | this.z = Math.floor(z); 31 | } 32 | /** 33 | * @remarks 34 | * Tests whether this block area size is equal to another 35 | * BlockAreaSize object. 36 | * @param other 37 | */ 38 | equals(other: BlockAreaSize): boolean { 39 | if (this.x === other.x && this.y === other.y && this.z === other.z) 40 | return true; 41 | else return false; 42 | }; 43 | } -------------------------------------------------------------------------------- /scripts/vector3-polyfill/README.md: -------------------------------------------------------------------------------- 1 | # vector3-polyfill 2 | 3 | **Caution**: This package is no longer maintained. Please use the [@minecraft/math](https://jaylydev.github.io/scriptapi-docs/latest/modules/_minecraft_math.html) module. 4 | 5 | ## Description 6 | 7 | Polyfill for `Vector3` native classes before 1.19.70: 8 | 9 | - `BlockAreaSize` 10 | - `BlockLocation` 11 | - `Location` 12 | - `Vector` 13 | 14 | for everything in a class use `Vector3.ts` 15 | 16 | ## Credits 17 | 18 | These scripts were written by [JaylyDev](https://github.com/JaylyDev) 19 | -------------------------------------------------------------------------------- /scripts/vector3-polyfill/index.d.ts: -------------------------------------------------------------------------------- 1 | export * from './BlockAreaSize'; 2 | export * from './BlockLocation'; 3 | export * from './Location'; 4 | export * from './Vector'; 5 | export * from './Vector3'; 6 | -------------------------------------------------------------------------------- /scripts/vector3-polyfill/index.js: -------------------------------------------------------------------------------- 1 | // Script example for ScriptAPI 2 | // Author: bot174 3 | // Project: https://github.com/JaylyDev/ScriptAPI 4 | export * from './BlockAreaSize'; 5 | export * from './BlockLocation'; 6 | export * from './Location'; 7 | export * from './Vector'; 8 | export * from './Vector3'; 9 | -------------------------------------------------------------------------------- /scripts/vector3-polyfill/index.ts: -------------------------------------------------------------------------------- 1 | // Script example for ScriptAPI 2 | // Author: bot174 3 | // Project: https://github.com/JaylyDev/ScriptAPI 4 | export * from './BlockAreaSize'; 5 | export * from './BlockLocation'; 6 | export * from './Location'; 7 | export * from './Vector'; 8 | export * from './Vector3'; -------------------------------------------------------------------------------- /scripts/vector3-polyfill/tests.d.ts: -------------------------------------------------------------------------------- 1 | export {}; 2 | -------------------------------------------------------------------------------- /scripts/vector3-polyfill/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "es2020", 4 | "target": "es2020", 5 | "allowJs": true, 6 | "checkJs": true, 7 | "moduleResolution": "node", 8 | "allowSyntheticDefaultImports": false, 9 | }, 10 | "files": [ 11 | "BlockAreaSize.ts", 12 | "BlockLocation.ts", 13 | "index.ts", 14 | "Location.ts", 15 | "tests.ts", 16 | "Vector.ts", 17 | "Vector3.ts", 18 | ] 19 | } -------------------------------------------------------------------------------- /scripts/wait-move/README.md: -------------------------------------------------------------------------------- 1 | # wait-move 2 | 3 | ## Description 4 | 5 | When a wait-move is set, it will run code once the player has moved. 6 | 7 | **Parameters:** 8 | 9 | - `player` (type: Player or entity): The player or entity for which the function will be executed on. 10 | 11 | - `x` (type: number): The X-coordinate of the destination of the player's current location. 12 | 13 | - `y` (type: number): The Y-coordinate of the destination of the player's current location. 14 | 15 | - `z` (type: number): The Z-coordinate of the destination of the player's current location. 16 | 17 | - `callback` (type: function): The callback function to be executed once the player has moved. 18 | 19 | **Example:** 20 | 21 | ```js 22 | 23 | waitMove(player, x, y, z, (target) => { 24 | 25 | target.sendMessage('You have moved!'); 26 | 27 | }); 28 | 29 | ``` 30 | 31 | ## Credits 32 | 33 | These scripts were written by [defowler2005](https://github.com/defowler2005). 34 | -------------------------------------------------------------------------------- /scripts/world-border/README.md: -------------------------------------------------------------------------------- 1 | # world-border 2 | 3 | ## Description 4 | 5 | Rn code when the player is outside the set coordinates. 6 | 7 | **Parameters:** 8 | 9 | - `player` (type: Player or entity): The player or entity for which the function will be executed on. 10 | 11 | - `border` (type: object): An object representing the border with the following properties: 12 | 13 | - `minX` (type: number): The minimum X-coordinate value of the border. 14 | 15 | - `minZ` (type: number): The minimum Z-coordinate value of the border. 16 | 17 | - `maxX` (type: number): The maximum X-coordinate value of the border. 18 | 19 | - `maxZ` (type: number): The maximum Z-coordinate value of the border. 20 | 21 | The border is defined by the range between (`minX`, `minZ`) and (`maxX`, `maxZ`) coordinates. 22 | 23 | ## Credits 24 | 25 | These scripts were written by [defowler2005](https://github.com/defowler2005). 26 | -------------------------------------------------------------------------------- /scripts/world-time/README.md: -------------------------------------------------------------------------------- 1 | # world-time 2 | 3 | ## Description 4 | 5 | There are two functions in this script: 6 | 7 | - function `GetWorldTime` 8 | 9 | ## returns 10 | 11 | The hours and minutes of the world time. 12 | 13 | ## example 14 | 15 | `getworldtime.js` 16 | 17 | ```js 18 | import { world } from "@minecraft/server"; 19 | 20 | const { hours, minutes } = GetWorldTime(); 21 | world.sendMessage(`The time is ${hours}:${minutes}`); 22 | ``` 23 | 24 | - function `getTimeOfDay` 25 | Gets the name of the time of day 26 | 27 | ## returns 28 | 29 | 'Sunrise', 'Day', 'Noon', 'Sunset', 'Night', or 'Midnight' 30 | 31 | ## Credits 32 | 33 | These scripts were written by Jayly#1397 on Jayly Discord, Usernam#2058 on Jayly Discord 34 | -------------------------------------------------------------------------------- /tools/index.ts: -------------------------------------------------------------------------------- 1 | import * as headerChecks from "./headerChecks"; 2 | import * as packageCheck from "./packageCheck"; 3 | import * as testScriptChecks from "./testScriptChecks"; 4 | import * as readme from "./packageReadme"; 5 | 6 | function log (...args: string[]) { 7 | console.log(''); 8 | console.log(...args, '\n'); 9 | }; 10 | 11 | interface Task { 12 | message: string; 13 | execute: () => 0 | 1; 14 | }; 15 | 16 | function runTasks (tasks: Task[]): number { 17 | const taskStatus: number[] = []; 18 | 19 | for (const task of tasks) { 20 | log(task.message + '...'); 21 | const statusCode = task.execute(); 22 | taskStatus.push(statusCode); 23 | }; 24 | 25 | console.log(taskStatus.map((status, index) => `Task: ${tasks[index].message}, Status: ${status}`)); 26 | 27 | if (taskStatus.length <= 0) return 1; 28 | else if (taskStatus.filter(status => status !== 0).length > 0) return 1; 29 | else return 0; 30 | }; 31 | 32 | const exitCode = runTasks([ 33 | { message: "Checking script file headers", execute: headerChecks.execute }, 34 | { message: "Checking script names", execute: packageCheck.execute }, 35 | { message: "Looking for test files in packages", execute: testScriptChecks.execute }, 36 | { message: "Adding README for packages", execute: readme.execute }, 37 | ]); 38 | 39 | process.exit(exitCode); -------------------------------------------------------------------------------- /tools/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es2019", 4 | "module": "commonjs", 5 | "strict": true, 6 | "esModuleInterop": true, 7 | "forceConsistentCasingInFileNames": true, 8 | "noImplicitReturns": true, 9 | "noFallthroughCasesInSwitch": true, 10 | "allowUnreachableCode": false, 11 | "resolveJsonModule": true, 12 | "composite": false, 13 | "types": ["node"], 14 | "lib": ["es2022"], 15 | "outDir": "../dist" 16 | } 17 | } -------------------------------------------------------------------------------- /tsconfig-base.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "es2020", 4 | "target": "es2021", 5 | "moduleResolution": "classic", 6 | "allowSyntheticDefaultImports": true, 7 | "types": [ 8 | "@minecraft/server-gametest", 9 | "@minecraft/server", 10 | "@minecraft/server-ui", 11 | "@minecraft/server-admin", 12 | "@minecraft/server-editor", 13 | "@minecraft/server-net", 14 | "@minecraft/vanilla-data", 15 | "@minecraft/common", 16 | "@minecraft/math" 17 | ], 18 | "typeRoots": ["./node_modules/"], 19 | } 20 | } -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "files": [], 3 | "exclude": [ "docs" ], 4 | "references": [ 5 | { "path": "tools/tsconfig.json" }, 6 | { "path": "scripts/tsconfig.json" }, 7 | { "path": "scripts/jsconfig.json" } 8 | ] 9 | } --------------------------------------------------------------------------------