Search in sources :

Example 1 with Bot

use of me.xjcyan1de.cyanbot.Bot in project CyanBot by XjCyan1de.

the class MainFrame method registerListeners.

@SuppressWarnings("unchecked")
private void registerListeners() {
    join.addActionListener(e -> this.onJoin());
    getKey.addActionListener(e -> {
        final Bot bot = botManager.getBot(name.getText());
        if (bot != null) {
            final String accessKey = bot.generateAccessKey();
            if (accessKey != null) {
                Hover.hoverText("Введите этот код в чат", accessKey);
            }
        }
    });
    leave.addActionListener(e -> {
        final Bot bot = botManager.getBot(name.getText());
        if (bot != null) {
            botManager.disconnectBot(bot);
        /*final DefaultListModel model = (DefaultListModel) botList.getModel();
                model.removeElement(bot.getUsername());
                botList.setModel(model);*/
        }
    });
    sendMessage.addActionListener(e -> {
        final Bot bot = botManager.getBot(name.getText());
        if (bot != null) {
            bot.sendMessage(messageText.getText());
        }
    });
    autoJoin.addItemListener(e -> {
        this.updateRelogin();
    });
    deplayRelogin.addActionListener(e -> {
        this.updateRelogin();
    });
    final DefaultListModel listModel = new DefaultListModel();
    CommandListHandler.init(listModel);
    commandList.setModel(listModel);
    commandList.addListSelectionListener(e -> {
        final int index = commandList.getSelectedIndex();
        if (index != -1) {
            CommandListHandler.createPanel(commandPanel, index);
        }
    });
}
Also used : Bot(me.xjcyan1de.cyanbot.Bot)

Example 2 with Bot

use of me.xjcyan1de.cyanbot.Bot in project CyanBot by XjCyan1de.

the class CommandWalk method initPanel.

@Override
public void initPanel(JPanel commandPanel) {
    joystick = new SimpleJoystick(150);
    joystick.setPreferredSize(new Dimension(100, 100));
    joystick.addChangeListener(e -> {
        Bot[] selectedBots = Main.getMainFrame().getSelectedBots();
        final PointChangeEvent event = (PointChangeEvent) e;
        final Point p = event.p;
        double tempX = -p.getX() / 800;
        // Шобы понимать пространство майна - z
        double tempZ = p.getY() / 800;
        x = tempX;
        z = tempZ;
        if ((-0.0001 < x && x < 0.0001) && (-0.0001 < z && z < 0.0001)) {
            for (Bot bot : selectedBots) {
                TimerTask walkTask = walkTaskMap.get(bot);
                if (walkTask != null) {
                    walkTask.cancel();
                    walkTaskMap.remove(bot);
                }
            }
        } else {
            for (Bot bot : selectedBots) {
                TimerTask walkTask = walkTaskMap.get(bot);
                if (walkTask == null) {
                    walkTask = Schedule.timer(() -> {
                        bot.getLoc().add(x, 0, z);
                    }, 50, 50);
                }
                walkTaskMap.put(bot, walkTask);
            }
        }
    });
    commandPanel.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1));
    commandPanel.add(joystick, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
}
Also used : PointChangeEvent(me.xjcyan1de.cyanbot.gui.joystick.PointChangeEvent) TimerTask(java.util.TimerTask) GridLayoutManager(com.intellij.uiDesigner.core.GridLayoutManager) GridConstraints(com.intellij.uiDesigner.core.GridConstraints) Bot(me.xjcyan1de.cyanbot.Bot) SimpleJoystick(me.xjcyan1de.cyanbot.gui.joystick.SimpleJoystick)

Example 3 with Bot

use of me.xjcyan1de.cyanbot.Bot in project CyanBot by XjCyan1de.

the class CommandWhere method execute.

@Override
public void execute(CommandEvent event) {
    final Bot bot = event.getBot();
    final Entity entity = event.has(0, "я") ? bot.getWorld().getPlayer(event.getSender()) : bot.getWorld().getPlayer(event.arg(0));
    if (entity != null) {
        Schedule.cancel(timerTask);
        final Location loc = bot.getLoc();
        timerTask = Schedule.timer(new TimerCount(() -> {
            final float pitch = loc.getPitch();
            final float yaw = loc.getYaw();
            loc.setDir(entity.getX() - loc.getX(), entity.getY() - loc.getY(), entity.getZ() - loc.getZ());
            loc.setYaw(smoothly(loc.getYaw(), yaw));
            loc.setPitch(smoothly(loc.getPitch(), pitch));
            System.out.println(loc.getYaw() + " " + loc.getPitch());
        }, 100) {

            @Override
            public boolean cancel() {
                timerTask = null;
                bot.sendMessage("Та вижу я!");
                return super.cancel();
            }
        }, 50, 50);
    }
}
Also used : Entity(me.xjcyan1de.cyanbot.world.Entity) Bot(me.xjcyan1de.cyanbot.Bot) TimerCount(me.xjcyan1de.cyanbot.utils.schedule.TimerCount) Location(me.xjcyan1de.cyanbot.world.Location)

Example 4 with Bot

use of me.xjcyan1de.cyanbot.Bot in project CyanBot by XjCyan1de.

the class CommandSelectSlot method createButton.

public void createButton(JPanel jPanel, int slot) {
    JButton slotButton = new JButton();
    slotButton.setText("Слот " + slot);
    slotButton.addActionListener(e -> {
        final Bot[] selectedBots = Main.getMainFrame().getSelectedBots();
        for (Bot selectedBot : selectedBots) {
            selectedBot.sendPacket(new ClientPlayerChangeHeldItemPacket(slot));
        }
    });
    jPanel.add(slotButton, new GridConstraints(slot, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
}
Also used : ClientPlayerChangeHeldItemPacket(com.github.steveice10.mc.protocol.packet.ingame.client.player.ClientPlayerChangeHeldItemPacket) GridConstraints(com.intellij.uiDesigner.core.GridConstraints) Bot(me.xjcyan1de.cyanbot.Bot)

Aggregations

Bot (me.xjcyan1de.cyanbot.Bot)4 GridConstraints (com.intellij.uiDesigner.core.GridConstraints)2 ClientPlayerChangeHeldItemPacket (com.github.steveice10.mc.protocol.packet.ingame.client.player.ClientPlayerChangeHeldItemPacket)1 GridLayoutManager (com.intellij.uiDesigner.core.GridLayoutManager)1 TimerTask (java.util.TimerTask)1 PointChangeEvent (me.xjcyan1de.cyanbot.gui.joystick.PointChangeEvent)1 SimpleJoystick (me.xjcyan1de.cyanbot.gui.joystick.SimpleJoystick)1 TimerCount (me.xjcyan1de.cyanbot.utils.schedule.TimerCount)1 Entity (me.xjcyan1de.cyanbot.world.Entity)1 Location (me.xjcyan1de.cyanbot.world.Location)1