Skip to content

Commit bd4394c

Browse files
committed
test
1 parent 12dbe13 commit bd4394c

File tree

2 files changed

+29
-9
lines changed

2 files changed

+29
-9
lines changed

src/skyblock/AntiAFK.ts

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,17 @@ export class AntiAFK {
3636

3737
private registerListeners() {
3838
JsMacros.on('OpenScreen', JavaWrapper.methodToJava((event) => this.onOpenScreen(event)));
39-
JsMacros.on('Title', JavaWrapper.methodToJava((event) => this.onTitle(event)));
40-
JsMacros.on('Tick', JavaWrapper.methodToJava(() => this.onTick()));
39+
JsMacros.on('Tick', JavaWrapper.methodToJava((event) => this.onTick(event)));
40+
this.listenForTitle();
41+
}
42+
43+
private listenForTitle() {
44+
JsMacros.once('Title', JavaWrapper.methodToJava((event) => {
45+
new (Packages.java.lang.Thread as any)(() => {
46+
this.onTitle(event);
47+
this.listenForTitle();
48+
}).start();
49+
}));
4150
}
4251

4352
private setActive(active: boolean) {
@@ -51,10 +60,10 @@ export class AntiAFK {
5160
}
5261
}
5362

54-
private onTick() {
63+
private onTick(event: Events.Tick) {
5564
if (!this.isActive) return;
56-
// 5 seconds timeout
57-
if (Date.now() - this.lastTitleTime > 5000) {
65+
// 10 seconds timeout
66+
if (Date.now() - this.lastTitleTime > 10000) {
5867
this.setActive(false);
5968
}
6069
}
@@ -85,6 +94,7 @@ export class AntiAFK {
8594
if (!inv) return;
8695

8796
// Filter for "Activity Check" GUI
97+
Chat.log(inv.getContainerTitle())
8898
if (!inv.getContainerTitle().includes('Activity Check')) return;
8999

90100
// We assume if the GUI opens and we are enabled, we try to start the check.
@@ -106,9 +116,6 @@ export class AntiAFK {
106116

107117
private onTitle(event: Events.Title) {
108118
if (!this.config.enabled) return;
109-
// If we haven't clicked start recently, maybe we shouldn't auto-react?
110-
// But the prompt implies "a series of titles appear... macro should follow".
111-
// So even if we didn't trigger the start (maybe user did), we should help if enabled.
112119

113120
if (!event.message) return;
114121
const text = event.message.getString().trim();
@@ -126,31 +133,44 @@ export class AntiAFK {
126133
const player = Player.getPlayer();
127134
if (!player) return;
128135

136+
let matched = false;
137+
129138
if (lowerText.includes('look left')) {
130139
Chat.log('§aAntiAFK: §7Looking LEFT');
131140
const yaw = player.getYaw();
132141
player.lookAt(yaw - 90, player.getPitch());
142+
matched = true;
133143
} else if (lowerText.includes('look right')) {
134144
Chat.log('§aAntiAFK: §7Looking RIGHT');
135145
const yaw = player.getYaw();
136146
player.lookAt(yaw + 90, player.getPitch());
147+
matched = true;
137148
} else if (lowerText.includes('look down')) {
138149
Chat.log('§aAntiAFK: §7Looking DOWN');
139150
player.lookAt(player.getYaw(), 90);
151+
matched = true;
140152
} else if (lowerText.includes('look up')) {
141153
Chat.log('§aAntiAFK: §7Looking UP');
142154
player.lookAt(player.getYaw(), -90);
155+
matched = true;
143156
} else if (lowerText.includes('jump')) {
144157
Chat.log('§aAntiAFK: §7Jumping');
145158
this.keys.jump.click();
159+
matched = true;
146160
} else if (lowerText.includes('sneak')) {
147161
Chat.log('§aAntiAFK: §7Sneaking');
148162
this.keys.sneak.set(true);
149163
Client.waitTick(10);
150164
this.keys.sneak.set(false);
165+
matched = true;
151166
} else if (lowerText.includes('punch') || lowerText.includes('attack')) {
152167
Chat.log('§aAntiAFK: §7Punching');
153168
this.keys.attack.click();
169+
matched = true;
170+
}
171+
172+
if (matched) {
173+
Client.waitTick(10);
154174
}
155175
}
156176

src/skyblock/metadata.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "1.0.9",
2+
"version": "1.0.10",
33
"title": "Skyblock",
44
"description": "Macros for hub.mc-complex.com"
55
}

0 commit comments

Comments
 (0)