use of net.wurstclient.hack.Hack in project Wurst7 by Wurst-Imperium.
the class FeaturesCmd method call.
@Override
public void call(String[] args) throws CmdException {
if (args.length != 0)
throw new CmdSyntaxError();
if (WurstClient.VERSION.startsWith("7.0pre"))
ChatUtils.warning("This is just a pre-release! It doesn't (yet) have all of the features of Wurst 7.0! See download page for details.");
int hax = WURST.getHax().countHax();
int cmds = WURST.getCmds().countCmds();
int otfs = WURST.getOtfs().countOtfs();
int all = hax + cmds + otfs;
ChatUtils.message("All features: " + all);
ChatUtils.message("Hacks: " + hax);
ChatUtils.message("Commands: " + cmds);
ChatUtils.message("Other features: " + otfs);
int settings = 0;
for (Hack hack : WURST.getHax().getAllHax()) settings += hack.getSettings().size();
for (Command cmd : WURST.getCmds().getAllCmds()) settings += cmd.getSettings().size();
for (OtherFeature otf : WURST.getOtfs().getAllOtfs()) settings += otf.getSettings().size();
ChatUtils.message("Settings: " + settings);
}
use of net.wurstclient.hack.Hack in project Wurst7 by Wurst-Imperium.
the class NavigatorFeatureScreen method onResize.
@Override
protected void onResize() {
buttonDatas.clear();
// primary button
String primaryAction = feature.getPrimaryAction();
boolean hasPrimaryAction = !primaryAction.isEmpty();
// !feature.getHelpPage().isEmpty();
boolean hasHelp = false;
if (hasPrimaryAction) {
primaryButton = new ButtonWidget(width / 2 - 151, height - 65, hasHelp ? 149 : 302, 18, new LiteralText(primaryAction), b -> {
TooManyHaxHack tooManyHax = WurstClient.INSTANCE.getHax().tooManyHaxHack;
if (tooManyHax.isEnabled() && tooManyHax.isBlocked(feature)) {
ChatUtils.error(feature.getName() + " is blocked by TooManyHax.");
return;
}
feature.doPrimaryAction();
primaryButton.setMessage(new LiteralText(feature.getPrimaryAction()));
WurstClient.INSTANCE.getNavigator().addPreference(feature.getName());
});
addDrawableChild(primaryButton);
}
// help button
// if(hasHelp)
// method_37063(new ButtonWidget(
// width / 2 + (hasPrimaryAction ? 2 : -151), height - 65,
// hasPrimaryAction ? 149 : 302, 20, "Help", b -> {
// MiscUtils.openLink("https://www.wurstclient.net/wiki/"
// + feature.getHelpPage() + "/");
// wurst.navigator.analytics.trackEvent("help", "open",
// feature.getName());
// wurst.navigator.addPreference(feature.getName());
// ConfigFiles.NAVIGATOR.save();
// }));
// type
text = "Type: ";
if (feature instanceof Hack)
text += "Hack";
else if (feature instanceof Command)
text += "Command";
else
text += "Other Feature";
// category
if (feature.getCategory() != null)
text += ", Category: " + feature.getCategory().getName();
// description
String description = feature.getWrappedDescription(300);
if (!description.isEmpty())
text += "\n\nDescription:\n" + description;
// area
Rectangle area = new Rectangle(middleX - 154, 60, 308, height - 103);
// settings
Collection<Setting> settings = feature.getSettings().values();
if (!settings.isEmpty()) {
text += "\n\nSettings:";
windowComponentY = getStringHeight(text) + 2;
for (int i = 0; i < Math.ceil(window.getInnerHeight() / 9.0); i++) text += "\n";
}
// keybinds
Set<PossibleKeybind> possibleKeybinds = feature.getPossibleKeybinds();
if (!possibleKeybinds.isEmpty()) {
// heading
text += "\n\nKeybinds:";
// add keybind button
ButtonData addKeybindButton = new ButtonData(area.x + area.width - 16, area.y + getStringHeight(text) - 7, 12, 8, "+", 0x00ff00) {
@Override
public void press() {
// add keybind
WurstClient.MC.setScreen(new NavigatorNewKeybindScreen(possibleKeybinds, NavigatorFeatureScreen.this));
}
};
buttonDatas.add(addKeybindButton);
// keybind list
HashMap<String, String> possibleKeybindsMap = new HashMap<>();
for (PossibleKeybind possibleKeybind : possibleKeybinds) possibleKeybindsMap.put(possibleKeybind.getCommand(), possibleKeybind.getDescription());
TreeMap<String, PossibleKeybind> existingKeybinds = new TreeMap<>();
boolean noKeybindsSet = true;
for (Keybind keybind : WurstClient.INSTANCE.getKeybinds().getAllKeybinds()) {
String commands = keybind.getCommands();
commands = commands.replace(";", "\u00a7").replace("\u00a7\u00a7", ";");
for (String command : commands.split("\u00a7")) {
command = command.trim();
String keybindDescription = possibleKeybindsMap.get(command);
if (keybindDescription != null) {
if (noKeybindsSet)
noKeybindsSet = false;
text += "\n" + keybind.getKey().replace("key.keyboard.", "") + ": " + keybindDescription;
existingKeybinds.put(keybind.getKey(), new PossibleKeybind(command, keybindDescription));
} else if (feature instanceof Hack && command.equalsIgnoreCase(feature.getName())) {
if (noKeybindsSet)
noKeybindsSet = false;
text += "\n" + keybind.getKey().replace("key.keyboard.", "") + ": " + "Toggle " + feature.getName();
existingKeybinds.put(keybind.getKey(), new PossibleKeybind(command, "Toggle " + feature.getName()));
}
}
}
if (noKeybindsSet)
text += "\nNone";
else {
// remove keybind button
buttonDatas.add(new ButtonData(addKeybindButton.x, addKeybindButton.y, addKeybindButton.width, addKeybindButton.height, "-", 0xff0000) {
@Override
public void press() {
// remove keybind
client.setScreen(new NavigatorRemoveKeybindScreen(existingKeybinds, NavigatorFeatureScreen.this));
}
});
addKeybindButton.x -= 16;
}
}
// text height
setContentHeight(getStringHeight(text));
}
Aggregations