Skip to content

Commit 3af4e00

Browse files
committed
dont crash if not connected when trying to do some actions.
1 parent 2f01419 commit 3af4e00

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/main/java/gg/archipelago/APClient/APClient.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,8 @@ public void connect(String address) {
189189
}
190190

191191
public void sendChat(String message) {
192+
if(apWebSocket == null)
193+
return;
192194
if(apWebSocket.isAuthenticated()) {
193195
apWebSocket.sendChat(message);
194196
}
@@ -274,6 +276,8 @@ public DataManager getDataManager() {
274276
}
275277

276278
public void setGameState(ClientStatus status) {
279+
if(apWebSocket == null)
280+
return;
277281
if(apWebSocket.isAuthenticated())
278282
apWebSocket.sendPacket(new ClientStatusPacket(status));
279283
}
@@ -283,6 +287,8 @@ public void sync() {
283287
}
284288

285289
public void sendBounce(BouncePacket bouncePacket) {
290+
if(apWebSocket == null)
291+
return;
286292
if(apWebSocket.isAuthenticated())
287293
apWebSocket.sendPacket(bouncePacket);
288294
}

src/main/java/gg/archipelago/APClient/locationmanager/LocationManager.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,10 @@ public boolean checkLocation(int id) {
2626
apClient.getDataManager().save();
2727
LocationChecks packet = new LocationChecks();
2828
packet.locations.add(id);
29-
if(webSocket != null && webSocket.isAuthenticated()) {
29+
if(webSocket == null)
30+
return false;
31+
32+
if(webSocket.isAuthenticated()) {
3033
webSocket.sendPacket(packet);
3134
return true;
3235
}

0 commit comments

Comments
 (0)