From 46265e99b151922bad64d59844b567d878514f58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beatrice=20Dellac=C3=A0?= Date: Mon, 5 Aug 2024 19:18:44 +0200 Subject: [PATCH] Improve linting --- .../wtf/beatrice/autosqueal/CursorMoveListener.java | 8 ++++++-- .../java/wtf/beatrice/autosqueal/CursorMover.java | 13 +++++++++---- .../wtf/beatrice/autosqueal/KeyPressListener.java | 8 ++++---- src/main/java/wtf/beatrice/autosqueal/Main.java | 5 +++-- 4 files changed, 22 insertions(+), 12 deletions(-) diff --git a/src/main/java/wtf/beatrice/autosqueal/CursorMoveListener.java b/src/main/java/wtf/beatrice/autosqueal/CursorMoveListener.java index fa794ef..c2aec6c 100644 --- a/src/main/java/wtf/beatrice/autosqueal/CursorMoveListener.java +++ b/src/main/java/wtf/beatrice/autosqueal/CursorMoveListener.java @@ -8,8 +8,12 @@ import java.util.TimerTask; public class CursorMoveListener extends TimerTask { - private int oldX, oldY; - private int newX, newY; + private int oldX; + private int oldY; + + private int newX; + private int newY; + private int loops; private boolean isUserAway; diff --git a/src/main/java/wtf/beatrice/autosqueal/CursorMover.java b/src/main/java/wtf/beatrice/autosqueal/CursorMover.java index 52d2ba1..5b18470 100644 --- a/src/main/java/wtf/beatrice/autosqueal/CursorMover.java +++ b/src/main/java/wtf/beatrice/autosqueal/CursorMover.java @@ -10,11 +10,15 @@ public class CursorMover extends TimerTask { private static final Logger LOGGER = LogManager.getLogger(CursorMover.class); - final int destX, destY; + final int destX; + final int destY; final Robot robot; - float currentX, currentY; - float stepX = 1, stepY = 1; + float currentX; + float currentY; + + float stepX = 1; + float stepY = 1; boolean isRunning = true; @@ -26,7 +30,8 @@ public class CursorMover extends TimerTask { destX = destinationX; destY = destinationY; - int lengthX, lengthY; + int lengthX; + int lengthY; lengthX = Math.round(Math.abs(currentX - destX)); lengthY = Math.round(Math.abs(currentY - destY)); diff --git a/src/main/java/wtf/beatrice/autosqueal/KeyPressListener.java b/src/main/java/wtf/beatrice/autosqueal/KeyPressListener.java index c2e86c1..7972a19 100644 --- a/src/main/java/wtf/beatrice/autosqueal/KeyPressListener.java +++ b/src/main/java/wtf/beatrice/autosqueal/KeyPressListener.java @@ -13,8 +13,9 @@ import java.util.List; public class KeyPressListener implements NativeKeyListener { private static final Logger LOGGER = LogManager.getLogger(KeyPressListener.class); - private final static List pressedKeysIds = new ArrayList<>(); + private static final List pressedKeysIds = new ArrayList<>(); + @Override public void nativeKeyPressed(NativeKeyEvent e) { LOGGER.info("Key Pressed: {}", NativeKeyEvent.getKeyText(e.getKeyCode())); @@ -31,6 +32,7 @@ public class KeyPressListener implements NativeKeyListener handlePressedKeys(); } + @Override public void nativeKeyReleased(NativeKeyEvent e) { LOGGER.info("Key Released: {}", NativeKeyEvent.getKeyText(e.getKeyCode())); @@ -44,9 +46,7 @@ public class KeyPressListener implements NativeKeyListener pressedKeysIds.contains(NativeKeyEvent.VC_CONTROL)) { StringBuilder keys = new StringBuilder(); - pressedKeysIds.forEach(keyCode -> { - keys.append("[").append(NativeKeyEvent.getKeyText(keyCode)).append("]"); - }); + pressedKeysIds.forEach(keyCode -> keys.append("[").append(NativeKeyEvent.getKeyText(keyCode)).append("]")); LOGGER.warn("Received shutdown keystroke: {}", keys); diff --git a/src/main/java/wtf/beatrice/autosqueal/Main.java b/src/main/java/wtf/beatrice/autosqueal/Main.java index 67ec6db..a337ae8 100644 --- a/src/main/java/wtf/beatrice/autosqueal/Main.java +++ b/src/main/java/wtf/beatrice/autosqueal/Main.java @@ -41,7 +41,8 @@ public class Main { LOGGER.info("Starting coordinates: {}, {}", currentX, currentY); - int randomX, randomY; + int randomX; + int randomY; randomX = random.nextInt(width); randomY = random.nextInt(height); @@ -90,6 +91,6 @@ public class Main { timer.cancel(); - Thread.sleep(TIME_BETWEEN_MOVES * 1000); + Thread.sleep(TIME_BETWEEN_MOVES * 1000L); } }