-
Notifications
You must be signed in to change notification settings - Fork 84
Expand file tree
/
Copy pathModuleManager.java
More file actions
78 lines (69 loc) · 2.24 KB
/
ModuleManager.java
File metadata and controls
78 lines (69 loc) · 2.24 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
package com.zenith.module;
import com.zenith.module.api.Module;
import com.zenith.module.impl.*;
import it.unimi.dsi.fastutil.objects.Reference2ObjectMap;
import it.unimi.dsi.fastutil.objects.Reference2ObjectOpenHashMap;
import java.util.List;
import static com.zenith.Globals.MODULE_LOG;
import static java.util.Arrays.asList;
public class ModuleManager {
private final Reference2ObjectMap<Class<? extends Module>, Module> moduleClassMap = new Reference2ObjectOpenHashMap<>();
public void init() {
asList(
new ActionLimiter(),
new ActiveHours(),
new AntiAFK(),
new AntiKick(),
new AntiLeak(),
new AutoArmor(),
new AutoDisconnect(),
new AutoDrop(),
new AutoEat(),
new AutoGap(),
new AutoFish(),
new AutoMend(),
new AutoOmen(),
new AutoReconnect(),
new AutoReply(),
new AutoRespawn(),
new AutoTotem(),
new ChatHistory(),
new Click(),
new CoordObfuscation(),
new ExtraChat(),
new KillAura(),
new QueueWarning(),
new ReplayMod(),
new Requeue(),
new SessionTimeLimit(),
new Spammer(),
new Spook(),
new SpawnPatrol(),
new Tasks(),
new VisualRange()
).forEach(m -> {
addModule(m);
m.syncEnabledFromConfig();
});
}
private void addModule(Module module) {
moduleClassMap.put(module.getClass(), module);
}
public <T extends Module> T get(final Class<T> clazz) {
try {
return (T) moduleClassMap.get(clazz);
} catch (final Throwable e) {
return null;
}
}
public void registerModule(Module module) {
if (moduleClassMap.containsKey(module.getClass())) {
MODULE_LOG.warn("Duplicate module class being registered: {}", module.getClass().getSimpleName(), new RuntimeException());
}
addModule(module);
module.syncEnabledFromConfig();
}
public List<Module> getModules() {
return moduleClassMap.values().stream().toList();
}
}