Skip to content
This repository was archived by the owner on Dec 16, 2025. It is now read-only.
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.ultreon.devices.api.utils;

import com.ultreon.devices.core.Laptop;
import com.ultreon.devices.util.StreamUtils;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
Expand Down Expand Up @@ -121,6 +122,10 @@ public void run() {

while (!requests.isEmpty()) {
RequestWrapper wrapper = requests.poll();
if (Laptop.isOffline()) {
wrapper.handler.handle(false, "Disconnected from the internet.");
return;
}
try {
URL url = new URL(wrapper.url);
checkURLForSuspicions(url);
Expand Down
17 changes: 17 additions & 0 deletions common/src/main/java/com/ultreon/devices/core/Laptop.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ public class Laptop extends Screen implements System {
private static Laptop instance;
private Double dragWindowFromX;
private Double dragWindowFromY;
@Nullable
private final LaptopBlockEntity blockEntity;

@PlatformOnly("fabric")
public static List<Application> getApplicationsForFabric() {
Expand Down Expand Up @@ -184,12 +186,27 @@ public boolean add(Window<?> window) {

// World-less flag.
Laptop.worldLess = worldLess;
this.blockEntity = laptop;
}

public static Laptop getInstance() {
return instance;
}

public static boolean isOffline() {
Laptop laptop = instance;
if (laptop == null) {
return false;
}

LaptopBlockEntity blockEntity = laptop.blockEntity;
if (blockEntity == null) {
return false;
}

return blockEntity.getConnection() == null;
}

public CompoundTag getModSystemTag(Mod mod) {
return getModSystemTag(mod.getModId());
}
Expand Down