Skip to content

Commit 1d68906

Browse files
committed
Ignore subaccounts when altering friends
1 parent 64fc6d6 commit 1d68906

1 file changed

Lines changed: 25 additions & 2 deletions

File tree

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

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

3-
import com.fasterxml.jackson.core.JsonProcessingException;
4-
import com.fasterxml.jackson.databind.JsonMappingException;
53
import com.rtm516.mcxboxbroadcast.core.configs.FriendSyncConfig;
64
import com.rtm516.mcxboxbroadcast.core.exceptions.XboxFriendsException;
75
import com.rtm516.mcxboxbroadcast.core.models.FriendModifyResponse;
@@ -198,6 +196,11 @@ public void initAutoFriend(FriendSyncConfig friendSyncConfig) {
198196
// Auto Friend Checker
199197
try {
200198
for (FollowerResponse.Person person : get(friendSyncConfig.autoFollow(), friendSyncConfig.autoUnfollow())) {
199+
// Make sure we are not targeting a subaccount (eg: split screen)
200+
if (isSubAccount(person.xuid)) {
201+
continue;
202+
}
203+
201204
// Follow the person back
202205
if (friendSyncConfig.autoFollow() && person.isFollowingCaller && !person.isFollowedByCaller) {
203206
add(person.xuid, person.displayName);
@@ -215,6 +218,26 @@ public void initAutoFriend(FriendSyncConfig friendSyncConfig) {
215218
}
216219
}
217220

221+
/**
222+
* Internal function to check if the XUID is a subaccount (used by split screen)
223+
*
224+
* @return True if the XUID is a sub account
225+
*/
226+
private boolean isSubAccount(long xuid) {
227+
return xuid >> 52 == 1;
228+
}
229+
230+
/**
231+
* @see #isSubAccount(long)
232+
*/
233+
private boolean isSubAccount(String xuid) {
234+
try {
235+
return isSubAccount(Long.parseLong(xuid));
236+
} catch (NumberFormatException e) {
237+
return false;
238+
}
239+
}
240+
218241
/**
219242
* Internal function to process the add/remove requests
220243
* This will also handle retrying requests if they fail due to rate limits or other errors

0 commit comments

Comments
 (0)