-
-
Notifications
You must be signed in to change notification settings - Fork 517
Expand file tree
/
Copy pathFeature.java
More file actions
108 lines (86 loc) · 2.91 KB
/
Feature.java
File metadata and controls
108 lines (86 loc) · 2.91 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
/*
* Copyright (c) 2014-2026 Wurst-Imperium and contributors.
*
* This source code is subject to the terms of the GNU General Public
* License, version 3. If a copy of the GPL was not distributed with this
* file, You can obtain one at: https://www.gnu.org/licenses/gpl-3.0.txt
*/
package net.wurstclient;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import net.minecraft.client.Minecraft;
import net.wurstclient.event.EventManager;
import net.wurstclient.keybinds.PossibleKeybind;
import net.wurstclient.mixinterface.IMinecraftClient;
import net.wurstclient.settings.Setting;
import net.wurstclient.util.ChatUtils;
public abstract class Feature
{
protected static final WurstClient WURST = WurstClient.INSTANCE;
protected static final EventManager EVENTS = WURST.getEventManager();
protected static final Minecraft MC = WurstClient.MC;
protected static final IMinecraftClient IMC = WurstClient.IMC;
protected static final ScheduledExecutorService scheduler =
Executors.newScheduledThreadPool(5);
private final LinkedHashMap<String, Setting> settings =
new LinkedHashMap<>();
private final LinkedHashSet<PossibleKeybind> possibleKeybinds =
new LinkedHashSet<>();
private final String searchTags =
getClass().isAnnotationPresent(SearchTags.class) ? String.join("\u00a7",
getClass().getAnnotation(SearchTags.class).value()) : "";
private final boolean safeToBlock =
!getClass().isAnnotationPresent(DontBlock.class);
public abstract String getName();
public abstract String getDescription();
public String getWrappedDescription(int width)
{
return ChatUtils.wrapText(getDescription(), width);
}
public Category getCategory()
{
return null;
}
public abstract String getPrimaryAction();
public void doPrimaryAction()
{
}
public boolean isEnabled()
{
return false;
}
public final Map<String, Setting> getSettings()
{
return Collections.unmodifiableMap(settings);
}
protected final void addSetting(Setting setting)
{
String key = setting.getName().toLowerCase();
if(settings.containsKey(key))
throw new IllegalArgumentException(
"Duplicate setting: " + getName() + " " + key);
settings.put(key, setting);
possibleKeybinds.addAll(setting.getPossibleKeybinds(getName()));
}
protected final void addPossibleKeybind(String command, String description)
{
possibleKeybinds.add(new PossibleKeybind(command, description));
}
public final Set<PossibleKeybind> getPossibleKeybinds()
{
return Collections.unmodifiableSet(possibleKeybinds);
}
public final String getSearchTags()
{
return searchTags;
}
public final boolean isSafeToBlock()
{
return safeToBlock;
}
}