grakkit-boilerplate
grakkit-boilerplate copied to clipboard
Grakkit Boilerplate
Useful boilerplate for creating stuff with Grakkit
Grakkit is a Minecraft Server Plugin utilizing the GraalVM JavaScript Engine. This repository is a boilerplate implementation to quickly spawn up a workspace to get started using Babel, Webpack, and TypeScript.
This boilerplate features a "Hot Reload" method, which speeds up development significantly. Whenever you make changes to your code during Runtime and hit save, it'll rebuild the solution then reload it on the server. This takes less than a second.

What is new?
We have been hard at work revamping our typing implementation for grakkit. In the previous implementation, it was
limited to a fixed set of snapshot types for only Bukkit/Paper. However, with the newest implementation, we are
leveraging @graal-types and a custom babel plugin!
// Old; No need to do this anymore
const Bukkit = core.type('org.bukkit.Bukkit')
// New
import { Bukkit } from 'org.bukkit'
By leveraging the import feature and a change in tsconfig, this allows us to import type definitions from external
libraries. If you want to integrate your plugin with another plugin library (such as LuckPerms, Essentials), it just
became significantly easier!
You can checkout a list of typings available over at @Graal/Types.
Getting Started
- Click the "Use this template" in the top right.
- Once you have cloned the repo and have it locally, you'll need to do the following:
- Download your preferred Minecraft Server Plugin implementation
- Grakkit only supports Paper or Minestom.
- Place the server plugin jar file in the
./serverfolder and rename it toserver.jar. - Download the Grakkit jar and place it in the
./server/pluginsfolder. - Run
npm installoryarn. - Open a terminal and run
npm run start:jsoryarn start:js. This will start the webpack. - Open another terminal and run
npm run start:serveroryarn start:server- When running it for the first time, you'll need to accept the
EULAin./server/eula.txt. - After updating the
EULA, you may need to restart the server.
- When running it for the first time, you'll need to accept the
- Once everything is up and running, you can now start developing in
./src/index.ts.
What can you do with this?
- Through Grakkit, you have access to both Java and Paper classes, objects, and types.
- You can access the API of other server plugins, such as LibsDisguises, PlaceholderAPI, and so many more.
- You can import existing JavaScript libraries and use them within your plugin, such as Lodash, Redux, Yaml, Immer, and
so many more.
- Note: NodeJS does not work within GraalVM, so you cannot use libraries expecting NodeJS API.
- Note: Fetch/Websockets/Multithreading can be a challenge.

How It Works
Development Mode npm run start:js/yarn start:js
- This spawns a webserver within the Minecraft server.
- When in development mode, it enables a new API route called
/reload. - The solution is built using webpack (which is fast) and it will put the compiled files in
server/plugins/grakkit. - Using a custom start up script in
scripts/start/index.ts, it will build the solution, enable development mode, and ping the/reloadendpoint.- Once the endpoint is hit, well, the server reloads grakkit.
Production Mode npm run build/yarn build
- Using webpack, it'll build the files to
/dist. Any code relying ondevelopmentwill be disabled. - This can be a useful step for deployments.
Startup
- Run
npm run start:jsoryarn start:js - Run
npm run start:serveroryarn start:server
OR
- Run
npm run startoryarn start
Info
Deps Folder
When developing plugins, you may need to hook into additional dependencies. You can add those jars to the ./deps
folder. If you need further customization, you can update scripts/start/index.ts.