h1z1-server 0.25.2-4 → 0.25.3-0

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,58 @@
1
+ [
2
+ {
3
+ "iv": "6378e550250bea288db4c30e435a6566",
4
+ "encryptedData": "e02d51753ea018b4f0e0e8f28a7f3438"
5
+ },
6
+ {
7
+ "iv": "6378e550250bea288db4c30e435a6566",
8
+ "encryptedData": "0f2f3958decb755b99ae2093a43e0d12"
9
+ },
10
+ {
11
+ "iv": "6378e550250bea288db4c30e435a6566",
12
+ "encryptedData": "ad0d552e2a991960d0e9954b6103ebb8"
13
+ },
14
+ {
15
+ "iv": "6378e550250bea288db4c30e435a6566",
16
+ "encryptedData": "b303c9d7d5e26f4502181de97e57cd99"
17
+ },
18
+ {
19
+ "iv": "6378e550250bea288db4c30e435a6566",
20
+ "encryptedData": "df2323b28c4f45aae38a8689eef3e688"
21
+ },
22
+ {
23
+ "iv": "6378e550250bea288db4c30e435a6566",
24
+ "encryptedData": "fa4cdc7a9379b26b8f42006a75f0c6dc"
25
+ },
26
+ {
27
+ "iv": "6378e550250bea288db4c30e435a6566",
28
+ "encryptedData": "71bb386f2338be1d47caaeab7ea04b8b"
29
+ },
30
+ {
31
+ "iv": "6378e550250bea288db4c30e435a6566",
32
+ "encryptedData": "753d3b26b8eca2afc1f04eed589088d0"
33
+ },
34
+ {
35
+ "iv": "6378e550250bea288db4c30e435a6566",
36
+ "encryptedData": "fa1418782d81d44670f25833a509728a"
37
+ },
38
+ {
39
+ "iv": "6378e550250bea288db4c30e435a6566",
40
+ "encryptedData": "056a57813f1fdafb26050504b1792f8b"
41
+ },
42
+ {
43
+ "iv": "6378e550250bea288db4c30e435a6566",
44
+ "encryptedData": "e8e4ee451153d1fa924481bdc9138a58"
45
+ },
46
+ {
47
+ "iv": "6378e550250bea288db4c30e435a6566",
48
+ "encryptedData": "4dad473d52e6e7e06f22ee17c05072bd"
49
+ },
50
+ {
51
+ "iv": "6378e550250bea288db4c30e435a6566",
52
+ "encryptedData": "548a45b16d334154cc861e0a57422035"
53
+ },
54
+ {
55
+ "iv": "6378e550250bea288db4c30e435a6566",
56
+ "encryptedData": "86d17964dfee9a17ac0f960178eef68d10aa7a366d9c57c822cb7c422b568679"
57
+ }
58
+ ]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "h1z1-server",
3
- "version": "0.25.2-4",
3
+ "version": "0.25.3-0",
4
4
  "description": "Library for emulating h1z1 servers",
5
5
  "author": "Quentin Gruber <quentingruber@gmail.com> (http://github.com/quentingruber)",
6
6
  "license": "GPL-3.0-only",
@@ -1,147 +1,147 @@
1
- // ======================================================================
2
- //
3
- // GNU GENERAL PUBLIC LICENSE
4
- // Version 3, 29 June 2007
5
- // copyright (C) 2020 - 2021 Quentin Gruber
6
- // copyright (C) 2021 - 2023 H1emu community
7
- //
8
- // https://github.com/QuentinGruber/h1z1-server
9
- // https://www.npmjs.com/package/h1z1-server
10
- //
11
- // Based on https://github.com/psemu/soe-network
12
- // ======================================================================
13
-
14
- import { ZoneClient2016 as Client } from "../classes/zoneclient";
15
- import { ZoneServer2016 } from "../zoneserver";
16
- import { flhash, logClientActionToMongo } from "../../../utils/utils";
17
- import { Command } from "./types";
18
- import { commands } from "./commands";
19
- import { internalCommands } from "./internalcommands";
20
- import { DB_COLLECTIONS } from "../../../utils/enums";
21
- import { Collection } from "mongodb";
22
-
23
- export class CommandHandler {
24
- readonly commands: { [hash: number]: Command } = {};
25
- readonly internalCommands: { [name: string]: Command } = {};
26
-
27
- constructor() {
28
- this.indexCommands(commands, internalCommands);
29
- }
30
-
31
- private clientHasCommandPermission(
32
- server: ZoneServer2016,
33
- client: Client,
34
- command: Command
35
- ) {
36
- return (
37
- command.permissionLevel <= client.permissionLevel ||
38
- server._allowedCommands.includes(command.name)
39
- );
40
- }
41
-
42
- private indexCommands(
43
- commands: Array<Command>,
44
- internalCommands: Array<Command>
45
- ) {
46
- commands.forEach((command) => {
47
- this.commands[flhash(command.name.toUpperCase())] = command;
48
- });
49
- internalCommands.forEach((command) => {
50
- this.internalCommands[command.name] = command;
51
- });
52
- }
53
-
54
- executeCommand(server: ZoneServer2016, client: Client, packet: any) {
55
- if (
56
- !server.hookManager.checkHook(
57
- "OnClientExecuteCommand",
58
- client,
59
- packet.data.commandHash,
60
- packet.data.arguments
61
- )
62
- ) {
63
- return;
64
- }
65
- const hash = packet.data.commandHash,
66
- args: string[] = packet.data.arguments.toLowerCase().split(" ");
67
- if (this.commands[hash]) {
68
- const command = this.commands[hash];
69
- if (!this.clientHasCommandPermission(server, client, command)) {
70
- server.sendChatText(client, "You don't have access to that.");
71
- return;
72
- } else {
73
- if (!server._soloMode) {
74
- logClientActionToMongo(
75
- server._db?.collection(DB_COLLECTIONS.COMMAND_USED) as Collection,
76
- client,
77
- server._worldId,
78
- {
79
- name: command.name,
80
- permissionLevel: command.permissionLevel,
81
- args,
82
- }
83
- );
84
- }
85
- }
86
- command.execute(server, client, args);
87
- } else if (hash == flhash("HELP")) {
88
- server.sendChatText(
89
- client,
90
- `Command list: \n/${Object.values(this.commands)
91
- .filter((command) =>
92
- this.clientHasCommandPermission(server, client, command)
93
- )
94
- .map((command) => {
95
- return command.name;
96
- })
97
- .join("\n/")}`
98
- );
99
- } else {
100
- server.sendChatText(client, `Unknown command, hash: ${hash}`);
101
- }
102
- }
103
-
104
- executeInternalCommand(
105
- server: ZoneServer2016,
106
- client: Client,
107
- commandName: string,
108
- packet: any
109
- ) {
110
- if (
111
- !server.hookManager.checkHook(
112
- "OnClientExecuteInternalCommand",
113
- client,
114
- packet.data
115
- )
116
- ) {
117
- return;
118
- }
119
- if (this.internalCommands[commandName]) {
120
- const command = this.internalCommands[commandName];
121
- if (!this.clientHasCommandPermission(server, client, command)) {
122
- server.sendChatText(client, "You don't have access to that.");
123
- return;
124
- } else {
125
- if (!server._soloMode) {
126
- logClientActionToMongo(
127
- server._db?.collection(DB_COLLECTIONS.COMMAND_USED) as Collection,
128
- client,
129
- server._worldId,
130
- { name: command.name, permissionLevel: command.permissionLevel }
131
- );
132
- }
133
- }
134
- command.execute(server, client, packet.data);
135
- } else {
136
- server.sendChatText(client, `Unknown command: ${commandName}`);
137
- }
138
- }
139
-
140
- reloadCommands() {
141
- delete require.cache[require.resolve("./commands")];
142
- delete require.cache[require.resolve("./internalCommands")];
143
- const commands = require("./commands").commands,
144
- internalCommands = require("./internalCommands").internalCommands;
145
- this.indexCommands(commands, internalCommands);
146
- }
147
- }
1
+ // ======================================================================
2
+ //
3
+ // GNU GENERAL PUBLIC LICENSE
4
+ // Version 3, 29 June 2007
5
+ // copyright (C) 2020 - 2021 Quentin Gruber
6
+ // copyright (C) 2021 - 2023 H1emu community
7
+ //
8
+ // https://github.com/QuentinGruber/h1z1-server
9
+ // https://www.npmjs.com/package/h1z1-server
10
+ //
11
+ // Based on https://github.com/psemu/soe-network
12
+ // ======================================================================
13
+
14
+ import { ZoneClient2016 as Client } from "../classes/zoneclient";
15
+ import { ZoneServer2016 } from "../zoneserver";
16
+ import { flhash, logClientActionToMongo } from "../../../utils/utils";
17
+ import { Command } from "./types";
18
+ import { commands } from "./commands";
19
+ import { internalCommands } from "./internalcommands";
20
+ import { DB_COLLECTIONS } from "../../../utils/enums";
21
+ import { Collection } from "mongodb";
22
+
23
+ export class CommandHandler {
24
+ readonly commands: { [hash: number]: Command } = {};
25
+ readonly internalCommands: { [name: string]: Command } = {};
26
+
27
+ constructor() {
28
+ this.indexCommands(commands, internalCommands);
29
+ }
30
+
31
+ private clientHasCommandPermission(
32
+ server: ZoneServer2016,
33
+ client: Client,
34
+ command: Command
35
+ ) {
36
+ return (
37
+ command.permissionLevel <= client.permissionLevel ||
38
+ server._allowedCommands.includes(command.name)
39
+ );
40
+ }
41
+
42
+ private indexCommands(
43
+ commands: Array<Command>,
44
+ internalCommands: Array<Command>
45
+ ) {
46
+ commands.forEach((command) => {
47
+ this.commands[flhash(command.name.toUpperCase())] = command;
48
+ });
49
+ internalCommands.forEach((command) => {
50
+ this.internalCommands[command.name] = command;
51
+ });
52
+ }
53
+
54
+ executeCommand(server: ZoneServer2016, client: Client, packet: any) {
55
+ if (
56
+ !server.hookManager.checkHook(
57
+ "OnClientExecuteCommand",
58
+ client,
59
+ packet.data.commandHash,
60
+ packet.data.arguments
61
+ )
62
+ ) {
63
+ return;
64
+ }
65
+ const hash = packet.data.commandHash,
66
+ args: string[] = packet.data.arguments.split(" ");
67
+ if (this.commands[hash]) {
68
+ const command = this.commands[hash];
69
+ if (!this.clientHasCommandPermission(server, client, command)) {
70
+ server.sendChatText(client, "You don't have access to that.");
71
+ return;
72
+ } else {
73
+ if (!server._soloMode) {
74
+ logClientActionToMongo(
75
+ server._db?.collection(DB_COLLECTIONS.COMMAND_USED) as Collection,
76
+ client,
77
+ server._worldId,
78
+ {
79
+ name: command.name,
80
+ permissionLevel: command.permissionLevel,
81
+ args,
82
+ }
83
+ );
84
+ }
85
+ }
86
+ command.execute(server, client, args);
87
+ } else if (hash == flhash("HELP")) {
88
+ server.sendChatText(
89
+ client,
90
+ `Command list: \n/${Object.values(this.commands)
91
+ .filter((command) =>
92
+ this.clientHasCommandPermission(server, client, command)
93
+ )
94
+ .map((command) => {
95
+ return command.name;
96
+ })
97
+ .join("\n/")}`
98
+ );
99
+ } else {
100
+ server.sendChatText(client, `Unknown command, hash: ${hash}`);
101
+ }
102
+ }
103
+
104
+ executeInternalCommand(
105
+ server: ZoneServer2016,
106
+ client: Client,
107
+ commandName: string,
108
+ packet: any
109
+ ) {
110
+ if (
111
+ !server.hookManager.checkHook(
112
+ "OnClientExecuteInternalCommand",
113
+ client,
114
+ packet.data
115
+ )
116
+ ) {
117
+ return;
118
+ }
119
+ if (this.internalCommands[commandName]) {
120
+ const command = this.internalCommands[commandName];
121
+ if (!this.clientHasCommandPermission(server, client, command)) {
122
+ server.sendChatText(client, "You don't have access to that.");
123
+ return;
124
+ } else {
125
+ if (!server._soloMode) {
126
+ logClientActionToMongo(
127
+ server._db?.collection(DB_COLLECTIONS.COMMAND_USED) as Collection,
128
+ client,
129
+ server._worldId,
130
+ { name: command.name, permissionLevel: command.permissionLevel }
131
+ );
132
+ }
133
+ }
134
+ command.execute(server, client, packet.data);
135
+ } else {
136
+ server.sendChatText(client, `Unknown command: ${commandName}`);
137
+ }
138
+ }
139
+
140
+ reloadCommands() {
141
+ delete require.cache[require.resolve("./commands")];
142
+ delete require.cache[require.resolve("./internalCommands")];
143
+ const commands = require("./commands").commands,
144
+ internalCommands = require("./internalCommands").internalCommands;
145
+ this.indexCommands(commands, internalCommands);
146
+ }
147
+ }
@@ -1043,6 +1043,48 @@ export const commands: Array<Command> = [
1043
1043
  server._npcs[characterId] = npc; // save npc
1044
1044
  },
1045
1045
  },
1046
+ {
1047
+ name: "decoy",
1048
+ permissionLevel: PermissionLevels.ADMIN,
1049
+ execute: (server: ZoneServer2016, client: Client, args: Array<string>) => {
1050
+ if (!args[0]) {
1051
+ server.sendChatText(client, "usage /deocay {name}");
1052
+ return;
1053
+ }
1054
+ const mimic = client.character.pGetLightweight();
1055
+ const characterId = server.generateGuid();
1056
+ const decoy = {
1057
+ characterId: characterId,
1058
+ position: new Float32Array(mimic.position),
1059
+ action: "",
1060
+ };
1061
+ server._decoys[characterId] = decoy;
1062
+ mimic.identity.characterName = args[0].toString();
1063
+ mimic.characterId = characterId;
1064
+ mimic.transientId = 0;
1065
+ server.sendDataToAll("AddLightweightPc", {
1066
+ ...mimic,
1067
+ mountGuid: "",
1068
+ mountSeatId: 0,
1069
+ mountRelatedDword1: 0,
1070
+ });
1071
+ const equipment = client.character.pGetEquipment();
1072
+ equipment.characterData.characterId = characterId;
1073
+ server.sendDataToAll("Equipment.SetCharacterEquipment", equipment);
1074
+ },
1075
+ },
1076
+ {
1077
+ name: "deletedecoys",
1078
+ permissionLevel: PermissionLevels.ADMIN,
1079
+ execute: (server: ZoneServer2016, client: Client, args: Array<string>) => {
1080
+ for (const a in server._decoys) {
1081
+ server.sendDataToAll("Character.RemovePlayer", {
1082
+ characterId: server._decoys[a].characterId,
1083
+ });
1084
+ delete server._decoys[a];
1085
+ }
1086
+ },
1087
+ },
1046
1088
  {
1047
1089
  name: "dynamicweather",
1048
1090
  permissionLevel: PermissionLevels.ADMIN,
@@ -1439,7 +1481,13 @@ export const commands: Array<Command> = [
1439
1481
  client,
1440
1482
  `Players: ${Object.values(server._clients)
1441
1483
  .map((c) => {
1442
- return `${c.character.name}: ${c.loginSessionId}`;
1484
+ return `${c.character.name}: ${c.loginSessionId} | ${
1485
+ server.getSoeClient(client.soeClientId)?.getNetworkStats()[2]
1486
+ } | ${
1487
+ server.getSoeClient(client.soeClientId)?.getNetworkStats()[0]
1488
+ } | ${
1489
+ server.getSoeClient(client.soeClientId)?.getNetworkStats()[1]
1490
+ }`;
1443
1491
  })
1444
1492
  .join(",\n")}`
1445
1493
  );