@zardoy/flying-squid 0.0.102 → 0.0.103
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.
package/dist/lib/modules/log.js
CHANGED
|
@@ -185,16 +185,22 @@ const server = function (serv, settings) {
|
|
|
185
185
|
const orig = console.log;
|
|
186
186
|
return function () {
|
|
187
187
|
readline.cursorTo(process.stdout, 0);
|
|
188
|
-
//
|
|
189
|
-
// try {
|
|
190
|
-
// tmp = process.stdout
|
|
191
|
-
// // @ts-ignore
|
|
192
|
-
// process.stdout = process.stderr
|
|
193
|
-
// orig.apply(console, arguments)
|
|
194
|
-
// } finally {
|
|
195
|
-
// process.stdout = tmp
|
|
196
|
-
// }
|
|
188
|
+
// Apply original console.log to stdout
|
|
197
189
|
orig.apply(console, arguments);
|
|
190
|
+
// Redirect to server log if enabled and not disabled
|
|
191
|
+
if (!settings.noConsoleLogRedirect && logStream?.writable) {
|
|
192
|
+
const args = Array.from(arguments);
|
|
193
|
+
const message = args.map(arg => typeof arg === 'object' ? JSON.stringify(arg, null, 2) : String(arg)).join(' ');
|
|
194
|
+
// Add timestamp and prefix for console.log entries
|
|
195
|
+
const timestamp = new Date().toISOString();
|
|
196
|
+
const logEntry = `[${timestamp}] [CONSOLE]: ${message}\n`;
|
|
197
|
+
try {
|
|
198
|
+
logStream.write(logEntry);
|
|
199
|
+
}
|
|
200
|
+
catch (err) {
|
|
201
|
+
// Silently fail if log writing fails to avoid infinite loops
|
|
202
|
+
}
|
|
203
|
+
}
|
|
198
204
|
rl.prompt(true);
|
|
199
205
|
};
|
|
200
206
|
})();
|
|
@@ -14,7 +14,7 @@ export interface SpeedValidationResult {
|
|
|
14
14
|
export declare function validateMovementSpeed(player: Player, lastPosition: Vec3, newPosition: Vec3, packetCount: number): SpeedValidationResult;
|
|
15
15
|
export declare function findSafePosition(playerWorld: CustomWorld, mcData: IndexedData, attemptedPosition: Vec3): Vec3 | undefined;
|
|
16
16
|
export declare function isInsideStrict(pos: Vec3, box: AABB): boolean;
|
|
17
|
-
export declare function isInsideExpanded(pos: Vec3, box: AABB, threshold
|
|
17
|
+
export declare function isInsideExpanded(pos: Vec3, box: AABB, threshold?: number): boolean;
|
|
18
18
|
export declare function clampToAABBFromDirection(pos: Vec3, box: AABB): Vec3;
|
|
19
19
|
export declare function clamp(v: number, min: number, max: number): number;
|
|
20
20
|
export declare function distanceToAABB(p: Vec3, box: AABB): number;
|
|
@@ -77,7 +77,7 @@ const player = (player, serv, { basePositionAntiCheat = false, positionAntiCheat
|
|
|
77
77
|
player.chat(`[safeZones] Block collision detected. Teleporting to safe position.`);
|
|
78
78
|
}
|
|
79
79
|
let safePosition;
|
|
80
|
-
if (isPlayerInsideBlock(player, serv, lastPosition)) {
|
|
80
|
+
if (!isPlayerInsideBlock(player, serv, lastPosition)) {
|
|
81
81
|
safePosition = lastPosition;
|
|
82
82
|
}
|
|
83
83
|
else {
|
|
@@ -148,11 +148,16 @@ const player = (player, serv, { basePositionAntiCheat = false, positionAntiCheat
|
|
|
148
148
|
return;
|
|
149
149
|
}
|
|
150
150
|
// If new position is within expanded bounds (threshold), allow it
|
|
151
|
-
if (isInsideExpanded(position, zone
|
|
151
|
+
if (isInsideExpanded(position, zone))
|
|
152
152
|
return;
|
|
153
153
|
// Otherwise, clamp back inside from direction of attempted position
|
|
154
154
|
let corrected = clampToAABBFromDirection(position, zone);
|
|
155
|
-
|
|
155
|
+
let customCorrection = serv.onSafeZoneViolation?.(player);
|
|
156
|
+
if (customCorrection && !isInsideExpanded(customCorrection, zone)) {
|
|
157
|
+
serv.emit('error', new Error('Invalid custom zone pos correction!'));
|
|
158
|
+
customCorrection = undefined;
|
|
159
|
+
}
|
|
160
|
+
corrected = customCorrection ?? corrected;
|
|
156
161
|
// Prevent default cancel handling and perform corrective teleport ourselves
|
|
157
162
|
if (positionAntiCheatNotifyPlayer) {
|
|
158
163
|
player.chat(`[safeZones] Out of bounds ${zone.min.toString()} <-> ${zone.max.toString()}: ${position.toString()} -> ${corrected.toString()}. Teleporting to safe position.`);
|
|
@@ -298,7 +303,7 @@ function isInsideStrict(pos, box) {
|
|
|
298
303
|
pos.y >= box.min.y && pos.y <= box.max.y &&
|
|
299
304
|
pos.z >= box.min.z && pos.z <= box.max.z;
|
|
300
305
|
}
|
|
301
|
-
function isInsideExpanded(pos, box, threshold) {
|
|
306
|
+
function isInsideExpanded(pos, box, threshold = THRESHOLD) {
|
|
302
307
|
return pos.x >= (box.min.x - threshold) && pos.x <= (box.max.x + threshold) &&
|
|
303
308
|
pos.y >= (box.min.y - threshold) && pos.y <= (box.max.y + threshold) &&
|
|
304
309
|
pos.z >= (box.min.z - threshold) && pos.z <= (box.max.z + threshold);
|
|
@@ -82,13 +82,15 @@ const player = function (player) {
|
|
|
82
82
|
};
|
|
83
83
|
};
|
|
84
84
|
player.onPacket('teleport_confirm', ({ teleportId }) => {
|
|
85
|
+
if (!player.lastTeleportId)
|
|
86
|
+
return;
|
|
85
87
|
if (teleportId === player.lastTeleportId && player.pendingTeleport) {
|
|
86
88
|
// validate the position
|
|
87
89
|
player.validateNextPosition = player.pendingTeleport.position;
|
|
88
90
|
player.pendingTeleport = undefined;
|
|
89
91
|
}
|
|
90
92
|
else {
|
|
91
|
-
console.log('Invalid teleport confirm packet received', player.pendingTeleport, 'received:', teleportId)
|
|
93
|
+
// console.log('Invalid teleport confirm packet received', player.pendingTeleport, 'received:', teleportId)
|
|
92
94
|
}
|
|
93
95
|
});
|
|
94
96
|
player.sendAbilities = () => {
|