Skip to content

Commit

Permalink
jasonlaubb.exe crashed
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonlaubb committed Oct 26, 2024
1 parent 43b0fad commit 5475779
Show file tree
Hide file tree
Showing 38 changed files with 1,599 additions and 251 deletions.
12 changes: 6 additions & 6 deletions ac_BP/src/Assets/Action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,23 +56,23 @@ export class Action {
const origin = Action.tempTimeoutData[player.id];
if (origin) return;
Action.tempTimeoutData[player.id] = true;
const disableTag = Object.values(DisableTags)
const disableTag = Object.values(DisableTags);
disableTag.forEach((tag) => {
player.addTag(tag);
})
});
system.runTimeout(() => {
try {
disableTag.forEach((tag) => {
player.removeTag(tag);
})
} catch { }
});
} catch {}
Action.tempTimeoutData[player.id] = false;
}, duration)
}, duration);
}
public static freeze = freeze;
public static unfreeze = unfreeze;
public static ban = ban;
public static unban = unban;
public static unbanList = unbanList;
public static unbanRemove = unbanRemove;
}
}
14 changes: 13 additions & 1 deletion ac_BP/src/Assets/Language.ts
Original file line number Diff line number Diff line change
Expand Up @@ -261,4 +261,16 @@ export type Translate =
| "defender.verified"
| "defender.keepmove"
| "ping.ping"
| "ping.pong";
| "ping.pong"
| "afk.quit"
| "afk.ui.title"
| "afk.intro"
| "afk.why"
| "afk.clickbelow"
| "afk.ui.button"
| "afk.kick"
| "afk.warn"
| "afk.tips"
| "timeout.has"
| "tps.tps"
| "tpa.accept";
142 changes: 68 additions & 74 deletions ac_BP/src/Core/Utility/AntiAFK.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,82 +5,76 @@ import { ActionFormData } from "@minecraft/server-ui";
import { rawstr } from "../../Assets/Util";
import { Action } from "../../Assets/Action";
interface AfkData {
lastMove: number;
lastLocation: Vector3;
isPlayerChecking: boolean;
isWarned: boolean;
isTipped: boolean;
lastMove: number;
lastLocation: Vector3;
isPlayerChecking: boolean;
isWarned: boolean;
isTipped: boolean;
}
const afkData = new Map<string, AfkData>();
async function checkAFK (config: configi, player: Player) {
const data = afkData.get(player.id) ?? {
lastMove: Date.now(),
lastLocation: player.location,
isPlayerChecking: false,
isWarned: false,
isTipped: false,
} as AfkData;
if (data.isPlayerChecking) return;
const isPlayerMoving = player.hasTag(AnimationControllerTags.moving) && (player.location.x != data.lastLocation.x || player.location.z != data.lastLocation.z);
const timeSinceLastMove = Date.now() - data.lastMove;
if (isPlayerMoving) {
data.lastMove = Date.now();
if (timeSinceLastMove > config.antiAFK.tipsTime) {
player.sendMessage(rawstr.drt("afk.quit"));
}
} else {
if (timeSinceLastMove > config.antiAFK.maxAFKTime) {
data.isPlayerChecking = true;
const ui = new ActionFormData()
.title(rawstr.drt("afk.ui.title"))
.body(
new rawstr()
.tra("afk.intro")
.str("\n")
.tra("afk.why")
.str("\n")
.tra("afk.clickbelow")
.parse()
)
.button(rawstr.drt("afk.ui.button"))
//@ts-expect-error
.show(player);
afkData.set(player.id, data);
const disconnectState = await new Promise<boolean>((resolve) => {
const interval = system.runInterval(() => {
if (Date.now() - data.lastMove > config.antiAFK.maxUIallowance) {
system.clearRun(interval);
resolve(true);
}
}, 20);
ui.then((result) => {
system.clearRun(interval);
if (result.canceled) {
resolve(true);
} else {
resolve(false);
}
});
})
if (disconnectState) {
Action.tempkick(player);
world.sendMessage(rawstr.drt("afk.kick", player.name));
} else {
afkData.delete(player.id);
}
return;
} else if (timeSinceLastMove > config.antiAFK.warnTime) {
player.sendMessage(rawstr.drt("afk.warn", ((config.antiAFK.maxAFKTime - timeSinceLastMove) * 0.05).toString()));
data.isWarned = true;
} else if (timeSinceLastMove > config.antiAFK.tipsTime) {
player.sendMessage(rawstr.drt("afk.tips"));
data.isTipped = true;
}
}
data.lastLocation = player.location;
async function checkAFK(config: configi, player: Player) {
const data =
afkData.get(player.id) ??
({
lastMove: Date.now(),
lastLocation: player.location,
isPlayerChecking: false,
isWarned: false,
isTipped: false,
} as AfkData);
if (data.isPlayerChecking) return;
const isPlayerMoving = player.hasTag(AnimationControllerTags.moving) && (player.location.x != data.lastLocation.x || player.location.z != data.lastLocation.z);
const timeSinceLastMove = Date.now() - data.lastMove;
if (isPlayerMoving) {
data.lastMove = Date.now();
if (timeSinceLastMove > config.antiAFK.tipsTime) {
player.sendMessage(rawstr.drt("afk.quit"));
}
} else {
if (timeSinceLastMove > config.antiAFK.maxAFKTime) {
data.isPlayerChecking = true;
const ui = new ActionFormData()
.title(rawstr.drt("afk.ui.title"))
.body(new rawstr().tra("afk.intro").str("\n").tra("afk.why").str("\n").tra("afk.clickbelow").parse())
.button(rawstr.drt("afk.ui.button"))
//@ts-expect-error
.show(player);
afkData.set(player.id, data);
const disconnectState = await new Promise<boolean>((resolve) => {
const interval = system.runInterval(() => {
if (Date.now() - data.lastMove > config.antiAFK.maxUIallowance) {
system.clearRun(interval);
resolve(true);
}
}, 20);
ui.then((result) => {
system.clearRun(interval);
if (result.canceled) {
resolve(true);
} else {
resolve(false);
}
});
});
if (disconnectState) {
Action.tempkick(player);
world.sendMessage(rawstr.drt("afk.kick", player.name));
} else {
afkData.delete(player.id);
}
return;
} else if (timeSinceLastMove > config.antiAFK.warnTime) {
player.sendMessage(rawstr.drt("afk.warn", ((config.antiAFK.maxAFKTime - timeSinceLastMove) * 0.05).toString()));
data.isWarned = true;
} else if (timeSinceLastMove > config.antiAFK.tipsTime) {
player.sendMessage(rawstr.drt("afk.tips"));
data.isTipped = true;
}
}
data.lastLocation = player.location;
}

registerModule("antiAFK", false, [], {
tickInterval: 5,
intick: checkAFK,
})
tickInterval: 5,
intick: checkAFK,
});
Loading

0 comments on commit 5475779

Please sign in to comment.