(1.3.4) Fix voice chat issue in EaglerXBungee

This commit is contained in:
lax1dude 2024-12-01 23:02:39 -08:00
parent 1e235f93bf
commit 28b7627a0f
5 changed files with 102 additions and 57 deletions

View File

@ -64,8 +64,8 @@ import net.md_5.bungee.BungeeCord;
*/ */
public class EaglerXBungee extends Plugin { public class EaglerXBungee extends Plugin {
public static final String NATIVE_BUNGEECORD_BUILD = "1.21-R0.1-SNAPSHOT:4886c4b:1881"; public static final String NATIVE_BUNGEECORD_BUILD = "1.21-R0.1-SNAPSHOT:20a71b0:1887";
public static final String NATIVE_WATERFALL_BUILD = "1.21-R0.1-SNAPSHOT:de8345a:579"; public static final String NATIVE_WATERFALL_BUILD = "1.21-R0.1-SNAPSHOT:bf1be7e:581";
static { static {
CompatWarning.displayCompatWarning(); CompatWarning.displayCompatWarning();

View File

@ -5,6 +5,7 @@ import java.util.Collection;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.UUID; import java.util.UUID;
@ -98,8 +99,11 @@ public class VoiceServerImpl {
} }
void handleVoiceSignalPacketTypeRequest(UUID player, UserConnection sender) { void handleVoiceSignalPacketTypeRequest(UUID player, UserConnection sender) {
UUID senderUUID;
EaglerInitialHandler targetInitialHandler;
EaglerInitialHandler senderInitialHandler;
synchronized (voicePlayers) { synchronized (voicePlayers) {
UUID senderUUID = sender.getUniqueId(); senderUUID = sender.getUniqueId();
if (senderUUID.equals(player)) if (senderUUID.equals(player))
return; // prevent duplicates return; // prevent duplicates
if (!voicePlayers.containsKey(senderUUID)) if (!voicePlayers.containsKey(senderUUID))
@ -129,25 +133,26 @@ public class VoiceServerImpl {
voiceRequests.remove(senderUUID); voiceRequests.remove(senderUUID);
// send each other add data // send each other add data
voicePairs.add(newPair); voicePairs.add(newPair);
EaglerInitialHandler targetInitialHandler = (EaglerInitialHandler) targetPlayerCon targetInitialHandler = (EaglerInitialHandler) targetPlayerCon.getPendingConnection();
.getPendingConnection(); senderInitialHandler = (EaglerInitialHandler) sender.getPendingConnection();
if (targetInitialHandler.getEaglerProtocol().ver <= 3) { }else {
targetInitialHandler.sendEaglerMessage(new SPacketVoiceSignalConnectV3EAG( return;
senderUUID.getMostSignificantBits(), senderUUID.getLeastSignificantBits(), false, false));
} else {
targetInitialHandler.sendEaglerMessage(new SPacketVoiceSignalConnectV4EAG(
senderUUID.getMostSignificantBits(), senderUUID.getLeastSignificantBits(), false));
}
EaglerInitialHandler senderInitialHandler = (EaglerInitialHandler) sender.getPendingConnection();
if (senderInitialHandler.getEaglerProtocol().ver <= 3) {
senderInitialHandler.sendEaglerMessage(new SPacketVoiceSignalConnectV3EAG(
player.getMostSignificantBits(), player.getLeastSignificantBits(), false, true));
} else {
senderInitialHandler.sendEaglerMessage(new SPacketVoiceSignalConnectV4EAG(
player.getMostSignificantBits(), player.getLeastSignificantBits(), true));
}
} }
} }
if (targetInitialHandler.getEaglerProtocol().ver <= 3) {
targetInitialHandler.sendEaglerMessage(new SPacketVoiceSignalConnectV3EAG(
senderUUID.getMostSignificantBits(), senderUUID.getLeastSignificantBits(), false, false));
} else {
targetInitialHandler.sendEaglerMessage(new SPacketVoiceSignalConnectV4EAG(
senderUUID.getMostSignificantBits(), senderUUID.getLeastSignificantBits(), false));
}
if (senderInitialHandler.getEaglerProtocol().ver <= 3) {
senderInitialHandler.sendEaglerMessage(new SPacketVoiceSignalConnectV3EAG(
player.getMostSignificantBits(), player.getLeastSignificantBits(), false, true));
} else {
senderInitialHandler.sendEaglerMessage(new SPacketVoiceSignalConnectV4EAG(
player.getMostSignificantBits(), player.getLeastSignificantBits(), true));
}
} }
void handleVoiceSignalPacketTypeConnect(UserConnection sender) { void handleVoiceSignalPacketTypeConnect(UserConnection sender) {
@ -159,26 +164,47 @@ public class VoiceServerImpl {
if(eaglerHandler.getRPCEventSubscribed(EnumSubscribedEvent.TOGGLE_VOICE)) { if(eaglerHandler.getRPCEventSubscribed(EnumSubscribedEvent.TOGGLE_VOICE)) {
eaglerHandler.getRPCSessionHandler().handleVoiceStateTransition(SPacketRPCEventToggledVoice.VOICE_STATE_ENABLED); eaglerHandler.getRPCSessionHandler().handleVoiceStateTransition(SPacketRPCEventToggledVoice.VOICE_STATE_ENABLED);
} }
UUID senderUuid = eaglerHandler.getUniqueId();
List<UserConnection> lst;
synchronized (voicePlayers) { synchronized (voicePlayers) {
if (voicePlayers.containsKey(eaglerHandler.getUniqueId())) { if (voicePlayers.containsKey(senderUuid)) {
return; return;
} }
boolean hasNoOtherPlayers = voicePlayers.isEmpty(); boolean hasNoOtherPlayers = voicePlayers.isEmpty();
voicePlayers.put(eaglerHandler.getUniqueId(), sender); voicePlayers.put(senderUuid, sender);
if (hasNoOtherPlayers) { if (hasNoOtherPlayers) {
return; return;
} }
Collection<SPacketVoiceSignalGlobalEAG.UserData> userDatas = new ArrayList<>(voicePlayers.size()); lst = new ArrayList<>(voicePlayers.values());
for(UserConnection userCon : voicePlayers.values()) { }
UUID uuid = userCon.getUniqueId(); GameMessagePacket v3p = null;
userDatas.add(new SPacketVoiceSignalGlobalEAG.UserData(uuid.getMostSignificantBits(), GameMessagePacket v4p = null;
uuid.getLeastSignificantBits(), userCon.getDisplayName())); for (UserConnection conn : lst) {
} EaglerInitialHandler handler = (EaglerInitialHandler) conn.getPendingConnection();
GameMessagePacket packetToBroadcast = new SPacketVoiceSignalGlobalEAG(userDatas); if (handler.getEaglerProtocol().ver <= 3) {
for (UserConnection userCon : voicePlayers.values()) { handler.sendEaglerMessage(
((EaglerInitialHandler)userCon.getPendingConnection()).sendEaglerMessage(packetToBroadcast); v3p == null
? (v3p = new SPacketVoiceSignalConnectV3EAG(senderUuid.getMostSignificantBits(),
senderUuid.getLeastSignificantBits(), true, false))
: v3p);
} else {
handler.sendEaglerMessage(
v4p == null
? (v4p = new SPacketVoiceSignalConnectAnnounceV4EAG(senderUuid.getMostSignificantBits(),
senderUuid.getLeastSignificantBits()))
: v4p);
} }
} }
Collection<SPacketVoiceSignalGlobalEAG.UserData> userDatas = new ArrayList<>(lst.size());
for(UserConnection userCon : lst) {
UUID uuid = userCon.getUniqueId();
userDatas.add(new SPacketVoiceSignalGlobalEAG.UserData(uuid.getMostSignificantBits(),
uuid.getLeastSignificantBits(), userCon.getDisplayName()));
}
GameMessagePacket packetToBroadcast = new SPacketVoiceSignalGlobalEAG(userDatas);
for (UserConnection userCon : lst) {
((EaglerInitialHandler)userCon.getPendingConnection()).sendEaglerMessage(packetToBroadcast);
}
} }
void handleVoiceSignalPacketTypeICE(UUID player, byte[] str, UserConnection sender) { void handleVoiceSignalPacketTypeICE(UUID player, byte[] str, UserConnection sender) {
@ -212,6 +238,7 @@ public class VoiceServerImpl {
} }
void handleVoiceSignalPacketTypeDisconnectPeer(UUID player, UserConnection sender) { void handleVoiceSignalPacketTypeDisconnectPeer(UUID player, UserConnection sender) {
List<Runnable> peersToDisconnect = new ArrayList<>();
synchronized (voicePlayers) { synchronized (voicePlayers) {
if (!voicePlayers.containsKey(player)) { if (!voicePlayers.containsKey(player)) {
return; return;
@ -227,31 +254,42 @@ public class VoiceServerImpl {
} }
if (target != null) { if (target != null) {
pairsItr.remove(); pairsItr.remove();
UserConnection conn = voicePlayers.get(target); final UserConnection conn = voicePlayers.get(target);
if (conn != null) { final UUID target2 = target;
((EaglerInitialHandler) conn.getPendingConnection()).sendEaglerMessage( peersToDisconnect.add(() -> {
new SPacketVoiceSignalDisconnectPeerEAG(player.getMostSignificantBits(), if (conn != null) {
player.getLeastSignificantBits())); ((EaglerInitialHandler) conn.getPendingConnection()).sendEaglerMessage(
} new SPacketVoiceSignalDisconnectPeerEAG(player.getMostSignificantBits(),
((EaglerInitialHandler) sender.getPendingConnection()) player.getLeastSignificantBits()));
.sendEaglerMessage(new SPacketVoiceSignalDisconnectPeerEAG(target.getMostSignificantBits(), }
target.getLeastSignificantBits())); ((EaglerInitialHandler) sender.getPendingConnection())
.sendEaglerMessage(new SPacketVoiceSignalDisconnectPeerEAG(target2.getMostSignificantBits(),
target2.getLeastSignificantBits()));
});
} }
} }
} }
for(Runnable r : peersToDisconnect) {
r.run();
}
} }
void removeUser(UUID user) { void removeUser(final UUID user) {
List<Runnable> peersToDisconnect;
synchronized (voicePlayers) { synchronized (voicePlayers) {
UserConnection connRemove; final UserConnection connRemove;
if ((connRemove = voicePlayers.remove(user)) == null) { if ((connRemove = voicePlayers.remove(user)) == null) {
return; return;
}else { }
EaglerInitialHandler eaglerHandler = (EaglerInitialHandler)connRemove.getPendingConnection(); peersToDisconnect = new ArrayList<>();
eaglerHandler.fireVoiceStateChange(EaglercraftVoiceStatusChangeEvent.EnumVoiceState.DISABLED); if(connRemove != null) {
if(eaglerHandler.getRPCEventSubscribed(EnumSubscribedEvent.TOGGLE_VOICE)) { peersToDisconnect.add(() -> {
eaglerHandler.getRPCSessionHandler().handleVoiceStateTransition(SPacketRPCEventToggledVoice.VOICE_STATE_DISABLED); EaglerInitialHandler eaglerHandler = (EaglerInitialHandler)connRemove.getPendingConnection();
} eaglerHandler.fireVoiceStateChange(EaglercraftVoiceStatusChangeEvent.EnumVoiceState.DISABLED);
if(eaglerHandler.getRPCEventSubscribed(EnumSubscribedEvent.TOGGLE_VOICE)) {
eaglerHandler.getRPCSessionHandler().handleVoiceStateTransition(SPacketRPCEventToggledVoice.VOICE_STATE_DISABLED);
}
});
} }
voiceRequests.remove(user); voiceRequests.remove(user);
if (voicePlayers.size() > 0) { if (voicePlayers.size() > 0) {
@ -261,10 +299,12 @@ public class VoiceServerImpl {
userDatas.add(new SPacketVoiceSignalGlobalEAG.UserData(uuid.getMostSignificantBits(), userDatas.add(new SPacketVoiceSignalGlobalEAG.UserData(uuid.getMostSignificantBits(),
uuid.getLeastSignificantBits(), userCon.getDisplayName())); uuid.getLeastSignificantBits(), userCon.getDisplayName()));
} }
GameMessagePacket voicePlayersPkt = new SPacketVoiceSignalGlobalEAG(userDatas); final GameMessagePacket voicePlayersPkt = new SPacketVoiceSignalGlobalEAG(userDatas);
for (UserConnection userCon : voicePlayers.values()) { for (final UserConnection userCon : voicePlayers.values()) {
if (!user.equals(userCon.getUniqueId())) { if (!user.equals(userCon.getUniqueId())) {
((EaglerInitialHandler)userCon.getPendingConnection()).sendEaglerMessage(voicePlayersPkt); peersToDisconnect.add(() -> {
((EaglerInitialHandler)userCon.getPendingConnection()).sendEaglerMessage(voicePlayersPkt);
});
} }
} }
} }
@ -280,16 +320,21 @@ public class VoiceServerImpl {
if (target != null) { if (target != null) {
pairsItr.remove(); pairsItr.remove();
if (voicePlayers.size() > 0) { if (voicePlayers.size() > 0) {
UserConnection conn = voicePlayers.get(target); final UserConnection conn = voicePlayers.get(target);
if (conn != null) { if (conn != null) {
((EaglerInitialHandler) conn.getPendingConnection()).sendEaglerMessage( peersToDisconnect.add(() -> {
new SPacketVoiceSignalDisconnectPeerEAG(user.getMostSignificantBits(), ((EaglerInitialHandler) conn.getPendingConnection()).sendEaglerMessage(
user.getLeastSignificantBits())); new SPacketVoiceSignalDisconnectPeerEAG(user.getMostSignificantBits(),
user.getLeastSignificantBits()));
});
} }
} }
} }
} }
} }
for(Runnable r : peersToDisconnect) {
r.run();
}
} }
EnumVoiceState getPlayerVoiceState(UUID uniqueId) { EnumVoiceState getPlayerVoiceState(UUID uniqueId) {

View File

@ -1,5 +1,5 @@
name: EaglercraftXBungee name: EaglercraftXBungee
main: net.lax1dude.eaglercraft.v1_8.plugin.gateway_bungeecord.EaglerXBungee main: net.lax1dude.eaglercraft.v1_8.plugin.gateway_bungeecord.EaglerXBungee
version: 1.3.3 version: 1.3.4
description: Plugin to allow EaglercraftX 1.8 players to join your network, or allow EaglercraftX 1.8 players to use your network as a proxy to join other networks description: Plugin to allow EaglercraftX 1.8 players to join your network, or allow EaglercraftX 1.8 players to use your network as a proxy to join other networks
author: lax1dude author: lax1dude

View File

@ -1 +1 @@
1.3.3 1.3.4