From b80de9a31f605de5942627420b2582ee815fda5c Mon Sep 17 00:00:00 2001 From: Syrent Date: Thu, 8 Feb 2024 13:23:45 +0330 Subject: [PATCH] fix: NoClassDefError and ClassNotFoundException when Velocitab is not installed --- .../ir/syrent/velocityvanish/velocity/VelocityVanish.kt | 6 ++---- .../velocityvanish/velocity/bridge/VelocityBridgeManager.kt | 6 ++++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/java/ir/syrent/velocityvanish/velocity/VelocityVanish.kt b/src/main/java/ir/syrent/velocityvanish/velocity/VelocityVanish.kt index 05906e43..9377880c 100644 --- a/src/main/java/ir/syrent/velocityvanish/velocity/VelocityVanish.kt +++ b/src/main/java/ir/syrent/velocityvanish/velocity/VelocityVanish.kt @@ -35,8 +35,6 @@ class VelocityVanish @Inject constructor( lateinit var bridgeManager: VelocityBridgeManager private set - var velocitabHook: VelocitabHook? = null - /* * Note: This is not the best way to do this, but for time being it's fine. * TODO: Create a VanishedPlayer object with serializer and deserializer. @@ -51,9 +49,9 @@ class VelocityVanish @Inject constructor( instance = this try { - velocitabHook = VelocitabHook() - VelocitabAPI.getInstance().vanishIntegration = velocitabHook + VelocitabAPI.getInstance().vanishIntegration = VelocitabHook() } catch (_: ClassNotFoundException) { } + catch (_: NoClassDefFoundError) { } initializeMessagingChannels() initializeListeners() diff --git a/src/main/java/ir/syrent/velocityvanish/velocity/bridge/VelocityBridgeManager.kt b/src/main/java/ir/syrent/velocityvanish/velocity/bridge/VelocityBridgeManager.kt index 9a6daf78..726904b5 100644 --- a/src/main/java/ir/syrent/velocityvanish/velocity/bridge/VelocityBridgeManager.kt +++ b/src/main/java/ir/syrent/velocityvanish/velocity/bridge/VelocityBridgeManager.kt @@ -67,7 +67,8 @@ class VelocityBridgeManager( try { VelocitabAPI.getInstance().vanishPlayer(player) VelocitabAPI.getInstance().tabList.updateDisplayNames() - } catch (_: NoClassDefFoundError) {} + } catch (_: ClassNotFoundException) {} + catch (_: NoClassDefFoundError) { } } VRuom.getServer().eventManager.fire(VelocityVanishEvent(player, name)) } else { @@ -76,7 +77,8 @@ class VelocityBridgeManager( if (player != null) { try { VelocitabAPI.getInstance().unVanishPlayer(player) - } catch (_: NoClassDefFoundError) {} + } catch (_: ClassNotFoundException) {} + catch (_: NoClassDefFoundError) { } } VRuom.getServer().eventManager.fire(VelocityUnVanishEvent(player, name)) }