use of dev.hypnotic.module.Mod in project Hypnotic-Client by Hypnotic-Development.
the class ClickGUI method refresh.
private void refresh() {
buttons.clear();
buttonNames.clear();
Collections.sort(ModuleManager.INSTANCE.getModulesInCategory(currentCategory), Comparator.comparing(Mod::getName));
for (Mod mod : ModuleManager.INSTANCE.getModulesInCategory(currentCategory)) {
if (!(mod instanceof FlightBlink)) {
buttonNames.add(mod.getName());
}
}
buttonNames.sort(Collator.getInstance());
Collections.sort(buttons, Comparator.comparing(ModuleButton::getName));
int count = 0;
for (String name : buttonNames) {
ModuleButton mb = new ModuleButton(ModuleManager.INSTANCE.getModuleByName(name), currentCategory, x + 120, y + count);
buttons.add(mb);
mb.startY = count;
count += 30;
}
this.offset = 0;
}
use of dev.hypnotic.module.Mod in project Hypnotic-Client by Hypnotic-Development.
the class ModuleArgumentType method parse.
@Override
public Mod parse(StringReader reader) throws CommandSyntaxException {
String argument = reader.readString();
Mod module = ModuleManager.INSTANCE.getModuleByName(argument);
if (module == null)
throw NO_SUCH_MODULE.create(argument);
return module;
}
use of dev.hypnotic.module.Mod in project Hypnotic-Client by Hypnotic-Development.
the class Bind method build.
@Override
public void build(LiteralArgumentBuilder<CommandSource> builder) {
builder.then(argument("mod", ModuleArgumentType.module()).then(argument("key", StringArgumentType.string()).executes(context -> {
Mod mod = context.getArgument("mod", Mod.class);
String key = context.getArgument("key", String.class);
mod.setKey(KeyUtils.getKey(key));
ChatUtils.tellPlayer("Bound " + ColorUtils.white + mod.getName() + ColorUtils.gray + " to " + ColorUtils.white + (KeyUtils.getKey(key) != -1 ? GLFW.glfwGetKeyName(KeyUtils.getKey(key), KeyUtils.getKeyScanCode(key)).toUpperCase() : "NONE"));
return SINGLE_SUCCESS;
})));
}
use of dev.hypnotic.module.Mod in project Hypnotic-Client by Hypnotic-Development.
the class Config method serialize.
public String serialize() {
Gson gson = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().setPrettyPrinting().create();
for (Mod module : ModuleManager.INSTANCE.getAllModules()) {
List<ConfigSetting> settings = new ArrayList<>();
for (Setting setting : module.settings) {
if (setting instanceof KeybindSetting)
continue;
ConfigSetting cfgSetting = new ConfigSetting(null, null);
cfgSetting.name = setting.name;
if (setting instanceof BooleanSetting) {
cfgSetting.value = ((BooleanSetting) setting).isEnabled();
}
if (setting instanceof ModeSetting) {
cfgSetting.value = ((ModeSetting) setting).getSelected();
}
if (setting instanceof NumberSetting) {
cfgSetting.value = ((NumberSetting) setting).getValue();
}
if (setting instanceof ColorSetting) {
cfgSetting.value = ((ColorSetting) setting).getHex();
}
settings.add(cfgSetting);
}
module.cfgSettings = settings.toArray(new ConfigSetting[0]);
}
return gson.toJson(ModuleManager.INSTANCE.getAllModules());
}
use of dev.hypnotic.module.Mod in project Hypnotic-Client by Hypnotic-Development.
the class ConfigManager method loadConfig.
public boolean loadConfig() {
try {
String configString = new String(Files.readAllBytes(config.toPath()));
Gson gson = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().setPrettyPrinting().create();
Mod[] modules = gson.fromJson(configString, Mod[].class);
HudModule[] hudModules = gson.fromJson(configString, HudModule[].class);
for (Mod module : ModuleManager.INSTANCE.getAllModules()) {
if (module instanceof HudModule) {
HudModule hudMod = (HudModule) module;
for (HudModule configHudModule : hudModules) {
if (hudMod.getName().equals(configHudModule.getName())) {
hudMod.setX(configHudModule.getX());
hudMod.setY(configHudModule.getY());
System.out.println(hudMod.getName() + ":" + configHudModule.getX());
}
}
}
for (Mod configModule : modules) {
if (module.getName().equals(configModule.getName())) {
try {
if (configModule.isEnabled() && !module.isEnabled())
module.setEnabled(true);
else if (!configModule.isEnabled() && module.isEnabled())
module.setEnabled(false);
module.setKey(configModule.getKey());
for (Setting setting : module.settings) {
for (ConfigSetting cfgSetting : configModule.cfgSettings) {
if (setting.name.equals(cfgSetting.name)) {
if (setting instanceof BooleanSetting) {
((BooleanSetting) setting).setEnabled((boolean) cfgSetting.value);
}
if (setting instanceof ModeSetting) {
((ModeSetting) setting).setSelected((String) cfgSetting.value);
}
if (setting instanceof NumberSetting) {
((NumberSetting) setting).setValue((double) cfgSetting.value);
}
if (setting instanceof ColorSetting) {
int[] color = ((ColorSetting) setting).hexToRgbInt((String) cfgSetting.value);
((ColorSetting) setting).setRGB(color[0], color[1], color[2], color[3]);
}
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
return true;
}
Aggregations