mirror of
https://github.com/jwdeveloper/TikTokLiveJava.git
synced 2026-02-27 16:59:39 -05:00
Add helper methods to get TikTokLinkMicBattleEvent teams by battleHostName!
This commit is contained in:
@@ -25,6 +25,7 @@ package io.github.jwdeveloper.tiktok.data.events;
|
||||
import io.github.jwdeveloper.tiktok.annotations.*;
|
||||
import io.github.jwdeveloper.tiktok.data.events.common.TikTokHeaderEvent;
|
||||
import io.github.jwdeveloper.tiktok.data.models.battles.*;
|
||||
import io.github.jwdeveloper.tiktok.exceptions.TikTokLiveException;
|
||||
import io.github.jwdeveloper.tiktok.messages.enums.LinkMicBattleStatus;
|
||||
import io.github.jwdeveloper.tiktok.messages.webcast.WebcastLinkMicBattle;
|
||||
import lombok.*;
|
||||
@@ -69,6 +70,20 @@ public class TikTokLinkMicBattleEvent extends TikTokHeaderEvent
|
||||
// - msg.getHostTeamCount() always is 2 for 1v1 or 4 for 2v2
|
||||
}
|
||||
|
||||
public Team1v1 get1v1Team(String battleHostName) {
|
||||
if (!is1v1())
|
||||
throw new TikTokLiveException("Teams are not instance of 1v1 battle!");
|
||||
return teams.stream().filter(team -> team.getAs1v1Team().getHost().getName().equals(battleHostName)).findFirst().map(Team::getAs1v1Team).orElse(null);
|
||||
}
|
||||
|
||||
public Team2v2 get2v2Team(String battleHostName) {
|
||||
if (!is2v2())
|
||||
throw new TikTokLiveException("Teams are not instance of 2v2 battle!");
|
||||
return teams.stream().filter(team ->
|
||||
team.getAs2v2Team().getHosts().stream().anyMatch(user ->
|
||||
user.getName().equals(battleHostName))).findFirst().map(Team::getAs2v2Team).orElse(null);
|
||||
}
|
||||
|
||||
public boolean is1v1() {
|
||||
return teams.get(0) instanceof Team1v1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user