Map Repository - LCLPYT/mg-lobby GitHub Wiki

The MapRepository is a concept for storing and retrieving minigame maps. Each map can be found via a MapDescriptor, which just represents a path.

Supported Methods

Each MapRepository implementation must support the following operations.

Listing maps at a path

Collection<MapRef> getMapList(String path) throws IOException

This method returns a collection of MapRefs, which describe a path to map information.

Getting map information at a path

MapInfo getMapInfo(String path) throws IOException

This method returns the map information at a given path. MapInfo is just a tuple of the source URI the information was retrieved from, the target that represents the path from the repository root and properties, which is just an arbitrary key-value mapping.

Getting resources at a path

Optional<URI> getResource(String path, String resource)

This method is used to get a URI to a resource at a given path. The resource may be relative or absolute.

Optional Methods

Redirect Listener

void addRedirectAction(MapRedirectAction action)

Maps can define a "target" field, that behaves like a redirect, similar to a symbolic link on the file system or HTTP redirects. The repository will follow the target when resolving map information. Each time that happens, consumers may have an interest to perform an action in between the redirect. This operation is optional and can just throw an UnsupportedOperationException.

Map fetching

The default procedure to fetch maps is the following:

  1. Ask a MapLookup for the map world source
  2. Use a WorldCopier to extract the world from the map

The following chart shows the procedure using a RepositoryMapLookup: Direct map fetching flow chart

Caching fetched maps

It may be desirable to cache maps locally so that they don't need to be donwloaded every time. Using a CacheMapRepository will cache every map repository operation locally: Cached map fetching flow chart

⚠️ **GitHub.com Fallback** ⚠️