plasmoapp / plasmo-voice

Proximity voice сhat mod for Minecraft
GNU Lesser General Public License v3.0
226 stars 65 forks source link

Issue related to vanish #358

Open envizar opened 1 year ago

envizar commented 1 year ago

When players in vanish join they appear in "players volume" list Hiding players in "players volume" list work if player joins when already vanished player is playing on server I use PremiumVanish as vanish plugin

Apehum commented 1 year ago

Should be fixed in prerelease: https://github.com/plasmoapp/plasmo-voice/releases/tag/2.0.7

ydal251 commented 10 months ago

This seems to still be an issue in 2.0.7 and 2.1.0+3821a2f-SNAPSHOT. The vanished player's skin is changed to a default skin, but they are still shown in the volume list. If the player that isn't vanished sends a reload packet with /vrc then the vanished player correctly disappears from their volume list just as if someone was vanished when they first joined the server. image

It also appears when reappearing from vanish a /vrc needs to be sent by the reappearing player to appear in the volume list again for others

Using Premium Vanish 2.8.13, Paper 1.20.2-297, and Fabric 1.20.2 clients

Apehum commented 9 months ago

Hide/show in the volume menu on player vanish/unvanish should be fixed in 2.0.8 prerelease: https://github.com/plasmoapp/plasmo-voice/releases/tag/2.0.8

codeHusky commented 7 months ago

appears to still be an issue on the 2.0.8 prerelease when using EssentialsX @Apehum

codeHusky commented 7 months ago

after some closer examination and testing, it seems the current logic for vanish doesn't work.

https://github.com/plasmoapp/plasmo-voice/blob/2c935130b95b8e40c04bcf29336b909255b9ad8d/server/common/src/main/java/su/plo/voice/server/connection/VoiceTcpServerConnectionManager.java#L162C88-L162C106

This line of code currently sends the player disconnect packet to the person vanishing, which completely breaks their clientside voice connection. The test used is sending the packet if the user can see the vanished user, rather than if the user cannot see the user. This should be reasonably be inverted.

Here's code that works at the moment on my server.

PaperVoiceLoader loader = (PaperVoiceLoader) Bukkit.getPluginManager().getPlugin("PlasmoVoice");
Field voiceField = PaperVoiceLoader.class.getDeclaredField("voiceServer");
voiceField.setAccessible(true);

PaperVoiceServer voiceServer = (PaperVoiceServer) voiceField.get(loader);
Events.subscribe(VanishStatusChangeEvent.class, EventPriority.MONITOR)
        .handler(e -> {
            Player relevant = Players.getNullable(e.getAffected().getUUID());
            if(relevant == null) return;

            VoiceServerPlayer voiceServerPlayer = voiceServer.getPlayerManager().wrap(relevant);
            if(!voiceServerPlayer.hasVoiceChat()) return;

            if (e.getValue()) {
                // newly vanished
                Schedulers.sync().runLater(() -> {
                    voiceServer.getTcpConnectionManager().broadcast(new PlayerDisconnectPacket(voiceServerPlayer.getInstance().getUUID()), (player1) -> {
                        SubserverTools.getInstance().getLogger().info("Test? " + voiceServerPlayer.getInstance().getName() + " vs " + player1.getInstance().getName());
                        return !voiceServerPlayer.getInstance().getUUID().equals(player1.getInstance().getUUID()) && !player1.getInstance().canSee(voiceServerPlayer.getInstance());
                    });
                },1L).bindWith(consumer);
            } else {
                // unvanishing
                Schedulers.sync()
                        .runLater(() -> voiceServer.getTcpConnectionManager().broadcastPlayerInfoUpdate(voiceServerPlayer), 1L)
                        .bindWith(consumer);

            }
        }).bindWith(consumer);

This isn't entirely foolproof (the behavior makes vanished players disappear from the voice list slightly differently than actual logouts since they get a default skin for a few ms before they disappear) but it's most of the way there.