From cdc48cd4c313692c71ba3566f74bf4278adbaaee Mon Sep 17 00:00:00 2001 From: Syrent Date: Tue, 30 Apr 2024 13:18:11 +0330 Subject: [PATCH] fix: updated cmi api --- build.gradle.kts | 2 +- .../spigot/core/VanishManager.kt | 44 ++++++++++++------- .../spigot/listener/PlayerJoinListener.kt | 6 ++- 3 files changed, 33 insertions(+), 19 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 16399b91..7e045a4b 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -176,7 +176,7 @@ publishing { } val extraDependencies = mapOf( - "CMI.jar" to "https://www.zrips.net/wp-content/uploads/2021/09/CMI9.0.0.0API.jar", + "CMI.jar" to "https://github.com/Zrips/CMI-API/releases/download/9.7.0.1/CMI-API9.7.0.1.jar", "NexEngine.jar" to "https://github.com/nulli0n/NexEngine-spigot/releases/download/v2.2.11/NexEngine.jar", "SunLight.jar" to "https://www.dropbox.com/scl/fi/mmu7g32vj6oitkja65cws/SunLight-3.9.4.jar?rlkey=tqxgcy80yccxh80yzl24ubs7b&dl=1", "ServerListPlus.jar" to "https://ci.codemc.io/job/Minecrell/job/ServerListPlus/lastSuccessfulBuild/artifact/Velocity/build/libs/ServerListPlus-3.5.1-SNAPSHOT-Velocity.jar", diff --git a/src/main/java/ir/syrent/velocityvanish/spigot/core/VanishManager.kt b/src/main/java/ir/syrent/velocityvanish/spigot/core/VanishManager.kt index 6c3c1ac5..af433f9e 100644 --- a/src/main/java/ir/syrent/velocityvanish/spigot/core/VanishManager.kt +++ b/src/main/java/ir/syrent/velocityvanish/spigot/core/VanishManager.kt @@ -1,7 +1,7 @@ package ir.syrent.velocityvanish.spigot.core import com.Zrips.CMI.CMI -import com.Zrips.CMI.commands.list.vanishedit +import com.Zrips.CMI.Modules.Vanish.VanishAction import com.comphenix.protocol.PacketType import com.comphenix.protocol.events.PacketContainer import com.comphenix.protocol.wrappers.EnumWrappers @@ -155,21 +155,23 @@ class VanishManager( player.scoreboard.getTeam("Vanished")?.removeEntry(player.name) } - fun vanish(player: Player, sendQuitMessage: Boolean = true, callPostEvent: Boolean = false) { - vanish(player, sendQuitMessage, callPostEvent, false) + fun vanish(player: Player, sendQuitMessage: Boolean = true, callPostEvent: Boolean = false, sendPluginMessage: Boolean = true) { + vanish(player, sendQuitMessage, callPostEvent, false, sendPluginMessage = sendPluginMessage) } - fun vanish(player: Player, sendQuitMessage: Boolean = true, callPostEvent: Boolean = false, notifyAdmins: Boolean = false) { + fun vanish(player: Player, sendQuitMessage: Boolean = true, callPostEvent: Boolean = false, notifyAdmins: Boolean = false, sendPluginMessage: Boolean = true) { val preVanishEvent = PreVanishEvent(player, sendQuitMessage) VelocityVanishSpigot.instance.server.pluginManager.callEvent(preVanishEvent) if (preVanishEvent.isCancelled) return - plugin.bridgeManager?.updateVanishedPlayersRequest(player, true) - // Because plugin messaging is the most reliable thing in the world i have to send the vanish update after 20 ticks to make sure the message is received on the Velocity side - Ruom.runSync({ + if (sendPluginMessage) { plugin.bridgeManager?.updateVanishedPlayersRequest(player, true) - }, 20) + // Because plugin messaging is the most reliable thing in the world i have to send the vanish update after 20 ticks to make sure the message is received on the Velocity side + Ruom.runSync({ + plugin.bridgeManager?.updateVanishedPlayersRequest(player, true) + }, 20) + } setMeta(player, true) updateTabState(player, GameMode.SPECTATOR) @@ -231,8 +233,12 @@ class VanishManager( val cmiUser = CMI.getInstance().playerManager.getUser(player) cmiUser.isVanished = true CMI.getInstance().vanishManager.addPlayer(cmiUser) - cmiUser.vanish.set(vanishedit.VanishAction.isVanished, true) - cmiUser.vanish.set(vanishedit.VanishAction.informOnJoin, false) + cmiUser.vanish.set(VanishAction.isVanished, true) + cmiUser.vanish.set(VanishAction.informOnJoin, false) + cmiUser.vanish.set(VanishAction.PrivateMessages, false) + cmiUser.vanish.set(VanishAction.afkcommands, false) + cmiUser.vanish.set(VanishAction.deathMessages, false) + cmiUser.vanish.set(VanishAction.fakeJoinLeave, false) cmiUser.updateVanishMode() } @@ -285,16 +291,18 @@ class VanishManager( } - fun unVanish(player: Player, sendJoinMessage: Boolean = true, callPostEvent: Boolean = false) { - unVanish(player, sendJoinMessage, callPostEvent, false) + fun unVanish(player: Player, sendJoinMessage: Boolean = true, callPostEvent: Boolean = false, sendPluginMessage: Boolean = true) { + unVanish(player, sendJoinMessage, callPostEvent, false, sendPluginMessage = sendPluginMessage) } - fun unVanish(player: Player, sendJoinMessage: Boolean = true, callPostEvent: Boolean = false, notifyAdmins: Boolean = false) { + fun unVanish(player: Player, sendJoinMessage: Boolean = true, callPostEvent: Boolean = false, notifyAdmins: Boolean = false, sendPluginMessage: Boolean = true) { val preUnVanishEvent = PreUnVanishEvent(player, sendJoinMessage) VelocityVanishSpigot.instance.server.pluginManager.callEvent(preUnVanishEvent) if (preUnVanishEvent.isCancelled) return - plugin.bridgeManager?.updateVanishedPlayersRequest(player, false) + if (sendPluginMessage) { + plugin.bridgeManager?.updateVanishedPlayersRequest(player, false) + } setMeta(player, false) @@ -335,8 +343,12 @@ class VanishManager( val cmiUser = CMI.getInstance().playerManager.getUser(player) cmiUser.isVanished = false CMI.getInstance().vanishManager.removePlayer(cmiUser) - cmiUser.vanish.set(vanishedit.VanishAction.isVanished, false) - cmiUser.vanish.set(vanishedit.VanishAction.informOnJoin, true) + cmiUser.vanish.set(VanishAction.isVanished, false) + cmiUser.vanish.set(VanishAction.informOnJoin, false) + cmiUser.vanish.set(VanishAction.PrivateMessages, true) + cmiUser.vanish.set(VanishAction.afkcommands, true) + cmiUser.vanish.set(VanishAction.deathMessages, true) + cmiUser.vanish.set(VanishAction.fakeJoinLeave, false) cmiUser.updateVanishMode() } diff --git a/src/main/java/ir/syrent/velocityvanish/spigot/listener/PlayerJoinListener.kt b/src/main/java/ir/syrent/velocityvanish/spigot/listener/PlayerJoinListener.kt index 71e96e46..1828d177 100644 --- a/src/main/java/ir/syrent/velocityvanish/spigot/listener/PlayerJoinListener.kt +++ b/src/main/java/ir/syrent/velocityvanish/spigot/listener/PlayerJoinListener.kt @@ -15,6 +15,8 @@ import org.bukkit.event.EventPriority import org.bukkit.event.Listener import org.bukkit.event.player.PlayerJoinEvent import org.bukkit.metadata.FixedMetadataValue +import org.bukkit.permissions.Permission +import org.bukkit.permissions.PermissionDefault class PlayerJoinListener( private val plugin: VelocityVanishSpigot @@ -48,13 +50,13 @@ class PlayerJoinListener( plugin.vanishManager.vanish(player, sendQuitMessage = false, callPostEvent = true) event.joinMessage = null } else { - if (player.hasPermission("velocityvanish.action.vanish.onjoin")) { + if (player.hasPermission(Permission("velocityvanish.action.vanish.onjoin", PermissionDefault.FALSE))) { plugin.vanishManager.vanish(player, sendQuitMessage = false, callPostEvent = true) event.joinMessage = null } else if (player.hasPermission("velocityvanish.action.vanish.force") && Settings.forceVanishIfFirst && Ruom.onlinePlayers.size <= 1) { if (!Settings.remember) return player.sendMessage(Message.FORCE_VANISHED) - plugin.vanishManager.vanish(player, sendQuitMessage = false, callPostEvent = true) + plugin.vanishManager.vanish(player, sendQuitMessage = false, callPostEvent = true, sendPluginMessage = false) event.joinMessage = null Ruom.runSync({