Skip to content

Repository files navigation

@customrealms/core

CustomRealms Logo

This repo contains the core library for CustomRealms, the JavaScript runtime for Minecraft server plugins.

Installation

npm install --save @customrealms/core

Example #1 - Events

import { ServerEvents } from '@customrealms/core';

// Send a welcome message when a player joins the server
ServerEvents.register(org.bukkit.event.player.PlayerJoinEvent, (event) => {
	const player = event.getPlayer();
	event.setJoinMessage(`${player.getName()} joined the server!`);
});

Example #2 - Commands

import { ServerCommands } from '@customrealms/core';

// Strike lightning where the player is looking
ServerCommands.register('/strike', (player) => {
	const block = player.getTargetBlockExact(100);
	if (!block) return;
	const location = block.getLocation();
	location.getWorld()?.strikeLightning(location);
});

Example #3 - Menus

import { Menus } from '@customrealms/core';

const result = await Menus.create<string>('Difficulty')
	.button(11, easyItem, 'easy')
	.button(13, normalItem, 'normal')
	.button(15, hardItem, 'hard')
	.open(player);

switch (result) {
	case 'easy':
		player.sendMessage('Easy mode selected.');
		break;
	case 'normal':
		player.sendMessage('Normal mode selected.');
		break;
	case 'hard':
		player.sendMessage('Hard mode selected.');
		break;
	case null:
		player.sendMessage('Maybe next time.');
}

How it works

By default, without this library, the CustomRealms JavaScript runtime has access to all of the Java and Bukkit classes and functions.

This library serves several important purposes:

  • Provides TypeScript type declarations for the native Java / Bukkit types.
  • Implements a clean abstraction layer to make certain common tasks easier (such as commands, events, etc.)
  • Adds polyfills to support modern ES6+ features.

Contributing

We need your help to implement new features, fix bugs, and optimize the entire system. If you want to help, please join our Discord and/or check out the Issues tab.

About

Core library for the CustomRealms runtime

Topics

Resources

Stars

38 stars

Watchers

4 watching

Forks

Releases

Used by

Contributors

Languages