import java.awt.Color;
import java.awt.Font;
import javax.swing.BorderFactory;
import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
import javax.swing.WindowConstants;
public class Bunnyhop {
private static boolean isRunning = false;
public static void main(String[] args) {
JFrame frame = new JFrame("bhop, bla bla bla");
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
frame.setSize(300, 200);
frame.setLocationRelativeTo(null);
JPanel textPanel = new JPanel();
textPanel.setLayout(new BoxLayout(textPanel, BoxLayout.Y_AXIS));
textPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
JLabel label1 = new JLabel("welcome….");
label1.setForeground(Color.BLUE);
label1.setAlignmentX(SwingConstants.CENTER);
textPanel.add(label1);
JLabel label2 = new JLabel("najmi space");
label2.setForeground(Color.GREEN);
label2.setAlignmentX(SwingConstants.CENTER);
textPanel.add(Box.createVerticalStrut(10));
textPanel.add(label2);
JLabel label3 = new JLabel("zakrit na end");
label3.setForeground(Color.BLUE);
label3.setAlignmentX(SwingConstants.CENTER);
textPanel.add(Box.createVerticalStrut(10));
textPanel.add(label3);
JPanel mainPanel = new JPanel();
mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS));
mainPanel.setBackground(new Color(0xFFB10F));
mainPanel.add(textPanel);
JPanel groupPanel = new JPanel();
groupPanel.setLayout(new BoxLayout(groupPanel, BoxLayout.Y_AXIS));
groupPanel.setBackground(new Color(0xEEAA99));
groupPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
mainPanel.add(groupPanel);
JLabel groupLabel = new JLabel("text o cracke");
groupLabel.setForeground(Color.GREEN);
groupLabel.setFont(new Font("Arial Black", Font.PLAIN, 72));
groupLabel.setAlignmentX(SwingConstants.CENTER);
groupPanel.add(groupLabel);
frame.add(mainPanel);
frame.setUndecorated(true);
frame.getRootPane().setOpaque(false);
frame.setBackground(new Color(0, 0, 0, 0));
frame.setVisible(true);
HotkeyListener listener = new HotkeyListener();
listener.registerHotkey("F11", () -> {
listener.registerHotkey("*~$Space", Bunnyhop::toggle);
});
listener.registerHotkey("End", () -> {
System.exit(0);
});
}
private static void toggle() {
isRunning = !isRunning;
if (isRunning) {
new Thread(Bunnyhop::bunnyhop).start();
}
}
private static void bunnyhop() {
try {
while (isRunning) {
Thread.sleep(5);
boolean spaceState = Keyboard.isKeyDown(Keyboard.KEY_SPACE);
if (!spaceState) {
break;
}
Thread.sleep(1);
Keyboard.sendKey(Keyboard.KEY_SPACE);
}
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}