Skip to content

Commit 194d4c6

Browse files
committed
Fix friends not syncing on sub-sessions
1 parent 44060ab commit 194d4c6

3 files changed

Lines changed: 14 additions & 7 deletions

File tree

bootstrap/geyser/src/main/java/com/rtm516/mcxboxbroadcast/bootstrap/geyser/MCXboxBroadcastExtension.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ public void onPostInitialize(GeyserPostInitializeEvent event) {
156156
private void createSession() {
157157
// Create the Xbox session
158158
try {
159-
sessionManager.init(sessionInfo);
159+
sessionManager.init(sessionInfo, config.friendSync());
160160
} catch (SessionCreationException | SessionUpdateException e) {
161161
sessionManager.logger().error("Failed to create xbox session!", e);
162162
return;

bootstrap/standalone/src/main/java/com/rtm516/mcxboxbroadcast/bootstrap/standalone/StandaloneMain.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,7 @@ public static void restart() throws SessionUpdateException, SessionCreationExcep
8282
}
8383

8484
private static void createSession() throws SessionCreationException, SessionUpdateException {
85-
sessionManager.init(sessionInfo);
86-
87-
// Set up the auto friend sync
88-
sessionManager.friendManager().initAutoFriend(config.friendSync());
85+
sessionManager.init(sessionInfo, config.friendSync());
8986

9087
sessionManager.scheduledThread().scheduleWithFixedDelay(() -> {
9188
updateSessionInfo(sessionInfo);

core/src/main/java/com/rtm516/mcxboxbroadcast/core/SessionManager.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.rtm516.mcxboxbroadcast.core;
22

3+
import com.rtm516.mcxboxbroadcast.core.configs.FriendSyncConfig;
34
import com.rtm516.mcxboxbroadcast.core.exceptions.SessionCreationException;
45
import com.rtm516.mcxboxbroadcast.core.exceptions.SessionUpdateException;
56
import com.rtm516.mcxboxbroadcast.core.models.CreateSessionRequest;
@@ -30,6 +31,8 @@ public class SessionManager extends SessionManagerCore {
3031
private final ScheduledExecutorService scheduledThreadPool;
3132
private final Map<String, SubSessionManager> subSessionManagers;
3233

34+
private FriendSyncConfig friendSyncConfig;
35+
3336
/**
3437
* Create an instance of SessionManager
3538
*
@@ -64,16 +67,21 @@ public ExpandedSessionInfo sessionInfo() {
6467
/**
6568
* Initialize the session manager with the given session information
6669
*
67-
* @param sessionInfo The session information to use
70+
* @param sessionInfo The session information to use
71+
* @param friendSyncConfig The friend sync configuration to use
6872
* @throws SessionCreationException If the session failed to create either because it already exists or some other reason
6973
* @throws SessionUpdateException If the session data couldn't be set due to some issue
7074
*/
71-
public void init(SessionInfo sessionInfo) throws SessionCreationException, SessionUpdateException {
75+
public void init(SessionInfo sessionInfo, FriendSyncConfig friendSyncConfig) throws SessionCreationException, SessionUpdateException {
7276
// Set the internal session information based on the session info
7377
this.sessionInfo = new ExpandedSessionInfo("", "", sessionInfo);
7478

7579
super.init();
7680

81+
// Set up the auto friend sync
82+
this.friendSyncConfig = friendSyncConfig;
83+
friendManager().initAutoFriend(friendSyncConfig);
84+
7785
// Load sub-sessions from cache
7886
List<String> subSessions = new ArrayList<>();
7987
try {
@@ -84,6 +92,7 @@ public void init(SessionInfo sessionInfo) throws SessionCreationException, Sessi
8492
for (String subSession : subSessions) {
8593
SubSessionManager subSessionManager = new SubSessionManager(subSession, this, Paths.get(cache, subSession).toString(), logger);
8694
subSessionManager.init();
95+
subSessionManager.friendManager().initAutoFriend(friendSyncConfig);
8796
subSessionManagers.put(subSession, subSessionManager);
8897
}
8998
}
@@ -171,6 +180,7 @@ public void addSubSession(String id) {
171180
try {
172181
SubSessionManager subSessionManager = new SubSessionManager(id, this, Paths.get(cache, id).toString(), logger);
173182
subSessionManager.init();
183+
subSessionManager.friendManager().initAutoFriend(friendSyncConfig);
174184
subSessionManagers.put(id, subSessionManager);
175185
} catch (SessionCreationException | SessionUpdateException e) {
176186
coreLogger.error("Failed to create sub-session", e);

0 commit comments

Comments
 (0)