A robust and flexible Java property library.
repositories {
maven("https://jitpack.io")
}
Then:
dependencies {
implementation("rip.hippo.possi:core:4.2.2")
// Spigot module
implementation("rip.hippo.possi:spigot:4.2.2")
// Gson module
implementation("rip.hippo.possi:gson:4.2.2")
}
A Property, at its core, is simply just an object that holds a mutable value. Optionally however, they may contain:
- Keys
- Attributes
- Callbacks
A PropertySource is an arbitrary data source that can be read from and written to. For the source to be able to read and write to properties it must contain Binds.
The standard implementation handles adding binds to sources automatically
A PropertyBind is an adapter for binding properties to sources, these must contain a single Property.
Whenever PropertySource#load
is invoked, the bind will read the source and set the property's value accordingly.
Whenever PropertySource#save
is invoked, the bind will write the property's value to the source.
The standard implementation handles adding properties to binds automatically
A usage example of binds and sources can be found here
A PropertyKey is an object that is used to locate a property via a PropertyKeyRegistry.
A usage example of keys can be found here.
A PropertyAttribute is additional runtime information attached to the property. This may contain information such as number ranges, default values, and much more.
A usage example of attributes can be found here.
A ValueChangeCallback is a callback that is invoked when the value of a property changes. These may modify the value of the property or cancel the change entirely.
A usage example of callbacks can be found here.
A purpose of a module is to mainly provide implementations for Sources and Binds.
You may have to write your own module depending on your project, on this repo we provide modules for the following:
Spigot (YAML Configuration)
Gson