Search in sources :

Example 1 with Friend

use of dev.hypnotic.config.friends.Friend in project Hypnotic-Client by Hypnotic-Development.

the class SaveLoad method save.

public void save() {
    ArrayList<String> toSave = new ArrayList<String>();
    if (ModuleManager.INSTANCE == null || HudManager.INSTANCE == null)
        return;
    for (Mod mod : ModuleManager.INSTANCE.modules) {
        toSave.add("MOD:" + mod.getName() + ":" + mod.isEnabled() + ":" + mod.getKey());
    }
    for (HudModule element : HudManager.INSTANCE.hudModules) {
        toSave.add("HUD:" + element.getName() + ":" + element.getX() + ":" + element.getY());
    }
    for (Friend friend : FriendManager.INSTANCE.friends) {
        toSave.add("FRIEND:" + friend.name);
    }
    for (Frame frame : ClickGUI.INSTANCE.frames) {
        toSave.add("FRAME:" + frame.name + ":" + frame.getX() + ":" + frame.getY() + ":" + frame.isExtended());
    }
    toSave.add("FRAME:" + HudEditorScreen.INSTANCE.frame.name + ":" + HudEditorScreen.INSTANCE.frame.getX() + ":" + HudEditorScreen.INSTANCE.frame.getY() + ":" + HudEditorScreen.INSTANCE.frame.isExtended());
    toSave.add("CLICKGUI:X:" + dev.hypnotic.ui.clickgui.ClickGUI.INSTANCE.x + ":Y:" + dev.hypnotic.ui.clickgui.ClickGUI.INSTANCE.y);
    for (Waypoint waypoint : WaypointManager.INSTANCE.waypoints) {
        toSave.add("WAYPOINT:NAME:" + waypoint.getName() + ":X:" + waypoint.getX() + ":Y:" + waypoint.getY() + ":Z:" + waypoint.getZ());
    }
    try {
        PrintWriter pw = new PrintWriter(this.dataFile);
        for (String str : toSave) {
            pw.println(str);
        }
        pw.close();
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    }
}
Also used : Frame(dev.hypnotic.ui.clickgui2.frame.Frame) Mod(dev.hypnotic.module.Mod) Friend(dev.hypnotic.config.friends.Friend) ArrayList(java.util.ArrayList) FileNotFoundException(java.io.FileNotFoundException) Waypoint(dev.hypnotic.waypoint.Waypoint) HudModule(dev.hypnotic.module.hud.HudModule) PrintWriter(java.io.PrintWriter)

Example 2 with Friend

use of dev.hypnotic.config.friends.Friend in project Hypnotic-Client by Hypnotic-Development.

the class FriendCmd method build.

@Override
public void build(LiteralArgumentBuilder<CommandSource> builder) {
    builder.then(literal("add").then(argument("friend", FriendArgumentType.friend()).executes(context -> {
        Friend friend = FriendArgumentType.getFriend(context, "friend");
        if (!FriendManager.INSTANCE.isFriend(friend.name)) {
            FriendManager.INSTANCE.add(friend);
            info("Added (highlight)" + friend.name + " (default)to your friends list.");
        } else
            info("That person is already your friend.");
        SaveLoad.INSTANCE.save();
        return SINGLE_SUCCESS;
    })));
    builder.then(literal("remove").then(argument("friend", FriendArgumentType.friend()).executes(context -> {
        Friend friend = FriendManager.INSTANCE.getFriendByName(FriendArgumentType.getFriend(context, "friend").name);
        if (friend != null && FriendManager.INSTANCE.isFriend(friend.name)) {
            FriendManager.INSTANCE.friends.remove(friend);
            info("Removed (highlight)" + friend.name + " (default)from your friends list.");
        } else
            info("That person is not your friend.");
        return SINGLE_SUCCESS;
    })));
    builder.then(literal("list").executes(context -> {
        info("--- Friends ((highlight)" + FriendManager.INSTANCE.friends.size() + "(default)) ---");
        for (Friend friend : FriendManager.INSTANCE.friends) {
            ChatUtils.info("(highlight)" + friend.name);
        }
        return SINGLE_SUCCESS;
    }));
}
Also used : Arrays(java.util.Arrays) Suggestions(com.mojang.brigadier.suggestion.Suggestions) CommandContext(com.mojang.brigadier.context.CommandContext) Collection(java.util.Collection) Friend(dev.hypnotic.config.friends.Friend) CompletableFuture(java.util.concurrent.CompletableFuture) Collectors(java.util.stream.Collectors) ArgumentType(com.mojang.brigadier.arguments.ArgumentType) LiteralArgumentBuilder(com.mojang.brigadier.builder.LiteralArgumentBuilder) FriendManager(dev.hypnotic.config.friends.FriendManager) CommandSource(net.minecraft.command.CommandSource) ChatUtils(dev.hypnotic.utils.ChatUtils) StringReader(com.mojang.brigadier.StringReader) SaveLoad(dev.hypnotic.config.SaveLoad) CommandSyntaxException(com.mojang.brigadier.exceptions.CommandSyntaxException) SuggestionsBuilder(com.mojang.brigadier.suggestion.SuggestionsBuilder) Command(dev.hypnotic.command.Command) Friend(dev.hypnotic.config.friends.Friend)

Example 3 with Friend

use of dev.hypnotic.config.friends.Friend in project Hypnotic-Client by Hypnotic-Development.

the class SaveLoad method load.

public void load() {
    ArrayList<String> lines = new ArrayList<String>();
    try {
        BufferedReader reader = new BufferedReader(new FileReader(this.dataFile));
        String line = reader.readLine();
        while (line != null) {
            lines.add(line);
            line = reader.readLine();
        }
        reader.close();
    } catch (Exception e) {
        e.printStackTrace();
    }
    for (String s : lines) {
        String[] args = s.split(":");
        if (s.toLowerCase().startsWith("mod:")) {
            Mod m = ModuleManager.INSTANCE.getModuleByName(args[1]);
            if (m != null) {
                m.setKey(Integer.parseInt(args[3]));
            }
        } else if (s.toLowerCase().startsWith("friend:")) {
            FriendManager.INSTANCE.add(new Friend(args[1]));
        } else if (s.toLowerCase().startsWith("frame:")) {
            for (Frame frame : ClickGUI.INSTANCE.frames) {
                if (frame.name.equalsIgnoreCase(args[1])) {
                    frame.setX(Integer.parseInt(args[2]));
                    frame.setY(Integer.parseInt(args[3]));
                    frame.setExtended(Boolean.parseBoolean(args[4]));
                }
            }
            HudEditorScreen.INSTANCE.frame.setX(Integer.parseInt(args[2]));
            HudEditorScreen.INSTANCE.frame.setY(Integer.parseInt(args[3]));
            HudEditorScreen.INSTANCE.frame.setExtended(Boolean.parseBoolean(args[4]));
        } else if (s.toLowerCase().startsWith("waypoint:")) {
            for (Waypoint waypoint : WaypointManager.INSTANCE.waypoints) {
                if (waypoint.getName().equalsIgnoreCase(args[1])) {
                    int x = Integer.parseInt(args[2]);
                    int y = Integer.parseInt(args[3]);
                    int z = Integer.parseInt(args[4]);
                    waypoint.setX(x);
                    waypoint.setY(y);
                    waypoint.setZ(z);
                    waypoint.setPos(new BlockPos(x, y, z));
                }
            }
        } else if (s.toLowerCase().startsWith("clickgui:")) {
            dev.hypnotic.ui.clickgui.ClickGUI.INSTANCE.x = Integer.parseInt(args[2]);
            dev.hypnotic.ui.clickgui.ClickGUI.INSTANCE.y = Integer.parseInt(args[4]);
        } else if (s.toLowerCase().startsWith("settingpos:")) {
            for (ModuleButton mb : dev.hypnotic.ui.clickgui.ClickGUI.INSTANCE.buttons) {
                if (mb.mod.name.equalsIgnoreCase(args[1])) {
                    mb.settingsWindow.x = Integer.parseInt(args[3]);
                    mb.settingsWindow.y = Integer.parseInt(args[5]);
                }
            }
        }
    /*else if (s.toLowerCase().startsWith("message:")) {
            	ModuleManager.INSTANCE.chatSpammer.custom.add(args[1]);
            }*/
    }
}
Also used : Frame(dev.hypnotic.ui.clickgui2.frame.Frame) Mod(dev.hypnotic.module.Mod) ArrayList(java.util.ArrayList) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException) Friend(dev.hypnotic.config.friends.Friend) ModuleButton(dev.hypnotic.ui.clickgui.ModuleButton) BufferedReader(java.io.BufferedReader) FileReader(java.io.FileReader) Waypoint(dev.hypnotic.waypoint.Waypoint) BlockPos(net.minecraft.util.math.BlockPos)

Example 4 with Friend

use of dev.hypnotic.config.friends.Friend in project Hypnotic-Client by Hypnotic-Development.

the class MiddleClickFriend method mouseClicked.

@EventTarget
public void mouseClicked(EventMouseButton event) {
    if (event.getButton() == GLFW.GLFW_MOUSE_BUTTON_MIDDLE && event.getClickType() == EventMouseButton.ClickType.IN_GAME) {
        HitResult hitResult = mc.crosshairTarget;
        if (hitResult != null && hitResult.getType() == HitResult.Type.ENTITY) {
            PlayerEntity player = (PlayerEntity) ((EntityHitResult) hitResult).getEntity();
            if (!FriendManager.INSTANCE.isFriend(player) && !mc.options.sneakKey.isPressed()) {
                FriendManager.INSTANCE.add(new Friend(player.getName().asString()));
                ChatUtils.tellPlayer("Added " + ColorUtils.green + player.getName().asString() + ColorUtils.white + " to your friends list");
            }
            if (mc.options.sneakKey.isPressed() && FriendManager.INSTANCE.isFriend(player)) {
                for (Friend friend : FriendManager.INSTANCE.friends) {
                    if (friend.name == player.getName().asString()) {
                        FriendManager.INSTANCE.friends.remove(friend);
                        ChatUtils.tellPlayer("Removed " + ColorUtils.red + friend.name + ColorUtils.white + " from your friends list");
                    }
                }
            }
        }
    }
}
Also used : HitResult(net.minecraft.util.hit.HitResult) EntityHitResult(net.minecraft.util.hit.EntityHitResult) Friend(dev.hypnotic.config.friends.Friend) PlayerEntity(net.minecraft.entity.player.PlayerEntity) EventTarget(dev.hypnotic.event.EventTarget)

Aggregations

Friend (dev.hypnotic.config.friends.Friend)4 Mod (dev.hypnotic.module.Mod)2 Frame (dev.hypnotic.ui.clickgui2.frame.Frame)2 Waypoint (dev.hypnotic.waypoint.Waypoint)2 FileNotFoundException (java.io.FileNotFoundException)2 ArrayList (java.util.ArrayList)2 StringReader (com.mojang.brigadier.StringReader)1 ArgumentType (com.mojang.brigadier.arguments.ArgumentType)1 LiteralArgumentBuilder (com.mojang.brigadier.builder.LiteralArgumentBuilder)1 CommandContext (com.mojang.brigadier.context.CommandContext)1 CommandSyntaxException (com.mojang.brigadier.exceptions.CommandSyntaxException)1 Suggestions (com.mojang.brigadier.suggestion.Suggestions)1 SuggestionsBuilder (com.mojang.brigadier.suggestion.SuggestionsBuilder)1 Command (dev.hypnotic.command.Command)1 SaveLoad (dev.hypnotic.config.SaveLoad)1 FriendManager (dev.hypnotic.config.friends.FriendManager)1 EventTarget (dev.hypnotic.event.EventTarget)1 HudModule (dev.hypnotic.module.hud.HudModule)1 ModuleButton (dev.hypnotic.ui.clickgui.ModuleButton)1 ChatUtils (dev.hypnotic.utils.ChatUtils)1