Перейти к содержимому
Mineforgian

JS Runner

The plugin aims to add the ability to run JavaScript files in a Minecraft server.

Загрузки
62
Подписчики
0
Обновлён
31 декабря 2025 г.
Лицензия
CC-BY-SA-4.0

Опубликован 29 декабря 2025 г.

Description

This project was inspired by ScriptCraft. ScriptCraft is a plugin that allows JavaScript files to be ran on a Minecraft server, but sadly ScriptCraft is no longer being updated and only supports 1.8. This plugin aims to bring the function of ScriptCraft back to modern day Minecraft. This project includes custom JavaScript API to interact with the game server.

Setup

Put the .jar file into the server plugins folder and restart it. A new folder will pop up with the name: "JSRunner" and inside that folder will be another folder named: "scripts." You can put .js files into the scripts folder and use the appropriate command to execute it.

Commands

/js run <filename>

runs a Javascript file located in JSRunner/Scripts

/js stop <filename>

stops a Javascript file

/js reload

stops all JavaScript files

JavaScript API

Server

server.log()

logs a message to the server console

server.command()

runs a command as the console

Timers

timers.setTimeout(fn, ticks)

run fn once after ticks

timers.setInterval(fn, ticks)

run fn repeatedly every ticks

timers.clear(id)

cancels a timeout/interval

timers.clearAll()

cancels all timers.

Events

events.on(event, callback)

listens for an event

playerJoin

parameter: PlayerWrapper

playerQuit

parameter: PlayerWrapper

blockBreak

BlockWrapper

Block Wrapper

getType()

returns block type as string

getX()

get X position

getY()

get Y position

getZ()

get Z position

getPlayerName()

name of the player who broke the block

Player Wrapper

getName()

gets the players name

getUUID()

gets the players UUID

Sample Code (Requires latest version to work)

This sample code welcomes a player who joined the server.

server.log("Hello from JSRunner!");

events.on("playerJoin", function(player) {
    server.log("Welcome " + player.getName());
});

var intervalId = timers.setInterval(function() {
    server.log("Repeating message every 100 ticks");
}, 100);

This sample code clears the invenory of a player who breaks bedrock with their hands (not TNT).

events.on("blockBreak", function(block) {
    if (block.getType() === "BEDROCK") {
        server.command("clear " + block.getPlayerName());
        server.command("tell " + block.getPlayerName() + " Your inventory was cleared!");
    }
});

Ченджлог

1.2Релиз1.21.9, 1.21.10, 1.21.11 · 31 декабря 2025 г.

New Events

blockPlace

fires when a block is placed

getType()

returns the block that is being placed

getX(), getY(), getZ()

returns position

getPlayerName()

returns the name of the player who placed the block.

getPlayerUUID()

returns the UUID of the player who placed the block.

cancel()

stops the block from being placed

entityDamage

fires when an entity takes damage

getEntityType()

returns the damaged entity

isPlayer()

returns a boolean value

getPlayerName()

returns players name if it was a player that was damaged

getCause()

returns the cause of damage such as: "FALL", "ENTITY_ATTACK", "LAVA"

getDamage()

returns damage amount

setDamage(amount)

replaces the original damage with a new amount

cancel()

cancels the damage entirely

Complete List of Damage Types

BLOCK_EXPLOSION, CONTACT, CRAMMING, CUSTOM, DRAGON_BREATH, DROWNING, DRYOUT, ENTITY_ATTACK, ENTITY_EXPLOSION, ENTITY_SWEEP_ATTACK, FALL, FALLING_BLOCK, FIRE, FIRE_TICK, FLY_INTO_WALL, FREEZE, HOT_FLOOR, KILL, LAVA, LIGHTNING, MAGIC, MELTING, POISON, PROJECTILE, SONIC_BOOM, STARVATION, SUFFOCATION, THORNS, VOID, WITHER, WORLD_BORDER

1.1Релиз1.21.9, 1.21.10, 1.21.11 · 30 декабря 2025 г.

New Events

playerCommand
  • Fires when a player executes a command.

  • Commands can be blocked, modified, or redirected.

playerDeath
  • Fires when a player dies.

  • Provides death message and killer information.

New Methods

PlayerCommandWrapper

getPlayerName()

returns the name of the player who typed the command

getCommand()

returns the command

setCommand(newCommand)

replaces the command before execution (the new command must include a "/")

cancel()

cancels the command

PlayerDeathWrapper

getPlayerName()

Returns the name of the player who died.

getUUID()

Returns the UUID of the player who died.

getDeathMessage()

Returns the death message.

getKillerName()

Returns the name of the killer if killed by a player.

1.0Релиз1.21.9, 1.21.10, 1.21.11 · 30 декабря 2025 г.

The first public release of JS Runner.

Комментарии

Загружаем…