From 4bb3c2ab4f4d61af43012d4665799e506a8f5614 Mon Sep 17 00:00:00 2001 From: ChomeNS <95471003+ChomeNS@users.noreply.github.com> Date: Sat, 24 Jun 2023 16:42:56 +0700 Subject: [PATCH] hide the socket closed exception --- .../chayapak/chomens_bot/plugins/VoiceChatPlugin.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/VoiceChatPlugin.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/VoiceChatPlugin.java index 6dc74a9..3babb4a 100644 --- a/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/VoiceChatPlugin.java +++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/VoiceChatPlugin.java @@ -114,7 +114,7 @@ public class VoiceChatPlugin extends Bot.Listener { } } - private static class VoiceChatSocketBase { + private class VoiceChatSocketBase { private final byte[] BUFFER = new byte[4096]; public RawUdpPacket read (DatagramSocket socket) { @@ -130,6 +130,8 @@ public class VoiceChatPlugin extends Bot.Listener { System.arraycopy(packet.getData(), packet.getOffset(), data, 0, packet.getLength()); return new RawUdpPacket(data, packet.getSocketAddress(), timestamp); } catch (Exception e) { + if (!running) return null; + e.printStackTrace(); } @@ -145,7 +147,7 @@ public class VoiceChatPlugin extends Bot.Listener { running = false; } - private static class ClientVoiceChatSocket extends VoiceChatSocketBase { + private class ClientVoiceChatSocket extends VoiceChatSocketBase { private DatagramSocket socket; public void open() throws SocketException {