@zardoy/flying-squid 0.0.80 → 0.0.81
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export declare const server: (serv: Server) => {
|
|
2
|
+
customWaypoints: Record<string, Waypoint>;
|
|
3
|
+
customAddWaypoint: (id: string, waypoint: Waypoint) => void;
|
|
4
|
+
customRemoveWaypoint: (id: string) => void;
|
|
5
|
+
};
|
|
6
|
+
export declare const player: (player: Player, serv: Server) => Promise<void>;
|
|
7
|
+
export type Waypoint = {
|
|
8
|
+
x: number;
|
|
9
|
+
y: number;
|
|
10
|
+
z: number;
|
|
11
|
+
minDistance?: number;
|
|
12
|
+
label?: string;
|
|
13
|
+
color?: number;
|
|
14
|
+
};
|
|
15
|
+
declare global {
|
|
16
|
+
interface Server {
|
|
17
|
+
customWaypoints: ReturnType<typeof server>;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.player = exports.server = void 0;
|
|
4
|
+
const ADD_CHANNEL = 'minecraft-web-client:waypoint-add';
|
|
5
|
+
const DELETE_CHANNEL = 'minecraft-web-client:waypoint-delete';
|
|
6
|
+
const server = (serv) => {
|
|
7
|
+
const module = {
|
|
8
|
+
customWaypoints: {},
|
|
9
|
+
customAddWaypoint: (id, waypoint) => {
|
|
10
|
+
serv.customWaypoints.customWaypoints[id] = waypoint;
|
|
11
|
+
// Broadcast add/update to all online players
|
|
12
|
+
for (const player of serv.players ?? []) {
|
|
13
|
+
sendAddWaypoint(player, id, waypoint);
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
customRemoveWaypoint: (id) => {
|
|
17
|
+
delete serv.customWaypoints.customWaypoints[id];
|
|
18
|
+
// Broadcast delete to all online players
|
|
19
|
+
for (const player of serv.players ?? []) {
|
|
20
|
+
sendDeleteWaypoint(player, id);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
serv.customWaypoints = module;
|
|
25
|
+
return module;
|
|
26
|
+
};
|
|
27
|
+
exports.server = server;
|
|
28
|
+
function sendAddWaypoint(player, id, waypoint) {
|
|
29
|
+
player._client.writeChannel(ADD_CHANNEL, {
|
|
30
|
+
id,
|
|
31
|
+
x: waypoint.x,
|
|
32
|
+
y: waypoint.y,
|
|
33
|
+
z: waypoint.z,
|
|
34
|
+
minDistance: waypoint.minDistance ?? 0,
|
|
35
|
+
label: waypoint.label ?? '',
|
|
36
|
+
color: waypoint.color ?? 0
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
function sendDeleteWaypoint(player, id) {
|
|
40
|
+
player._client.writeChannel(DELETE_CHANNEL, { id });
|
|
41
|
+
}
|
|
42
|
+
function sendAllWaypoints(player, serv) {
|
|
43
|
+
const entries = Object.entries(serv.customWaypoints.customWaypoints ?? {});
|
|
44
|
+
for (const [id, waypoint] of entries) {
|
|
45
|
+
sendAddWaypoint(player, id, waypoint);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
const player = async (player, serv) => {
|
|
49
|
+
// Register channels expected by the client
|
|
50
|
+
player._client.registerChannel(ADD_CHANNEL, ['container', [
|
|
51
|
+
{ name: 'id', type: ['pstring', { countType: 'i16' }] },
|
|
52
|
+
{ name: 'x', type: 'f32' },
|
|
53
|
+
{ name: 'y', type: 'f32' },
|
|
54
|
+
{ name: 'z', type: 'f32' },
|
|
55
|
+
{ name: 'minDistance', type: 'i32' },
|
|
56
|
+
{
|
|
57
|
+
name: 'label',
|
|
58
|
+
type: ['pstring', { countType: 'i16' }]
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
name: 'color',
|
|
62
|
+
type: 'i32'
|
|
63
|
+
}
|
|
64
|
+
]]);
|
|
65
|
+
player._client.registerChannel(DELETE_CHANNEL, ['container', [
|
|
66
|
+
{ name: 'id', type: ['pstring', { countType: 'i16' }] },
|
|
67
|
+
]]);
|
|
68
|
+
// Send current server waypoints on join
|
|
69
|
+
sendAllWaypoints(player, serv);
|
|
70
|
+
};
|
|
71
|
+
exports.player = player;
|
|
@@ -15,6 +15,7 @@ module.exports = {
|
|
|
15
15
|
'communication': require('./communication'),
|
|
16
16
|
'crafting': require('./crafting'),
|
|
17
17
|
'customBlockBreakTime': require('./customBlockBreakTime'),
|
|
18
|
+
'customWaypoints': require('./customWaypoints'),
|
|
18
19
|
'database': require('./database'),
|
|
19
20
|
'daycycle': require('./daycycle'),
|
|
20
21
|
'digging': require('./digging'),
|
package/dist/types.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ import "./lib/modules/commands.d.ts"
|
|
|
12
12
|
import "./lib/modules/communication.d.ts"
|
|
13
13
|
import "./lib/modules/crafting.d.ts"
|
|
14
14
|
import "./lib/modules/customBlockBreakTime.d.ts"
|
|
15
|
+
import "./lib/modules/customWaypoints.d.ts"
|
|
15
16
|
import "./lib/modules/database.d.ts"
|
|
16
17
|
import "./lib/modules/daycycle.d.ts"
|
|
17
18
|
import "./lib/modules/digging.d.ts"
|