Skip to content

Commit

Permalink
awa
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonlaubb committed Jan 25, 2025
1 parent 06b6408 commit 5aadbdc
Show file tree
Hide file tree
Showing 5 changed files with 107 additions and 107 deletions.
206 changes: 103 additions & 103 deletions Matrix_BP/src/matrixAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -717,125 +717,125 @@ function* loadModuleRegistry(): Generator<void, void, void> {
resolve();
system.clearRun(id);
}
})
});
}).then(() => {
system.runJob(loadModuleList());
function* loadModuleList () {
world.sendMessage(`(Reload) Import ended, starting initialization`);
try {
for (let i = 1; i <= Module.moduleList.length; i++) {
const module = Module.moduleList[i - 1];
system.runJob(loadModuleList());
function* loadModuleList() {
world.sendMessage(`(Reload) Import ended, starting initialization`);
try {
if (module.locked || Module.config.modules[module.toggleId]?.state === true) {
if (module?.onEnable) module.onEnable();
module.enabled = true;
yield world.sendMessage(`(Reload) §aEnabling§f module [${module.getToggleId() ?? "Unknown"}]: ${i} / ${Module.moduleList.length}`);
} else {
yield world.sendMessage(`(Reload) §gChecked§f module [${module.getToggleId() ?? "Unknown"}]: ${i} / ${Module.moduleList.length}`);
}
} catch (error) {
console.error(error as Error);
yield world.sendMessage(`(Reload) §cErrored§f module [${module.getToggleId() ?? "Unknown"}]: ${i} / ${Module.moduleList.length}`);
}
}
} catch (error) {
console.error(error as Error);
} finally {
world.afterEvents.playerSpawn.subscribe(({ player, initialSpawn }) => {
if (!initialSpawn) return;
Module.currentPlayers.push(player);
if (Module.config.logSettings.logPlayerJoinLeave) {
write(false, "§aJoin §8(Connection)", player.name, {
playerId: player.id,
joinLocation: Object.values(player.location)
.map((x) => Math.floor(x).toFixed(0))
.join(" "),
});
}
for (const module of Module.moduleList) {
if (!module.enabled || !module.playerSpawn) continue;
try {
module.playerSpawn(player.id, player);
} catch (error) {
Module.sendError(error as Error);
}
}
system.runTimeout(() => {
if (player?.isValid() && Module.config.userRecruitmentFunction) player.sendMessage(rawtextTranslate("ad.running", Module.discordInviteLink));
let obj = world.scoreboard.getObjective("matrix:script-online");
if (!obj) {
obj = world.scoreboard.addObjective("matrix:script-online", "Made by jasonlaubb");
obj.setScore("is_enabled", -1);
}
}, 200);
});
yield;
if (world.getAllPlayers().length > 0) {
for (const player of world.getAllPlayers()) {
Module.currentPlayers.push(player);
for (const module of Module.moduleList) {
if (!module.enabled || !module.playerSpawn) continue;
for (let i = 1; i <= Module.moduleList.length; i++) {
const module = Module.moduleList[i - 1];
try {
module.playerSpawn(player.id, player);
if (module.locked || Module.config.modules[module.toggleId]?.state === true) {
if (module?.onEnable) module.onEnable();
module.enabled = true;
yield world.sendMessage(`(Reload) §aEnabling§f module [${module.getToggleId() ?? "Unknown"}]: ${i} / ${Module.moduleList.length}`);
} else {
yield world.sendMessage(`(Reload) §gChecked§f module [${module.getToggleId() ?? "Unknown"}]: ${i} / ${Module.moduleList.length}`);
}
} catch (error) {
Module.sendError(error as Error);
console.error(error as Error);
yield world.sendMessage(`(Reload) §cErrored§f module [${module.getToggleId() ?? "Unknown"}]: ${i} / ${Module.moduleList.length}`);
}
yield;
}
yield;
}
}
yield;
world.beforeEvents.playerLeave.subscribe(({ player: { location, id: playerId, name: playerName } }) => {
if (Module.config.logSettings.logPlayerJoinLeave) {
write(false, "§cLeave §8(Connection)", playerName, {
playerId: playerId,
leaveLocation: Object.values(location)
.map((x) => Math.floor(x).toFixed(0))
.join(" "),
} catch (error) {
console.error(error as Error);
} finally {
world.afterEvents.playerSpawn.subscribe(({ player, initialSpawn }) => {
if (!initialSpawn) return;
Module.currentPlayers.push(player);
if (Module.config.logSettings.logPlayerJoinLeave) {
write(false, "§aJoin §8(Connection)", player.name, {
playerId: player.id,
joinLocation: Object.values(player.location)
.map((x) => Math.floor(x).toFixed(0))
.join(" "),
});
}
for (const module of Module.moduleList) {
if (!module.enabled || !module.playerSpawn) continue;
try {
module.playerSpawn(player.id, player);
} catch (error) {
Module.sendError(error as Error);
}
}
system.runTimeout(() => {
if (player?.isValid() && Module.config.userRecruitmentFunction) player.sendMessage(rawtextTranslate("ad.running", Module.discordInviteLink));
let obj = world.scoreboard.getObjective("matrix:script-online");
if (!obj) {
obj = world.scoreboard.addObjective("matrix:script-online", "Made by jasonlaubb");
obj.setScore("is_enabled", -1);
}
}, 200);
});
}
Module.currentPlayers = Module.currentPlayers.filter(({ id }) => id !== playerId);
for (const module of Module.moduleList) {
if (!module.enabled || !module?.playerLeave) continue;
try {
system.run(() => {
if (!module?.playerLeave) return;
module?.playerLeave(playerId);
});
} catch (error) {
Module.sendError(error as Error);
yield;
if (world.getAllPlayers().length > 0) {
for (const player of world.getAllPlayers()) {
Module.currentPlayers.push(player);
for (const module of Module.moduleList) {
if (!module.enabled || !module.playerSpawn) continue;
try {
module.playerSpawn(player.id, player);
} catch (error) {
Module.sendError(error as Error);
}
yield;
}
yield;
}
}
}
});
yield;
system.runInterval(() => {
const allPlayers = Module.allWorldPlayers;
for (const player of allPlayers) {
if (!player?.isValid()) continue;
Module.playerLoopRunTime.forEach((event) => {
if (!(!event.booleanData && player.isAdmin())) {
yield;
world.beforeEvents.playerLeave.subscribe(({ player: { location, id: playerId, name: playerName } }) => {
if (Module.config.logSettings.logPlayerJoinLeave) {
write(false, "§cLeave §8(Connection)", playerName, {
playerId: playerId,
leaveLocation: Object.values(location)
.map((x) => Math.floor(x).toFixed(0))
.join(" "),
});
}
Module.currentPlayers = Module.currentPlayers.filter(({ id }) => id !== playerId);
for (const module of Module.moduleList) {
if (!module.enabled || !module?.playerLeave) continue;
try {
event.moduleFunction(player);
system.run(() => {
if (!module?.playerLeave) return;
module?.playerLeave(playerId);
});
} catch (error) {
Module.sendError(error as Error);
}
}
});
yield;
system.runInterval(() => {
const allPlayers = Module.allWorldPlayers;
for (const player of allPlayers) {
if (!player?.isValid()) continue;
Module.playerLoopRunTime.forEach((event) => {
if (!(!event.booleanData && player.isAdmin())) {
try {
event.moduleFunction(player);
} catch (error) {
Module.sendError(error as Error);
}
}
});
}
Module.tickLoopRunTime.forEach((event) => {
try {
event.moduleFunction();
} catch (error) {
Module.sendError(error as Error);
}
});
});
world.sendMessage("(Reload) Finish!");
yield;
}
Module.tickLoopRunTime.forEach((event) => {
try {
event.moduleFunction();
} catch (error) {
Module.sendError(error as Error);
}
});
});
world.sendMessage("(Reload) Finish!");
yield;
}
}
});
});
} catch (error) {
Module.sendError(error as Error);
} finally {
Expand Down
2 changes: 1 addition & 1 deletion Matrix_BP/src/program/detection/deviceBanning.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ new Module()
if (kickState === "none") return;
strengthenKick(player, `Banned device (${kickState})`);
})
.register();
.register();
2 changes: 1 addition & 1 deletion Matrix_BP/src/program/detection/mobAura.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function entityHitEntity({ damagingEntity, hitEntity }: EntityHitEntityAfterEven
let isDummyHit = false;
try {
isDummyHit = hitEntity.typeId === TEST_ENTITY && hitEntity?.hasTag("matrix:dummy::" + damagingEntity.id);
} catch { }
} catch {}
const location = damagingEntity.location;
if (isDummyHit) {
// Prevent spamming
Expand Down
2 changes: 1 addition & 1 deletion Matrix_BP/src/program/import.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export default [
"./program/detection/entityFly",
"./program/detection/elytraFly",
"./program/detection/autoTool",
"./program/detection/deviceBanning",
"./program/detection/deviceBanning",
"./program/utility/welcomer",
"./program/utility/worldBorder",
"./program/utility/chatRankAndAntiSpam",
Expand Down
2 changes: 1 addition & 1 deletion langfileGenerator.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ function generatePoFile(sourcePot, poFile, lang) {
const msgstr = msgstrMatch !== null && msgstrMatch[1] !== '' ? msgstrMatch[1] : '';
poContent += `#: ${msgid}\nmsgid "${msgstr}"\nmsgstr "${dataData ? dataData.slice(0, -1).slice(8) : ''}"\n\n`;
if (msgid === "pack.description") {
fs.writeFileSync(`./Matrix_BP/texts/${lang}.lang`, `pack.description=${dataData?.slice(0, -1)?.slice(8) ? (dataData?.slice(0, -1)?.slice(8) > 0 ? dataData?.slice(0, -1)?.slice(8) : msgstr) : msgstr}`);
fs.writeFileSync(`./Matrix_BP/texts/${lang}.lang`, `pack.description=${dataData?.slice(0, -1)?.slice(8) ? (dataData.slice(0, -1).slice(8).length > 0 ? dataData.slice(0, -1).slice(8) : msgstr) : msgstr}`);
}
}
return poContent;
Expand Down

0 comments on commit 5aadbdc

Please sign in to comment.