Skip to content

raikasdev/craftjs

 
 

Repository files navigation

CraftJS (raikas' fork)

CraftJS is a PaperMC plugin that adds support for writing plugins in TypeScript and JavaScript.

Current status

CraftJS is in early development and has little documentation aside of the JS/Javadocs. No guarantees about API stability are provided.

Requirements

  • Paper (Minecraft 1.19.3)
    • Spigot does not work. PaperMC or Purpur recommended.
  • GraalVM 22.3 (Java 17 version)
    • Older known not to work, newer versions might be ok

Usage

Tutorials for creating CraftJS plugins will come later. For now, see 'internal' for a JS plugin example. If you copy the package.json from there, make sure to change dependency '@craftjs-typings/core' to latest version from npm.

To install CraftJS, just copy the jar file to your plugins folder.

Development

CraftJS can be built with 'build.sh' script available at repository root. Unfortunately, only Linux is supported for building at the moment.

More development instructions will come later.

Technical details

JavaScript is executed with GraalJS, which (unline Nashorn) supports modern JavaScript features. CraftJS itself provides

  • JavaScript plugin loader implementation
  • require() implementation with Java import support (for TypeScript)
  • Bukkit scheduling helpers
  • Event handler and command registration support
  • Various standard library function implementations/polyfills

TypeScript types are generated automatically from Java source code and include Javadoc. They are available on npm as '@craftjs-typings/core'.

Components

CraftJS consists of the following components that can be found in directories with similar names:

  • core: Javascript core
    • Provides core APIs (e.g. require) to JS plugins
    • Injected to each Graal context before loading JS plugin
  • internal: CraftJS JS plugin
    • Internal JS plugin that provides e.g. /craftjs command
    • Has access to internal APIs from java component
  • java: CraftJS Java code
    • Maven project with all our Java code

Differences from ScriptCraft

CraftJS is inspired by an older scripting plugin, Scriptcraft. Despite the obvious similarities, the two plugins have several important differences:

  • CraftJS uses GraalJS instead of Nashorn
    • Better support for new JS features
    • (Usually) better performance
  • CraftJS has TypeScript types
    • Autocomplete (and import) Bukkit classes!

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • TypeScript 53.9%
  • Java 43.6%
  • JavaScript 1.1%
  • Other 1.4%