Class GameRegister

java.lang.Object
org.collebol.game.GameRegister

public class GameRegister extends Object
The GameRegister class is responsible for managing players, entities, and worlds within the game. It allows registration, retrieval, and removal of players, entities, and worlds. It ensures that necessary validations are performed during these operations.
Since:
1.0-dev
Author:
ColleBol - contact@collebol.org
  • Constructor Details

    • GameRegister

      public GameRegister()
      Constructs a new GameRegister instance, initializing empty collections for players, entities, and worlds.
  • Method Details

    • registerPlayer

      public void registerPlayer(Player player)
      Registers a player to the game register.
      Parameters:
      player - The player to be registered.
      Throws:
      RuntimeException - if the player or player's UUID is null.
    • getPlayer

      public Player getPlayer(UUID uuid)
      Retrieves a player from the game register based on their UUID.
      Parameters:
      uuid - The UUID of the player to retrieve.
      Returns:
      The player associated with the given UUID.
      Throws:
      RuntimeException - if the UUID is null or no player is found for the given UUID.
    • removePlayer

      public Player removePlayer(UUID uuid)
      Removes a player from the game register based on their UUID.
      Parameters:
      uuid - The UUID of the player to remove.
      Returns:
      The player that was removed.
      Throws:
      RuntimeException - if the UUID is null.
    • registerEntity

      public void registerEntity(Entity entity)
      Registers an entity to the game register.
      Parameters:
      entity - The entity to be registered.
      Throws:
      RuntimeException - if the entity is a player, or if the entity or its UUID is null.
    • getEntity

      public Entity getEntity(UUID uuid)
      Retrieves an entity from the game register based on its UUID.
      Parameters:
      uuid - The UUID of the entity to retrieve.
      Returns:
      The entity associated with the given UUID.
      Throws:
      RuntimeException - if the UUID is null or no entity is found for the given UUID.
    • removeEntity

      public Entity removeEntity(UUID uuid)
      Removes an entity from the game register based on its UUID.
      Parameters:
      uuid - The UUID of the entity to remove.
      Returns:
      The entity that was removed.
      Throws:
      RuntimeException - if the UUID is null.
    • registerWorld

      public void registerWorld(World world)
      Registers a world to the game register.
      Parameters:
      world - The world to be registered.
      Throws:
      RuntimeException - if the world or its name is null, or if the world is already registered.
    • getWorld

      public World getWorld(String name)
      Retrieves a world from the game register based on its name.
      Parameters:
      name - The name of the world to retrieve.
      Returns:
      The world associated with the given name.
      Throws:
      RuntimeException - if the world name is null or no world is found for the given name.
    • removeWorld

      public World removeWorld(String name)
      Removes a world from the game register based on its name.
      Parameters:
      name - The name of the world to remove.
      Returns:
      The world that was removed.
      Throws:
      RuntimeException - if the world name is null or no world is found for the given name.