@@ -30,7 +30,7 @@ public record GameState(JSONObject gameData, String gamePk) {
3030 */
3131 @ NotNull
3232 public static GameState fromPk (String gamePk ) {
33- String res = RestClient .get ("https://statsapi.mlb.com/api/v1.1/game/:id/feed/live?language=en&fields=gameData,venue,fieldInfo,capacity,weather,condition,temp,wind,gameInfo,attendance,game,pk,datetime,dateTime,status,detailedState,abstractGameState,liveData,plays,allPlays,result,rbi,description,awayScore,homeScore,event,about,inning,isTopInning,isComplete,count,balls,strikes,outs,playEvents,details,isInPlay,isScoringPlay,eventType,hitData,launchSpeed,launchAngle,totalDistance,trajectory,hardness,isPitch,atBatIndex,playId,currentPlay,scoringPlays,matchup,batter,fullName,pitcher,postOnFirst,postOnSecond,postOnThird,linescore,currentInning,currentInningOrdinal,inningState,teams,home,name,clubName,abbreviation,runs,away,innings,num,hits,errors,leftOnBase,decisions,winner,id,loser,save,boxscore,players,stats,pitching,note"
33+ String res = RestClient .get ("https://statsapi.mlb.com/api/v1.1/game/:id/feed/live?language=en&fields=gameData,venue,fieldInfo,capacity,weather,condition,temp,wind,gameInfo,attendance,game,pk,datetime,dateTime,status,detailedState,abstractGameState,liveData,plays,allPlays,result,rbi,description,awayScore,homeScore,event,about,inning,isTopInning,isComplete,count,balls,strikes,outs,playEvents,details,isInPlay,isScoringPlay,eventType,hitData,launchSpeed,launchAngle,totalDistance,trajectory,hardness,isPitch,atBatIndex,playId,currentPlay,scoringPlays,matchup,batter,fullName,pitcher,postOnFirst,postOnSecond,postOnThird,linescore,offense,onDeck,inHole, currentInning,currentInningOrdinal,inningState,teams,home,name,clubName,abbreviation,runs,away,innings,num,hits,errors,leftOnBase,decisions,winner,id,loser,save,boxscore,players,stats,pitching,note"
3434 .replace (":id" , gamePk )).asString ();
3535
3636 try {
@@ -241,6 +241,33 @@ public String currentBatter() {
241241 return currentPlay ().getJSONObject ("matchup" ).getJSONObject ("batter" ).getString ("fullName" );
242242 }
243243
244+ /**
245+ * The next batter for the offense. Not necessarily the same as {@link #currentBatter()}.
246+ *
247+ * @return the next batter for the offense.
248+ */
249+ public String offenseBatter () {
250+ return lineScore ().getJSONObject ("offense" ).getJSONObject ("batter" ).getString ("fullName" );
251+ }
252+
253+ /**
254+ * The batter on deck (after the next batter) for the offense.
255+ *
256+ * @return the batter on deck for the offense.
257+ */
258+ public String onDeck () {
259+ return lineScore ().getJSONObject ("offense" ).getJSONObject ("onDeck" ).getString ("fullName" );
260+ }
261+
262+ /**
263+ * The batter in the hole (after the on deck batter) for the offense.
264+ *
265+ * @return the batter in the hole for the offense.
266+ */
267+ public String inTheHole () {
268+ return lineScore ().getJSONObject ("offense" ).getJSONObject ("inHole" ).getString ("fullName" );
269+ }
270+
244271 /**
245272 * Gets who is currently on a base. E.g., "1st: Mike Trout".
246273 * Can also be "No one is on base." if no one is on base.
0 commit comments