Skip to content
This repository has been archived by the owner on Jan 20, 2025. It is now read-only.

Commit

Permalink
up
Browse files Browse the repository at this point in the history
  • Loading branch information
lgc2333 committed Feb 24, 2024
1 parent bb5dcd0 commit e93d341
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 44 deletions.
59 changes: 31 additions & 28 deletions SimpleTransferCmd.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,36 +3,39 @@
/* global ll mc PermType ParamType */

const PLUGIN_NAME = 'SimpleTransferCmd';
const PLUGIN_VERSION = [0, 1, 0];
/** @type {[number, number, number]} */
const PLUGIN_VERSION = [0, 1, 1];

const cmdTransfer = mc.newCommand('transfer', '跨服指令', PermType.Any);
cmdTransfer.mandatory('host', ParamType.String);
cmdTransfer.mandatory('port', ParamType.Int);
cmdTransfer.optional('player', ParamType.Player);
cmdTransfer.overload(['host', 'port', 'player']);
cmdTransfer.setCallback(
/**
* @param {Command} _
* @param {CommandOrigin} param1
* @param {CommandOutput} out
* @param {{host: string, port: number, player?: Player[]}} param3
*/
(_, { player }, out, { host, port, player: selector }) => {
if (!player && !selector) {
out.error('请指定要跨服的玩家');
return false;
}
if (player && selector && player.permLevel < 1) {
out.error('仅OP可以传送其他人');
return false;
}
mc.listen('onServerStarted', () => {
const cmdTransfer = mc.newCommand('transfer', '跨服指令', PermType.Any);
cmdTransfer.mandatory('host', ParamType.String);
cmdTransfer.mandatory('port', ParamType.Int);
cmdTransfer.optional('player', ParamType.Player);
cmdTransfer.overload(['host', 'port', 'player']);
cmdTransfer.setCallback(
/**
* @param {Command} _
* @param {CommandOrigin} param1
* @param {CommandOutput} out
* @param {{host: string, port: number, player?: Player[]}} param3
*/
(_, { player }, out, { host, port, player: selector }) => {
if (!player && !selector) {
out.error('请指定要跨服的玩家');
return false;
}
if (player && selector && player.permLevel < 1) {
out.error('仅OP可以传送其他人');
return false;
}

const willTransfer = selector || [player];
willTransfer.forEach((p) => p.transServer(host, port));
return true;
}
);
cmdTransfer.setup();
const willTransfer = selector || [player];
willTransfer.forEach((p) => (p ? p.transServer(host, port) : undefined));
return true;
}
);
cmdTransfer.setup();
});

ll.registerPlugin(PLUGIN_NAME, '跨服指令', PLUGIN_VERSION, {
Author: 'student_2333',
Expand Down
10 changes: 10 additions & 0 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"entry": "SimpleTransferCmd.js",
"name": "SimpleTransferCmd",
"type": "lse-quickjs",
"dependencies": [
{
"name": "legacy-script-engine-quickjs"
}
]
}
36 changes: 20 additions & 16 deletions tooth.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
{
"format_version": 1,
"tooth": "github.com/lgc-LLSEDev/SimpleTransferCmd",
"version": "0.1.0",
"dependencies": {},
"information": {
"$schema": "https://raw.githubusercontent.com/lippkg/lip/main/schemas/tooth.v2.schema.json",
"format_version": 2,
"tooth": "github.com/lgc-LLDev/SimpleTransferCmd",
"version": "0.1.1",
"info": {
"name": "SimpleTransferCmd",
"description": "简易跨服指令",
"author": "lgc2333",
"license": "Apache-2.0",
"homepage": "https://github.com/lgc-LLSEDev/SimpleTransferCmd"
"description": "A plugin provides the `/transfer` command",
"author": "student_2333",
"tags": ["plugin", "lse", "quickjs", "transfer"]
},
"placement": [
{
"source": "SimpleTransferCmd.js",
"destination": "plugins/SimpleTransferCmd.js"
}
],
"possession": []
"files": {
"place": [
{
"src": "SimpleTransferCmd.js",
"dest": "plugins/SimpleTransferCmd/SimpleTransferCmd.js"
},
{
"src": "manifest.json",
"dest": "plugins/SimpleTransferCmd/manifest.json"
}
]
}
}
7 changes: 7 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extends": "../tsconfig.template.json",
"include": ["*.js"],
"compilerOptions": {
"outDir": "./dist"
}
}

0 comments on commit e93d341

Please sign in to comment.