Skip to content

Commit 29f7d7d

Browse files
author
Spexx
committed
initial stable release
0 parents  commit 29f7d7d

12 files changed

Lines changed: 1551 additions & 0 deletions

File tree

.gitattributes

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#
2+
# https://help.github.com/articles/dealing-with-line-endings/
3+
#
4+
# Linux start script should use lf
5+
/gradlew text eol=lf
6+
7+
# These are Windows script files and should use crlf
8+
*.bat text eol=crlf
9+
10+
# Binary files should be left untouched
11+
*.jar binary

.gitignore

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
# User-specific stuff
2+
.idea/
3+
4+
*.iml
5+
*.ipr
6+
*.iws
7+
8+
# IntelliJ
9+
out/
10+
11+
# Compiled class file
12+
*.class
13+
14+
# Log file
15+
*.log
16+
17+
# BlueJ files
18+
*.ctxt
19+
20+
# Package Files #
21+
*.jar
22+
*.war
23+
*.nar
24+
*.ear
25+
*.zip
26+
*.tar.gz
27+
*.rar
28+
29+
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
30+
hs_err_pid*
31+
32+
*~
33+
34+
# temporary files which can be created if a process still has a handle open of a deleted file
35+
.fuse_hidden*
36+
37+
# KDE directory preferences
38+
.directory
39+
40+
# Linux trash folder which might appear on any partition or disk
41+
.Trash-*
42+
43+
# .nfs files are created when an open file is removed but is still being accessed
44+
.nfs*
45+
46+
# General
47+
.DS_Store
48+
.AppleDouble
49+
.LSOverride
50+
51+
# Icon must end with two \r
52+
Icon
53+
54+
# Thumbnails
55+
._*
56+
57+
# Files that might appear in the root of a volume
58+
.DocumentRevisions-V100
59+
.fseventsd
60+
.Spotlight-V100
61+
.TemporaryItems
62+
.Trashes
63+
.VolumeIcon.icns
64+
.com.apple.timemachine.donotpresent
65+
66+
# Directories potentially created on remote AFP share
67+
.AppleDB
68+
.AppleDesktop
69+
Network Trash Folder
70+
Temporary Items
71+
.apdisk
72+
73+
# Windows thumbnail cache files
74+
Thumbs.db
75+
Thumbs.db:encryptable
76+
ehthumbs.db
77+
ehthumbs_vista.db
78+
79+
# Dump file
80+
*.stackdump
81+
82+
# Folder config file
83+
[Dd]esktop.ini
84+
85+
# Recycle Bin used on file shares
86+
$RECYCLE.BIN/
87+
88+
# Windows Installer files
89+
*.cab
90+
*.msi
91+
*.msix
92+
*.msm
93+
*.msp
94+
95+
# Windows shortcuts
96+
*.lnk
97+
98+
target/
99+
100+
pom.xml.tag
101+
pom.xml.releaseBackup
102+
pom.xml.versionsBackup
103+
pom.xml.next
104+
105+
release.properties
106+
dependency-reduced-pom.xml
107+
buildNumber.properties
108+
.mvn/timing.properties
109+
.mvn/wrapper/maven-wrapper.jar
110+
.flattened-pom.xml
111+
112+
# Common working directory
113+
run/

pom.xml

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
7+
<groupId>dev.spexx</groupId>
8+
<artifactId>ConfigurationAPI</artifactId>
9+
<version>1.0.0</version>
10+
<packaging>jar</packaging>
11+
12+
<name>ConfigurationAPI</name>
13+
14+
<properties>
15+
<java.version>25</java.version>
16+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
17+
</properties>
18+
19+
<build>
20+
<defaultGoal>clean package</defaultGoal>
21+
<plugins>
22+
<plugin>
23+
<groupId>org.apache.maven.plugins</groupId>
24+
<artifactId>maven-compiler-plugin</artifactId>
25+
<version>3.13.0</version>
26+
<configuration>
27+
<source>${java.version}</source>
28+
<target>${java.version}</target>
29+
</configuration>
30+
</plugin>
31+
32+
<plugin>
33+
<groupId>org.apache.maven.plugins</groupId>
34+
<artifactId>maven-javadoc-plugin</artifactId>
35+
<version>3.7.0</version>
36+
37+
<configuration>
38+
<source>${java.version}</source>
39+
40+
<!-- THIS FIXES YOUR ERROR -->
41+
<tags>
42+
<tag>
43+
<name>apiNote</name>
44+
<placement>a</placement>
45+
<head>API Note:</head>
46+
</tag>
47+
<tag>
48+
<name>implSpec</name>
49+
<placement>a</placement>
50+
<head>Implementation Requirements:</head>
51+
</tag>
52+
<tag>
53+
<name>implNote</name>
54+
<placement>a</placement>
55+
<head>Implementation Note:</head>
56+
</tag>
57+
</tags>
58+
<encoding>UTF-8</encoding>
59+
60+
<doctitle>ConfigurationAPI ${project.version}</doctitle>
61+
<windowtitle>ConfigurationAPI Docs</windowtitle>
62+
</configuration>
63+
64+
<executions>
65+
<execution>
66+
<id>attach-javadocs</id>
67+
<goals>
68+
<goal>jar</goal>
69+
</goals>
70+
</execution>
71+
</executions>
72+
</plugin>
73+
74+
</plugins>
75+
<resources>
76+
<resource>
77+
<directory>src/main/resources</directory>
78+
<filtering>true</filtering>
79+
</resource>
80+
</resources>
81+
</build>
82+
83+
<repositories>
84+
<repository>
85+
<id>papermc-repo</id>
86+
<url>https://repo.papermc.io/repository/maven-public/</url>
87+
</repository>
88+
</repositories>
89+
90+
<dependencies>
91+
<dependency>
92+
<groupId>io.papermc.paper</groupId>
93+
<artifactId>paper-api</artifactId>
94+
<version>1.21.11-R0.1-SNAPSHOT</version>
95+
<scope>provided</scope>
96+
</dependency>
97+
</dependencies>
98+
</project>
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
package dev.spexx.configurationAPI;
2+
3+
import dev.spexx.configurationAPI.config.YamlConfig;
4+
import dev.spexx.configurationAPI.events.ConfigReloadedEvent;
5+
import dev.spexx.configurationAPI.manager.ConfigManager;
6+
import org.bukkit.event.EventHandler;
7+
import org.bukkit.event.Listener;
8+
import org.bukkit.plugin.java.JavaPlugin;
9+
import org.jetbrains.annotations.NotNull;
10+
11+
/**
12+
* Entry point for the ConfigurationAPI plugin.
13+
*
14+
* <p>This class is responsible for initializing core components and
15+
* registering listeners required for configuration monitoring.</p>
16+
*
17+
* @apiNote
18+
* This plugin primarily serves as a runtime host for the configuration API.
19+
*
20+
* @implSpec
21+
* Lifecycle methods are invoked by the Bukkit framework.
22+
*
23+
* @since 1.0
24+
*/
25+
public final class ConfigurationAPI extends JavaPlugin implements Listener {
26+
27+
/**
28+
* Constructs the plugin instance.
29+
*
30+
* @since 1.0
31+
*/
32+
public ConfigurationAPI() { }
33+
34+
private ConfigManager configManager;
35+
36+
@Override
37+
public void onEnable() {
38+
39+
this.configManager = new ConfigManager(this);
40+
41+
// load test config
42+
YamlConfig config = configManager.getOrLoadResource("config.yml");
43+
44+
getLogger().info("Loaded config value: " +
45+
config.config().getInt("value"));
46+
47+
// register event listener
48+
getServer().getPluginManager().registerEvents(this, this);
49+
}
50+
51+
@Override
52+
public void onDisable() { }
53+
54+
/**
55+
* Handles configuration reload events.
56+
*
57+
* @param event the reload event
58+
*
59+
* @since 1.0
60+
*/
61+
@EventHandler
62+
public void onReload(@NotNull ConfigReloadedEvent event) {
63+
getLogger().info("Config reloaded: " +
64+
event.getConfig().file().getName());
65+
66+
getLogger().info("New value: " +
67+
event.getConfig().config().getInt("value"));
68+
}
69+
}
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
package dev.spexx.configurationAPI.config;
2+
3+
import dev.spexx.configurationAPI.properties.FileProperties;
4+
import org.bukkit.configuration.file.FileConfiguration;
5+
import org.jetbrains.annotations.NotNull;
6+
7+
import java.io.File;
8+
9+
/**
10+
* Immutable snapshot of a YAML configuration file.
11+
*
12+
* <p>This class encapsulates the following components:</p>
13+
* <ul>
14+
* <li>The underlying {@link File} on disk</li>
15+
* <li>The parsed {@link FileConfiguration} instance</li>
16+
* <li>Associated {@link FileProperties} metadata</li>
17+
* </ul>
18+
*
19+
* <p>Instances represent a point-in-time view of a configuration and are intended
20+
* to be treated as read-only. New instances are created during reload operations
21+
* and atomically swapped by the managing component.</p>
22+
*
23+
* @apiNote
24+
* Consumers should avoid holding long-lived references if they require access to
25+
* the most up-to-date configuration. Instead, they should retrieve the current
26+
* instance from the managing component when needed.
27+
*
28+
* @implSpec
29+
* This class is immutable. All fields are {@code final}, and no mutator methods
30+
* are provided. Thread-safety is achieved through immutability and atomic
31+
* replacement at a higher level.
32+
*
33+
* @implNote
34+
* Atomic replacement of instances ensures that readers never observe partially
35+
* updated configuration state and do not require synchronization.
36+
*
37+
* @since 1.0.0
38+
*/
39+
public final class YamlConfig {
40+
41+
/**
42+
* The underlying configuration file on disk.
43+
*/
44+
private final File file;
45+
46+
/**
47+
* Metadata describing the underlying file.
48+
*/
49+
private final FileProperties properties;
50+
51+
/**
52+
* Parsed configuration snapshot.
53+
*/
54+
private final FileConfiguration config;
55+
56+
/**
57+
* Constructs a new immutable {@code YamlConfig} instance.
58+
*
59+
* @param file the configuration file, must not be {@code null}
60+
* @param config the parsed configuration snapshot, must not be {@code null}
61+
*/
62+
public YamlConfig(
63+
@NotNull File file,
64+
@NotNull FileConfiguration config) {
65+
this.file = file;
66+
this.properties = new FileProperties(file);
67+
this.config = config;
68+
}
69+
70+
/**
71+
* Returns the underlying configuration file.
72+
*
73+
* @return the configuration file, never {@code null}
74+
*/
75+
public @NotNull File file() {
76+
return file;
77+
}
78+
79+
/**
80+
* Returns metadata associated with this configuration file.
81+
*
82+
* @return file properties, never {@code null}
83+
*/
84+
public @NotNull FileProperties properties() {
85+
return properties;
86+
}
87+
88+
/**
89+
* Returns the parsed configuration snapshot.
90+
*
91+
* <p>The returned instance represents a stable view of the configuration
92+
* at the time this {@code YamlConfig} was created.</p>
93+
*
94+
* @return the configuration snapshot, never {@code null}
95+
*/
96+
public @NotNull FileConfiguration config() {
97+
return config;
98+
}
99+
}

0 commit comments

Comments
 (0)