Skip to content
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
11 changes: 9 additions & 2 deletions src/main/java/com/coflnet/sky/SkyCofl.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,15 @@ public void preInit(FMLPreInitializationEvent event) {
MinecraftForge.EVENT_BUS.register(new com.coflnet.sky.listeners.SellProtectionListener());
MinecraftForge.EVENT_BUS.register(new com.coflnet.sky.handlers.SellProtectionTooltipHandler());

// Cache all the mods on load
WSCommandHandler.cacheMods();
// Cache all the mods on load in background to avoid blocking the main thread
new Thread(() -> {
try {
WSCommandHandler.cacheMods();
} catch (Exception e) {
System.err.println("Failed to cache mods: " + e.getMessage());
e.printStackTrace();
}
}, "cofl-cache-mods").start();
}

@EventHandler
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/coflnet/sky/handlers/EventHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -163,13 +163,13 @@ private static void ProcessTabMenu(String line) {
}

private static void checkIfInSkyblock(String s) {
if ((s.contains("SKYBLOCK") || s.contains("E")) && !isInSkyblock) {
if (s.contains("SKYBLOCK") && !isInSkyblock) {
if (config.autoStart) {
CoflCore.Wrapper.stop();
CoflCore.Wrapper.startConnection(PlayerDataProvider.getUsername());
}
isInSkyblock = true;
} else if (!s.contains("SKYBLOCK") && !s.contains("E") && isInSkyblock) {
} else if (!s.contains("SKYBLOCK") && isInSkyblock) {
if (config.autoStart) {
CoflCore.Wrapper.stop();
Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("connection to ")
Expand Down
13 changes: 10 additions & 3 deletions src/main/java/com/coflnet/sky/handlers/EventRegistry.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,18 @@ public class EventRegistry {

@SubscribeEvent
public void onDisconnectedFromServerEvent(ClientDisconnectionFromServerEvent event) {
EventHandler.isInSkyblock = false;
if (CoflCore.CoflCore.Wrapper != null && CoflCore.CoflCore.Wrapper.isRunning) {
System.out.println("Disconnected from server");
CoflCore.CoflCore.Wrapper.stop();
EventHandler.isInSkyblock = false;
System.out.println("SkyCofl stopped");
new Thread(() -> {
try {
CoflCore.CoflCore.Wrapper.stop();
System.out.println("SkyCofl stopped");
} catch (Exception e) {
System.err.println("Failed to stop SkyCofl on disconnect: " + e.getMessage());
e.printStackTrace();
}
}, "cofl-disconnect").start();
}
}

Expand Down