Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 22 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ both ways.
#### Full sample (with comments)

```java
import dev.spexx.configurationAPI.manager.ConfigManager;
import dev.spexx.configurationAPI.api.manager.ConfigManager;

// ConfigManager takes a plugin instance, should only
// be initialized once!
Expand All @@ -64,36 +64,45 @@ ConfigManager configManager = new ConfigManager(this);
// Which means you should NOT use saveDefaultConfig() / saveConfig()
// anywhere in your plugin.

// This is where you want the config from the plugin resources to be saved.
File myPluginConfigDestination = new File(getDataFolder(), "config.yml");
// This is where you want the config from the plugin resources to be saved.
File myPluginConfigDestination = new File(getDataFolder(), "config.yml");

// 2nd parameter, "config.yml" is the path inside the jar. Should really leave that as it is, only
// change your file name. 3rd parameter is your plugin instance - so we know from which plugin we're
// pulling the config.
configManager.registerFromJar(myPluginConfigDestination, "config.yml", this);
configManager.

registerFromJar(myPluginConfigDestination, "config.yml",this);

// I recommend putting all of this in your onEnable, at the end don't forget to
// actually start the watch service. Note that you can also dynamically create files during
// runtime, you don't have to do everything in onEnable.
manager.start();
manager.

start();

// Sample 2 - registering custom yaml files, except not from plugin jar
// Sample 2 - registering custom yaml files, except not from plugin jar
// This is fairly simple!
YamlConfig myCustomConfig = manager.register(
new File(getDataFolder(), "data.yml")
);
YamlConfig myCustomConfig = manager.register(
new File(getDataFolder(), "data.yml")
);

// What you're doing here is creating a file, in your plugin folder - getDataFolder(),
// and you're naming it 'data.yml', that's about it.
// You can write to it:
myCustomConfig.get().set("hello", "world");
myCustomConfig.

get().

set("hello","world");

// Read from it (get() - returns the latest internally cached config,
// Read from it (get() - returns the latest internally cached config,
// basically, the latest config that matches the file on your disk)
// with get(), you get raw YamlConfiguration access, so you're able to do
// anything. If you do change anything in the file don't forget to
// save it in the end: myCustomConfig.save(), api will handle the rest.
@Nullable String myValue = myCustomConfig.get().getString("something.here");
@Nullable
String myValue = myCustomConfig.get().getString("something.here");

// ---
// If you find this confusing, there is javadoc at every method / public variable. So you won't be lost!
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package dev.spexx.configurationAPI.configuration.yaml;
package dev.spexx.configurationAPI.api.config.yaml;

import dev.spexx.configurationAPI.exceptions.ConfigException;
import dev.spexx.configurationAPI.exceptions.ConfigFileException;
import dev.spexx.configurationAPI.exceptions.ConfigParseException;
import dev.spexx.configurationAPI.exceptions.ConfigPermissionException;
import dev.spexx.configurationAPI.utils.FileChecksum;
import dev.spexx.configurationAPI.api.exceptions.ConfigException;
import dev.spexx.configurationAPI.api.exceptions.ConfigFileException;
import dev.spexx.configurationAPI.api.exceptions.ConfigParseException;
import dev.spexx.configurationAPI.api.exceptions.ConfigPermissionException;
import dev.spexx.configurationAPI.api.utils.FileChecksum;
import org.bukkit.configuration.InvalidConfigurationException;
import org.bukkit.configuration.file.YamlConfiguration;
import org.jetbrains.annotations.NotNull;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package dev.spexx.configurationAPI.configuration.yaml;
package dev.spexx.configurationAPI.api.config.yaml;

import dev.spexx.configurationAPI.events.ConfigReloadEvent;
import dev.spexx.configurationAPI.exceptions.ConfigException;
import dev.spexx.configurationAPI.utils.FileChecksum;
import dev.spexx.configurationAPI.api.event.ConfigReloadEvent;
import dev.spexx.configurationAPI.api.exceptions.ConfigException;
import dev.spexx.configurationAPI.api.utils.FileChecksum;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;
import org.jetbrains.annotations.NotNull;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package dev.spexx.configurationAPI.events;
package dev.spexx.configurationAPI.api.event;

import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.event.Event;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package dev.spexx.configurationAPI.exceptions;
package dev.spexx.configurationAPI.api.exceptions;

import org.jetbrains.annotations.NotNull;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package dev.spexx.configurationAPI.exceptions;
package dev.spexx.configurationAPI.api.exceptions;

import org.jetbrains.annotations.NotNull;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package dev.spexx.configurationAPI.exceptions;
package dev.spexx.configurationAPI.api.exceptions;

import org.jetbrains.annotations.NotNull;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package dev.spexx.configurationAPI.exceptions;
package dev.spexx.configurationAPI.api.exceptions;

import org.jetbrains.annotations.NotNull;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package dev.spexx.configurationAPI.manager;
package dev.spexx.configurationAPI.api.manager;

import dev.spexx.configurationAPI.configuration.yaml.YamlConfig;
import dev.spexx.configurationAPI.configuration.yaml.YamlConfigWatcher;
import dev.spexx.configurationAPI.exceptions.ConfigException;
import dev.spexx.configurationAPI.api.config.yaml.YamlConfig;
import dev.spexx.configurationAPI.api.config.yaml.YamlConfigWatcher;
import dev.spexx.configurationAPI.api.exceptions.ConfigException;
import org.bukkit.plugin.java.JavaPlugin;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package dev.spexx.configurationAPI.utils;
package dev.spexx.configurationAPI.api.utils;

import org.jetbrains.annotations.NotNull;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package dev.spexx.configurationAPI.bootstrap;

import io.papermc.paper.plugin.bootstrap.BootstrapContext;
import io.papermc.paper.plugin.bootstrap.PluginBootstrap;
import org.jetbrains.annotations.NotNull;

/**
* Bootstrap entry point for the ConfigurationAPI plugin.
*
* <p>This class is invoked during the early plugin bootstrap phase,
* before the plugin is fully loaded and enabled.</p>
*
* <p>It can be used to perform early initialization logic such as
* preparing resources, validating environment state, or influencing
* plugin loading behavior.</p>
*
* <p>Note that the Bukkit API is not fully available at this stage.</p>
*
* @since 1.3.0
*/
public class ConfigurationBootstrap implements PluginBootstrap {

/**
* Creates a new ConfigurationBootstrap instance.
*
* @since 1.3.0
*/
public ConfigurationBootstrap() {
}

/**
* Called during the bootstrap phase of plugin initialization.
*
* @param context the bootstrap context providing access to plugin metadata and logging
*/
@Override
public void bootstrap(@NotNull BootstrapContext context) {
// no-op (reserved for future use)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package dev.spexx.configurationAPI.loader;

import io.papermc.paper.plugin.loader.PluginClasspathBuilder;
import io.papermc.paper.plugin.loader.PluginLoader;
import org.jetbrains.annotations.NotNull;

/**
* Classpath loader for the ConfigurationAPI plugin.
*
* <p>This class is responsible for modifying the plugin's classpath
* during the loading phase.</p>
*
* <p>It can be used to add external libraries or dependencies to the
* plugin classloader before the plugin is initialized.</p>
*
* <p>Currently, no additional libraries are injected.</p>
*
* @since 1.3.0
*/
public class ConfigurationLoader implements PluginLoader {

/**
* Creates a new ConfigurationLoader instance.
*
* @since 1.3.0
*/
public ConfigurationLoader() {
}

/**
* Called when the plugin classloader is being constructed.
*
* @param builder the classpath builder used to modify the plugin classpath
*/
@Override
public void classloader(@NotNull PluginClasspathBuilder builder) {
// no-op (reserved for future use)
}
}
5 changes: 4 additions & 1 deletion src/main/resources/paper-plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ description: "Lightweight YAML config API with automatic reload and event-driven
version: '1.3.0'

main: dev.spexx.configurationAPI.ConfigurationAPI
api-version: '1.21.11'
bootstrapper: dev.spexx.configurationAPI.bootstrap.ConfigurationBootstrap
loader: dev.spexx.configurationAPI.bootstrap.ConfigurationLoader

api-version: '21.1.1'
load: POSTWORLD

authors: [ Spexx ]
Expand Down
Loading