-
Notifications
You must be signed in to change notification settings - Fork 84
Expand file tree
/
Copy pathModulePriorityCommand.java
More file actions
270 lines (258 loc) · 13.2 KB
/
ModulePriorityCommand.java
File metadata and controls
270 lines (258 loc) · 13.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
package com.zenith.command.impl;
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import com.zenith.command.api.Command;
import com.zenith.command.api.CommandCategory;
import com.zenith.command.api.CommandContext;
import com.zenith.command.api.CommandUsage;
import com.zenith.feature.pathfinder.Baritone;
import com.zenith.module.impl.*;
import org.jetbrains.annotations.NotNull;
import org.jspecify.annotations.Nullable;
import java.util.Comparator;
import java.util.function.IntSupplier;
import java.util.function.Supplier;
import java.util.stream.Stream;
import static com.mojang.brigadier.arguments.IntegerArgumentType.getInteger;
import static com.mojang.brigadier.arguments.IntegerArgumentType.integer;
import static com.zenith.Globals.CONFIG;
import static com.zenith.Globals.MODULE;
public class ModulePriorityCommand extends Command {
@Override
public CommandUsage commandUsage() {
return CommandUsage.builder()
.name("modulePriority")
.category(CommandCategory.MODULE)
.description("""
Configures the priority of ZenithProxy modules.
A higher priority means the module's actions (like rotations, clicks, etc.) will take precedence over modules with lower priorities.
Should not be edited normally, only for advanced use cases.
Default module priorities may be changed between versions.
""")
.usageLines(
"autoTotem <default/int>",
"autoArmor <default/int>",
"autoEat <default/int>",
"autoGap <default/int>",
"autoOmen <default/int>",
"click <default/int>",
"killAura <default/int>",
"pathfinder <default/int>",
"spawnPatrol <default/int>",
"antiAfk <default/int>",
"autoMend <default/int>",
"autoDrop <default/int>",
"autoFish <default/int>",
"spook <default/int>",
"list"
)
.build();
}
@Override
public LiteralArgumentBuilder<CommandContext> register() {
return command("modulePriority")
.then(literal("autoTotem")
.then(argument("priority", integer()).executes(c -> {
CONFIG.client.extra.autoTotem.priority = getInteger(c, "priority");
c.getSource().getEmbed()
.title("AutoTotem Priority Set");
}))
.then(literal("default").executes(c -> {
CONFIG.client.extra.autoTotem.priority = null;
c.getSource().getEmbed()
.title("AutoTotem Priority Reset");
})))
.then(literal("autoArmor")
.then(argument("priority", integer()).executes(c -> {
CONFIG.client.extra.autoArmor.priority = getInteger(c, "priority");
c.getSource().getEmbed()
.title("AutoArmor Priority Set");
}))
.then(literal("default").executes(c -> {
CONFIG.client.extra.autoArmor.priority = null;
c.getSource().getEmbed()
.title("AutoArmor Priority Reset");
})))
.then(literal("autoEat")
.then(argument("priority", integer()).executes(c -> {
CONFIG.client.extra.autoEat.priority = getInteger(c, "priority");
c.getSource().getEmbed()
.title("AutoEat Priority Set");
}))
.then(literal("default").executes(c -> {
CONFIG.client.extra.autoEat.priority = null;
c.getSource().getEmbed()
.title("AutoEat Priority Reset");
})))
.then(literal("autoGap")
.then(argument("priority", integer()).executes(c -> {
CONFIG.client.extra.autoGap.priority = getInteger(c, "priority");
c.getSource().getEmbed()
.title("AutoGap Priority Set");
}))
.then(literal("default").executes(c -> {
CONFIG.client.extra.autoGap.priority = null;
c.getSource().getEmbed()
.title("AutoGap Priority Reset");
})))
.then(literal("autoOmen")
.then(argument("priority", integer()).executes(c -> {
CONFIG.client.extra.autoOmen.priority = getInteger(c, "priority");
c.getSource().getEmbed()
.title("AutoOmen Priority Set");
}))
.then(literal("default").executes(c -> {
CONFIG.client.extra.autoOmen.priority = null;
c.getSource().getEmbed()
.title("AutoOmen Priority Reset");
})))
.then(literal("click")
.then(argument("priority", integer()).executes(c -> {
CONFIG.client.extra.click.priority = getInteger(c, "priority");
c.getSource().getEmbed()
.title("Click Priority Set");
}))
.then(literal("default").executes(c -> {
CONFIG.client.extra.click.priority = null;
c.getSource().getEmbed()
.title("Click Priority Reset");
})))
.then(literal("killAura")
.then(argument("priority", integer()).executes(c -> {
CONFIG.client.extra.killAura.actionPriority = getInteger(c, "priority");
c.getSource().getEmbed()
.title("KillAura Priority Set");
}))
.then(literal("default").executes(c -> {
CONFIG.client.extra.killAura.actionPriority = null;
c.getSource().getEmbed()
.title("KillAura Priority Reset");
})))
.then(literal("pathfinder")
.then(argument("priority", integer()).executes(c -> {
CONFIG.client.extra.pathfinder.priority = getInteger(c, "priority");
c.getSource().getEmbed()
.title("Pathfinder Priority Set");
}))
.then(literal("default").executes(c -> {
CONFIG.client.extra.pathfinder.priority = null;
c.getSource().getEmbed()
.title("Pathfinder Priority Reset");
})))
.then(literal("spawnPatrol")
.then(argument("priority", integer()).executes(c -> {
CONFIG.client.extra.spawnPatrol.priority = getInteger(c, "priority");
c.getSource().getEmbed()
.title("SpawnPatrol Priority Set");
}))
.then(literal("default").executes(c -> {
CONFIG.client.extra.spawnPatrol.priority = null;
c.getSource().getEmbed()
.title("SpawnPatrol Priority Reset");
})))
.then(literal("antiAfk")
.then(argument("priority", integer()).executes(c -> {
CONFIG.client.extra.antiafk.priority = getInteger(c, "priority");
c.getSource().getEmbed()
.title("AntiAFK Priority Set");
}))
.then(literal("default").executes(c -> {
CONFIG.client.extra.antiafk.priority = null;
c.getSource().getEmbed()
.title("AntiAFK Priority Reset");
})))
.then(literal("autoMend")
.then(argument("priority", integer()).executes(c -> {
CONFIG.client.extra.autoMend.priority = getInteger(c, "priority");
c.getSource().getEmbed()
.title("AutoMend Priority Set");
}))
.then(literal("default").executes(c -> {
CONFIG.client.extra.autoMend.priority = null;
c.getSource().getEmbed()
.title("AutoMend Priority Reset");
})))
.then(literal("autoDrop")
.then(argument("priority", integer()).executes(c -> {
CONFIG.client.extra.autoDrop.priority = getInteger(c, "priority");
c.getSource().getEmbed()
.title("AutoDrop Priority Set");
}))
.then(literal("default").executes(c -> {
CONFIG.client.extra.autoDrop.priority = null;
c.getSource().getEmbed()
.title("AutoDrop Priority Reset");
})))
.then(literal("autoFish")
.then(argument("priority", integer()).executes(c -> {
CONFIG.client.extra.autoFish.priority = getInteger(c, "priority");
c.getSource().getEmbed()
.title("AutoFish Priority Set");
}))
.then(literal("default").executes(c -> {
CONFIG.client.extra.autoFish.priority = null;
c.getSource().getEmbed()
.title("AutoFish Priority Reset");
})))
.then(literal("spook")
.then(argument("priority", integer()).executes(c -> {
CONFIG.client.extra.spook.priority = getInteger(c, "priority");
c.getSource().getEmbed()
.title("Spook Priority Set");
}))
.then(literal("default").executes(c -> {
CONFIG.client.extra.spook.priority = null;
c.getSource().getEmbed()
.title("Spook Priority Reset");
})))
.then(literal("list").executes(c -> {
c.getSource().getEmbed()
.title("Module Priority List")
.description(priorityList());
}));
}
@Override
public void defaultHandler(CommandContext ctx) {
ctx.getEmbed()
.primaryColor();
}
String priorityList() {
var sb = new StringBuilder();
Stream.of(
new ModuleInstance("AutoTotem", () -> MODULE.get(AutoTotem.class).getPriority(), () -> CONFIG.client.extra.autoTotem.priority),
new ModuleInstance("AutoArmor", () -> MODULE.get(AutoArmor.class).getPriority(), () -> CONFIG.client.extra.autoArmor.priority),
new ModuleInstance("AutoEat", () -> MODULE.get(AutoEat.class).getPriority(), () -> CONFIG.client.extra.autoEat.priority),
new ModuleInstance("AutoGap", () -> MODULE.get(AutoGap.class).getPriority(), () -> CONFIG.client.extra.autoGap.priority),
new ModuleInstance("AutoOmen", () -> MODULE.get(AutoOmen.class).getPriority(), () -> CONFIG.client.extra.autoOmen.priority),
new ModuleInstance("Click", () -> MODULE.get(Click.class).getPriority(), () -> CONFIG.client.extra.click.priority),
new ModuleInstance("KillAura", () -> MODULE.get(KillAura.class).getPriority(), () -> CONFIG.client.extra.killAura.actionPriority),
new ModuleInstance("Pathfinder", () -> Baritone.getPriority(), () -> CONFIG.client.extra.pathfinder.priority),
new ModuleInstance("SpawnPatrol", () -> MODULE.get(SpawnPatrol.class).getPriority(), () -> CONFIG.client.extra.spawnPatrol.priority),
new ModuleInstance("AntiAFK", () -> MODULE.get(AntiAFK.class).getPriority(), () -> CONFIG.client.extra.antiafk.priority),
new ModuleInstance("AutoMend", () -> MODULE.get(AutoMend.class).getPriority(), () -> CONFIG.client.extra.autoMend.priority),
new ModuleInstance("AutoDrop", () -> MODULE.get(AutoDrop.class).getPriority(), () -> CONFIG.client.extra.autoDrop.priority),
new ModuleInstance("AutoFish", () -> MODULE.get(AutoFish.class).getPriority(), () -> CONFIG.client.extra.autoFish.priority),
new ModuleInstance("Spook", () -> MODULE.get(Spook.class).getPriority(), () -> CONFIG.client.extra.spook.priority))
.sorted(Comparator.reverseOrder())
.forEach(instance -> {
sb
.append("**")
.append(instance.name())
.append("**: ")
.append(instance.priorityAccessor().getAsInt());
if (instance.isDefault()) {
sb.append(" (default)");
}
sb.append("\n");
});
return sb.toString();
}
record ModuleInstance(String name, IntSupplier priorityAccessor, Supplier<@Nullable Integer> settingValueAccessor) implements Comparable<ModuleInstance> {
boolean isDefault() {
return settingValueAccessor.get() == null;
}
@Override
public int compareTo(@NotNull final ModulePriorityCommand.ModuleInstance o) {
return Integer.compare(this.priorityAccessor.getAsInt(), o.priorityAccessor.getAsInt());
}
}
}