@zardoy/flying-squid 0.0.110 → 0.0.112
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.
|
@@ -13,7 +13,7 @@ const server = (serv) => {
|
|
|
13
13
|
// Send update to the player if they're online
|
|
14
14
|
const player = serv.uuidToPlayer[uuid];
|
|
15
15
|
if (player) {
|
|
16
|
-
sendBreakTimeConfig(
|
|
16
|
+
player.sendBreakTimeConfig();
|
|
17
17
|
}
|
|
18
18
|
};
|
|
19
19
|
serv.customRemovePlayerBreakTime = (uuid) => {
|
|
@@ -21,24 +21,11 @@ const server = (serv) => {
|
|
|
21
21
|
// Send empty config to the player if they're online
|
|
22
22
|
const player = serv.uuidToPlayer[uuid];
|
|
23
23
|
if (player) {
|
|
24
|
-
sendBreakTimeConfig(
|
|
24
|
+
player.sendBreakTimeConfig();
|
|
25
25
|
}
|
|
26
26
|
};
|
|
27
27
|
};
|
|
28
28
|
exports.server = server;
|
|
29
|
-
function sendBreakTimeConfig(player, serv) {
|
|
30
|
-
if (!serv.customPlayersBreakTime[player.uuid])
|
|
31
|
-
return;
|
|
32
|
-
const config = serv.customPlayersBreakTime[player.uuid];
|
|
33
|
-
const data = {
|
|
34
|
-
customBreakTime: config?.blocks ?? {},
|
|
35
|
-
customBreakTimeToolAllowance: config?.toolNames ?? [],
|
|
36
|
-
...config?.rawConfig
|
|
37
|
-
};
|
|
38
|
-
player._client.writeChannel(CHANNEL_NAME, {
|
|
39
|
-
newConfiguration: JSON.stringify(data)
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
29
|
const player = async (player, serv) => {
|
|
43
30
|
player.customGetBreakTime = (block) => {
|
|
44
31
|
const config = serv.customPlayersBreakTime[player.uuid];
|
|
@@ -59,7 +46,20 @@ const player = async (player, serv) => {
|
|
|
59
46
|
]]);
|
|
60
47
|
// Send initial configuration if it exists
|
|
61
48
|
player.on('login', () => {
|
|
62
|
-
sendBreakTimeConfig(
|
|
49
|
+
player.sendBreakTimeConfig();
|
|
63
50
|
});
|
|
51
|
+
player.sendBreakTimeConfig = () => {
|
|
52
|
+
if (!serv.customPlayersBreakTime[player.uuid])
|
|
53
|
+
return;
|
|
54
|
+
const config = serv.customPlayersBreakTime[player.uuid];
|
|
55
|
+
const data = {
|
|
56
|
+
customBreakTime: config?.blocks ?? {},
|
|
57
|
+
customBreakTimeToolAllowance: config?.toolNames ?? [],
|
|
58
|
+
...config?.rawConfig
|
|
59
|
+
};
|
|
60
|
+
player._client.writeChannel(CHANNEL_NAME, {
|
|
61
|
+
newConfiguration: JSON.stringify(data)
|
|
62
|
+
});
|
|
63
|
+
};
|
|
64
64
|
};
|
|
65
65
|
exports.player = player;
|
|
@@ -164,7 +164,7 @@ const player = function (player, serv, { version }) {
|
|
|
164
164
|
const DIG_TIME_ALLOWED_THRESHOLD = 50;
|
|
165
165
|
const tooFast = digTimeDiff > DIG_TIME_ALLOWED_THRESHOLD;
|
|
166
166
|
const tooFar = player.position.distanceTo(location) > MAX_DIG_DISTANCE;
|
|
167
|
-
if (
|
|
167
|
+
if (tooFar) {
|
|
168
168
|
stop = true;
|
|
169
169
|
await player.behavior('suspiciousDigStopped', {
|
|
170
170
|
tooFast,
|
|
@@ -173,8 +173,11 @@ const player = function (player, serv, { version }) {
|
|
|
173
173
|
location,
|
|
174
174
|
digTimeAllowedThreshold: DIG_TIME_ALLOWED_THRESHOLD,
|
|
175
175
|
actualDiggingTime: diggingTime,
|
|
176
|
-
expectedDiggingTime
|
|
177
|
-
|
|
176
|
+
expectedDiggingTime,
|
|
177
|
+
stop
|
|
178
|
+
}, (data) => {
|
|
179
|
+
stop = data.stop;
|
|
180
|
+
}, () => {
|
|
178
181
|
stop = false;
|
|
179
182
|
});
|
|
180
183
|
}
|
|
@@ -44,6 +44,7 @@ declare global {
|
|
|
44
44
|
* ```
|
|
45
45
|
*/
|
|
46
46
|
'save': () => Promise<any>;
|
|
47
|
+
"sendChunk": (chunkX: number, chunkZ: number, column: any) => Promise<void>;
|
|
47
48
|
/** The world object which the player is in (use serv.overworld, serv.netherworld, serv.endworld, or a custom world). Options:
|
|
48
49
|
*
|
|
49
50
|
* - gamemode: Gamemode of the world (Default is player gamemode)
|
|
@@ -224,7 +224,7 @@ const server = async function (serv, options) {
|
|
|
224
224
|
serv.chunksUsed[id] = 0;
|
|
225
225
|
}
|
|
226
226
|
serv.chunksUsed[id]++;
|
|
227
|
-
player.loadedChunks[id] =
|
|
227
|
+
player.loadedChunks[id] = true;
|
|
228
228
|
};
|
|
229
229
|
serv._unloadPlayerChunk = (chunkX, chunkZ, player) => {
|
|
230
230
|
const id = chunkX + ',' + chunkZ;
|
|
@@ -232,7 +232,8 @@ const server = async function (serv, options) {
|
|
|
232
232
|
if (serv.chunksUsed[id] > 0) {
|
|
233
233
|
serv.chunksUsed[id]--;
|
|
234
234
|
}
|
|
235
|
-
if (!serv.chunksUsed[id]) {
|
|
235
|
+
if (!serv.chunksUsed[id] && player.world.storageProvider) {
|
|
236
|
+
// Never delete chunks when we do not have a storage provider! They will be lost
|
|
236
237
|
player.world.unloadColumn(chunkX, chunkZ);
|
|
237
238
|
return true;
|
|
238
239
|
}
|
|
@@ -561,7 +562,7 @@ const player = function (player, serv, settings) {
|
|
|
561
562
|
return player.world.getColumn(chunkX, chunkZ);
|
|
562
563
|
})
|
|
563
564
|
.then((column) => {
|
|
564
|
-
if (abortSignal?.aborted)
|
|
565
|
+
if (!column || abortSignal?.aborted)
|
|
565
566
|
return;
|
|
566
567
|
return player.sendChunk(chunkX, chunkZ, column);
|
|
567
568
|
});
|