Skip to content

Commit

Permalink
Fixed random crashes and load ViaVersion async
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorianMichael committed Nov 26, 2023
1 parent 67285d4 commit cf93a04
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 1,396 deletions.
10 changes: 8 additions & 2 deletions src/main/java/de/florianmichael/viafabricplus/ViaFabricPlus.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import org.apache.logging.log4j.Logger;

import java.io.File;
import java.util.concurrent.CompletableFuture;

/*
* TODO | General
Expand Down Expand Up @@ -66,17 +67,22 @@ public class ViaFabricPlus {
private SettingsManager settingsManager;
private SaveManager saveManager;

private CompletableFuture<Void> loadingFuture;

@SuppressWarnings("ResultOfMethodCallIgnored")
public void bootstrap() {
directory.mkdir();
ClassLoaderPriorityUtil.loadOverridingJars(directory); // Load overriding jars first so other code can access the new classes

ClientsideFixes.init(); // Init clientside related fixes
ProtocolHack.init(directory); // Init ViaVersion protocol translator platform
loadingFuture = ProtocolHack.init(directory); // Init ViaVersion protocol translator platform

settingsManager = new SettingsManager();
saveManager = new SaveManager(settingsManager);
PostGameLoadCallback.EVENT.register(saveManager::init); // Has to wait for Minecraft because of the translation system usages
PostGameLoadCallback.EVENT.register(() -> {
saveManager.init();
loadingFuture.join();
}); // Has to wait for Minecraft because of the translation system usages
}

public static ViaFabricPlus global() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1369,5 +1369,4 @@ public static boolean keepItem(final Item item) {
return !ITEM_DIFF.containsKey(item) || ITEM_DIFF.get(item).contains(ProtocolHack.getTargetVersion() /*ProtocolHack.getTargetVersion().isNewerThanOrEqualTo(ITEM_DIFF.get(item)*/);
}


}
Loading

0 comments on commit cf93a04

Please sign in to comment.