use of me.earth.earthhack.api.module.Module in project 3arthh4ck by 3arthqu4ke.
the class ModuleListCommand method getComponent.
public static ITextComponent getComponent() {
AbstractTextComponent component = new SimpleComponent("Modules: ");
component.setWrap(true);
List<Module> moduleList = Managers.MODULES.getRegistered().stream().sorted(Comparator.comparing(Displayable::getDisplayName)).collect(Collectors.toList());
for (int i = 0; i < moduleList.size(); i++) {
Module module = moduleList.get(i);
if (module != null) {
int finalI = i;
ITextComponent sibling = new SuppliedComponent(() -> (module.isEnabled() ? TextColor.GREEN : TextColor.RED) + module.getName() + (finalI == moduleList.size() - 1 ? "" : ", ")).setWrap(true);
Style style = new Style().setHoverEvent(ChatComponentUtil.setOffset(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponentString(module.getData().getDescription())))).setClickEvent(new SmartClickEvent(ClickEvent.Action.RUN_COMMAND) {
@Override
public String getValue() {
return Commands.getPrefix() + "toggle " + module.getName();
}
});
((IStyle) style).setSuppliedInsertion(() -> Commands.getPrefix() + module.getName());
((IStyle) style).setMiddleClickEvent(new SmartClickEvent(ClickEvent.Action.RUN_COMMAND) {
@Override
public String getValue() {
return Commands.getPrefix() + module.getName();
}
});
sibling.setStyle(style);
component.appendSibling(sibling);
}
}
return component;
}
use of me.earth.earthhack.api.module.Module in project 3arthh4ck by 3arthqu4ke.
the class ToggleCommand method execute.
@Override
public void execute(String[] args) {
if (args.length > 1) {
Module module = Managers.MODULES.getObject(args[1]);
if (module != null) {
int times = 1;
if (args.length > 2) {
try {
times = Integer.parseInt(args[2]);
} catch (NumberFormatException ignored) {
ChatUtil.sendMessage("<ToggleCommand> " + TextColor.RED + args[2] + " is not a valid number.");
return;
}
}
String color = module.isEnabled() && times % 2 == 0 || !module.isEnabled() && times % 2 != 0 ? TextColor.GREEN : TextColor.RED;
Managers.CHAT.sendDeleteMessage(color + "Toggling " + TextColor.WHITE + TextColor.BOLD + module.getDisplayName() + color + (times > 1 ? " " + times + "x." : "."), module.getName(), ChatIDs.MODULE);
int finalTimes = times;
Scheduler.getInstance().schedule(() -> {
for (int i = 0; i < finalTimes; i++) {
module.toggle();
}
});
} else {
ChatUtil.sendMessage("<ToggleCommand> " + TextColor.RED + "Couldn't find " + args[1] + ".");
}
return;
}
ChatUtil.sendMessage("<ToggleCommand> " + TextColor.RED + "Usage is: " + this.getFullUsage());
}
use of me.earth.earthhack.api.module.Module in project 3arthh4ck by 3arthqu4ke.
the class HSettingCommand method execute.
@Override
public void execute(String[] args) {
if (args.length > 2) {
Module module = Managers.MODULES.getObject(args[1]);
if (module != null) {
Setting<?> setting = module.getSetting(args[2]);
if (setting != null) {
if (args.length == 3) {
String command = getCommand(setting, module);
Scheduler.getInstance().schedule(() -> mc.displayGuiScreen(new GuiChat(command)));
} else {
update(setting, module, args, false);
}
}
}
}
}
use of me.earth.earthhack.api.module.Module in project 3arthh4ck by 3arthqu4ke.
the class HModulesCommand method execute.
@Override
public void execute(String[] args) {
if (args.length > 1) {
String name = args[1];
Module module = Managers.MODULES.getObject(name);
if (module != null) {
if (Mouse.isButtonDown(1)) {
mc.displayGuiScreen(new GuiChat(Commands.getPrefix() + module.getName() + " "));
} else {
module.toggle();
}
} else {
ChatUtil.sendMessage(TextColor.RED + "An error occurred.");
}
}
}
use of me.earth.earthhack.api.module.Module in project 3arthh4ck by 3arthqu4ke.
the class PresetCommand method getPossibleInputs.
@Override
public PossibleInputs getPossibleInputs(String[] args) {
if (args.length > 2) {
if (args.length == 3) {
Module module = Managers.MODULES.getObject(args[1]);
if (module == null) {
return PossibleInputs.empty();
}
ModuleData<?> data = module.getData();
if (data == null) {
return PossibleInputs.empty();
}
ModulePreset<?> preset = CommandUtil.getNameableStartingWith(args[2], data.getPresets());
if (preset != null) {
return new PossibleInputs(TextUtil.substring(preset.getName(), args[2].length()), "");
}
}
return PossibleInputs.empty();
}
return super.getPossibleInputs(args);
}
Aggregations