Package tk.airshipcraft.commonlib.configuration
package tk.airshipcraft.commonlib.configuration
Provides classes and interfaces for managing configurations and player preferences within a Bukkit plugin environment.
This package includes tools for handling both general plugin configuration and player-specific settings,
facilitating a robust, flexible approach to managing data within Minecraft plugins.
Key Components:
ConfigHelper
: Handles loading, saving, and repairing configurations for plugins that extend CommonLib. It uses reflection to initialize configuration values and maintains a default configuration file for robustness.ConfigOption
: An annotation used to mark fields in a class as configuration options, specifying a key and a default value. It's designed to work in conjunction withConfigurationManager
for automated configuration management.IPlayerPreference
: An interface outlining methods for handling player preferences, including loading, saving, resetting, and describing player-specific settings.PlayerPref
: An annotation indicating that a field should be considered a player preference, facilitating automatic persistence and retrieval by the preference system.
Usage:
For general configuration management, create classes with fields annotated with ConfigOption
and manage them through a ConfigurationManager
instance. For player preferences, implement the
IPlayerPreference
interface in classes, annotating fields with PlayerPref
.
Example:
// for creating config fields and their default values in side the classes
public class SomePluginConfig {
@ConfigOption(key = "feature.enabled", defaultValue = "true")
private static boolean featureEnabled;
}
// example for implementing player preferences inside of a class
public class ExamplePlayerPreference implements IPlayerPreference {
@PlayerPref
private String someSetting;
public void load(Player player) {
// Implement loading logic here
}
public void save(Player player) {
// Implement saving logic here
}
public void reset(Player player) {
// Implement reset logic here
}
public String describe(Player player) {
// Implement description logic here
}
}
This package allows for a comprehensive and modular approach to both global plugin configurations and individual player preferences, supporting diverse requirements and facilitating easy integration into Bukkit plugins.
- Since:
- 2023-11-20
- Version:
- 1.0.0
- Author:
- notzune
- See Also:
-
ClassDescriptionManages the configuration for plugins that extend CommonLib.The
ConfigOption
annotation is used to mark fields in a class that represent configuration options.IPlayerPreference is an interface that defines the contract for managing player-specific preferences in a Minecraft server environment.The PlayerPref annotation is used to designate fields within classes that implement the IPlayerPreference interface as player preference settings.