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

Commit 3129516

Browse files
committed
up
1 parent b307c6b commit 3129516

File tree

5 files changed

+79
-202
lines changed

5 files changed

+79
-202
lines changed

NavigationAPI.lls.js renamed to NavigationAPI.js

+39-26
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,23 @@ const exportNamespace = 'NavAPI';
77
const tasks = new Map();
88
const { Red, Green, Aqua, White, LightPurple, Clear, MinecoinGold } = Format;
99

10+
/**
11+
* @typedef {Object} FloatPosObject
12+
* @property {number} x
13+
* @property {number} y
14+
* @property {number} z
15+
* @property {number} dimId
16+
*/
17+
/**
18+
* @typedef {Object} Warp
19+
* @property {FloatPosObject} pos
20+
* @property {string} name
21+
*/
22+
23+
/**
24+
* @param {FloatPosObject} pos
25+
* @returns {string}
26+
*/
1027
function formatPos(pos) {
1128
const { x, y, z, dimId } = pos;
1229
const dim = (() => {
@@ -32,8 +49,8 @@ function formatPos(pos) {
3249
/**
3350
* 停止导航任务
3451
*
35-
* @param {String} xuid 玩家Xuid
36-
* @returns {Boolean} 是否成功
52+
* @param {string} xuid 玩家Xuid
53+
* @returns {boolean} 是否成功
3754
*/
3855
function clearNavigationTask(xuid) {
3956
const pl = mc.getPlayer(xuid);
@@ -53,8 +70,8 @@ function clearNavigationTask(xuid) {
5370
/**
5471
* 获取玩家是否正在导航中
5572
*
56-
* @param {String} xuid 玩家Xuid
57-
* @returns {Boolean} 玩家导航状态 true为正在导航
73+
* @param {string} xuid 玩家Xuid
74+
* @returns {boolean} 玩家导航状态 true为正在导航
5875
*/
5976
function hasNavigationTask(xuid) {
6077
return !!tasks.get(xuid); // to boolean
@@ -63,24 +80,18 @@ function hasNavigationTask(xuid) {
6380
/**
6481
* 新建导航任务
6582
*
66-
* warp对象必须包含的项目示例
67-
* {
68-
* "pos": {
69-
* "x": 39.43924331665039,
70-
* "y": 65.62001037597656,
71-
* "z": 92.11305236816406,
72-
* "dimId": 0
73-
* },
74-
* "name": "岩浆池"
75-
* }
76-
*
77-
* @param {String} xuid 玩家Xuid
78-
* @param {Object} warp warp对象,示例见上
79-
* @returns {Boolean} 是否成功
83+
* @param {string} xuid 玩家Xuid
84+
* @param {Warp} warp warp对象
85+
* @returns {boolean} 是否成功
8086
*/
8187
function newNavigationTask(xuid, warp) {
8288
const tmpPl = mc.getPlayer(xuid);
8389

90+
/**
91+
* @param {number} x
92+
* @param {number} z
93+
* @returns {string}
94+
*/
8495
function formatXZPos(x, z) {
8596
return `${Green}${x.toFixed()} ${Red}~ ${Aqua}${z.toFixed()}`;
8697
}
@@ -99,7 +110,7 @@ function newNavigationTask(xuid, warp) {
99110
const { x: dx, y: dy, z: dz, dimId: dDim } = pos;
100111
const distance = Math.sqrt(
101112
(x - dx) * (x - dx) + (y - dy) * (y - dy) + (z - dz) * (z - dz)
102-
).toFixed(2);
113+
);
103114

104115
let msg =
105116
`${Green}${name}${Clear} | ` +
@@ -121,7 +132,9 @@ function newNavigationTask(xuid, warp) {
121132
return;
122133
}
123134

124-
msg += `${MinecoinGold}距离 ${Green}${distance} ${MinecoinGold}方块`;
135+
msg +=
136+
`${MinecoinGold}距离 ${Green}${distance.toFixed(2)} ` +
137+
`${MinecoinGold}方块`;
125138
}
126139
pl.tell(msg, 5);
127140
}
@@ -135,7 +148,7 @@ function newNavigationTask(xuid, warp) {
135148

136149
mc.listen('onLeft', (pl) => clearNavigationTask(pl.xuid));
137150

138-
(() => {
151+
mc.listen('onServerStarted', () => {
139152
const cmd = mc.newCommand('stopnav', '停止导航', PermType.Any);
140153

141154
cmd.setCallback((_, origin, out) => {
@@ -150,13 +163,13 @@ mc.listen('onLeft', (pl) => clearNavigationTask(pl.xuid));
150163

151164
cmd.overload();
152165
cmd.setup();
153-
})();
166+
});
154167

155-
ll.export(newNavigationTask, `${exportNamespace}_newTask`);
156-
ll.export(clearNavigationTask, `${exportNamespace}_clearTask`);
157-
ll.export(hasNavigationTask, `${exportNamespace}_hasTask`);
168+
ll.exports(newNavigationTask, `${exportNamespace}_newTask`);
169+
ll.exports(clearNavigationTask, `${exportNamespace}_clearTask`);
170+
ll.exports(hasNavigationTask, `${exportNamespace}_hasTask`);
158171

159-
ll.registerPlugin(pluginName, '导航API', [0, 1, 2], {
172+
ll.registerPlugin(pluginName, '导航API', [0, 1, 3], {
160173
Author: 'student_2333',
161174
License: 'Apache-2.0',
162175
});

NavigationAPI_OldLXL.lls.js

-142
This file was deleted.

README.md

+13-18
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,8 @@
2121

2222
### 引入
2323

24-
我已经将插件上传到了我自己的服务器,用 `require` 声明依赖时填入我给出的 URL 即可免除腐竹装前置的烦恼
25-
2624
```js
27-
ll.require(
28-
'NavigationAPI.lls.js',
29-
'https://www.lgc2333.top/llse/NavigationAPI.min.lls.js'
30-
);
25+
ll.require('NavigationAPI');
3126
const newNavigationTask = ll.import('NavAPI_newTask');
3227
const clearNavigationTask = ll.import('NavAPI_clearTask');
3328
const hasNavigationTask = ll.import('NavAPI_hasTask');
@@ -91,10 +86,9 @@ function hasNavigationTask(xuid) {}
9186

9287
## 安装
9388

94-
`NavigationAPI.lls.js` 扔进 BDS 插件目录即可
95-
`NavigationAPI.min.lls.js`为我用 js 压缩工具得到的代码
96-
97-
一般情况下如果插件开发者使用了我给出的 URL 作为前置依赖的远程下载链接,则**本插件不需要另外手动下载安装**
89+
```bash
90+
lip install github.com/lgc-LLDev/NavigationAPI
91+
```
9892

9993
## 配置文件
10094

@@ -128,12 +122,13 @@ QQ:3076823485
128122

129123
## 更新日志
130124

131-
**如果是自动下载的依赖,请删除`plugins/lib/NavigationAPI.lls.js`文件来更新!(旧版请删除`plugins/lib/NavigationAPI_OldLXL.lls.js`**
125+
### 0.1.2
126+
127+
- 修复坐标换算显示错误的 Bug
128+
- 适配旧版 lxl
129+
130+
### 0.1.1
132131

133-
- 0.1.1
134-
- 修复了在末地时显示坐标换算的 Bug
135-
- 修复玩家到地方不能结束导航
136-
- 修改了指令`stopnavigation` -> `stopnav`
137-
- 0.1.2
138-
- 修复坐标换算显示错误的 Bug
139-
- 适配旧版 lxl
132+
- 修复了在末地时显示坐标换算的 Bug
133+
- 修复玩家到地方不能结束导航
134+
- 修改了指令 `stopnavigation` -> `stopnav`

tooth.json

+20-16
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,24 @@
11
{
2-
"format_version": 1,
3-
"tooth": "github.com/lgc-LLSEDev/NavigationAPI",
4-
"version": "0.1.2",
5-
"dependencies": {},
6-
"information": {
2+
"$schema": "https://raw.githubusercontent.com/lippkg/lip/main/schemas/tooth.v2.schema.json",
3+
"format_version": 2,
4+
"tooth": "github.com/lgc-LLDev/NavigationAPI",
5+
"version": "0.1.3",
6+
"info": {
77
"name": "NavigationAPI",
8-
"description": "其他插件可对接的导航 API",
9-
"author": "lgc2333",
10-
"license": "Apache-2.0",
11-
"homepage": "https://github.com/lgc-LLSEDev/NavigationAPI"
8+
"description": "A navigation library",
9+
"author": "student_2333",
10+
"tags": ["library", "lse", "quickjs", "navigate", "navigation"]
1211
},
13-
"placement": [
14-
{
15-
"source": "NavigationAPI.lls.js",
16-
"destination": "plugins/lib/NavigationAPI.lls.js"
17-
}
18-
],
19-
"possession": []
12+
"files": {
13+
"place": [
14+
{
15+
"src": "NavigationAPI.js",
16+
"dest": "plugins/NavigationAPI/NavigationAPI.js"
17+
},
18+
{
19+
"src": "manifest.json",
20+
"dest": "plugins/NavigationAPI/manifest.json"
21+
}
22+
]
23+
}
2024
}

tsconfig.json

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"extends": "../tsconfig.template.json",
3+
"include": ["*.js"],
4+
"compilerOptions": {
5+
"outDir": "./dist"
6+
}
7+
}

0 commit comments

Comments
 (0)