Skip to content

Commit

Permalink
Update index.js
Browse files Browse the repository at this point in the history
Added watchdog crash protection
  • Loading branch information
smell-of-curry committed Aug 30, 2022
1 parent 70de678 commit c93163e
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions scripts/Smelly Api/vendor/Anti Cheat/src/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import "./modules/autoload.js";
import "./moderation/index.js";
import { SA } from "../../../index.js";
import { world } from "mojang-minecraft";
import { system, world } from "mojang-minecraft";
import { BLOCK_CONTAINERS, CHECK_SIZE } from "./config.js";
import { BlockInventory } from "./Models/BlockInventory.js";

Expand All @@ -16,6 +16,10 @@ export let db_regions = new SA.Utilities.storage.scoreboard("regions");
*/
export const CONTAINER_LOCATIONS = {};

system.events.beforeWatchdogTerminate.subscribe((data) => {
console.warn(`WATCHDOG TRIED TO CRASH GAME REASON: ${data.terminateReason}`);
data.cancel = true;
});

SA.Utilities.time.setTickInterval(() => {
for (const player of world.getPlayers()) {
Expand All @@ -29,7 +33,11 @@ SA.Utilities.time.setTickInterval(() => {
CONTAINER_LOCATIONS[JSON.stringify(location)] = new BlockInventory(
block.getComponent("inventory").container
);
block.dimension.runCommand(`particle minecraft:dragon_breath_trail ${location.x} ${location.y + 1} ${location.z}`)
block.dimension.runCommand(
`particle minecraft:dragon_breath_trail ${location.x} ${
location.y + 1
} ${location.z}`
);
}
}
}, 100);
}, 100);

0 comments on commit c93163e

Please sign in to comment.