Package org.collebol.game
Class GameRegister
java.lang.Object
org.collebol.game.GameRegister
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 Summary
ConstructorsConstructorDescriptionConstructs a new GameRegister instance, initializing empty collections for players, entities, and worlds. -
Method Summary
Modifier and TypeMethodDescriptionRetrieves an entity from the game register based on its UUID.Retrieves a player from the game register based on their UUID.Retrieves a world from the game register based on its name.voidregisterEntity(Entity entity) Registers an entity to the game register.voidregisterPlayer(Player player) Registers a player to the game register.voidregisterWorld(World world) Registers a world to the game register.removeEntity(UUID uuid) Removes an entity from the game register based on its UUID.removePlayer(UUID uuid) Removes a player from the game register based on their UUID.removeWorld(String name) Removes a world from the game register based on its name.
-
Constructor Details
-
GameRegister
public GameRegister()Constructs a new GameRegister instance, initializing empty collections for players, entities, and worlds.
-
-
Method Details
-
getPlayer
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
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.
-
getEntity
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
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
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
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
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.