(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 static final String NATIVE_BUNGEECORD_BUILD = "1.21-R0.1-SNAPSHOT:4886c4b:1881";
public static final String NATIVE_WATERFALL_BUILD = "1.21-R0.1-SNAPSHOT:de8345a:579";
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:bf1be7e:581";
static {
CompatWarning.displayCompatWarning();

View File

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

View File

@ -1,5 +1,5 @@
name: EaglercraftXBungee
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
author: lax1dude

View File

@ -1 +1 @@
1.3.3
1.3.4