staminadevelopment / minecraftapi

A cross-version compatible API for interacting with the Minecraft client.
MIT License
11 stars 2 forks source link

Improve system for providing static dependencies #1

Closed feature closed 6 years ago

feature commented 6 years ago

Motivation:

Minecraft API uses an interface-based architecture, and heavily relies on static factory methods for object creation. Some interfaces are therefore dependent on implementations provided by another component of the system. These implementation are currently provided by a SPI inspired system. This system is very fragile, and does not propagate compile errors, when new dependencies are added, or if implementations are not provided.

Goal:

The goal is to provide a new API that is type-safe and robust, so you cannot accidentally forget to provide an implementation for a dependency. This greatly improves maintainability by promoting runtime errors to compile time errors. It is also especially useful when expanding the API, or implementing Minecraft API for other versions.