Class BundleManager

java.lang.Object
de.luckymcdev.foundryengine.common.bundle.BundleManager
All Implemented Interfaces:
net.minecraft.server.packs.resources.PreparableReloadListener, net.minecraft.server.packs.resources.ResourceManagerReloadListener

public class BundleManager extends Object implements net.minecraft.server.packs.resources.ResourceManagerReloadListener
Bundle Manager that manages Bundle Lifecycles.

Script loading is sided:

  • Nested Class Summary

    Nested classes/interfaces inherited from interface net.minecraft.server.packs.resources.PreparableReloadListener

    net.minecraft.server.packs.resources.PreparableReloadListener.PreparationBarrier, net.minecraft.server.packs.resources.PreparableReloadListener.SharedState, net.minecraft.server.packs.resources.PreparableReloadListener.StateKey<T>
  • Constructor Summary

    Constructors
    Constructor
    Description
    BundleManager(net.neoforged.bus.api.IEventBus modBus, Path configDirectory)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    discover(Path directory)
    Discovers and loads all bundles from the specified directory.
    Retrieves a bundle by its ID.
     
    Returns all currently loaded bundles.
     
    void
    Loads client-side scripts for all registered bundles.
    void
    Loads server-side scripts for all registered bundles.
    void
    onResourceManagerReload(net.minecraft.server.packs.resources.ResourceManager resourceManager)
     
    void
    register(Bundle bundle)
    Registers a bundle and immediately loads its common-side scripts.
    void
    Reloads all bundles by clearing all script event callbacks, unloading current bundles, rediscovering them from disk, and re-loading common + server scripts.
    void
    remove(Bundle bundle)
    Removes and cleans up a bundle, including closing its ZIP FileSystem if applicable.
    void
    setServer(net.minecraft.server.MinecraftServer server)
     

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface net.minecraft.server.packs.resources.PreparableReloadListener

    getName, prepareSharedState

    Methods inherited from interface net.minecraft.server.packs.resources.ResourceManagerReloadListener

    reload
  • Constructor Details

    • BundleManager

      public BundleManager(net.neoforged.bus.api.IEventBus modBus, Path configDirectory)
  • Method Details

    • setServer

      public void setServer(net.minecraft.server.MinecraftServer server)
    • register

      public void register(Bundle bundle)
      Registers a bundle and immediately loads its common-side scripts.
    • loadClientScripts

      public void loadClientScripts()
      Loads client-side scripts for all registered bundles. Call this from FoundryEngineModClient during client setup.
    • loadServerScripts

      public void loadServerScripts()
      Loads server-side scripts for all registered bundles. Call this from FoundryEngineModServer during server setup.
    • remove

      public void remove(Bundle bundle)
      Removes and cleans up a bundle, including closing its ZIP FileSystem if applicable.
    • discover

      public void discover(Path directory) throws IOException
      Discovers and loads all bundles from the specified directory.
      Throws:
      IOException
    • getBundles

      public Collection<Bundle> getBundles()
      Returns all currently loaded bundles.
    • getBundle

      public Bundle getBundle(String id)
      Retrieves a bundle by its ID.
    • reload

      public void reload()
      Reloads all bundles by clearing all script event callbacks, unloading current bundles, rediscovering them from disk, and re-loading common + server scripts.
    • getLifecycleDispatcher

      public BundleLifecycleDispatcher getLifecycleDispatcher()
    • getBundleDiscovery

      public BundleDiscovery getBundleDiscovery()
    • onResourceManagerReload

      public void onResourceManagerReload(net.minecraft.server.packs.resources.ResourceManager resourceManager)
      Specified by:
      onResourceManagerReload in interface net.minecraft.server.packs.resources.ResourceManagerReloadListener