From 73de5ef3bed7943e27a314d668c88095834736e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?ZX=E5=A4=8F=E5=A4=9C=E4=B9=8B=E9=A3=8E?= Date: Fri, 29 Jul 2022 16:05:32 +0800 Subject: [PATCH] Fix an issue in the builder/updater of VoiceChannel. --- src/main/java/snw/kookbc/impl/entity/builder/EntityBuilder.java | 2 +- src/main/java/snw/kookbc/impl/entity/builder/EntityUpdater.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/snw/kookbc/impl/entity/builder/EntityBuilder.java b/src/main/java/snw/kookbc/impl/entity/builder/EntityBuilder.java index e6703535..7e8d6279 100644 --- a/src/main/java/snw/kookbc/impl/entity/builder/EntityBuilder.java +++ b/src/main/java/snw/kookbc/impl/entity/builder/EntityBuilder.java @@ -169,7 +169,7 @@ public Channel buildChannel(JsonObject object) { chatLimitTime ); } else if (type == 2) { // VoiceChannel - boolean hasPassword = object.get("has_password").getAsBoolean(); + boolean hasPassword = object.has("has_password") && object.get("has_password").getAsBoolean(); int size = object.get("limit_amount").getAsInt(); return new VoiceChannelImpl( id, diff --git a/src/main/java/snw/kookbc/impl/entity/builder/EntityUpdater.java b/src/main/java/snw/kookbc/impl/entity/builder/EntityUpdater.java index 65bc0acb..f7d735dd 100644 --- a/src/main/java/snw/kookbc/impl/entity/builder/EntityUpdater.java +++ b/src/main/java/snw/kookbc/impl/entity/builder/EntityUpdater.java @@ -133,7 +133,7 @@ public void updateChannel(JsonObject object, Channel channel) { int chatLimitTime = object.get("slow_mode").getAsInt(); ((TextChannelImpl) channel).setChatLimitTime(chatLimitTime); } else if (type == 2) { // VoiceChannel - boolean hasPassword = object.get("has_password").getAsBoolean(); + boolean hasPassword = object.has("has_password") && object.get("has_password").getAsBoolean(); int size = object.get("limit_amount").getAsInt(); ((VoiceChannelImpl) channel).setPasswordProtected(hasPassword); ((VoiceChannelImpl) channel).setMaxSize(size);