stirante/lol-client-java-api

Getting error when I try to loop through ListIterator<LolChampSelectChampSelectPlayerSelection

Closed this issue · 2 comments

Am I doing something wrong or is there a better way to do it?

Code:
ListIterator allyteam = session.myTeam.listIterator();
while (allyteam.hasNext())
{
System.out.println("Aly Cell:" + allyteam.next().cellId + " Ally Champ:" + allyteam.next().championId + " " + allyteam.next().assignedPosition);
}

ListIterator enemyteam = session.theirTeam.listIterator();
while (enemyteam.hasNext())
{
System.out.println("Enemy Cell:" + enemyteam.next().cellId + " Enemy Champ:" + enemyteam.next().championId);
}
}`

Error:

Aly Cell:5 Ally Champ:875 utility
[WebSocketConnectReadThread-18] ERROR org.java_websocket.drafts.Draft_6455 - Runtime exception during onWebsocketMessage
java.util.NoSuchElementException
at java.base/java.util.ArrayList$Itr.next(ArrayList.java:970)
at examples.ChampSelect$1$1.onEvent(ChampSelect.java:69)
at com.stirante.lolclient.ClientWebSocket.onMessage(ClientWebSocket.java:79)
at org.java_websocket.client.WebSocketClient.onWebsocketMessage(WebSocketClient.java:591)
at org.java_websocket.drafts.Draft_6455.processFrameText(Draft_6455.java:885)
at org.java_websocket.drafts.Draft_6455.processFrame(Draft_6455.java:819)
at org.java_websocket.WebSocketImpl.decodeFrames(WebSocketImpl.java:379)
at org.java_websocket.WebSocketImpl.decode(WebSocketImpl.java:216)
at org.java_websocket.client.WebSocketClient.run(WebSocketClient.java:508)
at java.base/java.lang.Thread.run(Thread.java:832)
java.util.NoSuchElementException
at java.base/java.util.ArrayList$Itr.next(ArrayList.java:970)
at examples.ChampSelect$1$1.onEvent(ChampSelect.java:69)
at com.stirante.lolclient.ClientWebSocket.onMessage(ClientWebSocket.java:79)
at org.java_websocket.client.WebSocketClient.onWebsocketMessage(WebSocketClient.java:591)
at org.java_websocket.drafts.Draft_6455.processFrameText(Draft_6455.java:885)
at org.java_websocket.drafts.Draft_6455.processFrame(Draft_6455.java:819)
at org.java_websocket.WebSocketImpl.decodeFrames(WebSocketImpl.java:379)
at org.java_websocket.WebSocketImpl.decode(WebSocketImpl.java:216)
at org.java_websocket.client.WebSocketClient.run(WebSocketClient.java:508)
at java.base/java.lang.Thread.run(Thread.java:832)
[WebSocketConnectReadThread-18] ERROR org.java_websocket.drafts.Draft_6455 - Runtime exception during onWebsocketMessage
java.util.NoSuchElementException
at java.base/java.util.ArrayList$Itr.next(ArrayList.java:970)
at examples.ChampSelect$1$1.onEvent(ChampSelect.java:69)
at com.stirante.lolclient.ClientWebSocket.onMessage(ClientWebSocket.java:79)
at org.java_websocket.client.WebSocketClient.onWebsocketMessage(WebSocketClient.java:591)
at org.java_websocket.drafts.Draft_6455.processFrameText(Draft_6455.java:885)
at org.java_websocket.drafts.Draft_6455.processFrame(Draft_6455.java:819)
at org.java_websocket.WebSocketImpl.decodeFrames(WebSocketImpl.java:379)
at org.java_websocket.WebSocketImpl.decode(WebSocketImpl.java:216)
at org.java_websocket.client.WebSocketClient.run(WebSocketClient.java:508)
at java.base/java.lang.Thread.run(Thread.java:832)
java.util.NoSuchElementException
at java.base/java.util.ArrayList$Itr.next(ArrayList.java:970)
at examples.ChampSelect$1$1.onEvent(ChampSelect.java:69)
at com.stirante.lolclient.ClientWebSocket.onMessage(ClientWebSocket.java:79)
at org.java_websocket.client.WebSocketClient.onWebsocketMessage(WebSocketClient.java:591)
at org.java_websocket.drafts.Draft_6455.processFrameText(Draft_6455.java:885)
at org.java_websocket.drafts.Draft_6455.processFrame(Draft_6455.java:819)
at org.java_websocket.WebSocketImpl.decodeFrames(WebSocketImpl.java:379)
at org.java_websocket.WebSocketImpl.decode(WebSocketImpl.java:216)
at org.java_websocket.client.WebSocketClient.run(WebSocketClient.java:508)
at java.base/java.lang.Thread.run(Thread.java:832)

Issue-Label Bot is automatically applying the label question to this issue, with a confidence of 0.83. Please mark this comment with 👍 or 👎 to give our bot feedback!

Links: app homepage, dashboard and code for this bot.

nvm fixed it with this : allyteam.forEachRemaining(player -> {System.out.println("Ally Champ:" + whichChamp.champname(player.championId));});