Klasse GameManager

java.lang.Object
de.luckymcdev.foundryengine.common.game.GameManager
Alle implementierten Schnittstellen:
BundleLifecycleListener

public class GameManager extends Object implements BundleLifecycleListener
Manages the lifecycle and tick dispatch of game sessions, scoped per world.

Lifecycle tracking (STOPPED → STARTING → RUNNING → STOPPING → STOPPED) is per-world, not per-session. All sessions in a world share the world's lifecycle.

  • Konstruktordetails

    • GameManager

      public GameManager()
  • Methodendetails

    • beginServerTick

      public void beginServerTick()
      Resets the per-tick session deduplication state. Must be called once per server tick before any level/session ticking so that each session's tick handlers run exactly once per server tick regardless of how many dimensions the world has.
    • register

      public boolean register(GameSession session)
      Registers a game session for all worlds (current and future). Returns false if a session with the same ID is already registered globally.
    • register

      public boolean register(String worldName, GameSession session)
      Registers a game session for the given world. Returns false if already registered.
    • unregister

      public void unregister(String worldName, net.minecraft.resources.Identifier id)
      Unregisters a game session for the given world and stops it if started.
    • getSession

      public @Nullable GameSession getSession(String worldName, net.minecraft.resources.Identifier id)
      Returns the registered session for the given world, or null if not found.
    • getSessions

      public Collection<GameSession> getSessions(String worldName)
      Returns an unmodifiable collection of all sessions for the given world.
    • getAllSessions

      public Collection<GameSession> getAllSessions()
      Returns all sessions across all worlds and global sessions.
    • hasSession

      public boolean hasSession(String worldName, net.minecraft.resources.Identifier id)
      Checks if a session with the given ID is registered for the given world.
    • anySession

      public boolean anySession()
    • worldLifecycle

      public GameLifecycle worldLifecycle(String worldName)
      Returns the lifecycle state for the given world.
    • getOrCreateSessionData

      public net.minecraft.nbt.CompoundTag getOrCreateSessionData(net.minecraft.resources.Identifier id)
      Returns the persistent CompoundTag for a session ID, creating one if absent. The returned tag survives bundle reloads and is shared by all GameData instances with the same ID.
    • setWorldDataPath

      public void setWorldDataPath(String worldName, Path dataPath)
      Sets the data directory for a world, used for session persistence.
    • worldDataPath

      public Path worldDataPath(String worldName)
      Returns the data directory for a world, or Common.GAME if not set.
    • autoStartAll

      public void autoStartAll(String worldName)
      Starts all auto-start sessions for the given world and sets its lifecycle to RUNNING.
    • startSession

      public boolean startSession(String worldName, net.minecraft.resources.Identifier id)
      Starts the given session for the given world.
    • stopSession

      public boolean stopSession(String worldName, net.minecraft.resources.Identifier id)
      Stops the given session for the given world.
    • stopAll

      public void stopAll(String worldName)
      Stops all sessions for the given world and sets its lifecycle to STOPPED.
    • stopAll

      public void stopAll()
      Stops all sessions across all worlds.
    • tickCommon

      public void tickCommon(net.minecraft.world.level.Level level)
      Ticks all started sessions for the world of the given level.
    • tickClient

      public void tickClient(net.minecraft.client.Minecraft client, net.minecraft.world.level.Level level)
      Ticks all started sessions for the world of the given client level.
    • tickServer

      public void tickServer(net.minecraft.server.MinecraftServer server, net.minecraft.server.level.ServerLevel level)
      Ticks all started sessions for the world of the given server level.
    • onBundlePreUnload

      public void onBundlePreUnload(Bundle bundle)
      Angegeben von:
      onBundlePreUnload in Schnittstelle BundleLifecycleListener
    • onBundleReloadStarted

      public void onBundleReloadStarted()
      Angegeben von:
      onBundleReloadStarted in Schnittstelle BundleLifecycleListener
    • onBundleReloadCompleted

      public void onBundleReloadCompleted()
      Angegeben von:
      onBundleReloadCompleted in Schnittstelle BundleLifecycleListener