From fa001996ffb6e31eb1417899bb560ae45258ae35 Mon Sep 17 00:00:00 2001 From: Andrew Lalis Date: Sun, 20 Jun 2021 19:06:11 +0200 Subject: [PATCH] Moved resources and added package.bat for windows installer generation. --- client/package.bat | 9 +++++++++ .../nl/andrewlalis/aos_client/SoundManager.java | 2 +- .../nl/andrewlalis/aos_client/view/GameFrame.java | 2 +- .../{ => nl/andrewlalis/aos_client}/icon.png | Bin .../andrewlalis/aos_client}/sound/ak47shot1.wav | Bin .../aos_client}/sound/bullet_impact_1.wav | Bin .../aos_client}/sound/bullet_impact_2.wav | Bin .../aos_client}/sound/bullet_impact_3.wav | Bin .../aos_client}/sound/bullet_impact_4.wav | Bin .../aos_client}/sound/bullet_impact_5.wav | Bin .../{ => nl/andrewlalis/aos_client}/sound/chat.wav | Bin .../{ => nl/andrewlalis/aos_client}/sound/death.wav | Bin .../aos_client}/sound/m1garand-shot1.wav | Bin .../andrewlalis/aos_client}/sound/reload.wav | Bin .../andrewlalis/aos_client}/sound/shotgun-shot1.wav | Bin pom.xml | 3 +++ .../nl/andrewlalis/aos_server/ClientHandler.java | 1 + 17 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 client/package.bat rename client/src/main/resources/{ => nl/andrewlalis/aos_client}/icon.png (100%) rename client/src/main/resources/{ => nl/andrewlalis/aos_client}/sound/ak47shot1.wav (100%) rename client/src/main/resources/{ => nl/andrewlalis/aos_client}/sound/bullet_impact_1.wav (100%) rename client/src/main/resources/{ => nl/andrewlalis/aos_client}/sound/bullet_impact_2.wav (100%) rename client/src/main/resources/{ => nl/andrewlalis/aos_client}/sound/bullet_impact_3.wav (100%) rename client/src/main/resources/{ => nl/andrewlalis/aos_client}/sound/bullet_impact_4.wav (100%) rename client/src/main/resources/{ => nl/andrewlalis/aos_client}/sound/bullet_impact_5.wav (100%) rename client/src/main/resources/{ => nl/andrewlalis/aos_client}/sound/chat.wav (100%) rename client/src/main/resources/{ => nl/andrewlalis/aos_client}/sound/death.wav (100%) rename client/src/main/resources/{ => nl/andrewlalis/aos_client}/sound/m1garand-shot1.wav (100%) rename client/src/main/resources/{ => nl/andrewlalis/aos_client}/sound/reload.wav (100%) rename client/src/main/resources/{ => nl/andrewlalis/aos_client}/sound/shotgun-shot1.wav (100%) diff --git a/client/package.bat b/client/package.bat new file mode 100644 index 0000000..83c5cc0 --- /dev/null +++ b/client/package.bat @@ -0,0 +1,9 @@ +cd target +jpackage^ + --type exe^ + --name "Ace-of-Shades"^ + --description "Top-down 2D shooter game inspired by Ace of Spades."^ + --module-path "aos-client-3.1.jar;../../core/target/aos-core-3.1.jar"^ + --module aos_client/nl.andrewlalis.aos_client.Client^ + --win-shortcut^ + --win-dir-chooser \ No newline at end of file diff --git a/client/src/main/java/nl/andrewlalis/aos_client/SoundManager.java b/client/src/main/java/nl/andrewlalis/aos_client/SoundManager.java index 5d030b2..cff5895 100644 --- a/client/src/main/java/nl/andrewlalis/aos_client/SoundManager.java +++ b/client/src/main/java/nl/andrewlalis/aos_client/SoundManager.java @@ -21,7 +21,7 @@ public class SoundManager { private Clip getClip(String sound) { var soundBytes = this.soundData.get(sound); if (soundBytes == null) { - InputStream is = Client.class.getResourceAsStream("/sound/" + sound); + InputStream is = Client.class.getResourceAsStream("/nl/andrewlalis/aos_client/sound/" + sound); if (is == null) { System.err.println("Could not load sound: " + sound); return null; diff --git a/client/src/main/java/nl/andrewlalis/aos_client/view/GameFrame.java b/client/src/main/java/nl/andrewlalis/aos_client/view/GameFrame.java index 5a1e76a..665a0f8 100644 --- a/client/src/main/java/nl/andrewlalis/aos_client/view/GameFrame.java +++ b/client/src/main/java/nl/andrewlalis/aos_client/view/GameFrame.java @@ -16,7 +16,7 @@ public class GameFrame extends JFrame { public GameFrame(String title, Client client, GamePanel gamePanel) throws HeadlessException { super(title); this.setDefaultCloseOperation(DISPOSE_ON_CLOSE); - InputStream iconInputStream = GameFrame.class.getClassLoader().getResourceAsStream("icon.png"); + InputStream iconInputStream = GameFrame.class.getClassLoader().getResourceAsStream("/nl/andrewlalis/aos_client/icon.png"); if (iconInputStream != null) { try { this.setIconImage(ImageIO.read(iconInputStream)); diff --git a/client/src/main/resources/icon.png b/client/src/main/resources/nl/andrewlalis/aos_client/icon.png similarity index 100% rename from client/src/main/resources/icon.png rename to client/src/main/resources/nl/andrewlalis/aos_client/icon.png diff --git a/client/src/main/resources/sound/ak47shot1.wav b/client/src/main/resources/nl/andrewlalis/aos_client/sound/ak47shot1.wav similarity index 100% rename from client/src/main/resources/sound/ak47shot1.wav rename to client/src/main/resources/nl/andrewlalis/aos_client/sound/ak47shot1.wav diff --git a/client/src/main/resources/sound/bullet_impact_1.wav b/client/src/main/resources/nl/andrewlalis/aos_client/sound/bullet_impact_1.wav similarity index 100% rename from client/src/main/resources/sound/bullet_impact_1.wav rename to client/src/main/resources/nl/andrewlalis/aos_client/sound/bullet_impact_1.wav diff --git a/client/src/main/resources/sound/bullet_impact_2.wav b/client/src/main/resources/nl/andrewlalis/aos_client/sound/bullet_impact_2.wav similarity index 100% rename from client/src/main/resources/sound/bullet_impact_2.wav rename to client/src/main/resources/nl/andrewlalis/aos_client/sound/bullet_impact_2.wav diff --git a/client/src/main/resources/sound/bullet_impact_3.wav b/client/src/main/resources/nl/andrewlalis/aos_client/sound/bullet_impact_3.wav similarity index 100% rename from client/src/main/resources/sound/bullet_impact_3.wav rename to client/src/main/resources/nl/andrewlalis/aos_client/sound/bullet_impact_3.wav diff --git a/client/src/main/resources/sound/bullet_impact_4.wav b/client/src/main/resources/nl/andrewlalis/aos_client/sound/bullet_impact_4.wav similarity index 100% rename from client/src/main/resources/sound/bullet_impact_4.wav rename to client/src/main/resources/nl/andrewlalis/aos_client/sound/bullet_impact_4.wav diff --git a/client/src/main/resources/sound/bullet_impact_5.wav b/client/src/main/resources/nl/andrewlalis/aos_client/sound/bullet_impact_5.wav similarity index 100% rename from client/src/main/resources/sound/bullet_impact_5.wav rename to client/src/main/resources/nl/andrewlalis/aos_client/sound/bullet_impact_5.wav diff --git a/client/src/main/resources/sound/chat.wav b/client/src/main/resources/nl/andrewlalis/aos_client/sound/chat.wav similarity index 100% rename from client/src/main/resources/sound/chat.wav rename to client/src/main/resources/nl/andrewlalis/aos_client/sound/chat.wav diff --git a/client/src/main/resources/sound/death.wav b/client/src/main/resources/nl/andrewlalis/aos_client/sound/death.wav similarity index 100% rename from client/src/main/resources/sound/death.wav rename to client/src/main/resources/nl/andrewlalis/aos_client/sound/death.wav diff --git a/client/src/main/resources/sound/m1garand-shot1.wav b/client/src/main/resources/nl/andrewlalis/aos_client/sound/m1garand-shot1.wav similarity index 100% rename from client/src/main/resources/sound/m1garand-shot1.wav rename to client/src/main/resources/nl/andrewlalis/aos_client/sound/m1garand-shot1.wav diff --git a/client/src/main/resources/sound/reload.wav b/client/src/main/resources/nl/andrewlalis/aos_client/sound/reload.wav similarity index 100% rename from client/src/main/resources/sound/reload.wav rename to client/src/main/resources/nl/andrewlalis/aos_client/sound/reload.wav diff --git a/client/src/main/resources/sound/shotgun-shot1.wav b/client/src/main/resources/nl/andrewlalis/aos_client/sound/shotgun-shot1.wav similarity index 100% rename from client/src/main/resources/sound/shotgun-shot1.wav rename to client/src/main/resources/nl/andrewlalis/aos_client/sound/shotgun-shot1.wav diff --git a/pom.xml b/pom.xml index aaa1af8..4cd0375 100644 --- a/pom.xml +++ b/pom.xml @@ -17,6 +17,9 @@ 16 16 + 16 + 16 + UTF-8 diff --git a/server/src/main/java/nl/andrewlalis/aos_server/ClientHandler.java b/server/src/main/java/nl/andrewlalis/aos_server/ClientHandler.java index 21269ea..fb69e58 100644 --- a/server/src/main/java/nl/andrewlalis/aos_server/ClientHandler.java +++ b/server/src/main/java/nl/andrewlalis/aos_server/ClientHandler.java @@ -50,6 +50,7 @@ public class ClientHandler extends Thread { } public void send(Message message) { + if (this.socket.isClosed()) return; this.sendingQueue.submit(() -> { try { this.out.reset();