Skip to content

Commit

Permalink
Merge pull request #93
Browse files Browse the repository at this point in the history
Spigot | Add essentials vanish system to VelocityVanish
  • Loading branch information
Syrent authored Feb 10, 2023
2 parents ebeb4e0 + 5a49d27 commit 30adb28
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 16 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
version=3.13.1
version=3.14.0
plugin-name=VelocityVanish
37 changes: 23 additions & 14 deletions src/main/java/ir/syrent/velocityvanish/spigot/core/VanishManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@ import com.comphenix.protocol.PacketType
import com.comphenix.protocol.events.PacketContainer
import com.comphenix.protocol.wrappers.*
import com.comphenix.protocol.wrappers.EnumWrappers.NativeGameMode
import ir.syrent.nms.accessors.ClientboundRemoveMobEffectPacketAccessor
import ir.syrent.nms.accessors.ClientboundUpdateMobEffectPacketAccessor
import ir.syrent.nms.accessors.MobEffectAccessor
import ir.syrent.nms.accessors.MobEffectInstanceAccessor
import ir.syrent.nms.accessors.*
import ir.syrent.velocityvanish.spigot.VelocityVanishSpigot
import ir.syrent.velocityvanish.spigot.event.PostUnVanishEvent
import ir.syrent.velocityvanish.spigot.event.PostVanishEvent
Expand All @@ -19,8 +16,8 @@ import ir.syrent.velocityvanish.spigot.storage.Settings
import ir.syrent.velocityvanish.spigot.utils.NMSUtils
import ir.syrent.velocityvanish.spigot.utils.ServerVersion
import ir.syrent.velocityvanish.spigot.utils.Utils
import net.minecraft.network.protocol.game.ClientboundRemoveMobEffectPacket
import net.minecraft.world.effect.MobEffect
import net.minecraft.network.protocol.game.ClientboundPlayerInfoRemovePacket
import net.minecraft.network.protocol.game.ClientboundPlayerInfoUpdatePacket
import org.bukkit.GameMode
import org.bukkit.entity.Creature
import org.bukkit.entity.Player
Expand Down Expand Up @@ -76,15 +73,27 @@ class VanishManager(

val newTabPacket = PacketContainer(PacketType.Play.Server.PLAYER_INFO, tabPacket?.handle)

for (onlinePlayer in Ruom.getOnlinePlayers()) {
if (onlinePlayer.hasPermission("velocityvanish.admin.seevanished")) {
if (onlinePlayer == player) continue
DependencyManager.protocolLibHook.protocolManager.sendServerPacket(onlinePlayer, newTabPacket)
}
for (onlinePlayer in Ruom.getOnlinePlayers().filter { it.hasPermission("velocityvanish.admin.seevanished") }.filter { it != player }) {
DependencyManager.protocolLibHook.protocolManager.sendServerPacket(onlinePlayer, newTabPacket)
}
} catch (e: Exception) {
// TODO: Fix it
Ruom.warn("Failed to update tab state for ${player.name}, It might be a ProtocolLib issue. (Players who have `seevanished` permission can see this player in tab and game character as survival mode)")
/*val removePacket = ClientboundPlayerInfoRemovePacketAccessor.getConstructor0().newInstance(
ClientboundPlayerInfoRemovePacketAccessor.getFieldProfileIds(),
)
val addPacket = ClientboundPlayerInfoUpdatePacketAccessor.getConstructor0().newInstance(
ClientboundPlayerInfoUpdatePacket_i_ActionAccessor.getFieldADD_PLAYER(),
NMSUtils.getServerPlayer(player)
)
val packet = ClientboundPlayerInfoUpdatePacketAccessor.getConstructor0().newInstance(
ClientboundPlayerInfoUpdatePacket_i_ActionAccessor.getFieldUPDATE_GAME_MODE(),
NMSUtils.getServerPlayer(player)
)
for (onlinePlayer in Ruom.getOnlinePlayers().filter { it.hasPermission("velocityvanish.admin.seevanished") }.filter { it != player }) {
NMSUtils.sendPacket(onlinePlayer, packet)
}*/
}
}, 2)
} else {
Expand Down Expand Up @@ -225,7 +234,7 @@ class VanishManager(
addPotionEffects(player)

if (DependencyManager.essentialsXHook.exists) {
DependencyManager.essentialsXHook.vanish(player, false)
DependencyManager.essentialsXHook.vanish(player, true)
}

if (ServerVersion.supports(9)) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/velocity-plugin.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"id":"velocityvanish","name":"VelocityVanish","version":"3.13.1","description":"Vanish plugin for velocity servers","url":"syrent.ir","authors":["Syrent"],"dependencies":[],"main":"ir.syrent.velocityvanish.velocity.VelocityVanish"}
{"id":"velocityvanish","name":"VelocityVanish","version":"3.14.0","description":"Vanish plugin for velocity servers","url":"syrent.ir","authors":["Syrent"],"dependencies":[],"main":"ir.syrent.velocityvanish.velocity.VelocityVanish"}

0 comments on commit 30adb28

Please sign in to comment.