githubEdit

scrollJSpp

circle-exclamation

Warning

.jspp

circle-info

Remember to update the vscode extensionarrow-up-right to get autocompletion and common errors checking of the new preview .jspp format.

This scripting mode uses Java under the hood but allows some JavaScript-inspired syntax for convenience.

Advantages:

  • Requires less code: common imports are automatically resolved.

  • Faster to write.

Disadvantages:

  • No debugger.

  • Autocomplete is not precise and mostly missing.

  • The intellisense is not always reliable on errors.

  • Hard to identify and fix bugs in your code.

✅ Syntax Basics

  • Semicolons (;) are mandatory at the end of each statement, like in Java.

  • You can use const, let, or var to declare variables.

  • Supports lambda expressions and Java class imports.

🌟 Script Variables

Scripts inherit several predefined variables from the event that triggered the script. These variables are automatically available in your script and are prefixed with a $ to avoid name conflicts:

  • $plugin: The plugin instance.

  • $event: The event that triggered the script.

  • $player: The player involved in the event (if applicable).

  • $customStack: The custom item stack involved (if applicable).

  • $itemStack: The standard item stack involved (if applicable).

  • $customEntity: The standard custom entity involved (if applicable).

The generated Java class for the script includes a main function with the following signature:

Or the following signature if a custom entity script:

📝 Note: This structure is currently fixed and cannot be modified. Ensure your scripts are designed to work within this framework.

⏳ Delays

Use the delay(ticks, () -> { ... }) function to delay execution.

  • 1 second = 20 ticks


📦 Importing Java Classes

You can import external classes using the import keyword with quotes:


❌ Cancelling The Event

You can cancel the current event using:


🔧 Utility Functions

🧱 ItemStack Utilities

🧍 Player Held Item

🧱 Block Utilities

💬 Messaging and Logging

↺ Casting

Exactly how it works in Java.


📌 Best Practices

  • Use delay() for animations or delayed feedback.

  • Always check isCustom() before modifying custom items or blocks.

  • Log actions with log() during debugging.

  • Use cancelEvent() to prevent default behavior when handling interactions.

Last updated