New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

ylmodule

Package Overview
Dependencies
Maintainers
1
Versions
67
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
Package was removed
Sorry, it seems this package was removed from the registry

ylmodule

A gametest scripting module that aims to make scripting much more customized.

1.1.0-dev
unpublished
latest
development
npm
Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

YlModule

A minecraft gametest scripting module that aims to make gametest scripting much more customized, and currently has a few features.

YlModule Features

  • Command Management System
  • Event Handlers
  • Database System
  • Customized Events

And much more there is to come in the near future.

Command Management System

YlModule manages custom commands in clusters, giving the module the opportunity to be much more efficient in handling data. Command instances are the units of data in the system, which are separated and stored in different managers. Managers, or CommandManager instances to be precise, manage commands and handle their execution. Command managers must have unique names and prefixes to be easily distinguishable from each other.


Creating Custom Commands


For custom commands to be created, a CommandManager must be instantiated first in order for the commands to be stored and managed somewhere.


Command Manager constructor

constructor(name: string, prefix: string): CommandManager


Command constructor

constructor(options: CommandOptions): Command

import { CommandManager, Command } from "ylmodule";

// Instantiation of CommandManager
const testManager = new CommandManager("Test", "-");

// Registration of a command
testManager.register(
    new Command({
        name: "ping",
        description: "Replies with pong!",

        callback: (interaction) => {
            // Reply to the interaction
            interaction.reply("Pong!");
        },
    })
);

Command Execution

The command system is quite unique and requires a little more effort to execute. The command test from above can be executed in the format {prefix}{command}, where {prefix} is the prefix of the manager where the command is stored, and {command} being the name of the command itself.

In cases where a command has subcommands and options, the format for specifying which subcommand is executed is {subcommand}, and the format for specifying options is {option}: {value}. The {option} is the name of the option and {value} is the value passed. Note that the colon is required to avoid ambiguity between options and subcommands.

This may be confusing, but consider the following example to illustrate the format:

Say a command tag is created:

import { CommandManager, Command, CommandTypes } from "ylmodule";

// Instantiate the CommandManager
const commands = new CommandManager("GeneralCommands", "-");

// Register the command
commands.register(
    new Command({
        name: "tag",
        description: "Manages the tag of players",

        options: [
            {
                name: "player",
                description: "The player to have their tags managed",
                type: CommandTypes.Player,
                required: true,

                subcommands: [
                    {
                        name: "add",
                        description: "Adds tags to the player",

                        options: [
                            {
                                name: "tag",
                                description: "The tag to be added",
                                type: CommandTypes.String, // This is not required as "type" is set to String by default,
                                required: true,
                            },
                        ],
                    },
                    {
                        name: "remove",
                        description: "Removes tags from the player",

                        options: [
                            {
                                name: "tag",
                                description: "The tag to be added",
                                type: CommandTypes.String,
                                required: true,
                            },
                        ],
                    },
                    {
                        name: "list",
                        description: "Shows the tags of the player",
                    },
                ],
            },
        ],

        callback: (interaction) => {
            // Just reply for the mean time
            interaction.reply(`${interaction.commandName} used!`);
        },
    })
);

In the command example above, the command can be executed this way:

{prefix}{command} {option}: {value} {subcommand} {option}: {value}

For example:
-tag player: Ylon add tag: "test-tag"
-tag player: Ylon list



Installation

YlModule is installed with Node Package Manager (npm) by typing npm i ylmodule in the terminal. Do note that Node.js must be installed for the npm CLI to be accessible.

# To install YlModule
npm i ylmodule

After installing YlModule, you can initialize the current working directory as the script pack to be used by running npx ylmodule init, doing so will initialize the directory as a pack by adding the manifest.json and the src folder. The command also adds the scripts field inside the package.json for production.

NOTE: Executing npx ylmodule init will not overwrite the existing manifest.json file and src folder, and will, by default, generate a javascript file (index.js) inside src that is used as the entry file in the manifest.json.

# To initialize the current working directory
npx ylmodule init

The build script can then be ran once done editing the contents of the src folder. Running the script will compile all of the javascript files inside the source folder to the scripts folder, as well as the built ylmodule which will be inside yl_modules/YlModule.

# To compile the source folder and build the module
npm run build

Keywords

minecraft

FAQs

Package last updated on 11 May 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts